[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59881] branches/soc-2013-ui_replay/source /blender: Buttons in the icon shelf are now icon-only.

Vincent Akkermans vincent at ack-err.net
Fri Sep 6 16:33:00 CEST 2013


Revision: 59881
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59881
Author:   ack-err
Date:     2013-09-06 14:32:59 +0000 (Fri, 06 Sep 2013)
Log Message:
-----------
Buttons in the icon shelf are now icon-only. The region and buttons are 1.5 * the normal button size. Adding and removing buttons take into account the operator properties.

Modified Paths:
--------------
    branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h
    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/screen/area.c
    branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c
    branches/soc-2013-ui_replay/source/blender/editors/transform/transform_ops.c
    branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c

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-06 13:25:54 UTC (rev 59880)
+++ branches/soc-2013-ui_replay/source/blender/editors/include/UI_interface.h	2013-09-06 14:32:59 UTC (rev 59881)
@@ -904,6 +904,10 @@
 void uiItemMenuEnumO(uiLayout *layout, struct bContext *C, const char *opname, const char *propname, const char *name, int icon);
 void uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name, int icon);
 
+/* OperatorListItem utilities */
+int uiOperatorListItemPresent(ListBase *lb, const char *idname, IDProperty *properties);
+
+
 /* UI Operators */
 void UI_buttons_operatortypes(void);
 

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-06 13:25:54 UTC (rev 59880)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_handlers.c	2013-09-06 14:32:59 UTC (rev 59881)
@@ -5072,6 +5072,7 @@
 //	WM_operator_default_properties_store(op);
 //}
 
+// TODO: this should make use of the new comparison method, perhaps based on sort order
 static void remove_from_custom_panel(bContext *UNUSED(C), void *arg_pa, void *arg_optype)
 {
 	Panel *pa = arg_pa;
@@ -5083,15 +5084,21 @@
 	BKE_operator_list_item_free(oli);
 }
 
-static void remove_from_menu_bar(bContext *UNUSED(C), void *arg_ar, void *arg_optype)
+static void remove_from_icon_shelf(bContext *C, void *arg_ot, void *arg_opptr)
 {
-	ARegion *ar = arg_ar;
-	wmOperatorType *ot = arg_optype;
+	ARegion *ar = CTX_wm_region(C);
+	wmOperatorType *ot = arg_ot;
+	PointerRNA *opptr = (PointerRNA*)arg_opptr;
 	OperatorListItem *oli;
 	
-	oli = BLI_findstring(&ar->operators, ot->idname, offsetof(OperatorListItem, optype_idname));
-	BLI_remlink(&ar->operators, oli);
-	BKE_operator_list_item_free(oli);
+	for (oli = ar->operators.first; oli; oli = oli->next) {
+		if (strcmp(oli->optype_idname, ot->idname) == 0 && IDP_EqualsProperties(opptr->data, oli->properties)) {
+			BLI_remlink(&ar->operators, oli);
+			BKE_operator_list_item_free(oli);
+		}
+	}
+	
+	ED_region_tag_redraw(ar);
 }
 
 static bool ui_but_menu(bContext *C, uiBut *but)
@@ -5354,17 +5361,17 @@
 				uiButSetFunc(opp_but, remove_from_custom_panel, pa, but->optype);
 				uiItemS(layout);
 			}
-			else if (ar->regiontype == RGN_TYPE_MENU_BAR && BLI_findstring(&ar->operators, but->optype->idname
-, offsetof(OperatorListItem, optype_idname)) != NULL) {
-				opp_but = uiDefIconTextBut(block, BUT, 0, ICON_NONE, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove From Menu Bar"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
-				uiButSetFunc(opp_but, remove_from_menu_bar, ar, but->optype);
+			else if (ar->regiontype == RGN_TYPE_MENU_BAR &&
+					 uiOperatorListItemPresent(&ar->operators, but->optype->idname, but->opptr->data)) {
+				opp_but = uiDefIconTextBut(block, BUT, 0, ICON_NONE, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Remove From Icon Shelf"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, "");
+				uiButSetFunc(opp_but, remove_from_icon_shelf, but->optype, but->opptr);
 				uiItemS(layout);
 			}
 			
 			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);
+			uiButSetFunc(opp_but, add_to_icon_shelf, but->optype, but->opptr);
 			
-			uiItemMenuF(layout, IFACE_("Add to Custom Panel..."), ICON_NONE, add_to_custom_panel_menu, but->optype);			
+			uiItemMenuF(layout, IFACE_("Add to Custom Panel..."), ICON_NONE, add_to_custom_panel_menu, but->optype);
 			
 		}
 		

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-06 13:25:54 UTC (rev 59880)
+++ branches/soc-2013-ui_replay/source/blender/editors/interface/interface_layout.c	2013-09-06 14:32:59 UTC (rev 59881)
@@ -1822,6 +1822,37 @@
 	ui_item_menu(layout, name, icon, menu_item_enum_rna_menu, NULL, lvl, RNA_property_description(prop), false);
 }
 
+/********************* OperatorListItem utilities ********************/
+
+/* return 1 when an OperatorListItem with the same name and properties is already present in lb */
+int uiOperatorListItemPresent(ListBase *lb, const char *idname, IDProperty *properties)
+{
+	OperatorListItem *oli;
+	
+	for (oli = lb->first; oli; oli = oli->next) {
+		
+		if (strcmp(oli->optype_idname, idname) == 0) {
+			/* if no idprops are present, and the name is the same */
+			if (oli->properties == NULL && properties == NULL) {
+				return 1;
+			}
+			/* if one of the properties is set, then they are not equal */
+			else if (oli->properties == NULL || properties == NULL) {
+				continue;
+			}
+			else if (IDP_EqualsProperties(oli->properties, properties)) {
+				return 1;
+			}
+		}
+		else {
+			continue;
+		}
+	}
+	
+	return 0;
+}
+
+
 /**************************** Layout Items ***************************/
 
 /* single-row layout */

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-06 13:25:54 UTC (rev 59880)
+++ branches/soc-2013-ui_replay/source/blender/editors/screen/area.c	2013-09-06 14:32:59 UTC (rev 59881)
@@ -957,9 +957,12 @@
 	/* prefsize, for header we stick to exception (prevent dpi rounding error) */
 	prefsizex = UI_DPI_FAC * (ar->sizex > 1 ? ar->sizex + 0.5f : ar->type->prefsizex);
 	
-	if (ar->regiontype == RGN_TYPE_HEADER || ar->regiontype == RGN_TYPE_MENU_BAR) {
+	if (ar->regiontype == RGN_TYPE_HEADER) {
 		prefsizey = ED_area_headersize();
 	}
+	else if (ar->regiontype == RGN_TYPE_MENU_BAR) {
+		prefsizey = ED_area_headersize() * 1.5f;
+	}
 	else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) {
 		prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2);
 	}
@@ -1854,7 +1857,7 @@
 //	MenuBarType *mbt;
 //	MenuBar mb = {NULL};
 	int maxco, xco, yco;
-	int headery = ED_area_headersize();
+	int headery = ED_area_headersize() * 1.5f;
 //	const char *context = CTX_data_mode_string(C);
 	OperatorListItem *oli;
 	
@@ -1900,11 +1903,13 @@
 	block = uiBeginBlock(C, ar, "menubar icons", UI_EMBOSS);
 	layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style);
 	row = uiLayoutRow(layout, TRUE);
+	uiLayoutSetScaleX(row, 1.5f);
+	uiLayoutSetScaleY(row, 1.5f);
 	
 	for (oli = ar->operators.first; oli; oli = oli->next) {
 		if (strcmp(oli->context, CTX_data_mode_string(C)) == 0) {
 			wmOperatorType *ot = WM_operatortype_find(oli->optype_idname, TRUE);
-			uiItemFullO_ptr(row, ot, ot->name, ICON_AUTOMATIC, IDP_CopyProperty(oli->properties), oli->opcontext, 0);
+			uiItemFullO_ptr(row, ot, "", ICON_AUTOMATIC, IDP_CopyProperty(oli->properties), oli->opcontext, UI_ITEM_O_SINGLE_UNIT);
 		}
 	}
 

Modified: branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c	2013-09-06 13:25:54 UTC (rev 59880)
+++ branches/soc-2013-ui_replay/source/blender/editors/space_view3d/space_view3d.c	2013-09-06 14:32:59 UTC (rev 59881)
@@ -625,8 +625,9 @@
 	ARegion *ar = CTX_wm_region(C);
 
 	if (drag->type == WM_DRAG_OP && ot && ar && ar->regiontype == RGN_TYPE_MENU_BAR) {
-		if (!BLI_findstring(&ar->operators, ot->idname, offsetof(OperatorListItem, optype_idname)))
-			return 1;
+		/* check to see if an oli with the same properties is already present */
+		if (drag->ptr)
+			return !uiOperatorListItemPresent(&ar->operators, ot->idname, drag->ptr->data);
 	}
 	
 	return 0;
@@ -666,15 +667,16 @@
 {
 	wmOperatorType *ot = (wmOperatorType*)drag->poin;
 	Panel *pa = NULL;
-	void *present_p = NULL;
+	int present_p = 0;
 
 	if (drag->type == WM_DRAG_OP && ot) {
 		pa = over_panel(C, event);
-		if (pa != NULL)
-			present_p = BLI_findstring(&pa->operators, ot->idname, offsetof(OperatorListItem, optype_idname));
+		if (pa != NULL && drag->ptr && drag->ptr->data)
+			/* check to see if an oli with the same properties is already present */
+			present_p =	uiOperatorListItemPresent(&pa->operators, ot->idname, drag->ptr->data);
 	}
 	
-	return pa != NULL && present_p == NULL;
+	return pa != NULL && !present_p;
 }
 
 /* region dropbox definition */

Modified: branches/soc-2013-ui_replay/source/blender/editors/transform/transform_ops.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/editors/transform/transform_ops.c	2013-09-06 13:25:54 UTC (rev 59880)
+++ branches/soc-2013-ui_replay/source/blender/editors/transform/transform_ops.c	2013-09-06 14:32:59 UTC (rev 59881)
@@ -557,6 +557,7 @@
 	ot->description = "Translate (move) selected items";
 	ot->idname = OP_TRANSLATION;
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+	ot->default_icon = ICON_MAN_TRANS;
 
 	/* api callbacks */
 	ot->invoke = transform_invoke;
@@ -577,6 +578,7 @@
 	ot->description = "Scale (resize) selected items"; 
 	ot->idname = OP_RESIZE;
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+	ot->default_icon = ICON_MAN_SCALE;
 
 	/* api callbacks */
 	ot->invoke = transform_invoke;
@@ -653,6 +655,7 @@
 	ot->description = "Rotate selected items";
 	ot->idname = OP_ROTATION;
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
+	ot->default_icon = ICON_MAN_ROT;
 
 	/* api callbacks */
 	ot->invoke = transform_invoke;

Modified: branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c	2013-09-06 13:25:54 UTC (rev 59880)
+++ branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c	2013-09-06 14:32:59 UTC (rev 59881)
@@ -4164,8 +4164,9 @@
 	{
 		wmOperatorType *ot = (wmOperatorType*)ot_arg;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list