Fix [#20115] Some theme settings are not saved

Theme colours were getting overwritten on startup with defaults (as in 2.4 
system). Changed this to allow changing the default theme, and added a 
'Reset to defaults' operator in user prefs. Perhaps next step to look into the 
py presets system for themes too (nice and easy to share).

If you're using a custom B.blend you may get some strange theme colours on 
startup if they weren't saved properly before. 'Reset to default' button in theme 
preferences should fix it back to defaults.
This commit is contained in:
Matt Ebb
2010-03-30 04:27:13 +00:00
parent f20427ffbe
commit 1f8cd57073
6 changed files with 10901 additions and 9164 deletions
+9 -7
View File
@@ -164,17 +164,19 @@ class USERPREF_HT_header(bpy.types.Header):
layout.operator_context = 'EXEC_AREA'
layout.operator("wm.save_homefile", text="Save As Default")
layout.operator_context = 'INVOKE_DEFAULT'
if userpref.active_section == 'INPUT':
layout.operator_context = 'INVOKE_DEFAULT'
op = layout.operator("wm.keyconfig_export", "Export Key Configuration...")
op = layout.operator("wm.keyconfig_export")
op.path = "keymap.py"
op = layout.operator("wm.keyconfig_import", "Import Key Configuration...")
op = layout.operator("wm.keyconfig_import")
op.path = "keymap.py"
elif userpref.active_section == 'ADDONS':
layout.operator_context = 'INVOKE_DEFAULT'
op = layout.operator("wm.addon_install", "Install Add-On...")
op = layout.operator("wm.addon_install")
op.path = "*.py"
elif userpref.active_section == 'THEMES':
op = layout.operator("ui.reset_default_theme")
class USERPREF_PT_tabs(bpy.types.Panel):
@@ -1593,7 +1595,7 @@ class WM_OT_addon_disable(bpy.types.Operator):
class WM_OT_addon_install(bpy.types.Operator):
"Install an addon"
bl_idname = "wm.addon_install"
bl_label = "Install Add-On"
bl_label = "Install Add-On..."
module = StringProperty(name="Module", description="Module name of the addon to disable")
File diff suppressed because it is too large Load Diff
@@ -3327,9 +3327,6 @@ void UI_init_userdef(void)
{
/* fix saved themes */
init_userdef_do_versions();
/* set default colors in default theme */
ui_theme_init_userdef();
uiStyleInit();
}
@@ -474,7 +474,7 @@ int ui_id_icon_get(struct bContext *C, struct ID *id, int preview);
/* resources.c */
void init_userdef_do_versions(void);
void ui_theme_init_userdef(void);
void ui_theme_init_default(void);
void ui_resources_init(void);
void ui_resources_free(void);
@@ -33,6 +33,7 @@
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "BLI_blenlib.h"
#include "BLI_math_color.h"
@@ -43,14 +44,17 @@
#include "RNA_access.h"
#include "RNA_define.h"
#include "BIF_gl.h"
#include "UI_interface.h"
#include "interface_intern.h"
#include "WM_api.h"
#include "WM_types.h"
#include "BIF_gl.h"
#include "UI_interface.h"
/* ********************************************************** */
typedef struct Eyedropper {
@@ -190,6 +194,29 @@ void UI_OT_eyedropper(wmOperatorType *ot)
/* properties */
}
/* Reset Default Theme ------------------------ */
static int reset_default_theme_exec(bContext *C, wmOperator *op)
{
ui_theme_init_default();
WM_event_add_notifier(C, NC_WINDOW, NULL);
return OPERATOR_FINISHED;
}
void UI_OT_reset_default_theme(wmOperatorType *ot)
{
/* identifiers */
ot->name= "Reset to Default Theme";
ot->idname= "UI_OT_reset_default_theme";
ot->description= "Reset to the default theme colors";
/* callbacks */
ot->exec= reset_default_theme_exec;
/* flags */
ot->flag= OPTYPE_REGISTER;
}
/* Copy Data Path Operator ------------------------ */
@@ -381,6 +408,7 @@ void UI_OT_copy_to_selected_button(wmOperatorType *ot)
void UI_buttons_operatortypes(void)
{
WM_operatortype_append(UI_OT_eyedropper);
WM_operatortype_append(UI_OT_reset_default_theme);
WM_operatortype_append(UI_OT_copy_data_path_button);
WM_operatortype_append(UI_OT_reset_default_button);
WM_operatortype_append(UI_OT_copy_to_selected_button);
+2 -2
View File
@@ -455,11 +455,11 @@ static void ui_theme_init_new(bTheme *btheme)
#define SETCOL(col, r, g, b, a) col[0]=r; col[1]=g; col[2]= b; col[3]= a;
#define SETCOLF(col, r, g, b, a) col[0]=r*255; col[1]=g*255; col[2]= b*255; col[3]= a*255;
/* initialize default theme, can't be edited
/* initialize default theme
Note: when you add new colors, created & saved themes need initialized
use function below, init_userdef_do_versions()
*/
void ui_theme_init_userdef(void)
void ui_theme_init_default(void)
{
bTheme *btheme= U.themes.first;