Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_keymap.h4
-rw-r--r--source/blender/windowmanager/WM_types.h6
-rw-r--r--source/blender/windowmanager/intern/wm.c59
-rw-r--r--source/blender/windowmanager/intern/wm_files.c12
-rw-r--r--source/blender/windowmanager/intern/wm_init_exit.c13
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c19
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c17
-rw-r--r--source/blender/windowmanager/intern/wm_window.c11
-rw-r--r--source/blender/windowmanager/wm_window.h1
9 files changed, 58 insertions, 84 deletions
diff --git a/source/blender/windowmanager/WM_keymap.h b/source/blender/windowmanager/WM_keymap.h
index 547028c88f9..2e84140707d 100644
--- a/source/blender/windowmanager/WM_keymap.h
+++ b/source/blender/windowmanager/WM_keymap.h
@@ -70,6 +70,10 @@ wmKeyMapItem *WM_keymap_add_panel(struct wmKeyMap *keymap, const char *idname, i
wmKeyMapItem *WM_keymap_add_tool(struct wmKeyMap *keymap, const char *idname, int type,
int val, int modifier, int keymodifier);
+void WM_keymap_add_context_enum_set_items(
+ wmKeyMap *keymap, const struct EnumPropertyItem *items, const char *data_path,
+ int type_start, int val, int modifier, int keymodifier);
+
bool WM_keymap_remove_item(struct wmKeyMap *keymap, struct wmKeyMapItem *kmi);
int WM_keymap_item_to_string(wmKeyMapItem *kmi, const bool compact, char *result, const int result_len);
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index a5536dbd652..60dd9ad2e72 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -585,6 +585,12 @@ typedef struct wmOperatorType {
* that the operator might still fail to execute even if this return true */
bool (*poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT;
+ /* Use to check of properties should be displayed in auto-generated UI.
+ * Use 'check' callback to enforce refreshing. */
+ bool (*poll_property)(
+ const struct bContext *C, struct wmOperator *op,
+ const PropertyRNA *prop) ATTR_WARN_UNUSED_RESULT;
+
/* optional panel for redo and repeat, autogenerated if not set */
void (*ui)(struct bContext *, struct wmOperator *);
diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c
index f92cc511449..7247529d02d 100644
--- a/source/blender/windowmanager/intern/wm.c
+++ b/source/blender/windowmanager/intern/wm.c
@@ -223,65 +223,6 @@ void WM_operator_handlers_clear(wmWindowManager *wm, wmOperatorType *ot)
}
}
-/* ************ uiListType handling ************** */
-
-static GHash *uilisttypes_hash = NULL;
-
-uiListType *WM_uilisttype_find(const char *idname, bool quiet)
-{
- uiListType *ult;
-
- if (idname[0]) {
- ult = BLI_ghash_lookup(uilisttypes_hash, idname);
- if (ult) {
- return ult;
- }
- }
-
- if (!quiet) {
- printf("search for unknown uilisttype %s\n", idname);
- }
-
- return NULL;
-}
-
-bool WM_uilisttype_add(uiListType *ult)
-{
- BLI_ghash_insert(uilisttypes_hash, ult->idname, ult);
- return 1;
-}
-
-void WM_uilisttype_freelink(uiListType *ult)
-{
- bool ok;
-
- ok = BLI_ghash_remove(uilisttypes_hash, ult->idname, NULL, MEM_freeN);
-
- BLI_assert(ok);
- (void)ok;
-}
-
-/* called on initialize WM_init() */
-void WM_uilisttype_init(void)
-{
- uilisttypes_hash = BLI_ghash_str_new_ex("uilisttypes_hash gh", 16);
-}
-
-void WM_uilisttype_free(void)
-{
- GHashIterator gh_iter;
-
- GHASH_ITER (gh_iter, uilisttypes_hash) {
- uiListType *ult = BLI_ghashIterator_getValue(&gh_iter);
- if (ult->ext.free) {
- ult->ext.free(ult->ext.data);
- }
- }
-
- BLI_ghash_free(uilisttypes_hash, NULL, MEM_freeN);
- uilisttypes_hash = NULL;
-}
-
/* ****************************************** */
void WM_keymap_init(bContext *C)
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index c191255cd21..042bd8823c4 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -279,6 +279,10 @@ static void wm_window_match_replace_by_file_wm(
wm->initialized = 0;
wm->winactive = NULL;
+ /* Clearing drawable of before deleting any context
+ * to avoid clearing the wrong wm. */
+ wm_window_clear_drawable(oldwm);
+
/* only first wm in list has ghostwins */
for (wmWindow *win = wm->windows.first; win; win = win->next) {
for (wmWindow *oldwin = oldwm->windows.first; oldwin; oldwin = oldwin->next) {
@@ -488,13 +492,7 @@ static void wm_file_read_post(bContext *C, const bool is_startup_file, const boo
Main *bmain = CTX_data_main(C);
DEG_on_visible_update(bmain, true);
-
- if (!is_startup_file) {
- /* When starting up, the UI hasn't been fully initialised yet, and
- * this call can trigger icon updates, causing a segfault due to a
- * not-yet-initialised ghash for the icons. */
- wm_event_do_depsgraph(C);
- }
+ wm_event_do_depsgraph(C);
ED_editors_init(C);
diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c
index c51d4c5534a..4b0d751a7ce 100644
--- a/source/blender/windowmanager/intern/wm_init_exit.c
+++ b/source/blender/windowmanager/intern/wm_init_exit.c
@@ -115,6 +115,7 @@
#include "ED_undo.h"
#include "UI_interface.h"
+#include "UI_resources.h"
#include "BLF_api.h"
#include "BLT_lang.h"
@@ -237,6 +238,11 @@ void WM_init(bContext *C, int argc, const char **argv)
BLF_init();
BLT_lang_init();
+ /* Init icons before reading .blend files for preview icons, which can
+ * get triggered by the depsgraph. This is also done in background mode
+ * for scripts that do background processing with preview icons. */
+ BKE_icons_init(BIFICONID_LAST);
+
/* reports cant be initialized before the wm,
* but keep before file reading, since that may report errors */
wm_init_reports(C);
@@ -259,13 +265,6 @@ void WM_init(bContext *C, int argc, const char **argv)
UI_init();
BKE_studiolight_init();
}
- else {
- /* Note: Currently only inits icons, which we now want in background mode too
- * (scripts could use those in background processing...).
- * In case we do more later, we may need to pass a 'background' flag.
- * Called from 'UI_init' above */
- BKE_icons_init(1);
- }
ED_spacemacros_init();
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index a95ccf36fdb..6815ff4413a 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -526,6 +526,25 @@ wmKeyMapItem *WM_keymap_add_tool(wmKeyMap *keymap, const char *idname, int type,
return kmi;
}
+/** Useful for mapping numbers to an enum. */
+void WM_keymap_add_context_enum_set_items(
+ wmKeyMap *keymap, const EnumPropertyItem *items, const char *data_path,
+ int type_start, int val, int modifier, int keymodifier)
+{
+ for (int i = 0, type_offset = 0; items[i].identifier; i++) {
+ if (items[i].identifier[0] == '\0') {
+ continue;
+ }
+ wmKeyMapItem *kmi = WM_keymap_add_item(
+ keymap, "WM_OT_context_set_enum",
+ type_start + type_offset, val, modifier, keymodifier);
+ RNA_string_set(kmi->ptr, "data_path", data_path);
+ RNA_string_set(kmi->ptr, "value", items[i].identifier);
+ type_offset += 1;
+ }
+}
+
+
bool WM_keymap_remove_item(wmKeyMap *keymap, wmKeyMapItem *kmi)
{
if (BLI_findindex(&keymap->items, kmi) != -1) {
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index e757c7bee52..df869ba6b68 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1043,15 +1043,17 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op)
if (op->type->flag & OPTYPE_MACRO) {
for (op = op->macro.first; op; op = op->next) {
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
- UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
+ uiTemplateOperatorPropertyButs(
+ C, layout, op, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
if (op->next)
uiItemS(layout);
}
}
else {
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
- UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
+ uiTemplateOperatorPropertyButs(
+ C, layout, op, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
}
UI_block_bounds_set_popup(block, 4, 0, 0);
@@ -1120,8 +1122,9 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData)
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
- UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
+ uiTemplateOperatorPropertyButs(
+ C, layout, op, UI_BUT_LABEL_ALIGN_SPLIT_COLUMN,
+ UI_TEMPLATE_OP_PROPS_SHOW_TITLE);
/* clear so the OK button is left alone */
UI_block_func_set(block, NULL, NULL, NULL);
@@ -1160,7 +1163,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData)
layout = UI_block_layout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, 0, style);
/* since ui is defined the auto-layout args are not used */
- uiTemplateOperatorPropertyButs(C, layout, op, NULL, UI_BUT_LABEL_ALIGN_COLUMN, 0);
+ uiTemplateOperatorPropertyButs(C, layout, op, UI_BUT_LABEL_ALIGN_COLUMN, 0);
UI_block_func_set(block, NULL, NULL, NULL);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index c1006db34ef..dd4013efdf2 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -123,7 +123,6 @@ static struct WMInitStruct {
/* ******** win open & close ************ */
static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool activate);
-static void wm_window_clear_drawable(wmWindowManager *wm);
/* XXX this one should correctly check for apple top header...
* done for Cocoa : returns window contents (and not frame) max size*/
@@ -202,7 +201,6 @@ static void wm_ghostwindow_destroy(wmWindowManager *wm, wmWindow *win)
GHOST_DisposeWindow(g_system, win->ghostwin);
win->ghostwin = NULL;
win->gpuctx = NULL;
-
}
}
@@ -1103,7 +1101,7 @@ static void wm_window_set_drawable(wmWindowManager *wm, wmWindow *win, bool acti
immActivate();
}
-static void wm_window_clear_drawable(wmWindowManager *wm)
+void wm_window_clear_drawable(wmWindowManager *wm)
{
if (wm->windrawable) {
BLF_batch_reset();
@@ -2169,7 +2167,12 @@ ViewLayer *WM_window_get_active_view_layer(const wmWindow *win)
return view_layer;
}
- return BKE_view_layer_default_view(scene);
+ view_layer = BKE_view_layer_default_view(scene);
+ if (view_layer) {
+ WM_window_set_active_view_layer((wmWindow*)win, view_layer);
+ }
+
+ return view_layer;
}
void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
diff --git a/source/blender/windowmanager/wm_window.h b/source/blender/windowmanager/wm_window.h
index 385d61217ad..4fd5d66fb43 100644
--- a/source/blender/windowmanager/wm_window.h
+++ b/source/blender/windowmanager/wm_window.h
@@ -57,6 +57,7 @@ void wm_window_ghostwindows_remove_invalid(bContext *C, wmWindowManager *wm);
void wm_window_process_events (const bContext *C);
void wm_window_process_events_nosleep(void);
+void wm_window_clear_drawable(wmWindowManager *wm);
void wm_window_make_drawable(wmWindowManager *wm, wmWindow *win);
void wm_window_reset_drawable(void);