[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19652] branches/blender2.5/blender: UI:
Brecht Van Lommel
brecht at blender.org
Sat Apr 11 04:18:28 CEST 2009
Revision: 19652
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19652
Author: blendix
Date: 2009-04-11 04:18:24 +0200 (Sat, 11 Apr 2009)
Log Message:
-----------
UI:
* Added very basic loading of .py files on startup to define panels.
It now executes all .py files in .blender/ui on startup. Right now
this contains the object buttons, the C code for it is commented out.
These files should get embedded in the blender executable as well
eventually, that's a bit more complicated so this works for now.
* For scons and cmake it seems to copy & find the files OK, for make
only "make release" works (same with scripts/ folder it seems).
* Added BLI_gethome_folder function in BLI_util.h. This is adapted
from bpy_gethome, and gives the path to a folder in .blender like
scripts or ui.
There's plenty of things to figure out here about paths, embedding,
caching, user configs ...
Modified Paths:
--------------
branches/blender2.5/blender/SConstruct
branches/blender2.5/blender/release/Makefile
branches/blender2.5/blender/source/blender/blenlib/BLI_util.h
branches/blender2.5/blender/source/blender/blenlib/intern/util.c
branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_object.c
branches/blender2.5/blender/source/blender/python/BPY_extern.h
branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c
branches/blender2.5/blender/source/creator/CMakeLists.txt
branches/blender2.5/blender/source/creator/creator.c
Added Paths:
-----------
branches/blender2.5/blender/release/ui/
branches/blender2.5/blender/release/ui/buttons_objects.py
Modified: branches/blender2.5/blender/SConstruct
===================================================================
--- branches/blender2.5/blender/SConstruct 2009-04-11 01:52:27 UTC (rev 19651)
+++ branches/blender2.5/blender/SConstruct 2009-04-11 02:18:24 UTC (rev 19652)
@@ -472,6 +472,17 @@
source=[dp+os.sep+f for f in df]
scriptinstall.append(env.Install(dir=dir,source=source))
+ #-- .blender/ui
+ scriptpath='release/ui'
+ for dp, dn, df in os.walk(scriptpath):
+ if 'CVS' in dn:
+ dn.remove('CVS')
+ if '.svn' in dn:
+ dn.remove('.svn')
+ dir=env['BF_INSTALLDIR']+'/.blender/ui'+dp[len(scriptpath):]
+ source=[dp+os.sep+f for f in df]
+ scriptinstall.append(env.Install(dir=dir,source=source))
+
#-- icons
if env['OURPLATFORM']=='linux2':
iconlist = []
Modified: branches/blender2.5/blender/release/Makefile
===================================================================
--- branches/blender2.5/blender/release/Makefile 2009-04-11 01:52:27 UTC (rev 19651)
+++ branches/blender2.5/blender/release/Makefile 2009-04-11 02:18:24 UTC (rev 19652)
@@ -163,6 +163,9 @@
@echo "----> Copy python infrastructure"
@[ ! -d scripts ] || cp -r scripts $(CONFDIR)/scripts
+ @echo "----> Copy python UI files"
+ @[ ! -d ui ] || cp -r ui $(CONFDIR)/ui
+
ifeq ($(OS),darwin)
@echo "----> Move .blender to .app/Contents/MacOS/"
@rm -fr $(DISTDIR)/blender$(EXT0)/Contents/MacOS/.blender
Added: branches/blender2.5/blender/release/ui/buttons_objects.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_objects.py (rev 0)
+++ branches/blender2.5/blender/release/ui/buttons_objects.py 2009-04-11 02:18:24 UTC (rev 19652)
@@ -0,0 +1,124 @@
+
+class OBJECT_PT_transform(bpy.types.Panel):
+ __label__ = "Transform"
+ __context__ = "object"
+
+ def draw(self, context):
+ ob = context.active_object
+ layout = self.layout
+
+ if not ob:
+ return
+
+ layout.template_column_flow(3)
+ layout.itemR(ob, "location")
+ layout.itemR(ob, "rotation")
+ layout.itemR(ob, "scale")
+
+class OBJECT_PT_groups(bpy.types.Panel):
+ __label__ = "Groups"
+ __context__ = "object"
+
+ def draw(self, context):
+ ob = context.active_object
+ layout = self.layout
+
+ if not ob:
+ return
+
+ layout.template_column_flow(2)
+ layout.itemR(ob, "pass_index")
+ layout.itemR(ob, "parent")
+
+ # layout.template_left_right()
+ # layout.itemO("OBJECT_OT_add_group");
+
+ for group in bpy.data.groups:
+ if ob in group.objects:
+ sublayout = layout.template_stack()
+
+ sublayout.template_left_right()
+ sublayout.itemR(group, "name")
+ # sublayout.itemO("OBJECT_OT_remove_group")
+
+ sublayout.template_column_flow(2)
+ sublayout.itemR(group, "layer")
+ sublayout.itemR(group, "dupli_offset")
+
+class OBJECT_PT_display(bpy.types.Panel):
+ __label__ = "Display"
+ __context__ = "object"
+
+ def draw(self, context):
+ ob = context.active_object
+ layout = self.layout
+
+ if not ob:
+ return
+
+ layout.template_column_flow(2)
+ layout.itemR(ob, "max_draw_type", text="Type")
+ layout.itemR(ob, "draw_bounds_type", text="Bounds")
+
+ layout.template_column_flow(2)
+ layout.itemR(ob, "draw_name", text="Name")
+ layout.itemR(ob, "draw_axis", text="Axis")
+ layout.itemR(ob, "draw_wire", text="Wire")
+ layout.itemR(ob, "draw_texture_space", text="Texture Space")
+ layout.itemR(ob, "x_ray", text="X-Ray")
+ layout.itemR(ob, "draw_transparent", text="Transparency")
+
+class OBJECT_PT_duplication(bpy.types.Panel):
+ __label__ = "Duplication"
+ __context__ = "object"
+
+ def draw(self, context):
+ ob = context.active_object
+ layout = self.layout
+
+ if not ob:
+ return
+
+ layout.template_column()
+ layout.itemR(ob, "dupli_type", text="")
+
+ if ob.dupli_type == "FRAMES":
+ layout.template_column_flow(2)
+ layout.itemR(ob, "dupli_frames_start", text="Start:")
+ layout.itemR(ob, "dupli_frames_end", text="End:")
+ layout.itemR(ob, "dupli_frames_on", text="On:")
+ layout.itemR(ob, "dupli_frames_off", text="Off:")
+
+class OBJECT_PT_animation(bpy.types.Panel):
+ __label__ = "Animation"
+ __context__ = "object"
+
+ def draw(self, context):
+ ob = context.active_object
+ layout = self.layout
+
+ if not ob:
+ return
+
+ layout.template_column()
+
+ layout.template_slot("COLUMN_1")
+ layout.itemL(text="Time Offset:")
+ layout.itemR(ob, "time_offset_edit", text="Edit")
+ layout.itemR(ob, "time_offset_particle", text="Particle")
+ layout.itemR(ob, "time_offset_parent", text="Parent")
+ layout.itemR(ob, "slow_parent")
+ layout.itemR(ob, "time_offset", text="Offset:")
+
+ layout.template_slot("COLUMN_2")
+ layout.itemL(text="Tracking:")
+ layout.itemR(ob, "track_axis", text="Axis")
+ layout.itemR(ob, "up_axis", text="Up Axis")
+ layout.itemR(ob, "track_rotation", text="Rotation")
+
+bpy.ui.addPanel(OBJECT_PT_transform, "BUTTONS_WINDOW", "WINDOW")
+bpy.ui.addPanel(OBJECT_PT_groups, "BUTTONS_WINDOW", "WINDOW")
+bpy.ui.addPanel(OBJECT_PT_display, "BUTTONS_WINDOW", "WINDOW")
+bpy.ui.addPanel(OBJECT_PT_duplication, "BUTTONS_WINDOW", "WINDOW")
+bpy.ui.addPanel(OBJECT_PT_animation, "BUTTONS_WINDOW", "WINDOW")
+
Modified: branches/blender2.5/blender/source/blender/blenlib/BLI_util.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/BLI_util.h 2009-04-11 01:52:27 UTC (rev 19651)
+++ branches/blender2.5/blender/source/blender/blenlib/BLI_util.h 2009-04-11 02:18:24 UTC (rev 19652)
@@ -42,6 +42,8 @@
struct direntry;
char *BLI_gethome(void);
+char *BLI_gethome_folder(char *folder_name);
+
void BLI_make_file_string(const char *relabase, char *string, const char *dir, const char *file);
void BLI_make_exist(char *dir);
void BLI_make_existing_file(char *name);
Modified: branches/blender2.5/blender/source/blender/blenlib/intern/util.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/util.c 2009-04-11 01:52:27 UTC (rev 19651)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/util.c 2009-04-11 02:18:24 UTC (rev 19652)
@@ -827,6 +827,102 @@
#endif
}
+/* this function returns the path to a blender folder, if it exists,
+ * trying in this order:
+ *
+ * $HOME/.blender/folder_name
+ * path_to_executable/.blender/folder_name
+ * release/folder_name (in svn)
+ *
+ * returns NULL if none is found. */
+
+char *BLI_gethome_folder(char *folder_name)
+{
+ extern char bprogname[]; /* argv[0] from creator.c */
+ static char homedir[FILE_MAXDIR] = "";
+ static char fulldir[FILE_MAXDIR] = "";
+ char tmpdir[FILE_MAXDIR];
+ char bprogdir[FILE_MAXDIR];
+ char *s;
+ int i;
+
+ if(folder_name) {
+ if(fulldir[0] != '\0')
+ return fulldir;
+ }
+ else if(homedir[0] != '\0')
+ return homedir;
+
+ /* BLI_gethome() can return NULL if env vars are not set */
+ s = BLI_gethome();
+
+ if(!s) { /* bail if no $HOME */
+ printf("$HOME is NOT set\n");
+ return NULL;
+ }
+
+ if(strstr(s, ".blender"))
+ BLI_strncpy(homedir, s, FILE_MAXDIR);
+ else
+ BLI_make_file_string("/", homedir, s, ".blender");
+
+ /* if $HOME/.blender/folder_name exists, return it */
+ if(BLI_exists(homedir)) {
+ if (folder_name) {
+ BLI_make_file_string("/", fulldir, homedir, folder_name);
+ if(BLI_exists(fulldir))
+ return fulldir;
+ }
+ else
+ return homedir;
+ }
+ else
+ homedir[0] = '\0';
+
+ /* if either:
+ * no homedir was found or
+ * folder_name = 1 but there's no folder_name/ inside homedir,
+ * use argv[0] (bprogname) to get .blender/ in
+ * Blender's installation dir */
+ s = BLI_last_slash(bprogname);
+
+ i = s - bprogname + 1;
+ BLI_strncpy(bprogdir, bprogname, i);
+
+ /* using tmpdir to preserve homedir (if) found above:
+ * the ideal is to have a home dir with folder_name dir inside
+ * it, but if that isn't available, it's possible to
+ * have a 'broken' home dir somewhere and a folder_name dir in the
+ * svn sources */
+ BLI_make_file_string("/", tmpdir, bprogdir, ".blender");
+
+ if(BLI_exists(tmpdir)) {
+ if(folder_name) {
+ BLI_make_file_string("/", fulldir, tmpdir, folder_name);
+ if(BLI_exists(fulldir)) {
+ BLI_strncpy(homedir, tmpdir, FILE_MAXDIR);
+ return fulldir;
+ }
+ else {
+ homedir[0] = '\0';
+ fulldir[0] = '\0';
+ }
+ }
+ else return homedir;
+ }
+
+ /* last try for folder_name dir: blender in svn dir, folder_name/ inside release/: */
+ if (folder_name) {
+ BLI_snprintf(tmpdir, sizeof(tmpdir), "release/%s", folder_name);
+ BLI_make_file_string("/", fulldir, bprogdir, tmpdir);
+ if (BLI_exists(fulldir)) return fulldir;
+ else fulldir[0] = '\0';
+ }
+
+ return NULL;
+}
+
+
void BLI_clean(char *path)
{
if(path==0) return;
Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c 2009-04-11 01:52:27 UTC (rev 19651)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c 2009-04-11 02:18:24 UTC (rev 19652)
@@ -4458,6 +4458,7 @@
pa->active= 0;
pa->sortcounter= 0;
pa->activedata= NULL;
+ pa->type= NULL;
}
ar->regiondata= newdataadr(fd, ar->regiondata);
Modified: branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_object.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_object.c 2009-04-11 01:52:27 UTC (rev 19651)
+++ branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_object.c 2009-04-11 02:18:24 UTC (rev 19652)
@@ -51,6 +51,7 @@
#include "WM_types.h"
+#if 0
static void object_panel_transform(const bContext *C, Panel *pnl)
{
uiLayout *layout= pnl->layout;
@@ -166,9 +167,11 @@
uiItemR(layout, "Up Axis: ", 0, &obptr, "up_axis");
uiItemR(layout, "Rotation", 0, &obptr, "track_rotation");
}
+#endif
void buttons_object_register(ARegionType *art)
{
+#if 0
PanelType *pt;
/* panels: transform */
@@ -210,5 +213,6 @@
pt->context= "object";
pt->draw= object_panel_animation;
BLI_addtail(&art->paneltypes, pt);
+#endif
}
Modified: branches/blender2.5/blender/source/blender/python/BPY_extern.h
===================================================================
--- branches/blender2.5/blender/source/blender/python/BPY_extern.h 2009-04-11 01:52:27 UTC (rev 19651)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list