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/intern')
-rw-r--r--source/blender/windowmanager/intern/wm_cursors.c26
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c194
-rw-r--r--source/blender/windowmanager/intern/wm_files.c54
-rw-r--r--source/blender/windowmanager/intern/wm_files_link.c2
-rw-r--r--source/blender/windowmanager/intern/wm_gesture_ops.c2
-rw-r--r--source/blender/windowmanager/intern/wm_keymap.c22
-rw-r--r--source/blender/windowmanager/intern/wm_window.c8
7 files changed, 252 insertions, 56 deletions
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 50d3a856cbe..9c020b16234 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -1146,5 +1146,31 @@ void wm_init_cursor_data(void)
BlenderCursor[WM_CURSOR_ZOOM_OUT] = &ZoomOutCursor;
END_CURSOR_BLOCK;
+ /********************** Area Pick Cursor ***********************/
+ BEGIN_CURSOR_BLOCK;
+
+ static char pick_area_bitmap[] = {
+ 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0xfe, 0x00, 0x10,
+ 0x00, 0x10, 0x00, 0x10, 0x00, 0x00, 0xbf, 0x00, 0x81, 0x00, 0x81,
+ 0x00, 0x81, 0x00, 0x81, 0x00, 0x81, 0x00, 0x80, 0x00, 0xff,
+ };
+
+ static char pick_area_mask[] = {
+ 0x38, 0x00, 0x38, 0x00, 0x38, 0x00, 0xff, 0x01, 0xff, 0x01, 0xff,
+ 0x01, 0x38, 0x00, 0xb8, 0x7f, 0xb8, 0xff, 0x80, 0xc1, 0x80, 0xc1,
+ 0x80, 0xc1, 0x80, 0xc1, 0x80, 0xc1, 0x80, 0xff, 0x00, 0xff,
+ };
+
+ static BCursor PickAreaCursor = {
+ pick_area_bitmap,
+ pick_area_mask,
+ 4,
+ 4,
+ false,
+ };
+
+ BlenderCursor[WM_CURSOR_PICK_AREA] = &PickAreaCursor;
+ END_CURSOR_BLOCK;
+
/********************** Put the cursors in the array ***********************/
}
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 83a9a6c6383..ae09786356a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -1673,6 +1673,172 @@ int WM_operator_call_py(bContext *C,
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Operator Wait For Input
+ *
+ * Delay executing operators that depend on cursor location.
+ *
+ * See: #OPTYPE_DEPENDS_ON_CURSOR doc-string for more information.
+ * \{ */
+
+typedef struct uiOperatorWaitForInput {
+ ScrArea *area;
+ wmOperatorCallParams optype_params;
+ bContextStore *context;
+} uiOperatorWaitForInput;
+
+static void ui_handler_wait_for_input_remove(bContext *C, void *userdata)
+{
+ uiOperatorWaitForInput *opwait = userdata;
+ if (opwait->optype_params.opptr) {
+ if (opwait->optype_params.opptr->data) {
+ IDP_FreeProperty(opwait->optype_params.opptr->data);
+ }
+ MEM_freeN(opwait->optype_params.opptr);
+ }
+ if (opwait->context) {
+ CTX_store_free(opwait->context);
+ }
+
+ if (opwait->area != NULL) {
+ ED_area_status_text(opwait->area, NULL);
+ }
+ else {
+ ED_workspace_status_text(C, NULL);
+ }
+
+ MEM_freeN(opwait);
+}
+
+static int ui_handler_wait_for_input(bContext *C, const wmEvent *event, void *userdata)
+{
+ uiOperatorWaitForInput *opwait = userdata;
+ enum { CONTINUE = 0, EXECUTE, CANCEL } state = CONTINUE;
+ state = CONTINUE;
+
+ switch (event->type) {
+ case LEFTMOUSE: {
+ if (event->val == KM_PRESS) {
+ state = EXECUTE;
+ }
+ break;
+ }
+ /* Useful if the operator isn't convenient to access while the mouse button is held.
+ * If it takes numeric input for example. */
+ case EVT_SPACEKEY:
+ case EVT_RETKEY: {
+ if (event->val == KM_PRESS) {
+ state = EXECUTE;
+ }
+ break;
+ }
+ case RIGHTMOUSE: {
+ if (event->val == KM_PRESS) {
+ state = CANCEL;
+ }
+ break;
+ }
+ case EVT_ESCKEY: {
+ if (event->val == KM_PRESS) {
+ state = CANCEL;
+ }
+ break;
+ }
+ }
+
+ if (state != CONTINUE) {
+ wmWindow *win = CTX_wm_window(C);
+ WM_cursor_modal_restore(win);
+
+ if (state == EXECUTE) {
+ CTX_store_set(C, opwait->context);
+ WM_operator_name_call_ptr(C,
+ opwait->optype_params.optype,
+ opwait->optype_params.opcontext,
+ opwait->optype_params.opptr);
+ CTX_store_set(C, NULL);
+ }
+
+ WM_event_remove_ui_handler(&win->modalhandlers,
+ ui_handler_wait_for_input,
+ ui_handler_wait_for_input_remove,
+ opwait,
+ false);
+
+ ui_handler_wait_for_input_remove(C, opwait);
+
+ return WM_UI_HANDLER_BREAK;
+ }
+
+ return WM_UI_HANDLER_CONTINUE;
+}
+
+void WM_operator_name_call_ptr_with_depends_on_cursor(
+ bContext *C, wmOperatorType *ot, short opcontext, PointerRNA *properties, const char *drawstr)
+{
+ int flag = ot->flag;
+
+ LISTBASE_FOREACH (wmOperatorTypeMacro *, macro, &ot->macro) {
+ wmOperatorType *otm = WM_operatortype_find(macro->idname, 0);
+ if (otm != NULL) {
+ flag |= otm->flag;
+ }
+ }
+
+ if ((flag & OPTYPE_DEPENDS_ON_CURSOR) == 0) {
+ WM_operator_name_call_ptr(C, ot, opcontext, properties);
+ return;
+ }
+
+ wmWindow *win = CTX_wm_window(C);
+ ScrArea *area = CTX_wm_area(C);
+
+ {
+ char header_text[UI_MAX_DRAW_STR];
+ SNPRINTF(header_text,
+ "%s %s",
+ IFACE_("Input pending "),
+ (drawstr && drawstr[0]) ? drawstr : CTX_IFACE_(ot->translation_context, ot->name));
+ if (area != NULL) {
+ ED_area_status_text(area, header_text);
+ }
+ else {
+ ED_workspace_status_text(C, header_text);
+ }
+ }
+
+ WM_cursor_modal_set(win, WM_CURSOR_PICK_AREA);
+
+ uiOperatorWaitForInput *opwait = MEM_callocN(sizeof(*opwait), __func__);
+ opwait->optype_params.optype = ot;
+ opwait->optype_params.opcontext = opcontext;
+ opwait->optype_params.opptr = properties;
+
+ opwait->area = area;
+
+ if (properties) {
+ opwait->optype_params.opptr = MEM_mallocN(sizeof(*opwait->optype_params.opptr), __func__);
+ *opwait->optype_params.opptr = *properties;
+ if (properties->data != NULL) {
+ opwait->optype_params.opptr->data = IDP_CopyProperty(properties->data);
+ }
+ }
+
+ bContextStore *store = CTX_store_get(C);
+ if (store) {
+ opwait->context = CTX_store_copy(store);
+ }
+
+ WM_event_add_ui_handler(C,
+ &win->modalhandlers,
+ ui_handler_wait_for_input,
+ ui_handler_wait_for_input_remove,
+ opwait,
+ WM_HANDLER_BLOCKING);
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Handler Types
*
* General API for different handler types.
@@ -4692,47 +4858,27 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, void
case EVT_LEFTSHIFTKEY:
case EVT_RIGHTSHIFTKEY:
if (event.val == KM_PRESS) {
- if (event_state->ctrl || event_state->alt || event_state->oskey) {
- keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
- }
- else {
- keymodifier = KM_MOD_FIRST;
- }
+ keymodifier = KM_MOD_HELD;
}
event.shift = event_state->shift = keymodifier;
break;
case EVT_LEFTCTRLKEY:
case EVT_RIGHTCTRLKEY:
if (event.val == KM_PRESS) {
- if (event_state->shift || event_state->alt || event_state->oskey) {
- keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
- }
- else {
- keymodifier = KM_MOD_FIRST;
- }
+ keymodifier = KM_MOD_HELD;
}
event.ctrl = event_state->ctrl = keymodifier;
break;
case EVT_LEFTALTKEY:
case EVT_RIGHTALTKEY:
if (event.val == KM_PRESS) {
- if (event_state->ctrl || event_state->shift || event_state->oskey) {
- keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
- }
- else {
- keymodifier = KM_MOD_FIRST;
- }
+ keymodifier = KM_MOD_HELD;
}
event.alt = event_state->alt = keymodifier;
break;
case EVT_OSKEY:
if (event.val == KM_PRESS) {
- if (event_state->ctrl || event_state->alt || event_state->shift) {
- keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
- }
- else {
- keymodifier = KM_MOD_FIRST;
- }
+ keymodifier = KM_MOD_HELD;
}
event.oskey = event_state->oskey = keymodifier;
break;
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c
index 5cbf2da9bfa..41c1982a0e5 100644
--- a/source/blender/windowmanager/intern/wm_files.c
+++ b/source/blender/windowmanager/intern/wm_files.c
@@ -1527,10 +1527,6 @@ static ImBuf *blend_file_thumb_from_screenshot(bContext *C, BlendThumbnail **thu
return BKE_main_thumbnail_to_imbuf(NULL, *thumb_pt);
}
- /* Redraw to remove menus that might be open. */
- WM_redraw_windows(C);
- WM_cursor_wait(true);
-
/* The window to capture should be a main window (without parent). */
wmWindow *win = CTX_wm_window(C);
while (win && win->parent) {
@@ -1563,7 +1559,6 @@ static ImBuf *blend_file_thumb_from_screenshot(bContext *C, BlendThumbnail **thu
IMB_freeImBuf(thumb_ibuf);
*thumb_pt = thumb;
}
- WM_cursor_wait(false);
/* Must be freed by caller. */
return ibuf;
@@ -1607,10 +1602,9 @@ static ImBuf *blend_file_thumb_from_camera(const bContext *C,
return NULL;
}
- if ((scene->camera == NULL) && (screen != NULL)) {
+ if (screen != NULL) {
area = BKE_screen_find_big_area(screen, SPACE_VIEW3D, 0);
- region = BKE_area_find_region_type(area, RGN_TYPE_WINDOW);
- if (region) {
+ if (area) {
v3d = area->spacedata.first;
}
}
@@ -1629,13 +1623,14 @@ static ImBuf *blend_file_thumb_from_camera(const bContext *C,
if (scene->camera) {
ibuf = ED_view3d_draw_offscreen_imbuf_simple(depsgraph,
scene,
- NULL,
- OB_SOLID,
+ (v3d) ? &v3d->shading : NULL,
+ (v3d) ? v3d->shading.type : OB_SOLID,
scene->camera,
PREVIEW_RENDER_LARGE_HEIGHT * 2,
PREVIEW_RENDER_LARGE_HEIGHT * 2,
IB_rect,
- V3D_OFSDRAW_NONE,
+ (v3d) ? V3D_OFSDRAW_OVERRIDE_SCENE_SETTINGS :
+ V3D_OFSDRAW_NONE,
R_ALPHAPREMUL,
NULL,
NULL,
@@ -1758,17 +1753,41 @@ static bool wm_file_write(bContext *C,
/* Enforce full override check/generation on file save. */
BKE_lib_override_library_main_operations_create(bmain, true);
+ if (!G.background) {
+ /* Redraw to remove menus that might be open. */
+ WM_redraw_windows(C);
+ }
+
+ /* don't forget not to return without! */
+ WM_cursor_wait(true);
+
/* blend file thumbnail */
/* Save before exit_editmode, otherwise derivedmeshes for shared data corrupt T27765. */
/* Main now can store a '.blend' thumbnail, useful for background mode
* or thumbnail customization. */
main_thumb = thumb = bmain->blen_thumb;
- if (BLI_thread_is_main()) {
- if (U.file_preview_type == USER_FILE_PREVIEW_SCREENSHOT) {
- ibuf_thumb = blend_file_thumb_from_screenshot(C, &thumb);
+ if (BLI_thread_is_main() && U.file_preview_type != USER_FILE_PREVIEW_NONE) {
+
+ int file_preview_type = U.file_preview_type;
+
+ if (file_preview_type == USER_FILE_PREVIEW_AUTO) {
+ Scene *scene = CTX_data_scene(C);
+ bool do_render = (scene != NULL && scene->camera != NULL &&
+ (BKE_screen_find_big_area(CTX_wm_screen(C), SPACE_VIEW3D, 0) != NULL));
+ file_preview_type = do_render ? USER_FILE_PREVIEW_CAMERA : USER_FILE_PREVIEW_SCREENSHOT;
}
- else if (U.file_preview_type == USER_FILE_PREVIEW_CAMERA) {
- ibuf_thumb = blend_file_thumb_from_camera(C, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
+
+ switch (file_preview_type) {
+ case USER_FILE_PREVIEW_SCREENSHOT: {
+ ibuf_thumb = blend_file_thumb_from_screenshot(C, &thumb);
+ break;
+ }
+ case USER_FILE_PREVIEW_CAMERA: {
+ ibuf_thumb = blend_file_thumb_from_camera(C, CTX_data_scene(C), CTX_wm_screen(C), &thumb);
+ break;
+ }
+ default:
+ BLI_assert_unreachable();
}
}
@@ -1778,9 +1797,6 @@ static bool wm_file_write(bContext *C,
BKE_packedfile_pack_all(bmain, reports, false);
}
- /* don't forget not to return without! */
- WM_cursor_wait(true);
-
ED_editors_flush_edits(bmain);
/* First time saving. */
diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c
index 29e34313be5..d0117d9d57a 100644
--- a/source/blender/windowmanager/intern/wm_files_link.c
+++ b/source/blender/windowmanager/intern/wm_files_link.c
@@ -709,7 +709,7 @@ static void wm_append_do(WMLinkAppendData *lapp_data,
break;
case WM_APPEND_ACT_REUSE_LOCAL:
/* We only need to set `newid` to ID found in previous loop, for proper remapping. */
- ID_NEW_SET(id->newid, item->customdata);
+ ID_NEW_SET(id, item->customdata);
/* This is not a 'new' local appended id, do not set `local_appended_new_id` here. */
break;
case WM_APPEND_ACT_UNSET:
diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c
index 788e4214ac7..cc376d8f201 100644
--- a/source/blender/windowmanager/intern/wm_gesture_ops.c
+++ b/source/blender/windowmanager/intern/wm_gesture_ops.c
@@ -818,6 +818,8 @@ void WM_OT_lasso_gesture(wmOperatorType *ot)
ot->poll = WM_operator_winactive;
+ ot->flag = OPTYPE_DEPENDS_ON_CURSOR;
+
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(ot->srna, prop, &RNA_OperatorMousePath);
}
diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c
index f1fe3e89007..f955abaed53 100644
--- a/source/blender/windowmanager/intern/wm_keymap.c
+++ b/source/blender/windowmanager/intern/wm_keymap.c
@@ -484,13 +484,20 @@ static void keymap_event_set(
kmi->shift = kmi->ctrl = kmi->alt = kmi->oskey = KM_ANY;
}
else {
- kmi->shift = (modifier & KM_SHIFT) ? KM_MOD_FIRST :
- ((modifier & KM_SHIFT2) ? KM_MOD_SECOND : false);
- kmi->ctrl = (modifier & KM_CTRL) ? KM_MOD_FIRST :
- ((modifier & KM_CTRL2) ? KM_MOD_SECOND : false);
- kmi->alt = (modifier & KM_ALT) ? KM_MOD_FIRST : ((modifier & KM_ALT2) ? KM_MOD_SECOND : false);
- kmi->oskey = (modifier & KM_OSKEY) ? KM_MOD_FIRST :
- ((modifier & KM_OSKEY2) ? KM_MOD_SECOND : false);
+ /* Only one of the flags should be set. */
+ BLI_assert(((modifier & (KM_SHIFT | KM_SHIFT_ANY)) != (KM_SHIFT | KM_SHIFT_ANY)) &&
+ ((modifier & (KM_CTRL | KM_CTRL_ANY)) != (KM_CTRL | KM_CTRL_ANY)) &&
+ ((modifier & (KM_ALT | KM_ALT_ANY)) != (KM_ALT | KM_ALT_ANY)) &&
+ ((modifier & (KM_OSKEY | KM_OSKEY_ANY)) != (KM_OSKEY | KM_OSKEY_ANY)));
+
+ kmi->shift = ((modifier & KM_SHIFT) ? KM_MOD_HELD :
+ ((modifier & KM_SHIFT_ANY) ? KM_ANY : KM_NOTHING));
+ kmi->ctrl = ((modifier & KM_CTRL) ? KM_MOD_HELD :
+ ((modifier & KM_CTRL_ANY) ? KM_ANY : KM_NOTHING));
+ kmi->alt = ((modifier & KM_ALT) ? KM_MOD_HELD :
+ ((modifier & KM_ALT_ANY) ? KM_ANY : KM_NOTHING));
+ kmi->oskey = ((modifier & KM_OSKEY) ? KM_MOD_HELD :
+ ((modifier & KM_OSKEY_ANY) ? KM_ANY : KM_NOTHING));
}
}
@@ -1164,7 +1171,6 @@ int WM_keymap_item_raw_to_string(const short shift,
buf[0] = '\0';
- /* TODO: support order (KM_SHIFT vs. KM_SHIFT2) ? */
if (shift == KM_ANY && ctrl == KM_ANY && alt == KM_ANY && oskey == KM_ANY) {
/* Don't show anything for any mapping. */
}
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 0402b0d778a..887aed7ffc7 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -1197,7 +1197,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
#ifdef USE_WIN_ACTIVATE
else {
if (keymodifier & KM_SHIFT) {
- win->eventstate->shift = KM_MOD_FIRST;
+ win->eventstate->shift = KM_MOD_HELD;
}
}
#endif
@@ -1210,7 +1210,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
#ifdef USE_WIN_ACTIVATE
else {
if (keymodifier & KM_CTRL) {
- win->eventstate->ctrl = KM_MOD_FIRST;
+ win->eventstate->ctrl = KM_MOD_HELD;
}
}
#endif
@@ -1223,7 +1223,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
#ifdef USE_WIN_ACTIVATE
else {
if (keymodifier & KM_ALT) {
- win->eventstate->alt = KM_MOD_FIRST;
+ win->eventstate->alt = KM_MOD_HELD;
}
}
#endif
@@ -1236,7 +1236,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr
#ifdef USE_WIN_ACTIVATE
else {
if (keymodifier & KM_OSKEY) {
- win->eventstate->oskey = KM_MOD_FIRST;
+ win->eventstate->oskey = KM_MOD_HELD;
}
}
#endif