Fix EditorProperty spacing

This commit is contained in:
passivestar 2024-06-12 18:02:24 +04:00
parent 2fb296a5cd
commit 2cd0f3584d
2 changed files with 24 additions and 13 deletions

View File

@ -88,17 +88,17 @@ Size2 EditorProperty::get_minimum_size() const {
if (keying) {
Ref<Texture2D> key = get_editor_theme_icon(SNAME("Key"));
ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
ms.width += key->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
}
if (deletable) {
Ref<Texture2D> key = get_editor_theme_icon(SNAME("Close"));
ms.width += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
ms.width += key->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
}
if (checkable) {
Ref<Texture2D> check = get_theme_icon(SNAME("checked"), SNAME("CheckBox"));
ms.width += check->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("CheckBox")) + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
ms.width += check->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
}
if (bottom_editor != nullptr && bottom_editor->is_visible()) {
@ -179,9 +179,9 @@ void EditorProperty::_notification(int p_what) {
key = get_editor_theme_icon(SNAME("Key"));
}
rect.size.x -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
rect.size.x -= key->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
if (is_layout_rtl()) {
rect.position.x += key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
rect.position.x += key->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
}
if (no_children) {
@ -194,16 +194,27 @@ void EditorProperty::_notification(int p_what) {
close = get_editor_theme_icon(SNAME("Close"));
rect.size.x -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
rect.size.x -= close->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
if (is_layout_rtl()) {
rect.position.x += close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
rect.position.x += close->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
}
if (no_children) {
text_size -= close->get_width() + 4 * EDSCALE;
}
}
// Account for the space needed on the outer side
// when any of the icons are visible.
if (keying || deletable) {
int separation = get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
rect.size.x -= separation;
if (is_layout_rtl()) {
rect.position.x += separation;
}
}
}
//set children
@ -291,7 +302,7 @@ void EditorProperty::_notification(int p_what) {
} else {
draw_texture(checkbox, check_rect.position, color2);
}
int check_ofs = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) + checkbox->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("CheckBox"));
int check_ofs = checkbox->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
ofs += check_ofs;
text_limit -= check_ofs;
} else {
@ -300,7 +311,7 @@ void EditorProperty::_notification(int p_what) {
if (can_revert && !is_read_only()) {
Ref<Texture2D> reload_icon = get_editor_theme_icon(SNAME("ReloadSmall"));
text_limit -= reload_icon->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2;
text_limit -= reload_icon->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
revert_rect = Rect2(ofs + text_limit, (size.height - reload_icon->get_height()) / 2, reload_icon->get_width(), reload_icon->get_height());
Color color2(1, 1, 1);
@ -320,7 +331,7 @@ void EditorProperty::_notification(int p_what) {
if (!pin_hidden && pinned) {
Ref<Texture2D> pinned_icon = get_editor_theme_icon(SNAME("Pin"));
int margin_w = get_theme_constant(SNAME("hseparator"), SNAME("Tree")) * 2;
int margin_w = get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
int total_icon_w = margin_w + pinned_icon->get_width();
int text_w = font->get_string_size(label, rtl ? HORIZONTAL_ALIGNMENT_RIGHT : HORIZONTAL_ALIGNMENT_LEFT, text_limit - total_icon_w, font_size).x;
int y = (size.height - pinned_icon->get_height()) / 2;
@ -350,7 +361,7 @@ void EditorProperty::_notification(int p_what) {
key = get_editor_theme_icon(SNAME("Key"));
}
ofs -= key->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
ofs -= key->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
Color color2(1, 1, 1);
if (keying_hover) {
@ -374,7 +385,7 @@ void EditorProperty::_notification(int p_what) {
close = get_editor_theme_icon(SNAME("Close"));
ofs -= close->get_width() + get_theme_constant(SNAME("hseparator"), SNAME("Tree"));
ofs -= close->get_width() + get_theme_constant(SNAME("h_separation"), SNAME("Tree"));
Color color2(1, 1, 1);
if (delete_hover) {

View File

@ -1 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M1 4v2h1v2h3V6h2.133a4 4 0 1 0 0-2zm10-1a2 2 0 0 1 0 4 2 2 0 0 1 0-4z" fill="#e0e0e0"/></svg>
<svg width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path fill="#e0e0e0" d="M1 7v2h1v2h3V9h2.133a4 4 0 1 0 0-2zm10-1a2 2 0 0 1 0 4 2 2 0 0 1 0-4z"/></svg>

Before

Width:  |  Height:  |  Size: 186 B

After

Width:  |  Height:  |  Size: 185 B