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
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')
-rw-r--r--source/blender/editors/interface/interface_panel.c69
-rw-r--r--source/blender/editors/interface/interface_widgets.c61
2 files changed, 97 insertions, 33 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;
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index b550dc2665f..9c7b112855f 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -264,7 +264,7 @@ typedef struct uiWidgetType {
/* converted colors for state */
uiWidgetColors wcol;
- void (*state)(struct uiWidgetType *, int state, int drawflag);
+ void (*state)(struct uiWidgetType *, int state, int drawflag, char emboss);
void (*draw)(uiWidgetColors *, rcti *, int state, int roundboxalign);
void (*custom)(uiBut *, uiWidgetColors *, rcti *, int state, int roundboxalign);
void (*text)(const uiFontStyle *, const uiWidgetColors *, uiBut *, rcti *);
@@ -2541,7 +2541,7 @@ static const uchar *widget_color_blend_from_flags(const uiWidgetStateColors *wco
}
/* copy colors from theme, and set changes in it based on state */
-static void widget_state(uiWidgetType *wt, int state, int drawflag)
+static void widget_state(uiWidgetType *wt, int state, int drawflag, char emboss)
{
uiWidgetStateColors *wcol_state = wt->wcol_state;
@@ -2591,7 +2591,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag)
if (state & UI_BUT_REDALERT) {
const uchar red[4] = {255, 0, 0};
- if (wt->draw) {
+ if (wt->draw && emboss != UI_EMBOSS_NONE) {
color_blend_v3_v3(wt->wcol.inner, red, 0.4f);
}
else {
@@ -2619,12 +2619,12 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag)
* \{ */
/* sliders use special hack which sets 'item' as inner when drawing filling */
-static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag)
+static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag, char emboss)
{
uiWidgetStateColors *wcol_state = wt->wcol_state;
/* call this for option button */
- widget_state(wt, state, drawflag);
+ widget_state(wt, state, drawflag, emboss);
const uchar *color_blend = widget_color_blend_from_flags(wcol_state, state, drawflag);
if (color_blend != NULL) {
@@ -2642,7 +2642,7 @@ static void widget_state_numslider(uiWidgetType *wt, int state, int drawflag)
}
/* labels use theme colors for text */
-static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag)
+static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag, char emboss)
{
const bTheme *btheme = UI_GetTheme();
@@ -2654,24 +2654,33 @@ static void widget_state_option_menu(uiWidgetType *wt, int state, int drawflag)
copy_v3_v3_uchar(wcol_menu_option.text_sel, btheme->tui.wcol_menu_back.text_sel);
wt->wcol_theme = &wcol_menu_option;
- widget_state(wt, state, drawflag);
+ widget_state(wt, state, drawflag, emboss);
wt->wcol_theme = old_wcol;
}
-static void widget_state_nothing(uiWidgetType *wt, int UNUSED(state), int UNUSED(drawflag))
+static void widget_state_nothing(uiWidgetType *wt,
+ int UNUSED(state),
+ int UNUSED(drawflag),
+ char UNUSED(emboss))
{
wt->wcol = *(wt->wcol_theme);
}
/* special case, button that calls pulldown */
-static void widget_state_pulldown(uiWidgetType *wt, int UNUSED(state), int UNUSED(drawflag))
+static void widget_state_pulldown(uiWidgetType *wt,
+ int UNUSED(state),
+ int UNUSED(drawflag),
+ char UNUSED(emboss))
{
wt->wcol = *(wt->wcol_theme);
}
/* special case, pie menu items */
-static void widget_state_pie_menu_item(uiWidgetType *wt, int state, int UNUSED(drawflag))
+static void widget_state_pie_menu_item(uiWidgetType *wt,
+ int state,
+ int UNUSED(drawflag),
+ char UNUSED(emboss))
{
wt->wcol = *(wt->wcol_theme);
@@ -2703,7 +2712,10 @@ static void widget_state_pie_menu_item(uiWidgetType *wt, int state, int UNUSED(d
}
/* special case, menu items */
-static void widget_state_menu_item(uiWidgetType *wt, int state, int UNUSED(drawflag))
+static void widget_state_menu_item(uiWidgetType *wt,
+ int state,
+ int UNUSED(drawflag),
+ char UNUSED(emboss))
{
wt->wcol = *(wt->wcol_theme);
@@ -3872,7 +3884,8 @@ static void widget_unitvec(
static void widget_icon_has_anim(
uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int roundboxalign)
{
- if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT)) {
+ if (state & (UI_BUT_ANIMATED | UI_BUT_ANIMATED_KEY | UI_BUT_DRIVEN | UI_BUT_REDALERT) &&
+ but->emboss != UI_EMBOSS_NONE) {
uiWidgetBase wtb;
widget_init(&wtb);
wtb.draw_outline = false;
@@ -4051,18 +4064,18 @@ static void widget_optionbut(uiWidgetColors *wcol,
}
/* labels use Editor theme colors for text */
-static void widget_state_label(uiWidgetType *wt, int state, int drawflag)
+static void widget_state_label(uiWidgetType *wt, int state, int drawflag, char emboss)
{
if (state & UI_BUT_LIST_ITEM) {
/* Override default label theme's colors. */
bTheme *btheme = UI_GetTheme();
wt->wcol_theme = &btheme->tui.wcol_list_item;
/* call this for option button */
- widget_state(wt, state, drawflag);
+ widget_state(wt, state, drawflag, emboss);
}
else {
/* call this for option button */
- widget_state(wt, state, drawflag);
+ widget_state(wt, state, drawflag, emboss);
if (state & UI_SELECT) {
UI_GetThemeColor3ubv(TH_TEXT_HI, wt->wcol.text);
}
@@ -4799,7 +4812,7 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
}
#endif
- wt->state(wt, state, drawflag);
+ wt->state(wt, state, drawflag, but->emboss);
if (wt->custom) {
wt->custom(but, &wt->wcol, rect, state, roundboxalign);
}
@@ -4844,7 +4857,7 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_BACK);
- wt->state(wt, 0, 0);
+ wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
if (block) {
wt->draw(&wt->wcol, rect, block->flag, block->direction);
}
@@ -4865,7 +4878,7 @@ void ui_draw_box_opaque(rcti *rect, int roundboxalign)
/* Alpha blend with the region's background color to force an opaque background. */
uiWidgetColors *wcol = &wt->wcol;
- wt->state(wt, 0, 0);
+ wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
float background[4];
UI_GetThemeColor4fv(TH_BACK, background);
float new_inner[4];
@@ -4967,7 +4980,7 @@ void ui_draw_popover_back(struct ARegion *region,
wt->wcol_theme, rect, block->direction, U.widget_unit / block->aspect, mval_origin);
}
else {
- wt->state(wt, 0, 0);
+ wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
wt->draw(&wt->wcol, rect, 0, 0);
}
@@ -5156,7 +5169,7 @@ static void ui_draw_widget_back_color(uiWidgetTypeEnum type,
}
rcti rect_copy = *rect;
- wt->state(wt, 0, 0);
+ wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
if (color) {
rgba_float_to_uchar(wt->wcol.inner, color);
}
@@ -5175,7 +5188,7 @@ void ui_draw_widget_menu_back(const rcti *rect, bool use_shadow)
void ui_draw_tooltip_background(const uiStyle *UNUSED(style), uiBlock *UNUSED(block), rcti *rect)
{
uiWidgetType *wt = widget_type(UI_WTYPE_TOOLTIP);
- wt->state(wt, 0, 0);
+ wt->state(wt, 0, 0, UI_EMBOSS_UNDEFINED);
/* wt->draw ends up using same function to draw the tooltip as menu_back */
wt->draw(&wt->wcol, rect, 0, 0);
}
@@ -5202,7 +5215,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
const rcti _rect = *rect;
char *cpoin = NULL;
- wt->state(wt, state, 0);
+ wt->state(wt, state, 0, UI_EMBOSS_UNDEFINED);
wt->draw(&wt->wcol, rect, 0, 0);
UI_fontstyle_set(fstyle);
@@ -5285,7 +5298,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle,
if (use_sep) {
if (cpoin) {
/* Set inactive state for grayed out text. */
- wt->state(wt, state | UI_BUT_INACTIVE, 0);
+ wt->state(wt, state | UI_BUT_INACTIVE, 0, UI_EMBOSS_UNDEFINED);
rect->xmax = _rect.xmax - 5;
UI_fontstyle_draw(fstyle,
@@ -5309,7 +5322,7 @@ void ui_draw_preview_item(
uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
/* drawing button background */
- wt->state(wt, state, 0);
+ wt->state(wt, state, 0, UI_EMBOSS_UNDEFINED);
wt->draw(&wt->wcol, rect, 0, 0);
/* draw icon in rect above the space reserved for the label */