2.5: User Preferences
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 15 Jul 2009 19:19:43 +0000 (19:19 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 15 Jul 2009 19:19:43 +0000 (19:19 +0000)
* Added basic infrastructure to layout user preferences. The
  intention is that you open a user preferences space in place
  of the buttons space, and have panels there.
* The existing sections don't have to be followed, it's easy
  to create different ones, just change the user_pref_sections
  enum in RNA.
* This will get separated from the info header later.

release/ui/space_info.py
source/blender/blenloader/intern/readfile.c
source/blender/editors/interface/interface_panel.c
source/blender/editors/interface/resources.c
source/blender/editors/screen/area.c
source/blender/editors/space_buttons/space_buttons.c
source/blender/editors/space_info/space_info.c
source/blender/makesrna/intern/rna_context.c

index de33467..a946b30 100644 (file)
@@ -108,6 +108,31 @@ class INFO_MT_help(bpy.types.Menu):
                layout = self.layout
                layout.itemL(text="Nothing yet")
 
+class INFO_PT_tabs(bpy.types.Panel):
+       __space_type__ = "USER_PREFERENCES"
+       __no_header__ = True
+
+       def draw(self, context):
+               layout = self.layout
+               userpref = context.user_preferences
+
+               layout.itemR(userpref, "active_section")
+
+class INFO_PT_view(bpy.types.Panel):
+       __space_type__ = "USER_PREFERENCES"
+       __label__ = "View"
+
+       def poll(self, context):
+               userpref = context.user_preferences
+               return (userpref.active_section == 'VIEW_CONTROLS')
+
+       def draw(self, context):
+               layout = self.layout
+               userpref = context.user_preferences
+               view = userpref.view
+
+               layout.itemR(view, "show_view_name")
+
 bpy.types.register(INFO_HT_header)
 bpy.types.register(INFO_MT_file)
 bpy.types.register(INFO_MT_file_external_data)
@@ -116,4 +141,6 @@ bpy.types.register(INFO_MT_timeline)
 bpy.types.register(INFO_MT_game)
 bpy.types.register(INFO_MT_render)
 bpy.types.register(INFO_MT_help)
+bpy.types.register(INFO_PT_tabs)
+bpy.types.register(INFO_PT_view)
 
index 12d9588..37dda0e 100644 (file)
@@ -9191,6 +9191,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                }
        }
 
+       if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 1)) {
+       }
+
        /* TODO: should be moved into one of the version blocks once this branch moves to trunk and we can
           bump the version (or sub-version.) */
        {
index a3c456c..363717c 100644 (file)
@@ -104,6 +104,8 @@ static int panel_aligned(ScrArea *sa, ARegion *ar)
                SpaceButs *sbuts= sa->spacedata.first;
                return sbuts->align;
        }
+       else if(sa->spacetype==SPACE_INFO && ar->regiontype == RGN_TYPE_WINDOW)
+               return BUT_VERTICAL;
        else if(sa->spacetype==SPACE_FILE && ar->regiontype == RGN_TYPE_CHANNELS)
                return BUT_VERTICAL;
        else if(ELEM3(ar->regiontype, RGN_TYPE_UI, RGN_TYPE_TOOLS, RGN_TYPE_TOOL_PROPS))
index 2798f7a..297e226 100644 (file)
@@ -581,7 +581,7 @@ void ui_theme_init_userdef(void)
        
        /* space info */
        btheme->tinfo= btheme->tv3d;
-       SETCOL(btheme->tinfo.back,      153, 153, 153, 255);
+       SETCOLF(btheme->tinfo.back,     0.45, 0.45, 0.45, 1.0);
 
        /* space sound */
        btheme->tsnd= btheme->tv3d;
@@ -1231,6 +1231,8 @@ void init_userdef_do_versions(void)
                                btheme->tlogic= btheme->tv3d;
                                SETCOL(btheme->tlogic.back, 100, 100, 100, 255);
                        }
+
+                       SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0);
                }
        }
        
index e923a3b..addda6e 100644 (file)
@@ -1254,8 +1254,10 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar)
 {
        ListBase *keymap;
        
-       // XXX quick hack for files saved with 2.5 already (i.e. the builtin defaults file)
+       // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file)
        ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); 
+       if(!(ar->v2d.align & V2D_ALIGN_NO_POS_Y))
+               ar->v2d.flag &= ~V2D_IS_INITIALISED;
        
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_PANELS_UI, ar->winx, ar->winy);
 
index 65fbdeb..9345a24 100644 (file)
@@ -94,31 +94,6 @@ static SpaceLink *buttons_new(const bContext *C)
        BLI_addtail(&sbuts->regionbase, ar);
        ar->regiontype= RGN_TYPE_WINDOW;
        
-#if 0 // disabled, as this currently draws badly in new system
-       /* buts space goes from (0,0) to (1280, 228) */
-       ar->v2d.tot.xmin= 0.0f;
-       ar->v2d.tot.ymin= 0.0f;
-       ar->v2d.tot.xmax= 1279.0f;
-       ar->v2d.tot.ymax= 228.0f;
-       
-       ar->v2d.cur= sbuts->v2d.tot;
-       
-       ar->v2d.min[0]= 256.0f;
-       ar->v2d.min[1]= 42.0f;
-       
-       ar->v2d.max[0]= 2048.0f;
-       ar->v2d.max[1]= 450.0f;
-       
-       ar->v2d.minzoom= 0.5f;
-       ar->v2d.maxzoom= 1.21f;
-       
-       ar->v2d.scroll= 0;  // TODO: will we need scrollbars?
-       ar->v2d.align= V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y;
-       ar->v2d.keepzoom= V2D_KEEPZOOM|V2D_KEEPASPECT;
-       ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS;
-#endif 
-       
-       
        return (SpaceLink *)sbuts;
 }
 
@@ -164,13 +139,7 @@ static SpaceLink *buttons_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
-
        ED_region_panels_init(wm, ar);
-       
-       /* own keymap */
-       keymap= WM_keymap_listbase(wm, "Buttons", SPACE_BUTS, 0);       /* XXX weak? */
-       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
 }
 
 static void buttons_main_area_draw(const bContext *C, ARegion *ar)
index 7b24e8f..60d8b17 100644 (file)
@@ -84,9 +84,6 @@ static SpaceLink *info_new(const bContext *C)
        BLI_addtail(&sinfo->regionbase, ar);
        ar->regiontype= RGN_TYPE_WINDOW;
        
-       /* channel list region XXX */
-
-       
        return (SpaceLink *)sinfo;
 }
 
@@ -118,35 +115,12 @@ static SpaceLink *info_duplicate(SpaceLink *sl)
 /* add handlers, stuff you only do once or on area/region changes */
 static void info_main_area_init(wmWindowManager *wm, ARegion *ar)
 {
-       ListBase *keymap;
-       
-       UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_STANDARD, ar->winx, ar->winy);
-       
-       /* own keymap */
-       keymap= WM_keymap_listbase(wm, "info", SPACE_INFO, 0);  /* XXX weak? */
-       WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
+       ED_region_panels_init(wm, ar);
 }
 
 static void info_main_area_draw(const bContext *C, ARegion *ar)
 {
-       /* draw entirely, view changes should be handled here */
-       // SpaceInfo *sinfo= (SpaceInfo*)CTX_wm_space_data(C);
-       View2D *v2d= &ar->v2d;
-       float col[3];
-
-       /* clear and setup matrix */
-       UI_GetThemeColor3fv(TH_BACK, col);
-       glClearColor(col[0], col[1], col[2], 0.0);
-       glClear(GL_COLOR_BUFFER_BIT);
-       
-       UI_view2d_view_ortho(C, v2d);
-               
-       /* data... */
-
-       /* reset view matrix */
-       UI_view2d_view_restore(C);
-       
-       /* scrollers? */
+       ED_region_panels(C, ar, 1, NULL);
 }
 
 void info_operatortypes(void)
@@ -217,7 +191,7 @@ void ED_spacetype_info(void)
        art->init= info_main_area_init;
        art->draw= info_main_area_draw;
        art->listener= info_main_area_listener;
-       art->keymapflag= ED_KEYMAP_VIEW2D;
+       art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
 
        BLI_addhead(&st->regiontypes, art);
        
index 7fa2734..5e164c6 100644 (file)
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 
 #include "DNA_ID.h"
+#include "DNA_userdef_types.h"
 
 #include "RNA_access.h"
 #include "RNA_define.h"
@@ -102,6 +103,13 @@ static PointerRNA rna_Context_tool_settings_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_ToolSettings, CTX_data_tool_settings(C));
 }
 
+static PointerRNA rna_Context_user_preferences_get(PointerRNA *ptr)
+{
+       PointerRNA newptr;
+       RNA_pointer_create(NULL, &RNA_UserPreferences, &U, &newptr);
+       return newptr;
+}
+
 #else
 
 void RNA_def_context(BlenderRNA *brna)
@@ -165,6 +173,10 @@ void RNA_def_context(BlenderRNA *brna)
        RNA_def_property_struct_type(prop, "ToolSettings");
        RNA_def_property_pointer_funcs(prop, "rna_Context_tool_settings_get", NULL, NULL);
 
+       prop= RNA_def_property(srna, "user_preferences", PROP_POINTER, PROP_NONE);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_struct_type(prop, "UserPreferences");
+       RNA_def_property_pointer_funcs(prop, "rna_Context_user_preferences_get", NULL, NULL);
 }
 
 #endif