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:
@@ -50,10 +50,6 @@ void Button::_set_internal_margin(Side p_side, float p_value) {
|
||||
void Button::_queue_update_size_cache() {
|
||||
}
|
||||
|
||||
void Button::_set_h_separation_is_valid_when_no_text(bool p_h_separation_is_valid_when_no_text) {
|
||||
h_separation_is_valid_when_no_text = p_h_separation_is_valid_when_no_text;
|
||||
}
|
||||
|
||||
Ref<StyleBox> Button::_get_current_stylebox() const {
|
||||
Ref<StyleBox> stylebox = theme_cache.normal;
|
||||
const bool rtl = is_layout_rtl();
|
||||
@@ -171,14 +167,12 @@ void Button::_notification(int p_what) {
|
||||
float right_internal_margin_with_h_separation = _internal_margin[SIDE_RIGHT];
|
||||
{ // The width reserved for internal element in derived classes (and h_separation if need).
|
||||
|
||||
if (!xl_text.is_empty() || h_separation_is_valid_when_no_text) {
|
||||
if (_internal_margin[SIDE_LEFT] > 0.0f) {
|
||||
left_internal_margin_with_h_separation += h_separation;
|
||||
}
|
||||
if (_internal_margin[SIDE_LEFT] > 0.0f) {
|
||||
left_internal_margin_with_h_separation += h_separation;
|
||||
}
|
||||
|
||||
if (_internal_margin[SIDE_RIGHT] > 0.0f) {
|
||||
right_internal_margin_with_h_separation += h_separation;
|
||||
}
|
||||
if (_internal_margin[SIDE_RIGHT] > 0.0f) {
|
||||
right_internal_margin_with_h_separation += h_separation;
|
||||
}
|
||||
|
||||
drawable_size_remained.width -= left_internal_margin_with_h_separation + right_internal_margin_with_h_separation; // The size after the internal element is stripped.
|
||||
|
||||
Reference in New Issue
Block a user