diff options
author | Hans Goudey <h.goudey@me.com> | 2020-11-19 23:21:18 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-11-19 23:21:18 +0300 |
commit | 6d77e2bb1767828c887604040f7c718cb7e47da3 (patch) | |
tree | cf2a61a0fef0af760fb243b3a7fcc1f64c270e89 /source/blender/editors/interface/interface_panel.c | |
parent | b7d7051dc390e1dcc8e05a4a0db7ab59a5cf7d7f (diff) |
Geometry Nodes: Expose the active modifier to the UIgeometry-nodes-active-modifier-drawing
This exposes the operator to set the active modifier as the type icon
in the header of the modifier panels. Tweaks to the widget drawing
code were necessary to use the red alert for non-emboss operator
buttons. Then, the panel for the active modifier gets a border around it
(which currently uses the property search theme color), requiring
an "active property" field in the PanelType struct.
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 839363c9599..5fbc4818e8b 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -45,6 +45,8 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "RNA_access.h" + #include "BLF_api.h" #include "WM_api.h" @@ -90,6 +92,8 @@ typedef enum uiPanelRuntimeFlag { * position. Unlike #PANEL_STATE_ANIMATION, this is applied to sub-panels as well. */ PANEL_IS_DRAG_DROP = (1 << 10), + /** Draw a border with the active color around the panel. */ + PANEL_ACTIVE_BORDER = (1 << 11), } uiPanelRuntimeFlag; /* The state of the mouse position relative to the panel. */ @@ -579,6 +583,22 @@ static void set_panels_list_data_expand_flag(const bContext *C, const ARegion *r /** \name Panels * \{ */ +static bool panel_use_active_highlight(const Panel *panel) +{ + /* The caller should make sure the panel is active and has a type. */ + BLI_assert(UI_panel_is_active(panel)); + BLI_assert(panel->type != NULL); + + if (panel->type->active_property) { + PointerRNA *ptr = UI_panel_custom_data_get(panel); + if (ptr != NULL && !RNA_pointer_is_null(ptr)) { + return RNA_boolean_get(ptr, panel->type->active_property); + } + } + + return false; +} + /** * Set flag state for a panel and its sub-panels. */ @@ -1062,6 +1082,40 @@ static void panel_title_color_get(const Panel *panel, } } +static void panel_draw_highlight_border(const Panel *panel, + const rcti *rect, + const rcti *header_rect) +{ + const bool draw_box_style = panel->type->flag & PANEL_TYPE_DRAW_BOX; + const bool is_subpanel = panel->type->parent != NULL; + if (is_subpanel) { + return; + } + + float radius; + if (draw_box_style) { + /* Use the theme for box widgets. */ + const uiWidgetColors *box_wcol = &UI_GetTheme()->tui.wcol_box; + UI_draw_roundbox_corner_set(UI_CNR_ALL); + radius = box_wcol->roundness * U.widget_unit; + } + else { + UI_draw_roundbox_corner_set(UI_CNR_NONE); + radius = 0.0f; + } + + /* Abuse the property search theme color for now. */ + float color[4]; + UI_GetThemeColor4fv(TH_MATCH, color); + UI_draw_roundbox_aa(false, + rect->xmin, + UI_panel_is_closed(panel) ? header_rect->ymin : rect->ymin, + rect->xmax, + header_rect->ymax, + radius, + color); +} + static void panel_draw_aligned_widgets(const uiStyle *style, const Panel *panel, const rcti *header_rect, @@ -1287,6 +1341,10 @@ void ui_draw_aligned_panel(const uiStyle *style, show_background, region_search_filter_active); } + + if (panel_use_active_highlight(panel)) { + panel_draw_highlight_border(panel, rect, &header_rect); + } } /** \} */ |