[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59192] branches/soc-2013-ui_replay: Started on custom panels and icon shelf that can be defined at runtime.

Vincent Akkermans vincent at ack-err.net
Fri Aug 16 16:12:52 CEST 2013


Revision: 59192
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59192
Author:   ack-err
Date:     2013-08-16 14:12:52 +0000 (Fri, 16 Aug 2013)
Log Message:
-----------
Started on custom panels and icon shelf that can be defined at runtime. 

* currently saves in blend file
* interface is very rough still
* text-buttons only
* paint/sculpt modes have not yet been transitioned to the menubar approach

Modified Paths:
--------------
    branches/soc-2013-ui_replay/release/scripts/startup/bl_ui/space_view3d_menubar.py
    branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h
    branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c
    branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c
    branches/soc-2013-ui_replay/source/blender/blenloader/intern/versioning_250.c
    branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c
    branches/soc-2013-ui_replay/source/blender/editors/include/ED_screen.h
    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_panel.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/makesdna/DNA_screen_types.h
    branches/soc-2013-ui_replay/source/blender/makesrna/intern/rna_ui.c
    branches/soc-2013-ui_replay/source/blender/windowmanager/WM_api.h
    branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_init_exit.c
    branches/soc-2013-ui_replay/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/soc-2013-ui_replay/release/scripts/startup/bl_ui/space_view3d_menubar.py
===================================================================
--- branches/soc-2013-ui_replay/release/scripts/startup/bl_ui/space_view3d_menubar.py	2013-08-16 13:58:39 UTC (rev 59191)
+++ branches/soc-2013-ui_replay/release/scripts/startup/bl_ui/space_view3d_menubar.py	2013-08-16 14:12:52 UTC (rev 59192)
@@ -899,8 +899,6 @@
     def draw(self, context):
         layout = self.layout
         layout.operator_context = 'INVOKE_REGION_WIN'
-        layout.operator_enum("mesh.merge", "type")
-        layout.separator()
         layout.operator("mesh.merge", text="Merge at Center").type = 'CENTER'
         layout.operator("mesh.merge", text="Merge at Cursor").type = 'CURSOR'
         layout.operator("mesh.merge", text="Merge at First").type = 'FIRST'

Modified: branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h	2013-08-16 13:58:39 UTC (rev 59191)
+++ branches/soc-2013-ui_replay/source/blender/blenkernel/BKE_screen.h	2013-08-16 14:12:52 UTC (rev 59192)
@@ -294,6 +294,7 @@
 
 struct ARegion *BKE_area_find_region_type(struct ScrArea *sa, int type);
 struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
+struct ARegion *BKE_spacelink_find_region_type(struct SpaceLink *sl, int type);
 struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min);
 
 void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene);

Modified: branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c	2013-08-16 13:58:39 UTC (rev 59191)
+++ branches/soc-2013-ui_replay/source/blender/blenkernel/intern/screen.c	2013-08-16 14:12:52 UTC (rev 59192)
@@ -74,6 +74,7 @@
 
 		BLI_freelistN(&art->paneltypes);
 		BLI_freelistN(&art->headertypes);
+		BLI_freelistN(&art->menubartypes);
 	}
 	
 	BLI_freelistN(&st->regiontypes);
@@ -262,6 +263,8 @@
 /* not region itself */
 void BKE_area_region_free(SpaceType *st, ARegion *ar)
 {
+	Panel *pa;
+	
 	if (st) {
 		ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype);
 		
@@ -278,9 +281,14 @@
 		MEM_freeN(ar->v2d.tab_offset);
 		ar->v2d.tab_offset = NULL;
 	}
+	
+	for (pa = ar->panels.first; pa; pa = pa->next) {
+		BLI_freelistN(&pa->operators);
+	}
 
 	BLI_freelistN(&ar->panels);
 	BLI_freelistN(&ar->ui_lists);
+	BLI_freelistN(&ar->operators);
 }
 
 /* not area itself */
@@ -369,6 +377,20 @@
 	return NULL;
 }
 
+/* Find a region of the specified type from the given area */
+ARegion *BKE_spacelink_find_region_type(SpaceLink *sl, int type)
+{
+	if (sl) {
+		ARegion *ar;
+		
+		for (ar = sl->regionbase.first; ar; ar = ar->next) {
+			if (ar->regiontype == type)
+				return ar;
+		}
+	}
+	return NULL;
+}
+
 /* note, using this function is generally a last resort, you really want to be
  * using the context when you can - campbell
  * -1 for any type */

Modified: branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c	2013-08-16 13:58:39 UTC (rev 59191)
+++ branches/soc-2013-ui_replay/source/blender/blenloader/intern/readfile.c	2013-08-16 14:12:52 UTC (rev 59192)
@@ -6102,6 +6102,8 @@
 		pa->runtime_flag = 0;
 		pa->activedata = NULL;
 		pa->type = NULL;
+		
+		link_list(fd, &pa->operators);
 	}
 
 	link_list(fd, &ar->ui_lists);
@@ -6109,6 +6111,8 @@
 	for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next) {
 		ui_list->type = NULL;
 	}
+	
+	link_list(fd, &ar->operators);
 
 	ar->regiondata = newdataadr(fd, ar->regiondata);
 	if (ar->regiondata) {
@@ -9478,7 +9482,105 @@
 			}
 		}
 	}
+	
+	/* Remove the tool properties region from the space and clip toolbars.
+	 N.B. not at all sure that this is where these regions are supposed to be removed.
+	 */
+	
+	if (MAIN_VERSION_OLDER(main, 267, 2)) {
+		bScreen *sc;
+		
+		for (sc = main->screen.first; sc; sc = sc->id.next) {
+			ScrArea *sa;
+			for (sa = sc->areabase.first; sa; sa = sa->next) {
+				SpaceLink *sl;
+				ARegion *ar;
+				
+				for (ar = sa->regionbase.first; ar; ar = ar->next) {
+					if (ar->regiontype == RGN_TYPE_TOOL_PROPS) {
+						BLI_remlink(&sa->regionbase, ar);
+						MEM_freeN(ar);
+						BKE_area_region_free(NULL, ar);
+					}
+				}
+				
+				for (sl = sa->spacedata.first; sl; sl = sl->next) {
+					for (ar = sl->regionbase.first; ar; ar = ar->next) {
+						if (ar->regiontype == RGN_TYPE_TOOL_PROPS) {
+							BLI_remlink(&sl->regionbase, ar);
+							MEM_freeN(ar);
+							BKE_area_region_free(NULL, ar);
+						}
+					}
+				}
+			}
+		}
+	}
+	
+	// TODO: what is the right version here?
+	if (MAIN_VERSION_OLDER(main, 267, 2)) {
+		bScreen *sc;
+		
+		for (sc = main->screen.first; sc; sc = sc->id.next) {
+			ScrArea *sa;
+			ARegion *r;
+			
+			for (sa = sc->areabase.first; sa; sa = sa->next) {
+				SpaceLink *sl;
+				ARegion *ar;
+				
+				if (sa->spacetype == SPACE_VIEW3D) {
+					
+					/* The icon shelf is added first, right after the header region, which is assumed to be first in the list. 
+					 * The menubar is then added after the header as well, and then ends up before the icon shelf. 
+					 */
 
+					/* add icon shelf  */
+					ar = BKE_area_find_region_type(sa, RGN_TYPE_ICON_SHELF);
+					if (ar == NULL) {
+						ar = MEM_callocN(sizeof(ARegion), "tool operators icon shelf for view3d");
+						BLI_insertlinkafter(&sa->regionbase, sa->regionbase.first, ar);
+						ar->regiontype = RGN_TYPE_ICON_SHELF;
+						ar->alignment = RGN_ALIGN_TOP;
+					}
+					
+					/* add operators menubar  */
+					ar = BKE_area_find_region_type(sa, RGN_TYPE_MENU_BAR);
+					if (ar == NULL) {
+						ar = MEM_callocN(sizeof(ARegion), "tool operators menu bar for view3d");
+						
+						BLI_insertlinkafter(&sa->regionbase, sa->regionbase.first, ar);
+						ar->regiontype = RGN_TYPE_MENU_BAR;
+						ar->alignment = RGN_ALIGN_TOP;
+					}
+				}
+				
+				for (sl = sa->spacedata.first; sl; sl = sl->next) {
+					if (sl->spacetype == SPACE_VIEW3D) {
+						
+						/* add icon shelf  */
+						ar = BKE_spacelink_find_region_type(sl, RGN_TYPE_ICON_SHELF);
+						if (ar == NULL) {
+							ar = MEM_callocN(sizeof(ARegion), "tool operators icon shelf for view3d");
+							BLI_insertlinkafter(&sl->regionbase, sl->regionbase.first, ar);
+							ar->regiontype = RGN_TYPE_ICON_SHELF;
+							ar->alignment = RGN_ALIGN_TOP;
+						}
+						
+						/* add operators menubar  */
+						ar = BKE_spacelink_find_region_type(sl, RGN_TYPE_MENU_BAR);
+						if (ar == NULL) {
+							ar = MEM_callocN(sizeof(ARegion), "tool operators menu bar for view3d");
+							
+							BLI_insertlinkafter(&sl->regionbase, sl->regionbase.first, ar);
+							ar->regiontype = RGN_TYPE_MENU_BAR;
+							ar->alignment = RGN_ALIGN_TOP;
+						}
+					}
+				}
+			}
+		}
+	}
 
 	{
 		bScreen *sc;
@@ -9518,40 +9620,6 @@
 			}
 		}
 	}
-	
-	
-	/* Remove the tool properties region from the space (TODO: and clip) toolbars.
-	   N.B. not at all sure that this is where these regions are supposed to be removed.
-	 */
-	{
-		bScreen *sc;
-		
-		for (sc = main->screen.first; sc; sc = sc->id.next) {
-			ScrArea *sa;
-			for (sa = sc->areabase.first; sa; sa = sa->next) {
-				SpaceLink *sl;
-				ARegion *r;
-				
-				for (r = sa->regionbase.first; r; r = r->next) {
-					if (r->regiontype == RGN_TYPE_TOOL_PROPS) {
-						//printf("1 - found TOOL_PROPS!\n");
-						BLI_remlink(&sa->regionbase, r);
-					}
-				}
-								
-				for (sl = sa->spacedata.first; sl; sl = sl->next) {
-					if (sl->spacetype == SPACE_VIEW3D) {
-						for (r = sl->regionbase.first; r; r = r->next) {
-							if (r->regiontype == RGN_TYPE_TOOL_PROPS) {
-								//printf("2 - found TOOL_PROPS!\n");
-								BLI_remlink(&sl->regionbase, r);
-							}
-						}
-					}
-				}
-			}
-		}
-	}
 
 
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */

Modified: branches/soc-2013-ui_replay/source/blender/blenloader/intern/versioning_250.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenloader/intern/versioning_250.c	2013-08-16 13:58:39 UTC (rev 59191)
+++ branches/soc-2013-ui_replay/source/blender/blenloader/intern/versioning_250.c	2013-08-16 14:12:52 UTC (rev 59192)
@@ -250,13 +250,6 @@
 				ar->alignment = RGN_ALIGN_RIGHT;
 				ar->flag = RGN_FLAG_HIDDEN;
 				
-				/* operators menubar  */
-				ar = MEM_callocN(sizeof(ARegion), "tool operators menu bar for view3d");
-				
-				BLI_addtail(lb, ar);
-				ar->regiontype = RGN_TYPE_MENU_BAR;
-				ar->alignment = RGN_ALIGN_TOP;
-				
 #if 0
 			case SPACE_BUTS:
 				/* context UI region */

Modified: branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c	2013-08-16 13:58:39 UTC (rev 59191)
+++ branches/soc-2013-ui_replay/source/blender/blenloader/intern/writefile.c	2013-08-16 14:12:52 UTC (rev 59192)
@@ -2370,6 +2370,15 @@
 	}
 }
 
+static void write_panel(WriteData *wd, Panel *pa)
+{
+	OperatorListItem *oli;
+	writestruct(wd, DATA, "Panel", 1, pa);
+	
+	for (oli = pa->operators.first; oli; oli = oli->next)
+		writestruct(wd, DATA, "OperatorListItem", 1, oli);
+}
+
 static void write_region(WriteData *wd, ARegion *ar, int spacetype)
 {	
 	writestruct(wd, DATA, "ARegion", 1, ar);
@@ -2424,17 +2433,21 @@
 			Panel *pa;
 			uiList *ui_list;
 			ARegion *ar;
+			OperatorListItem *oli;
 			
 			writestruct(wd, DATA, "ScrArea", 1, sa);
 			
-			for (ar= sa->regionbase.first; ar; ar= ar->next) {
+			for (ar = sa->regionbase.first; ar; ar = ar->next) {
 				write_region(wd, ar, sa->spacetype);
 				
-				for (pa= ar->panels.first; pa; pa= pa->next)
-					writestruct(wd, DATA, "Panel", 1, pa);
+				for (pa = ar->panels.first; pa; pa = pa->next)
+					write_panel(wd, pa);
 				
 				for (ui_list = ar->ui_lists.first; ui_list; ui_list = ui_list->next)
 					writestruct(wd, DATA, "uiList", 1, ui_list);
+				
+				for (oli = ar->operators.first; oli; oli = oli->next)
+					writestruct(wd, DATA, "OperatorListItem", 1, oli);
 			}
 			

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list