[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60068] branches/soc-2013-ui_replay/source /blender/editors: Dividers can now be dragged.

Vincent Akkermans vincent at ack-err.net
Thu Sep 12 13:43:53 CEST 2013


Revision: 60068
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60068
Author:   ack-err
Date:     2013-09-12 11:43:52 +0000 (Thu, 12 Sep 2013)
Log Message:
-----------
Dividers can now be dragged. Buttons display a bit of text if there is no icon yet.

Modified Paths:
--------------
    branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c
    branches/soc-2013-ui_replay/source/blender/editors/interface/interface_layout.c
    branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c
    branches/soc-2013-ui_replay/source/blender/editors/screen/area.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-09-12 10:44:03 UTC (rev 60067)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c	2013-09-12 11:43:52 UTC (rev 60068)
@@ -7710,6 +7710,7 @@
 	while (dunits_iter != 0) {
 		oli_iter = dunits < 0 ? oli_iter->prev : oli_iter->next;
 		if (oli_iter == NULL) break;
+		// TODO: also take into account closed groups
 		if (strcmp(oli_iter->context, CTX_data_mode_string(C)) != 0)
 			extra_units += (dunits < 0 ? -1 : 1);
 		dunits_iter += (dunits < 0 ? 1 : -1);
@@ -7778,7 +7779,6 @@
 	return retval;
 }
 
-//static void ui_handler_region_drag_shelf_remove(bContext *C, void *userdata)
 static void ui_handler_region_drag_shelf_remove(bContext *UNUSED(C), void *UNUSED(userdata))
 {
 //	ARegion *ar = userdata;
@@ -7814,9 +7814,11 @@
 			OperatorListItem *oli = NULL;
 			uiBut *but = ui_but_find_activated(ar);
 			
-			// TODO: the divider buttons don't match these checks, so they can't be dragged yet
-			if (but->optype) {
-				oli = uiOperatorListItemPresent(&ar->operators, but->optype->idname, but->opptr ? but->opptr->data : NULL, CTX_data_mode_string(C));
+			if (but->optype || but->func_arg1) {
+				if (but->optype)
+					oli = uiOperatorListItemPresent(&ar->operators, but->optype->idname, but->opptr ? but->opptr->data : NULL, CTX_data_mode_string(C));
+				else
+					oli = (OperatorListItem*)but->func_arg1;
 				
 				if (oli) {
 					data = MEM_callocN(sizeof(uiHandleRegionDragData), "uiHandleRegionDragData");
@@ -7868,9 +7870,7 @@
 		retval = ui_handle_list_event(C, event, ar);
 
 	/* only if there's no drag going on inside the region */
-	if (retval == WM_UI_HANDLER_CONTINUE
-//		&& (ar->dragdata == NULL || (uiHandleRegionDragData*)(ar->dragdata)->state == REGION_STATE_DRAG_BUTTON_WAITING)
-		)
+	if (retval == WM_UI_HANDLER_CONTINUE)
 	{
 		if (but)
 			retval = ui_handle_button_event(C, event, but);

Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_layout.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_layout.c	2013-09-12 10:44:03 UTC (rev 60067)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_layout.c	2013-09-12 11:43:52 UTC (rev 60068)
@@ -701,6 +701,8 @@
 	if ((!(flag & UI_ITEM_O_SINGLE_UNIT) || flag & UI_ITEM_O_SHORTCUT)
 		&& block->flag & UI_BLOCK_SHORTCUTS)
 		w = ui_text_icon_width(layout, "|", icon, 0);
+	else if (flag & UI_ITEM_O_SINGLE_UNIT)
+		w = UI_UNIT_X;
 	else
 		w = ui_text_icon_width(layout, name, icon, 0);
 

Modified: branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c	2013-09-12 10:44:03 UTC (rev 60067)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_widgets.c	2013-09-12 11:43:52 UTC (rev 60068)
@@ -33,7 +33,6 @@
 #include <string.h>
 #include <assert.h>
 
-
 #include "DNA_screen_types.h"
 #include "DNA_userdef_types.h"
 

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-12 10:44:03 UTC (rev 60067)
+++ branches/soc-2013-ui_replay/source/blender/editors/screen/area.c	2013-09-12 11:43:52 UTC (rev 60068)
@@ -1855,18 +1855,21 @@
 	oli->flag ^= OLI_DIVIDER_CLOSED;
 }
 
-void static menubar_draw_oli(uiLayout *row, OperatorListItem *oli, int *draw_buttons)
+void static menubar_draw_oli(const bContext *C, uiLayout *row, OperatorListItem *oli, int *draw_buttons)
 {
 	uiBlock *block = uiLayoutGetBlock(row);
 	uiBut *but;
-	
+
 	if (oli && row) {
 		if (oli->flag & OLI_DIVIDER) {
 			uiItemS(row);
 			uiBlockSetEmboss(block, UI_EMBOSSN);
-//			uiDefIconButBitI(block, TOGBUT, OLI_DIVIDER_CLOSED, 0, (oli->flag & OLI_DIVIDER_CLOSED ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN), 0, 0, UI_UNIT_X/2, UI_UNIT_Y, &(oli->flag), 0.f, 0.f, 0.f, 0.f, "When checked shows the buttons to the right");
-			but = uiDefIconBut(block, BUT, 0, (oli->flag & OLI_DIVIDER_CLOSED ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN), 0, 0, UI_UNIT_X/3, UI_UNIT_Y, NULL, 0, 0, 0, 0, "When checked shows the buttons to the right");
+			but = uiDefIconBut(block, BUT, -1, (oli->flag & OLI_DIVIDER_CLOSED ? ICON_DISCLOSURE_TRI_RIGHT : ICON_DISCLOSURE_TRI_DOWN), 0, 0, UI_UNIT_X/3, UI_UNIT_Y, NULL, 0, 0, 0, 0, "When checked shows the buttons to the right");
+
+			/* N.B. func_arg1 is also used for the drag system */
 			uiButSetFunc(but, menubar_fold_divider, oli, NULL);
+			/* Hack to make the button system not catch drag events for non-operator buttons */
+			uiButSetDragOp(but, (wmOperatorType*)oli);
 			uiBlockSetEmboss(block, UI_EMBOSS);
 			uiItemS(row);
 			
@@ -1875,7 +1878,17 @@
 		else {
 			if (*draw_buttons) {
 				wmOperatorType *ot = WM_operatortype_find(oli->optype_idname, TRUE);
-				uiItemFullO_ptr(row, ot, "", ICON_AUTOMATIC, IDP_CopyProperty(oli->properties), oli->opcontext, 0);
+				int icon = ICON_NONE;
+				PointerRNA ptr;
+				
+				RNA_pointer_create(NULL, &RNA_Operator, oli->properties, &ptr);
+				icon = ot->icon ? ot->icon(C, &ptr) : ot->default_icon;
+				
+				if (icon != ICON_NONE)
+					uiItemFullO_ptr(row, ot, "", ICON_AUTOMATIC, IDP_CopyProperty(oli->properties), oli->opcontext, 0);
+				else
+					uiItemFullO_ptr(row, ot, ot->name, ICON_NONE, IDP_CopyProperty(oli->properties), oli->opcontext, UI_ITEM_O_SINGLE_UNIT);
+					
 			}
 		}
 	}
@@ -1918,27 +1931,27 @@
 				int cur_index = BLI_findindex(&ar->operators, oli_dragged);
 				// draw it before or after the button that currently has the new index
 				if (newindex == cur_index) {
-					menubar_draw_oli(row, oli_iter, &draw_buttons);
+					menubar_draw_oli(C, row, oli_iter, &draw_buttons);
 				}
 				else if (newindex < cur_index) {
-					menubar_draw_oli(row, oli_dragged, &draw_buttons);
+					menubar_draw_oli(C, row, oli_dragged, &draw_buttons);
 					if (strcmp(oli_iter->context, CTX_data_mode_string(C)) == 0)
-						menubar_draw_oli(row, oli_iter, &draw_buttons);
+						menubar_draw_oli(C, row, oli_iter, &draw_buttons);
 				}
 				else if (newindex > cur_index) {
 					if (strcmp(oli_iter->context, CTX_data_mode_string(C)) == 0)
-						menubar_draw_oli(row, oli_iter, &draw_buttons);
-					menubar_draw_oli(row, oli_dragged, &draw_buttons);
+						menubar_draw_oli(C, row, oli_iter, &draw_buttons);
+					menubar_draw_oli(C, row, oli_dragged, &draw_buttons);
 				}
 			}
 			// otherwise just draw normally
 			else if (oli_iter != oli_dragged)
 				if (strcmp(oli_iter->context, CTX_data_mode_string(C)) == 0)
-					menubar_draw_oli(row, oli_iter, &draw_buttons);
+					menubar_draw_oli(C, row, oli_iter, &draw_buttons);
 		}
 		else
 			if (strcmp(oli_iter->context, CTX_data_mode_string(C)) == 0)
-				menubar_draw_oli(row, oli_iter, &draw_buttons);
+				menubar_draw_oli(C, row, oli_iter, &draw_buttons);
 		i++;
 	}
 	




More information about the Bf-blender-cvs mailing list