Skip to content

Commit 2df90ee

Browse files
committed
Modern Style: Use a StyleBox in signals and groups
1 parent 06faefc commit 2df90ee

File tree

6 files changed

+28
-8
lines changed

6 files changed

+28
-8
lines changed

editor/docks/groups_editor.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ void GroupsEditor::_update_tree() {
201201
TreeItem *root = tree->create_item();
202202

203203
TreeItem *local_root = tree->create_item(root);
204+
local_root->set_cell_mode(0, TreeItem::CELL_MODE_CUSTOM);
205+
local_root->set_custom_draw_callback(0, callable_mp(this, &GroupsEditor::_highlight_subsection_root));
204206
local_root->set_text(0, TTR("Scene Groups"));
205207
local_root->set_icon(0, get_editor_theme_icon(SNAME("PackedScene")));
206208
local_root->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)));
@@ -238,6 +240,8 @@ void GroupsEditor::_update_tree() {
238240
keys.sort_custom<NoCaseComparator>();
239241

240242
TreeItem *global_root = tree->create_item(root);
243+
global_root->set_cell_mode(0, TreeItem::CELL_MODE_CUSTOM);
244+
global_root->set_custom_draw_callback(0, callable_mp(this, &GroupsEditor::_highlight_subsection_root));
241245
global_root->set_text(0, TTR("Global Groups"));
242246
global_root->set_icon(0, get_editor_theme_icon(SNAME("Environment")));
243247
global_root->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor)));
@@ -831,6 +835,14 @@ void GroupsEditor::_node_removed(Node *p_node) {
831835
}
832836
}
833837

838+
void GroupsEditor::_highlight_subsection_root(Object *p_item, const Rect2 p_rect) {
839+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
840+
ERR_FAIL_NULL(item);
841+
842+
const Ref<StyleBox> &stylebox = get_theme_stylebox(SNAME("style_highlight_subsection"), EditorStringName(Editor));
843+
stylebox->draw(tree->get_canvas_item(), p_rect);
844+
}
845+
834846
GroupsEditor::GroupsEditor() {
835847
node = nullptr;
836848
scene_tree = SceneTree::get_singleton();

editor/docks/groups_editor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ class GroupsEditor : public VBoxContainer {
122122

123123
void _node_removed(Node *p_node);
124124

125+
void _highlight_subsection_root(Object *p_item, const Rect2 p_rect);
126+
125127
protected:
126128
void _notification(int p_what);
127129
static void _bind_methods();

editor/scene/connections_dialog.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,6 +1474,14 @@ void ConnectionsDock::_close() {
14741474
hide();
14751475
}
14761476

1477+
void ConnectionsDock::_highlight_subsection_class(Object *p_item, const Rect2 p_rect) {
1478+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
1479+
ERR_FAIL_NULL(item);
1480+
1481+
const Ref<StyleBox> &stylebox = get_theme_stylebox(SNAME("style_highlight_subsection"), EditorStringName(Editor));
1482+
stylebox->draw(tree->get_canvas_item(), p_rect);
1483+
}
1484+
14771485
void ConnectionsDock::_connect_pressed() {
14781486
TreeItem *item = tree->get_selected();
14791487
if (!item) {
@@ -1620,6 +1628,8 @@ void ConnectionsDock::update_tree() {
16201628
class_signals.sort();
16211629

16221630
section_item = tree->create_item(root);
1631+
section_item->set_cell_mode(0, TreeItem::CELL_MODE_CUSTOM);
1632+
section_item->set_custom_draw_callback(0, callable_mp(this, &ConnectionsDock::_highlight_subsection_class));
16231633
section_item->set_text(0, class_name);
16241634
// `|` separators used in `EditorHelpBit`.
16251635
section_item->set_tooltip_text(0, "class|" + doc_class_name + "|");

editor/scene/connections_dialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ class ConnectionsDock : public VBoxContainer {
270270
void _tree_gui_input(const Ref<InputEvent> &p_event);
271271
void _close();
272272

273+
void _highlight_subsection_class(Object *p_item, const Rect2 p_rect);
274+
273275
protected:
274276
void _connect_pressed();
275277
void _notification(int p_what);

editor/themes/theme_classic.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,11 +1963,8 @@ void ThemeClassic::populate_editor_styles(const Ref<EditorTheme> &p_theme, Edito
19631963
p_theme->set_constant("indent_size", "EditorInspectorSection", 6.0 * EDSCALE);
19641964
p_theme->set_constant("h_separation", "EditorInspectorSection", 2.0 * EDSCALE);
19651965

1966-
Color prop_subsection_stylebox_color = Color(1, 1, 1, 0);
1967-
p_theme->set_color("prop_subsection_stylebox", EditorStringName(Editor), prop_subsection_stylebox_color);
1968-
19691966
Ref<StyleBoxFlat> style_highlight_subsection = p_config.base_style->duplicate();
1970-
style_highlight_subsection->set_bg_color(prop_subsection_stylebox_color);
1967+
style_highlight_subsection->set_bg_color(Color(1, 1, 1, 0));
19711968
p_theme->set_stylebox("style_highlight_subsection", EditorStringName(Editor), style_highlight_subsection);
19721969

19731970
Color prop_category_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);

editor/themes/theme_modern.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,11 +1923,8 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
19231923
p_theme->set_constant("indent_size", "EditorInspectorSection", 6.0 * EDSCALE);
19241924
p_theme->set_constant("h_separation", "EditorInspectorSection", p_config.base_margin * EDSCALE);
19251925

1926-
Color prop_subsection_stylebox_color = p_config.dark_color_1.lerp(p_config.mono_color_font, p_config.dark_icon_and_font ? 0.09 : 0.16);
1927-
p_theme->set_color("prop_subsection_stylebox", EditorStringName(Editor), prop_subsection_stylebox_color);
1928-
19291926
Ref<StyleBoxFlat> style_highlight_subsection = p_config.base_style->duplicate();
1930-
style_highlight_subsection->set_bg_color(prop_subsection_stylebox_color);
1927+
style_highlight_subsection->set_bg_color(p_config.button_disabled_color);
19311928
style_highlight_subsection->set_corner_radius_all(p_config.corner_radius * EDSCALE);
19321929
p_theme->set_stylebox("style_highlight_subsection", EditorStringName(Editor), style_highlight_subsection);
19331930

0 commit comments

Comments
 (0)