From 33b03f7f68922efada6ec7518c4fa60e9acb620a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 2 Mar 2019 00:52:00 +1100 Subject: Cleanup: move theme reset into it's own operator file --- source/blender/editors/include/ED_userpref.h | 26 +++++++++++ source/blender/editors/include/UI_interface.h | 4 ++ .../blender/editors/interface/interface_intern.h | 2 - source/blender/editors/interface/interface_ops.c | 26 ----------- source/blender/editors/interface/resources.c | 5 +- source/blender/editors/space_api/spacetypes.c | 2 + .../blender/editors/space_userpref/userpref_ops.c | 54 ++++++++++++++++++++-- 7 files changed, 85 insertions(+), 34 deletions(-) create mode 100644 source/blender/editors/include/ED_userpref.h (limited to 'source/blender/editors') diff --git a/source/blender/editors/include/ED_userpref.h b/source/blender/editors/include/ED_userpref.h new file mode 100644 index 00000000000..29470608933 --- /dev/null +++ b/source/blender/editors/include/ED_userpref.h @@ -0,0 +1,26 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +/** \file + * \ingroup editors + */ + +#ifndef __ED_USERPREF_H__ +#define __ED_USERPREF_H__ + +void ED_operatortypes_userpref(void); + +#endif /* __ED_USERPREF_H__ */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 79f80c67a1a..9c771994c4b 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1402,6 +1402,10 @@ void UI_widgetbase_draw_cache_begin(void); void UI_widgetbase_draw_cache_flush(void); void UI_widgetbase_draw_cache_end(void); +/* Use for resetting the theme. */ +void UI_theme_init_default(void); +void UI_style_init_default(void); + /* Special drawing for toolbar, mainly workarounds for inflexible icon sizing. */ #define USE_UI_TOOLBAR_HACK diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 656e7277fc2..19390a634fa 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -818,8 +818,6 @@ void icon_draw_rect_input( /* resources.c */ void init_userdef_do_versions(struct Main *bmain); -void ui_theme_init_default(void); -void ui_style_init_default(void); void ui_resources_init(void); void ui_resources_free(void); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index fdf666564b9..615259077b5 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -70,31 +70,6 @@ #include "BKE_main.h" #include "BLI_ghash.h" -/* Reset Default Theme ------------------------ */ - -static int reset_default_theme_exec(bContext *C, wmOperator *UNUSED(op)) -{ - ui_theme_init_default(); - ui_style_init_default(); - WM_event_add_notifier(C, NC_WINDOW, NULL); - - return OPERATOR_FINISHED; -} - -static 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 ------------------------ */ static bool copy_data_path_button_poll(bContext *C) @@ -1603,7 +1578,6 @@ static void UI_OT_drop_color(wmOperatorType *ot) void ED_operatortypes_ui(void) { - WM_operatortype_append(UI_OT_reset_default_theme); WM_operatortype_append(UI_OT_copy_data_path_button); WM_operatortype_append(UI_OT_copy_python_command_button); WM_operatortype_append(UI_OT_reset_default_button); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index eaa3da8c305..48b24da8f5c 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -744,9 +744,8 @@ const uchar *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid) * \note: when you add new colors, created & saved themes need initialized * use function below, init_userdef_do_versions() */ -void ui_theme_init_default(void) +void UI_theme_init_default(void) { - /* we search for the theme with name Default */ bTheme *btheme = BLI_findstring(&U.themes, "Default", offsetof(bTheme, name)); if (btheme == NULL) { @@ -761,7 +760,7 @@ void ui_theme_init_default(void) btheme->active_theme_area = active_theme_area; } -void ui_style_init_default(void) +void UI_style_init_default(void) { BLI_freelistN(&U.uistyles); /* gets automatically re-allocated */ diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 60094c4edb7..0288d7888d8 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -57,6 +57,7 @@ #include "ED_space_api.h" #include "ED_sound.h" #include "ED_uvedit.h" +#include "ED_userpref.h" #include "ED_lattice.h" #include "ED_mball.h" #include "ED_logic.h" @@ -99,6 +100,7 @@ void ED_spacetypes_init(void) // ... /* register operator types for screen and all spaces */ + ED_operatortypes_userpref(); ED_operatortypes_workspace(); ED_operatortypes_scene(); ED_operatortypes_screen(); diff --git a/source/blender/editors/space_userpref/userpref_ops.c b/source/blender/editors/space_userpref/userpref_ops.c index 4ba3c988c4d..f6aaf01747c 100644 --- a/source/blender/editors/space_userpref/userpref_ops.c +++ b/source/blender/editors/space_userpref/userpref_ops.c @@ -13,7 +13,7 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * The Original Code is Copyright (C) 2008 Blender Foundation. + * The Original Code is Copyright (C) 2009 Blender Foundation. * All rights reserved. */ @@ -21,6 +21,54 @@ * \ingroup spuserpref */ - #include -#include + +#include "DNA_screen_types.h" + +#include "BKE_context.h" +#include "BKE_report.h" + +#include "RNA_types.h" + +#include "UI_interface.h" + +#include "../interface/interface_intern.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_userpref.h" + +/* -------------------------------------------------------------------- */ +/** \name Reset Default Theme + * \{ */ + +static int reset_default_theme_exec(bContext *C, wmOperator *UNUSED(op)) +{ + UI_theme_init_default(); + UI_style_init_default(); + WM_event_add_notifier(C, NC_WINDOW, NULL); + + return OPERATOR_FINISHED; +} + +static void PREFERENCES_OT_reset_default_theme(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Reset to Default Theme"; + ot->idname = "PREFERENCES_OT_reset_default_theme"; + ot->description = "Reset to the default theme colors"; + + /* callbacks */ + ot->exec = reset_default_theme_exec; + + /* flags */ + ot->flag = OPTYPE_REGISTER; +} + +/** \} */ + +void ED_operatortypes_userpref(void) +{ + WM_operatortype_append(PREFERENCES_OT_reset_default_theme); +} -- cgit v1.2.3