[Bf-blender-cvs] [e8e7b30a946] greasepencil-object: GPencil: New prop_with_popover template
Antonio Vazquez
noreply at git.blender.org
Thu Feb 27 11:38:08 CET 2020
Commit: e8e7b30a94630b112989f3c87184693a69017e66
Author: Antonio Vazquez
Date: Thu Feb 27 11:37:44 2020 +0100
Branches: greasepencil-object
https://developer.blender.org/rBe8e7b30a94630b112989f3c87184693a69017e66
GPencil: New prop_with_popover template
Created by Julian Eisel
===================================================================
M source/blender/editors/interface/interface.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/interface/interface_layout.c
M source/blender/makesrna/intern/rna_ui_api.c
===================================================================
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 6a5aa59801c..5232c432419 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -4111,9 +4111,9 @@ static void ui_def_but_rna__panel_type(bContext *C, uiLayout *layout, void *but_
void ui_but_rna_menu_convert_to_panel_type(uiBut *but, const char *panel_type)
{
- BLI_assert(but->type == UI_BTYPE_MENU);
- BLI_assert(but->menu_create_func == ui_def_but_rna__menu);
- BLI_assert((void *)but->poin == but);
+ BLI_assert(ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_COLOR));
+ // BLI_assert(but->menu_create_func == ui_def_but_rna__menu);
+ // BLI_assert((void *)but->poin == but);
but->menu_create_func = ui_def_but_rna__panel_type;
but->func_argN = BLI_strdup(panel_type);
}
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 7332f3ee776..9400edc7517 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -3990,7 +3990,12 @@ static void ui_block_open_begin(bContext *C, uiBut *but, uiHandleButtonData *dat
copy_v3_v3(data->vec, data->origvec);
but->editvec = data->vec;
- handlefunc = ui_block_func_COLOR;
+ if (ui_but_menu_draw_as_popover(but)) {
+ popoverfunc = but->menu_create_func;
+ }
+ else {
+ handlefunc = ui_block_func_COLOR;
+ }
arg = but;
break;
@@ -4060,8 +4065,8 @@ int ui_but_menu_direction(uiBut *but)
}
/**
- * Hack for #uiList #UI_BTYPE_LISTROW buttons to "give" events to overlaying #UI_BTYPE_TEXT buttons
- * (Ctrl-Click rename feature & co).
+ * Hack for #uiList #UI_BTYPE_LISTROW buttons to "give" events to overlaying #UI_BTYPE_TEXT
+ * buttons (Ctrl-Click rename feature & co).
*/
static uiBut *ui_but_list_row_text_activate(bContext *C,
uiBut *but,
@@ -5550,14 +5555,13 @@ static int ui_do_but_BLOCK(bContext *C, uiBut *but, uiHandleButtonData *data, co
button_activate_state(C, but, BUTTON_STATE_EXIT);
ui_apply_but(C, but->block, but, data, true);
- /* Button's state need to be changed to EXIT so moving mouse away from this mouse wouldn't
- * lead to cancel changes made to this button, but changing state to EXIT also makes no
- * button active for a while which leads to triggering operator
- * when doing fast scrolling mouse wheel.
- * using post activate stuff from button allows to make button be active again after
- * checking for all all that mouse leave and cancel stuff,
- * so quick scroll wouldn't be an issue anymore.
- * Same goes for scrolling wheel in another direction below (sergey).
+ /* Button's state need to be changed to EXIT so moving mouse away from this mouse
+ * wouldn't lead to cancel changes made to this button, but changing state to EXIT also
+ * makes no button active for a while which leads to triggering operator when doing fast
+ * scrolling mouse wheel. using post activate stuff from button allows to make button be
+ * active again after checking for all all that mouse leave and cancel stuff, so quick
+ * scroll wouldn't be an issue anymore. Same goes for scrolling wheel in another
+ * direction below (sergey).
*/
data->postbut = but;
data->posttype = BUTTON_ACTIVATE_OVER;
@@ -9506,7 +9510,8 @@ static int ui_handle_menu_event(bContext *C,
/* Closing sub-levels of pull-downs.
*
* The actual event is handled by the button under the cursor.
- * This is done so we can right click on menu items even when they have sub-menus open. */
+ * This is done so we can right click on menu items even when they have sub-menus open.
+ */
case RIGHTMOUSE:
if (inside == false) {
if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) {
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 64c0e11976b..ae816b51bf1 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2325,7 +2325,7 @@ void uiItemFullR_with_popover(uiLayout *layout,
uiItemFullR(layout, ptr, prop, index, value, flag, name, icon);
but = but->next;
while (but) {
- if (but->rnaprop == prop && but->type == UI_BTYPE_MENU) {
+ if (but->rnaprop == prop && ELEM(but->type, UI_BTYPE_MENU, UI_BTYPE_COLOR)) {
ui_but_rna_menu_convert_to_panel_type(but, panel_type);
break;
}
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 527df695f5b..8b112031ada 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -152,8 +152,10 @@ static void rna_uiItemR_with_popover(uiLayout *layout,
RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
- if (RNA_property_type(prop) != PROP_ENUM) {
- RNA_warning("property is not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
+ if ((RNA_property_type(prop) != PROP_ENUM) &&
+ !ELEM(RNA_property_subtype(prop), PROP_COLOR, PROP_COLOR_GAMMA)) {
+ RNA_warning(
+ "property is not an enum or color: %s.%s", RNA_struct_identifier(ptr->type), propname);
return;
}
int flag = 0;
More information about the Bf-blender-cvs
mailing list