[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59801] branches/soc-2013-ui_replay/source /blender: Implemented a menu in the toolbar header that allows individual panels to be hidden .
Vincent Akkermans
vincent at ack-err.net
Wed Sep 4 16:34:09 CEST 2013
Revision: 59801
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59801
Author: ack-err
Date: 2013-09-04 14:34:09 +0000 (Wed, 04 Sep 2013)
Log Message:
-----------
Implemented a menu in the toolbar header that allows individual panels to be hidden.
Modified Paths:
--------------
branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h
branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c
branches/soc-2013-ui_replay/source/blender/editors/screen/area.c
branches/soc-2013-ui_replay/source/blender/editors/space_view3d/view3d_toolbar.c
branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h
Modified: branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h 2013-09-04 13:37:35 UTC (rev 59800)
+++ branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h 2013-09-04 14:34:09 UTC (rev 59801)
@@ -668,6 +668,7 @@
void uiEndPanels(const struct bContext *C, struct ARegion *ar, int *x, int *y);
void uiDrawPanels(const struct bContext *C, struct ARegion *ar);
+struct Panel *uiGetExistingPanel(struct ARegion *ar, struct PanelType *pt);
struct Panel *uiBeginPanel(struct ScrArea *sa, struct ARegion *ar, uiBlock *block, struct PanelType *pt, int *open);
void uiEndPanel(uiBlock *block, int width, int height);
void uiScalePanels(struct ARegion *ar, float new_width);
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-09-04 13:37:35 UTC (rev 59800)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_panel.c 2013-09-04 14:34:09 UTC (rev 59801)
@@ -198,6 +198,18 @@
pa->ofsy = papar->ofsy + papar->sizey - pa->sizey;
}
+Panel *uiGetExistingPanel(ARegion *ar, PanelType *pt)
+{
+ Panel *pa = NULL;
+
+ for (pa = ar->panels.first; pa; pa = pa->next)
+ if (strncmp(pa->panelname, pt->idname, UI_MAX_NAME_STR) == 0)
+ if (strncmp(pa->tabname, pt->idname, UI_MAX_NAME_STR) == 0)
+ break;
+
+ return pa;
+}
+
Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int *open)
{
Panel *pa, *patab, *palast, *panext;
@@ -209,10 +221,7 @@
int align = panel_aligned(sa, ar);
/* check if Panel exists, then use that one */
- for (pa = ar->panels.first; pa; pa = pa->next)
- if (strncmp(pa->panelname, idname, UI_MAX_NAME_STR) == 0)
- if (strncmp(pa->tabname, tabname, UI_MAX_NAME_STR) == 0)
- break;
+ pa = uiGetExistingPanel(ar, pt);
newpanel = (pa == NULL);
Modified: branches/soc-2013-ui_replay/source/blender/editors/screen/area.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/screen/area.c 2013-09-04 13:37:35 UTC (rev 59800)
+++ branches/soc-2013-ui_replay/source/blender/editors/screen/area.c 2013-09-04 14:34:09 UTC (rev 59801)
@@ -1658,6 +1658,11 @@
/* draw panel */
if (pt->draw && (!pt->poll || pt->poll(C, pt))) {
+ /* If there's a panel for this paneltype, and that panel is hidden, then do not draw it. */
+ panel = uiGetExistingPanel(ar, pt);
+ if (panel && panel->hidden)
+ continue;
+
block = uiBeginBlock(C, ar, pt->idname, UI_EMBOSS);
panel = uiBeginPanel(sa, ar, block, pt, &open);
Modified: branches/soc-2013-ui_replay/source/blender/editors/space_view3d/view3d_toolbar.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/space_view3d/view3d_toolbar.c 2013-09-04 13:37:35 UTC (rev 59800)
+++ branches/soc-2013-ui_replay/source/blender/editors/space_view3d/view3d_toolbar.c 2013-09-04 14:34:09 UTC (rev 59801)
@@ -122,6 +122,65 @@
CTX_wm_region_set((bContext *)C, ar);
}
+static void active_panel_menu_popup_cb(bContext *C, void *arg, int event)
+{
+ printf("button callback\n");
+}
+
+static void active_panel_menu_popup_button_cb(bContext *C, void *arg1, void *arg2)
+{
+ printf("popup callback\n");
+}
+
+static uiBlock *active_panel_menu_popup_create_block(bContext *C, ARegion *cur_ar, void *arg_ar)
+{
+ uiBlock *block;
+ Panel *pa;
+ ARegion *ar = (ARegion*)arg_ar;
+ uiLayout *layout, *col;
+ uiStyle *style = UI_GetStyle();
+ uiBut *but;
+ const char *context = CTX_data_mode_string(C);
+ int width = 10 * UI_UNIT_X;
+ int height = 12 * UI_UNIT_Y;
+
+ block = uiBeginBlock(C, cur_ar, __func__, UI_EMBOSS);
+ uiBlockClearFlag(block, UI_BLOCK_LOOP);
+ uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT);
+ uiBlockSetHandleFunc(block, active_panel_menu_popup_cb, NULL);
+
+ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, style->panelspace, 0, width - 2 * style->panelspace, height, style);
+ col = uiLayoutColumn(layout, TRUE);
+
+ CTX_wm_region_set(C, ar);
+ for (pa = ar->panels.first; pa; pa = pa->next) {
+ /* Create a button with a callback for each panel that belongs fits the mode */
+ if (!pa->type || pa->type->flag & PNL_NO_HEADER
+ || (context && pa->type->context[0] && strcmp(context, pa->type->context) != 0)
+ || (pa->type->poll && !pa->type->poll(C, pa->type)))
+ continue;
+
+ // TODO: sort order
+
+ uiLayoutRow(col, TRUE);
+ but = uiDefButBitI(block, OPTIONN, 1, 0, pa->drawname, 0, 0, width, UI_UNIT_Y, (int*)&pa->hidden, 0, 0, 0, 0, "Check to hide panel");
+ uiButSetFunc(but, active_panel_menu_popup_button_cb, pa, NULL);
+ }
+ CTX_wm_region_set(C, cur_ar);
+
+ uiBlockLayoutResolve(block, NULL, NULL);
+ uiPopupBoundsBlock(block, 4, 0, 0);
+ uiEndBlock(C, block);
+
+ return block;
+}
+
+static void active_panel_menu_popup(bContext *C, void *arg_ar, void *UNUSED(arg2))
+{
+ uiPupBlock(C, active_panel_menu_popup_create_block, arg_ar);
+}
+
+
static void collapse_all_panels(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2))
{
ScrArea *sa = CTX_wm_area(C);
@@ -131,6 +190,7 @@
static void view3d_toolbar_header_draw(const bContext *C, Panel *pa)
{
+ ARegion *ar = CTX_wm_region(C);
uiLayout *layout = pa->layout;
uiLayout *row = uiLayoutRow(layout, TRUE);
const char *name = "";
@@ -150,6 +210,9 @@
uiItemL(row, name, modeicon);
+ but = uiDefIconBut(uiLayoutGetBlock(row), BUT, 0, ICON_CHECKBOX_HLT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Collapse all panels in this toolbar");
+ uiButSetFunc(but, active_panel_menu_popup, ar, NULL);
+
but = uiDefIconBut(uiLayoutGetBlock(row), BUT, 0, ICON_TRIA_RIGHT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Collapse all panels in this toolbar");
uiButSetFunc(but, collapse_all_panels, pa, NULL);
Modified: branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h
===================================================================
--- branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h 2013-09-04 13:37:35 UTC (rev 59800)
+++ branches/soc-2013-ui_replay/source/blender/makesdna/DNA_screen_types.h 2013-09-04 14:34:09 UTC (rev 59801)
@@ -103,7 +103,8 @@
char panelname[64], tabname[64]; /* defined as UI_MAX_NAME_STR */
char drawname[64]; /* panelname is identifier for restoring location */
int ofsx, ofsy, sizex, sizey;
- short labelofs, pad;
+ short labelofs;
+ short hidden;
short flag, runtime_flag;
short control;
short snap;
More information about the Bf-blender-cvs
mailing list