[Bf-blender-cvs] [93da0a8] asset-experiments: Prepare assets UI: switch filebrowser to tools + tool props areas, instead of channels.

Bastien Montagne noreply at git.blender.org
Fri Jan 30 18:40:29 CET 2015


Commit: 93da0a8187866be4719eb4256e5622a63a42c3be
Author: Bastien Montagne
Date:   Fri Jan 30 18:38:02 2015 +0100
Branches: asset-experiments
https://developer.blender.org/rB93da0a8187866be4719eb4256e5622a63a42c3be

Prepare assets UI: switch filebrowser to tools + tool props areas, instead of channels.

This will allow us to keep op panel independent, and have tabs for future assets tools!

Note 'conversion' from previous file area (channels) is not perfect, you have to hit 'T'
twice currently if you had a filebrowser in your .blend file...

===================================================================

M	release/scripts/startup/bl_ui/space_filebrowser.py
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/file_panels.c
M	source/blender/editors/space_file/space_file.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 202845e..6b7be86 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -118,7 +118,8 @@ class FILEBROWSER_UL_dir(bpy.types.UIList):
 
 class FILEBROWSER_PT_system_folders(Panel):
     bl_space_type = 'FILE_BROWSER'
-    bl_region_type = 'CHANNELS'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
     bl_label = "System"
 
     def draw(self, context):
@@ -133,7 +134,8 @@ class FILEBROWSER_PT_system_folders(Panel):
 
 class FILEBROWSER_PT_system_bookmarks(Panel):
     bl_space_type = 'FILE_BROWSER'
-    bl_region_type = 'CHANNELS'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
     bl_label = "System Bookmarks"
 
     @classmethod
@@ -162,7 +164,8 @@ class FILEBROWSER_MT_bookmarks_specials(Menu):
 
 class FILEBROWSER_PT_bookmarks(Panel):
     bl_space_type = 'FILE_BROWSER'
-    bl_region_type = 'CHANNELS'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
     bl_label = "Bookmarks"
 
     def draw(self, context):
@@ -188,7 +191,8 @@ class FILEBROWSER_PT_bookmarks(Panel):
 
 class FILEBROWSER_PT_recent_folders(Panel):
     bl_space_type = 'FILE_BROWSER'
-    bl_region_type = 'CHANNELS'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
     bl_label = "Recent"
 
     @classmethod
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 652a452..c151bd2 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -51,11 +51,14 @@
 
 #include "BKE_main.h"
 #include "BKE_node.h"
+#include "BKE_screen.h"
 
 #include "BLI_math.h"
 #include "BLI_listbase.h"
 #include "BLI_string.h"
 
+#include "MEM_guardedalloc.h"
+
 #include "BLO_readfile.h"
 
 #include "readfile.h"
@@ -528,4 +531,31 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 				part->child_flag |= PART_CHILD_USE_ROUGH_CURVE;
 		}
 	}
+
+	{
+		bScreen *scr;
+		ScrArea *sa;
+		SpaceLink *sl;
+		ARegion *ar;
+
+		for (scr = main->screen.first; scr; scr = scr->id.next) {
+			/* add new regions for filebrowser */
+			for (sa = scr->areabase.first; sa; sa = sa->next) {
+				for (sl = sa->spacedata.first; sl; sl = sl->next) {
+					if (sl->spacetype == SPACE_FILE) {
+						for (ar = sl->regionbase.first; ar; ar = ar->next) {
+							if (ar->regiontype == RGN_TYPE_CHANNELS) {
+								break;
+							}
+						}
+
+						if (ar) {
+							BKE_area_region_free(NULL, ar);
+							BLI_freelinkN(&sl->regionbase, ar);
+						}
+					}
+				}
+			}
+		}
+	}
 }
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 9dabee4..b0e9fda 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -121,7 +121,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
 
 	/* exception to make space for collapsed region icon */
 	for (artmp = CTX_wm_area(C)->regionbase.first; artmp; artmp = artmp->next) {
-		if (artmp->regiontype == RGN_TYPE_CHANNELS && artmp->flag & RGN_FLAG_HIDDEN) {
+		if (artmp->regiontype == RGN_TYPE_TOOLS && artmp->flag & RGN_FLAG_HIDDEN) {
 			chan_offs = 16;
 			min_x += chan_offs;
 			available_w -= chan_offs;
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 64158c5..b82cb47 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1574,7 +1574,7 @@ ARegion *file_buttons_region(ScrArea *sa)
 	ARegion *ar, *arnew;
 	
 	for (ar = sa->regionbase.first; ar; ar = ar->next)
-		if (ar->regiontype == RGN_TYPE_CHANNELS)
+		if (ar->regiontype == RGN_TYPE_TOOLS)
 			return ar;
 
 	/* add subdiv level; after header */
@@ -1585,14 +1585,17 @@ ARegion *file_buttons_region(ScrArea *sa)
 	/* is error! */
 	if (ar == NULL) return NULL;
 	
-	arnew = MEM_callocN(sizeof(ARegion), "buttons for file panels");
-	
+	arnew = MEM_callocN(sizeof(ARegion), "tools for file");
 	BLI_insertlinkafter(&sa->regionbase, ar, arnew);
-	arnew->regiontype = RGN_TYPE_CHANNELS;
+	arnew->regiontype = RGN_TYPE_TOOLS;
 	arnew->alignment = RGN_ALIGN_LEFT;
-	
 	arnew->flag = RGN_FLAG_HIDDEN;
-	
+
+	ar = MEM_callocN(sizeof(ARegion), "tool props for file");
+	BLI_insertlinkafter(&sa->regionbase, arnew, ar);
+	ar->regiontype = RGN_TYPE_TOOL_PROPS;
+	ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+
 	return arnew;
 }
 
diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c
index 9a7ee93..3da83aa 100644
--- a/source/blender/editors/space_file/file_panels.c
+++ b/source/blender/editors/space_file/file_panels.c
@@ -85,7 +85,7 @@ static void file_panel_operator(const bContext *C, Panel *pa)
 	SpaceFile *sfile = CTX_wm_space_file(C);
 	wmOperator *op = sfile->op;
 	// int empty = 1, flag;
-	
+
 	UI_block_func_set(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL);
 
 	uiLayoutOperatorButs(C, pa->layout, op, file_panel_check_prop, '\0', UI_LAYOUT_OP_SHOW_EMPTY);
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 02e3dd2..3e87d11 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -71,7 +71,7 @@ static SpaceLink *file_new(const bContext *UNUSED(C))
 {
 	ARegion *ar;
 	SpaceFile *sfile;
-	
+
 	sfile = MEM_callocN(sizeof(SpaceFile), "initfile");
 	sfile->spacetype = SPACE_FILE;
 
@@ -81,12 +81,18 @@ static SpaceLink *file_new(const bContext *UNUSED(C))
 	ar->regiontype = RGN_TYPE_HEADER;
 	ar->alignment = RGN_ALIGN_TOP;
 
-	/* channel list region */
-	ar = MEM_callocN(sizeof(ARegion), "channel area for file");
+	/* Tools region */
+	ar = MEM_callocN(sizeof(ARegion), "tools area for file");
 	BLI_addtail(&sfile->regionbase, ar);
-	ar->regiontype = RGN_TYPE_CHANNELS;
+	ar->regiontype = RGN_TYPE_TOOLS;
 	ar->alignment = RGN_ALIGN_LEFT;
 
+	/* Tool props (aka operator) region */
+	ar = MEM_callocN(sizeof(ARegion), "tool props area for file");
+	BLI_addtail(&sfile->regionbase, ar);
+	ar->regiontype = RGN_TYPE_TOOL_PROPS;
+	ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV;
+
 	/* ui list region */
 	ar = MEM_callocN(sizeof(ARegion), "ui area for file");
 	BLI_addtail(&sfile->regionbase, ar);
@@ -490,7 +496,7 @@ static void file_keymap(struct wmKeyConfig *keyconf)
 }
 
 
-static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
+static void file_tools_area_init(wmWindowManager *wm, ARegion *ar)
 {
 	wmKeyMap *keymap;
 
@@ -502,12 +508,12 @@ static void file_channel_area_init(wmWindowManager *wm, ARegion *ar)
 	WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
-static void file_channel_area_draw(const bContext *C, ARegion *ar)
+static void file_tools_area_draw(const bContext *C, ARegion *ar)
 {
 	ED_region_panels(C, ar, 1, NULL, -1);
 }
 
-static void file_channel_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn))
+static void file_tools_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *UNUSED(ar), wmNotifier *UNUSED(wmn))
 {
 #if 0
 	/* context changes */
@@ -633,12 +639,24 @@ void ED_spacetype_file(void)
 
 	/* regions: channels (directories) */
 	art = MEM_callocN(sizeof(ARegionType), "spacetype file region");
-	art->regionid = RGN_TYPE_CHANNELS;
+	art->regionid = RGN_TYPE_TOOLS;
 	art->prefsizex = 240;
+	art->prefsizey = 60;
+	art->keymapflag = ED_KEYMAP_UI;
+	art->listener = file_tools_area_listener;
+	art->init = file_tools_area_init;
+	art->draw = file_tools_area_draw;
+	BLI_addhead(&st->regiontypes, art);
+
+	/* regions: tool properties */
+	art = MEM_callocN(sizeof(ARegionType), "spacetype file operator region");
+	art->regionid = RGN_TYPE_TOOL_PROPS;
+	art->prefsizex = 0;
+	art->prefsizey = 240;
 	art->keymapflag = ED_KEYMAP_UI;
-	art->listener = file_channel_area_listener;
-	art->init = file_channel_area_init;
-	art->draw = file_channel_area_draw;
+	art->listener = file_tools_area_listener;
+	art->init = file_tools_area_init;
+	art->draw = file_tools_area_draw;
 	BLI_addhead(&st->regiontypes, art);
 	file_panels_register(art);




More information about the Bf-blender-cvs mailing list