[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60172] branches/soc-2013-ui_replay/source /blender/editors: Failed attempt at refreshing popup blocks in commented code.

Vincent Akkermans vincent at ack-err.net
Mon Sep 16 18:00:19 CEST 2013


Revision: 60172
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60172
Author:   ack-err
Date:     2013-09-16 16:00:19 +0000 (Mon, 16 Sep 2013)
Log Message:
-----------
Failed attempt at refreshing popup blocks in commented code.

Modified Paths:
--------------
    branches/soc-2013-ui_replay/source/blender/editors/interface/interface_regions.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

Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_regions.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_regions.c	2013-09-16 15:48:37 UTC (rev 60171)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_regions.c	2013-09-16 16:00:19 UTC (rev 60172)
@@ -2830,6 +2830,9 @@
 	return block->_hsv;
 }
 
+/* OperatorListItem utility functions for dragging in the Menubar */
+
+/* Retrieve the OperatorListItem that is being dragged */
 OperatorListItem *uiRegionDraggedOperatorListItem(ARegion *ar)
 {
 	OperatorListItem *oli = NULL;
@@ -2845,6 +2848,7 @@
 	return oli;
 }
 
+/* Retrieve the new index for the dropped OperatorListItem */
 int uiRegionDraggedNewIndex(ARegion *ar)
 {
 	uiHandleRegionDragData *data;

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-16 15:48:37 UTC (rev 60171)
+++ branches/soc-2013-ui_replay/source/blender/editors/screen/area.c	2013-09-16 16:00:19 UTC (rev 60172)
@@ -1597,7 +1597,9 @@
 	}
 
 	uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
-	
+
+	uiBlockSetEmboss(block, UI_EMBOSS);
+
 	return xco + U.widget_unit;
 }
 

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-16 15:48:37 UTC (rev 60171)
+++ branches/soc-2013-ui_replay/source/blender/editors/space_view3d/view3d_toolbar.c	2013-09-16 16:00:19 UTC (rev 60172)
@@ -131,9 +131,21 @@
 	CTX_wm_region_set((bContext *)C, ar);
 }
 
-static void active_panel_menu_popup_cb(bContext *UNUSED(C), void *arg_ar, int UNUSED(event))
+static uiBlock *active_panel_menu_popup_create_block(bContext *C, ARegion *cur_ar, void *arg_ar);
+
+static void active_panel_menu_popup_cb(bContext *C, void *UNUSED(arg_block), int UNUSED(event))
 {
-	ARegion *ar = (ARegion *)arg_ar;
+	ScrArea *sa = CTX_wm_area(C);
+	ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_TOOLS);
+//	uiBlock *block = (uiBlock*)arg_block;
+
+	/* This results in a crash that has something to do with recursion 
+	   in the event handling system. I'm not quite sure it is possible
+	   to refresh popup blocks.
+	 */
+//	uiPupBlockClose(C, block);
+//	uiPupBlock(C, active_panel_menu_popup_create_block, ar);
+
 	ED_region_tag_redraw(ar);
 }
 
@@ -156,17 +168,49 @@
 	const char *context = CTX_data_mode_string(C);
 	int width = 10 * UI_UNIT_X;
 	int height = 12 * UI_UNIT_Y;
+//	bool all_showing = true;
 	
 	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, ar);
-	
+	uiBlockSetHandleFunc(block, active_panel_menu_popup_cb, block);
+
 	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);
+
 	BLI_sortlist(&ar->panels, sort_panels_by_sortorder);
+	
+	/* 
+	 The following code is meant to show 2 buttons:
+	 1. - Show all => a button that is shown if 1 or more panels are hidden and unhides all panels when pressed.
+		- Hide all => a button that is shown if all panels are visible and hides all panels when pressed
+	 2. Invert => a button that hides the visible panels and unhides the hidden ones when pressed.
+	 
+	 However, it is not so easy to redraw a popup block and this 
+	 severly limits the usefulness of these buttons. The rest of the 
+	 buttons don't update accordingly and the panel would have to be 
+	 reopened again by the user. Without these extra buttons the panel 
+	 is conceptually clear, and I doubt that the extra buttons would 
+	 be very helpful.
+	 */
+	
+//	for (pa = ar->panels.first; pa; pa = pa->next) {
+//		/* check to see if this panel should be considered */
+//		if (pa->type && !(pa->type->flag & PNL_NO_HEADER) &&
+//			(pa->type->context[0] ? strcmp(context, pa->type->context) == 0 : true) &&
+//			(pa->type->poll ? pa->type->poll(C, pa->type) : true)) {
+//			/* if any panel is not hidden, break */
+//			if (pa->hidden) {
+//				all_showing = false;
+//				break;
+//			}
+//		}
+//	}
+//	
+//	but = uiDefBut(block, BUT, 1, !all_showing ? "Show all" : "Hide all", 0, 0, width, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Show all panels");
+//	// TODO: set callback that shows or hides all panels.
+			
 	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
@@ -221,7 +265,7 @@
 
 	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");
+	but = uiDefIconBut(uiLayoutGetBlock(row), BUT, 0, ICON_CHECKBOX_HLT, 0, 0, UI_UNIT_X, UI_UNIT_Y, NULL, 0, 0, 0, 0, "Show and hide panels");
 	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");




More information about the Bf-blender-cvs mailing list