Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ComboBox vertical alignment seems off in FlexboxLayout #136

Closed
RustyJoeM opened this issue Oct 20, 2020 · 4 comments
Closed

ComboBox vertical alignment seems off in FlexboxLayout #136

RustyJoeM opened this issue Oct 20, 2020 · 4 comments

Comments

@RustyJoeM
Copy link

Hello,

i'm using FlexboxLayout across the app, and i stumbled upon issue with aligning the label with "dropdowns" - ComboBox<> elements...

Common alignment seems to work fine for labels, text inputs, buttons, but when i have dropdown on "line" of various elements, i'm unable to get it right (centered, or baselined) with the rest of elements.

Pseudo-code: (should be copy-able into raw/empty app template):

fn supported_langs() -> Vec<String> {
    vec!["English".to_string(), "Česky".to_string(), "русский".to_string()]
}

const SIZE: Size<Dimension> = Size { width: Dimension::Percent(0.25), height: Dimension::Points(40.0) };


**** UI elements: ****
    #[nwg_control(title: "misaligned combobox", size: (360, 240), position: (80, 60))]
    #[nwg_events(OnWindowClose: [FillerApp::exit(SELF)])]
    window: nwg::Window,

    #[nwg_layout(parent: window, flex_direction: FlexDirection::Row, align_items: AlignItems::Center)]
    main_layout: nwg::FlexboxLayout,

    #[nwg_control(text: "\u{2328}:", h_align: HTextAlign::Right)]
    #[nwg_layout_item(layout: main_layout, size: SIZE)]
    lang_label: nwg::Label,

    #[nwg_control(collection: supported_langs(), selected_index: Some(0))]
    #[nwg_layout_item(layout: main_layout, size: SIZE)]
    lang_dropdown: nwg::ComboBox<String>,
    
    #[nwg_control(text: "Value separator:", h_align: HTextAlign::Right)]
    #[nwg_layout_item(layout: main_layout, size: SIZE)]
    separator_label: nwg::Label,

    #[nwg_control(text: ";")]
    #[nwg_layout_item(layout: main_layout, size: SIZE)]
    separator_input: nwg::TextInput,
@gabdube
Copy link
Owner

gabdube commented Oct 20, 2020

I'll see what I can find. The combobox has a rendering hack, so it's probably messing with the layout.

@RustyJoeM
Copy link
Author

RustyJoeM commented Oct 20, 2020

thank you!

Not sure if it helps, but, i tested a workaround

  • adding a wrapping nwg::Frame over the ComboBox<>,
  • align_items: AlignItems::Center for the layout of wrapper frame

seems to align resulting set properly...

edit: also, the resulting ComboBox<> has some graphical artifact over itself, that disappears when I either resize window or move it...

@RicoRodriges
Copy link
Contributor

Layout works perfect. The problem is ComboBox<> control has system height based on fonts. See the picture

image

SetWindowPos for comboboxes works not as other controls.

@gabdube
Copy link
Owner

gabdube commented Jan 26, 2021

well... better late than never. I added a v_align parameter to the combobox to change the vertical alignment. It now defaults to center instead of top, just like the other controls. It will be in 1.0.9, which I am about to release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants