Skip to content

Commit aee211b

Browse files
committed
Modern Style: Use a style box for Input Map actions
1 parent 0fdbf05 commit aee211b

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-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, const 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, const Rect2 p_rect);
111112

112113
protected:
113114
void _notification(int p_what);

editor/themes/theme_classic.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,13 @@ 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+
1969+
Ref<StyleBoxFlat> style_highlight_subsection = p_config.base_style->duplicate();
1970+
style_highlight_subsection->set_bg_color(prop_subsection_stylebox_color);
1971+
p_theme->set_stylebox("style_highlight_subsection", EditorStringName(Editor), style_highlight_subsection);
1972+
19661973
Color prop_category_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);
19671974
Color prop_subsection_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.06);
19681975

editor/themes/theme_modern.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,6 +1923,14 @@ 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+
1929+
Ref<StyleBoxFlat> style_highlight_subsection = p_config.base_style->duplicate();
1930+
style_highlight_subsection->set_bg_color(prop_subsection_stylebox_color);
1931+
style_highlight_subsection->set_corner_radius_all(p_config.corner_radius * EDSCALE);
1932+
p_theme->set_stylebox("style_highlight_subsection", EditorStringName(Editor), style_highlight_subsection);
1933+
19261934
p_theme->set_color("prop_subsection", EditorStringName(Editor), Color(1, 1, 1, 0));
19271935
#ifndef DISABLE_DEPRECATED // Used before 4.3.
19281936
p_theme->set_color("property_color", EditorStringName(Editor), p_config.dark_color_1.lerp(p_config.mono_color_font, 0.12));

0 commit comments

Comments
 (0)