[Bf-blender-cvs] [9e2abbc] master: FileBrowser: Editable Bookmarks.

Bastien Montagne noreply at git.blender.org
Wed Feb 11 00:22:51 CET 2015


Commit: 9e2abbc9ba5d8edf3f43060122d683d0c6ae2525
Author: Bastien Montagne
Date:   Wed Feb 11 00:09:45 2015 +0100
Branches: master
https://developer.blender.org/rB9e2abbc9ba5d8edf3f43060122d683d0c6ae2525

FileBrowser: Editable Bookmarks.

Bookmarks are now editable (i.e. you can rename them, and reorder them).
They are also listed in regular UILists, so you can filter/sort them as usual too.

Also, FileBrowser 'T' side area is changed to something similar to 3DView one,
in this case because we need op panel to remain at the bottom, and later because
we'll more than likely need tabs here!

Thanks to Campbell and Sergey for reviews.

Differential Revision: https://developer.blender.org/D1093

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

M	release/scripts/startup/bl_ui/space_filebrowser.py
M	source/blender/blenkernel/BKE_blender.h
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/include/ED_fileselect.h
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_file/file_draw.c
M	source/blender/editors/space_file/file_intern.h
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_file/file_panels.c
M	source/blender/editors/space_file/filesel.c
M	source/blender/editors/space_file/fsmenu.c
M	source/blender/editors/space_file/fsmenu.h
M	source/blender/editors/space_file/space_file.c
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blenderplayer/bad_level_call_stubs/stubs.c

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

diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py
index 6fe50c7..cda3dfe 100644
--- a/release/scripts/startup/bl_ui/space_filebrowser.py
+++ b/release/scripts/startup/bl_ui/space_filebrowser.py
@@ -18,7 +18,7 @@
 
 # <pep8 compliant>
 import bpy
-from bpy.types import Header
+from bpy.types import Header, Panel, Menu
 
 
 class FILEBROWSER_HT_header(Header):
@@ -81,5 +81,128 @@ class FILEBROWSER_HT_header(Header):
             row.prop(params, "filter_search", text="", icon='VIEWZOOM')
 
 
+
+class FILEBROWSER_UL_dir(bpy.types.UIList):
+    def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
+        direntry = item
+        space = context.space_data
+        icon = 'NONE'
+        if active_propname == "system_folders_active":
+            icon = 'DISK_DRIVE'
+        if active_propname == "system_bookmarks_active":
+            icon = 'BOOKMARKS'
+        if active_propname == "bookmarks_active":
+            icon = 'BOOKMARKS'
+        if active_propname == "recent_folders_active":
+            icon = 'FILE_FOLDER'
+
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            row = layout.row(align=True)
+            row.prop(direntry, "name", text="", emboss=False, icon=icon)
+
+        elif self.layout_type in {'GRID'}:
+            layout.alignment = 'CENTER'
+            layout.prop(direntry, "path", text="")
+
+
+class FILEBROWSER_PT_system_folders(Panel):
+    bl_space_type = 'FILE_BROWSER'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
+    bl_label = "System"
+
+    def draw(self, context):
+        layout = self.layout
+        space = context.space_data
+
+        if space.system_folders:
+            row = layout.row()
+            row.template_list("FILEBROWSER_UL_dir", "system_folders", space, "system_folders",
+                              space, "system_folders_active", item_dyntip_propname="path", rows=1, maxrows=6)
+
+
+class FILEBROWSER_PT_system_bookmarks(Panel):
+    bl_space_type = 'FILE_BROWSER'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
+    bl_label = "System Bookmarks"
+
+    @classmethod
+    def poll(cls, context):
+        return not context.user_preferences.filepaths.hide_system_bookmarks
+
+    def draw(self, context):
+        layout = self.layout
+        space = context.space_data
+
+        if space.system_bookmarks:
+            row = layout.row()
+            row.template_list("FILEBROWSER_UL_dir", "system_bookmarks", space, "system_bookmarks",
+                              space, "system_bookmarks_active", item_dyntip_propname="path", rows=1, maxrows=6)
+
+
+class FILEBROWSER_MT_bookmarks_specials(Menu):
+    bl_label = "Bookmarks Specials"
+
+    def draw(self, context):
+        layout = self.layout
+
+        layout.operator("file.bookmark_move", icon='TRIA_UP_BAR', text="Move To Top").direction = 'TOP'
+        layout.operator("file.bookmark_move", icon='TRIA_DOWN_BAR', text="Move To Bottom").direction = 'BOTTOM'
+
+
+class FILEBROWSER_PT_bookmarks(Panel):
+    bl_space_type = 'FILE_BROWSER'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
+    bl_label = "Bookmarks"
+
+    def draw(self, context):
+        layout = self.layout
+        space = context.space_data
+
+        if space.bookmarks:
+            row = layout.row()
+            num_rows = len(space.bookmarks)
+            row.template_list("FILEBROWSER_UL_dir", "bookmarks", space, "bookmarks",
+                              space, "bookmarks_active", item_dyntip_propname="path",
+                              rows=(2 if num_rows < 2 else 4), maxrows=6)
+
+            col = row.column(align=True)
+            col.operator("file.bookmark_add", icon='ZOOMIN', text="")
+            col.operator("file.bookmark_delete", icon='ZOOMOUT', text="")
+            col.menu("FILEBROWSER_MT_bookmarks_specials", icon='DOWNARROW_HLT', text="")
+
+            if num_rows > 1:
+                col.separator()
+                col.operator("file.bookmark_move", icon='TRIA_UP', text="").direction = 'UP'
+                col.operator("file.bookmark_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+        else:
+            layout.operator("file.bookmark_add", icon='ZOOMIN')
+
+
+class FILEBROWSER_PT_recent_folders(Panel):
+    bl_space_type = 'FILE_BROWSER'
+    bl_region_type = 'TOOLS'
+    bl_category = "Bookmarks"
+    bl_label = "Recent"
+
+    @classmethod
+    def poll(cls, context):
+        return not context.user_preferences.filepaths.hide_recent_locations
+
+    def draw(self, context):
+        layout = self.layout
+        space = context.space_data
+
+        if space.recent_folders:
+            row = layout.row()
+            row.template_list("FILEBROWSER_UL_dir", "recent_folders", space, "recent_folders",
+                              space, "recent_folders_active", item_dyntip_propname="path", rows=1, maxrows=6)
+
+            col = row.column(align=True)
+            col.operator("file.reset_recent", icon='X', text="")
+
+
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 2c53a24..610a63c 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
  * and keep comment above the defines.
  * Use STRINGIFY() rather than defining with quotes */
 #define BLENDER_VERSION         273
-#define BLENDER_SUBVERSION      6
+#define BLENDER_SUBVERSION      7
 /* 262 was the last editmesh release but it has compatibility code for bmesh data */
 #define BLENDER_MINVERSION      270
 #define BLENDER_MINSUBVERSION   5
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 4ca1a44..572566d 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -51,6 +51,7 @@
 
 #include "BKE_main.h"
 #include "BKE_node.h"
+#include "BKE_screen.h"
 
 #include "BLI_math.h"
 #include "BLI_listbase.h"
@@ -60,6 +61,7 @@
 
 #include "readfile.h"
 
+#include "MEM_guardedalloc.h"
 
 static void do_version_constraints_radians_degrees_270_1(ListBase *lb)
 {
@@ -561,4 +563,32 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			FOREACH_NODETREE_END
 		}
 	}
+
+	if (!MAIN_VERSION_ATLEAST(main, 273, 7)) {
+		bScreen *scr;
+		ScrArea *sa;
+		SpaceLink *sl;
+		ARegion *ar;
+
+		for (scr = main->screen.first; scr; scr = scr->id.next) {
+			/* Remove old deprecated region from filebrowsers */
+			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) {
+							/* Free old deprecated 'channel' region... */
+							BKE_area_region_free(NULL, ar);
+							BLI_freelinkN(&sl->regionbase, ar);
+						}
+					}
+				}
+			}
+		}
+	}
 }
diff --git a/source/blender/editors/include/ED_fileselect.h b/source/blender/editors/include/ED_fileselect.h
index f2a6ce0..b81ea55 100644
--- a/source/blender/editors/include/ED_fileselect.h
+++ b/source/blender/editors/include/ED_fileselect.h
@@ -108,5 +108,40 @@ int ED_file_extension_icon(const char *relname);
 
 void ED_file_read_bookmarks(void);
 
+void ED_file_change_dir(struct bContext *C, const bool checkdir);
+
+/* File menu stuff */
+
+typedef enum FSMenuCategory {
+	FS_CATEGORY_SYSTEM,
+	FS_CATEGORY_SYSTEM_BOOKMARKS,
+	FS_CATEGORY_BOOKMARKS,
+	FS_CATEGORY_RECENT
+} FSMenuCategory;
+
+typedef enum FSMenuInsert {
+	FS_INSERT_SORTED = (1 << 0),
+	FS_INSERT_SAVE   = (1 << 1),
+	FS_INSERT_FIRST  = (1 << 2),  /* moves the item to the front of the list when its not already there */
+	FS_INSERT_LAST   = (1 << 3),  /* just append to preseve delivered order */
+} FSMenuInsert;
+
+struct FSMenu;
+struct FSMenuEntry;
+
+struct FSMenu *ED_fsmenu_get(void);
+struct FSMenuEntry *ED_fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory category);
+void ED_fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, struct FSMenuEntry *fsm_head);
+
+int ED_fsmenu_get_nentries(struct FSMenu *fsmenu, FSMenuCategory category);
+
+struct FSMenuEntry *ED_fsmenu_get_entry(struct FSMenu *fsmenu, FSMenuCategory category, int index);
+
+char *ED_fsmenu_entry_get_path(struct FSMenuEntry *fsentry);
+void ED_fsmenu_entry_set_path(struct FSMenuEntry *fsentry, const char *path);
+
+char *ED_fsmenu_entry_get_name(struct FSMenuEntry *fsentry);
+void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name);
+
 #endif /* __ED_FILESELECT_H__ */
 
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 83b22bb..4225b4b 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -1478,7 +1478,7 @@ void region_toggle_hidden(bContext *C, ARegion *ar, const bool do_fade)
 /* exported to all editors, uses fading default */
 void ED_region_toggle_hidden(bContext *C, ARegion *ar)
 {
-	region_toggle_hidden(C, ar, 1);
+	region_toggle_hidden(C, ar, true);
 }
 
 /**
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 5761193..9fe6ed7 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -119,7 +119,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_intern.h b/source/blender/editors/space_file/file_intern.h
index 7147353..31d479b 100644
--- a/source/blender/editors/space_file/fi

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list