Skip to content

Commit

Permalink
Combobox: use padding from theme
Browse files Browse the repository at this point in the history
Found also a bug - engine did not add the padding to the widget when
added to a layout.
  • Loading branch information
diegoiast committed Feb 23, 2024
1 parent df826e8 commit 025d11f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/combobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,19 @@ struct ComboboxList : ListView {
};

auto Combobox::size_hint() const -> Size {
// TODO: Size of text is not correct. We also need to calculate the yMin and yMax for example
// TODO: we need API in font provider to get the text height
auto s = get_theme()->font.text_size("X");
// auto padding_x = this->padding.get_horizontal();
auto padding_y = this->padding.get_vertical();
return {0, s.height * 2 + padding_y};
return {0, s.height + this->padding.get_vertical()};
}

auto Combobox::on_resize() -> void {
// TODO - find a better size - according to the theme + font size
// auto button_size = content.size.height;
auto button_size = 22;
auto p = Position{content.size.width - button_size, 0};
popup_button->position = p;
auto s = get_theme()->font.text_size("X");
s.height += padding.get_vertical();
s.width = s.height;

auto p = Position{content.size.width - s.height, 0};
this->popup_button->position = p;
this->popup_button->content.resize(s);
this->popup_button->invalidate();
}

auto Combobox::show_popup() -> void {
Expand Down
1 change: 1 addition & 0 deletions src/widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ struct PlatformWindow {
}
// TODO - this needs to be a setter - do we can set all children's window as well
widget->parent = &main_widget;
widget->padding = platform->default_theme->defaultPadding;
return widget;
};
};

0 comments on commit 025d11f

Please sign in to comment.