Add a h_separation between icons in CheckButton/CheckBox
Previously, the `h_separation` between internal elements and custom elements was added when `text` was not empty. That is, this `h_separation` does not exist when there is a valid custom `icon` but `text` is empty. Now, the `h_separation` between the internal element and the custom element is added when the internal element and any custom element exist (both width are greater than `0`).
This commit is contained in:
parent
652438a395
commit
5de496d3b0
5 changed files with 27 additions and 26 deletions
|
|
@ -68,12 +68,18 @@ Size2 CheckButton::get_icon_size() const {
|
|||
|
||||
Size2 CheckButton::get_minimum_size() const {
|
||||
Size2 minsize = Button::get_minimum_size();
|
||||
Size2 tex_size = get_icon_size();
|
||||
minsize.width += tex_size.width;
|
||||
if (get_text().length() > 0) {
|
||||
minsize.width += MAX(0, theme_cache.h_separation);
|
||||
const Size2 tex_size = get_icon_size();
|
||||
if (tex_size.width > 0 || tex_size.height > 0) {
|
||||
const Size2 padding = _get_current_stylebox()->get_minimum_size();
|
||||
Size2 content_size = minsize - padding;
|
||||
if (content_size.width > 0 && tex_size.width > 0) {
|
||||
content_size.width += MAX(0, theme_cache.h_separation);
|
||||
}
|
||||
content_size.width += tex_size.width;
|
||||
content_size.height = MAX(content_size.height, tex_size.height);
|
||||
|
||||
minsize = content_size + padding;
|
||||
}
|
||||
minsize.height = MAX(minsize.height, tex_size.height + theme_cache.normal_style->get_margin(SIDE_TOP) + theme_cache.normal_style->get_margin(SIDE_BOTTOM));
|
||||
|
||||
return minsize;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue