[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57863] branches/soc-2013-depsgraph_mt/ source/blender: Allow some operators when interface is locked
Sergey Sharybin
sergey.vfx at gmail.com
Fri Jun 28 23:58:52 CEST 2013
Revision: 57863
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57863
Author: nazgul
Date: 2013-06-28 21:58:52 +0000 (Fri, 28 Jun 2013)
Log Message:
-----------
Allow some operators when interface is locked
Now it's possible to mark operator as safe to be used
in locked interface mode by adding OPTYPE_ALLOW_LOCKED
bit to operator template flags.
This bit is completely handled by wm_evem_system, not
with operator run routines, so it's still possible to
run operators from drivers and handlers.
Currently allowed image editor navigation and zooming.
Modified Paths:
--------------
branches/soc-2013-depsgraph_mt/source/blender/editors/space_image/image_ops.c
branches/soc-2013-depsgraph_mt/source/blender/windowmanager/WM_types.h
branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c
Modified: branches/soc-2013-depsgraph_mt/source/blender/editors/space_image/image_ops.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/editors/space_image/image_ops.c 2013-06-28 21:58:48 UTC (rev 57862)
+++ branches/soc-2013-depsgraph_mt/source/blender/editors/space_image/image_ops.c 2013-06-28 21:58:52 UTC (rev 57863)
@@ -360,7 +360,7 @@
ot->poll = space_image_main_area_poll;
/* flags */
- ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER;
+ ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER | OPTYPE_ALLOW_LOCKED;
/* properties */
RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX,
@@ -575,7 +575,7 @@
ot->poll = space_image_main_area_poll;
/* flags */
- ot->flag = OPTYPE_BLOCKING;
+ ot->flag = OPTYPE_BLOCKING | OPTYPE_ALLOW_LOCKED;
/* properties */
RNA_def_float(ot->srna, "factor", 0.0f, -FLT_MAX, FLT_MAX,
@@ -638,6 +638,9 @@
/* api callbacks */
ot->invoke = image_view_ndof_invoke;
+
+ /* flags */
+ ot->flag = OPTYPE_ALLOW_LOCKED;
}
/********************** view all operator *********************/
@@ -693,6 +696,9 @@
/* api callbacks */
ot->exec = image_view_all_exec;
ot->poll = space_image_main_area_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_GRAB_POINTER;
}
/********************** view selected operator *********************/
@@ -755,6 +761,9 @@
/* api callbacks */
ot->exec = image_view_selected_exec;
ot->poll = image_view_selected_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_GRAB_POINTER;
}
/********************** view zoom in/out operator *********************/
@@ -797,6 +806,9 @@
ot->exec = image_view_zoom_in_exec;
ot->poll = space_image_main_area_poll;
+ /* flags */
+ ot->flag = OPTYPE_ALLOW_LOCKED;
+
/* properties */
RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in screen coordinates", -10.0f, 10.0f);
}
@@ -839,6 +851,9 @@
ot->exec = image_view_zoom_out_exec;
ot->poll = space_image_main_area_poll;
+ /* flags */
+ ot->flag = OPTYPE_ALLOW_LOCKED;
+
/* properties */
RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in screen coordinates", -10.0f, 10.0f);
}
@@ -880,7 +895,10 @@
/* api callbacks */
ot->exec = image_view_zoom_ratio_exec;
ot->poll = space_image_main_area_poll;
-
+
+ /* flags */
+ ot->flag = OPTYPE_ALLOW_LOCKED;
+
/* properties */
RNA_def_float(ot->srna, "ratio", 0.0f, -FLT_MAX, FLT_MAX,
"Ratio", "Zoom ratio, 1.0 is 1:1, higher is zoomed in, lower is zoomed out", -FLT_MAX, FLT_MAX);
Modified: branches/soc-2013-depsgraph_mt/source/blender/windowmanager/WM_types.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/windowmanager/WM_types.h 2013-06-28 21:58:48 UTC (rev 57862)
+++ branches/soc-2013-depsgraph_mt/source/blender/windowmanager/WM_types.h 2013-06-28 21:58:52 UTC (rev 57863)
@@ -133,6 +133,7 @@
* and don't make sense to be accessed from the
* search menu, even if poll() returns TRUE.
* currently only used for the search toolbox */
+#define OPTYPE_ALLOW_LOCKED 128 /* Allow operator to run when interface is locked */
/* context to call operator in for WM_operator_name_call */
/* rna_ui.c contains EnumPropertyItem's of these, keep in sync */
Modified: branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c 2013-06-28 21:58:48 UTC (rev 57862)
+++ branches/soc-2013-depsgraph_mt/source/blender/windowmanager/intern/wm_event_system.c 2013-06-28 21:58:52 UTC (rev 57863)
@@ -1441,6 +1441,22 @@
}
}
+/* Check whether operator is allowed to run in case interface is locked,
+ * If interface is unlocked, will always return truth.
+ */
+static bool wm_operator_check_locked_interface(bContext *C, wmOperatorType *ot)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+
+ if (wm->is_interface_locked) {
+ if ((ot->flag & OPTYPE_ALLOW_LOCKED) == 0) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
/* bad hacking event system... better restore event type for checking of KM_CLICK for example */
/* XXX modal maps could use different method (ton) */
static void wm_event_modalmap_end(wmEvent *event)
@@ -1467,7 +1483,12 @@
wmOperator *op = handler->op;
wmOperatorType *ot = op->type;
- if (ot->modal) {
+ if (!wm_operator_check_locked_interface(C, ot)) {
+ /* Interface is locked and pperator is not allowed to run,
+ * nothing to do in this case.
+ */
+ }
+ else if (ot->modal) {
/* we set context to where modal handler came from */
wmWindowManager *wm = CTX_wm_manager(C);
ScrArea *area = CTX_wm_area(C);
@@ -1537,7 +1558,9 @@
wmOperatorType *ot = WM_operatortype_find(event->keymap_idname, 0);
if (ot) {
- retval = wm_operator_invoke(C, ot, event, properties, NULL, FALSE);
+ if (wm_operator_check_locked_interface(C, ot)) {
+ retval = wm_operator_invoke(C, ot, event, properties, NULL, FALSE);
+ }
}
}
/* Finished and pass through flag as handled */
@@ -1825,14 +1848,18 @@
}
}
else if (handler->ui_handle) {
- action |= wm_handler_ui_call(C, handler, event, always_pass);
+ if (!wm->is_interface_locked) {
+ action |= wm_handler_ui_call(C, handler, event, always_pass);
+ }
}
else if (handler->type == WM_HANDLER_FILESELECT) {
- /* screen context changes here */
- action |= wm_handler_fileselect_call(C, handlers, handler, event);
+ if (!wm->is_interface_locked) {
+ /* screen context changes here */
+ action |= wm_handler_fileselect_call(C, handlers, handler, event);
+ }
}
else if (handler->dropboxes) {
- if (event->type == EVT_DROP) {
+ if (!wm->is_interface_locked && event->type == EVT_DROP) {
wmDropBox *drop = handler->dropboxes->first;
for (; drop; drop = drop->next) {
/* other drop custom types allowed */
@@ -2083,21 +2110,6 @@
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win;
- if (wm->is_interface_locked) {
- /* If we're in locked interaction mode, skip all the events
- * from the queue and prevent them from being accumulated.
- * This is so no events are applied after interface is unlocked.
- */
- for (win = wm->windows.first; win; win = win->next) {
- wmEvent *event;
- while ( (event = win->queue.first) ) {
- BLI_remlink(&win->queue, event);
- wm_event_free(event);
- }
- }
- return;
- }
-
/* update key configuration before handling events */
WM_keyconfig_update(wm);
More information about the Bf-blender-cvs
mailing list