[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59606] branches/soc-2013-ui_replay/source /blender/editors/interface: Added the option to remove operator buttons from custom panels in the right click menu .
Vincent Akkermans
vincent at ack-err.net
Wed Aug 28 17:25:01 CEST 2013
Revision: 59606
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59606
Author: ack-err
Date: 2013-08-28 15:25:01 +0000 (Wed, 28 Aug 2013)
Log Message:
-----------
Added the option to remove operator buttons from custom panels in the right click menu.
Modified Paths:
--------------
branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c
branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c
Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c 2013-08-28 14:48:04 UTC (rev 59605)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c 2013-08-28 15:25:01 UTC (rev 59606)
@@ -4959,6 +4959,16 @@
WM_operator_default_properties_store(op);
}
+static void remove_from_custom_panel(bContext *UNUSED(C), void *arg_pa, void *arg_optype)
+{
+ Panel *pa = arg_pa;
+ wmOperatorType *ot = arg_optype;
+ OperatorListItem *oli;
+
+ oli = BLI_findstring(&pa->operators, ot->idname, offsetof(OperatorListItem, optype_idname));
+ BLI_freelinkN(&pa->operators, oli);
+}
+
static bool ui_but_menu(bContext *C, uiBut *but)
{
uiPopupMenu *pup;
@@ -5211,11 +5221,25 @@
uiItemS(layout);
{
- uiBut *icon_add_but = uiDefIconTextBut(block, BUT, 0, ICON_NONE, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Icon Shelf"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
- uiButSetFunc(icon_add_but, add_to_icon_shelf, but->optype, NULL);
+ uiBut *opp_but;
+ ARegion *ar = CTX_wm_region(C);
+ Panel *pa = but->block->panel;
- uiItemMenuF(layout, IFACE_("Add to Custom Panel..."), ICON_NONE, add_to_custom_panel_menu, but->optype);
+ /* Remove the operator from the custom enclosure */
+ if (ar->regiontype == RGN_TYPE_TOOLS) {
+
+ opp_but = uiDefIconTextBut(block, BUT, 0, ICON_NONE, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove From Custom Panel"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(opp_but, remove_from_custom_panel, pa, but->optype);
+ }
+ else if (ar->regiontype == RGN_TYPE_MENU_BAR) {
+
+ }
+ opp_but = uiDefIconTextBut(block, BUT, 0, ICON_NONE, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Icon Shelf"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+ uiButSetFunc(opp_but, add_to_icon_shelf, but->optype, NULL);
+
+ uiItemMenuF(layout, IFACE_("Add to Custom Panel..."), ICON_NONE, add_to_custom_panel_menu, but->optype);
+
}
uiItemS(layout);
Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c 2013-08-28 14:48:04 UTC (rev 59605)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c 2013-08-28 15:25:01 UTC (rev 59606)
@@ -1406,9 +1406,6 @@
retval = WM_UI_HANDLER_BREAK;
continue;
}
- else if (event->type == RIGHTMOUSE && pa->flag & PNL_CUSTOM_PANEL) {
- uiPupBlock(C, custom_panel_options_create_block, block->panel);
- }
}
/* on active button, do not handle panels */
@@ -1482,6 +1479,9 @@
}
#endif
}
+ else if (event->type == RIGHTMOUSE && pa->flag & PNL_CUSTOM_PANEL) {
+ uiPupBlock(C, custom_panel_options_create_block, block->panel);
+ }
}
}
}
More information about the Bf-blender-cvs
mailing list