Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-12-02 15:35:07 +0300
committerJacques Lucke <jacques@blender.org>2020-12-02 17:38:47 +0300
commit600fb28b629598af2537c542e7f3f76ba0e94389 (patch)
treedb944815f74d9c81b48095f4d30402080c9192d6 /source/blender/editors/interface/interface_panel.c
parentfc4a853846123ed320914df7f78340ec95efc97e (diff)
Geometry Nodes: active modifier + geometry nodes editor
This commit adds functions to set and get the object's active modifier, which is stored as a flag in the ModifierData struct, similar to constraints. This will be used to set the context in the node editor. There are no visible changes in this commit. Similar to how the node editor context works for materials, this commit makes the node group displayed in the node editor depend on the active object and its active modifier. To keep the node group from changing, just pin the node group in the header. * Shortcuts performed while there is an active modifier will affect only that modifier (the exception is the A to expand the modifiers). * Clicking anywhere on the empty space in a modifier's panel will make it active. These changes require some refactoring of object modifier code. First is splitting up the modifier property invoke callback, which now needs to be able to get the active modifier separately from the hovered modifier for the different operators. Second is a change to removing modifiers, where there is now a separate function to remove a modifier from an object's list, in order to handle changing the active. Finally, the panel handler needs a small tweak so that this "click in panel" event can be handled afterwards.
Diffstat (limited to 'source/blender/editors/interface/interface_panel.c')
-rw-r--r--source/blender/editors/interface/interface_panel.c69
1 files changed, 60 insertions, 9 deletions
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 5cfaafeec2c..d1e5bbcb536 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);
+ }
}
/** \} */
@@ -2392,20 +2450,13 @@ int ui_handler_panel_region(bContext *C,
continue;
}
- /* All mouse clicks inside panels should return in break, but continue handling
- * in case there is a sub-panel header at the mouse location. */
- if (event->type == LEFTMOUSE &&
- ELEM(mouse_state, PANEL_MOUSE_INSIDE_CONTENT, PANEL_MOUSE_INSIDE_HEADER)) {
- retval = WM_UI_HANDLER_BREAK;
- }
-
if (mouse_state == PANEL_MOUSE_INSIDE_HEADER) {
+ /* All mouse clicks inside panel headers should return in break. */
+ retval = WM_UI_HANDLER_BREAK;
if (ELEM(event->type, EVT_RETKEY, EVT_PADENTER, LEFTMOUSE)) {
- retval = WM_UI_HANDLER_BREAK;
ui_handle_panel_header(C, block, mx, event->type, event->ctrl, event->shift);
}
else if (event->type == RIGHTMOUSE) {
- retval = WM_UI_HANDLER_BREAK;
ui_popup_context_menu_for_panel(C, region, block->panel);
}
break;