Skip to content

Commit 1190efb

Browse files
committed
Modern Style: Use a style box for Input Map actions
1 parent 250ef8d commit 1190efb

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

editor/settings/action_map_editor.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,18 @@ bool ActionMapEditor::_should_display_action(const String &p_name, const Array &
418418
return event_match && action_list_search_bar->get_name().is_subsequence_ofn(p_name);
419419
}
420420

421+
void ActionMapEditor::_highlight_subsection_action(Object *p_item, Rect2 p_rect) {
422+
TreeItem *item = Object::cast_to<TreeItem>(p_item);
423+
ERR_FAIL_NULL(item);
424+
425+
if (item->is_selected(0)) {
426+
return;
427+
}
428+
429+
const Ref<StyleBox> &stylebox = get_theme_stylebox(SNAME("style_highlight_subsection"), EditorStringName(Editor));
430+
stylebox->draw(action_tree->get_canvas_item(), p_rect);
431+
}
432+
421433
void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_infos) {
422434
if (!p_action_infos.is_empty()) {
423435
actions_cache = p_action_infos;
@@ -458,6 +470,8 @@ void ActionMapEditor::update_action_list(const Vector<ActionInfo> &p_action_info
458470

459471
// First Column - Action Name
460472
action_item->set_auto_translate_mode(0, AUTO_TRANSLATE_MODE_DISABLED);
473+
action_item->set_cell_mode(0, TreeItem::CELL_MODE_CUSTOM);
474+
action_item->set_custom_draw_callback(0, callable_mp(this, &ActionMapEditor::_highlight_subsection_action));
461475
action_item->set_text(0, action_info.name);
462476
action_item->set_editable(0, action_info.editable);
463477
action_item->set_icon(0, action_info.icon);

editor/settings/action_map_editor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ class ActionMapEditor : public Control {
108108
void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from);
109109

110110
void _set_show_builtin_actions(bool p_show);
111+
void _highlight_subsection_action(Object *p_item, Rect2 p_rect);
111112

112113
protected:
113114
void _notification(int p_what);

editor/themes/theme_classic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,10 @@ 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+
Ref<StyleBoxFlat> style_highlight_subsection = p_config.base_style->duplicate();
1967+
style_highlight_subsection->set_bg_color(Color(1, 1, 1, 0));
1968+
p_theme->set_stylebox("style_highlight_subsection", EditorStringName(Editor), style_highlight_subsection);
1969+
19661970
Color prop_category_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);
19671971
Color prop_subsection_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.06);
19681972

editor/themes/theme_modern.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,6 +1920,11 @@ void ThemeModern::populate_editor_styles(const Ref<EditorTheme> &p_theme, Editor
19201920
p_theme->set_constant("indent_size", "EditorInspectorSection", 6.0 * EDSCALE);
19211921
p_theme->set_constant("h_separation", "EditorInspectorSection", p_config.base_margin * EDSCALE);
19221922

1923+
Ref<StyleBoxFlat> style_highlight_subsection = p_config.base_style->duplicate();
1924+
style_highlight_subsection->set_bg_color(p_config.dark_color_1.lerp(p_config.mono_color_icon_and_font, p_config.dark_icon_and_font ? 0.09 : 0.16));
1925+
style_highlight_subsection->set_corner_radius_all(p_config.corner_radius * EDSCALE);
1926+
p_theme->set_stylebox("style_highlight_subsection", EditorStringName(Editor), style_highlight_subsection);
1927+
19231928
p_theme->set_color("prop_subsection", EditorStringName(Editor), Color(1, 1, 1, 0));
19241929
#ifndef DISABLE_DEPRECATED // Used before 4.3.
19251930
p_theme->set_color("property_color", EditorStringName(Editor), p_config.dark_color_1.lerp(p_config.mono_color_icon_and_font, 0.12));

0 commit comments

Comments
 (0)