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:
authorCampbell Barton <ideasman42@gmail.com>2018-09-18 09:10:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-09-18 09:15:06 +0300
commitd421adb83e8d39bd9d74ea3d526326b70e93c341 (patch)
tree4c5e16b5e2fcd8c587204aa85dde175a6951392a /source/blender/editors/util
parent0a3b66cfb573a91ba3b19f30ead4a026bdfa6873 (diff)
Gizmo: de-duplicate poll logic
Checking the active tool or operator was a common way to check if the gizmo was still in use.
Diffstat (limited to 'source/blender/editors/util')
-rw-r--r--source/blender/editors/util/CMakeLists.txt4
-rw-r--r--source/blender/editors/util/gizmo_utils.c64
2 files changed, 67 insertions, 1 deletions
diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt
index 4321365fb4f..82fced0a3c7 100644
--- a/source/blender/editors/util/CMakeLists.txt
+++ b/source/blender/editors/util/CMakeLists.txt
@@ -40,9 +40,10 @@ set(INC_SYS
)
set(SRC
- keymap_templates.c
ed_transverts.c
ed_util.c
+ gizmo_utils.c
+ keymap_templates.c
numinput.c
select_utils.c
@@ -57,6 +58,7 @@ set(SRC
../include/ED_datafiles.h
../include/ED_fileselect.h
../include/ED_gizmo_library.h
+ ../include/ED_gizmo_utils.h
../include/ED_gpencil.h
../include/ED_image.h
../include/ED_info.h
diff --git a/source/blender/editors/util/gizmo_utils.c b/source/blender/editors/util/gizmo_utils.c
new file mode 100644
index 00000000000..957ae221b0b
--- /dev/null
+++ b/source/blender/editors/util/gizmo_utils.c
@@ -0,0 +1,64 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file gizmo_utils.c
+ * \ingroup edutil
+ *
+ * \name Generic Gizmo Utilities.
+ */
+
+#include <string.h>
+
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+
+#include "DNA_workspace_types.h"
+
+#include "WM_types.h"
+#include "WM_api.h"
+#include "WM_toolsystem.h"
+
+#include "ED_gizmo_utils.h"
+
+bool ED_gizmo_poll_or_unlink_delayed_from_operator(
+ const bContext *C, wmGizmoGroupType *gzgt,
+ const char *idname)
+{
+ wmOperator *op = WM_operator_last_redo(C);
+ if (op == NULL || !STREQ(op->type->idname, idname)) {
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
+ return false;
+ }
+ return true;
+}
+
+/** Can use this as poll function directly. */
+bool ED_gizmo_poll_or_unlink_delayed_from_tool(const bContext *C, wmGizmoGroupType *gzgt)
+{
+ bToolRef_Runtime *tref_rt = WM_toolsystem_runtime_from_context((bContext *)C);
+ if ((tref_rt == NULL) ||
+ !STREQ(gzgt->idname, tref_rt->gizmo_group))
+ {
+ WM_gizmo_group_type_unlink_delayed_ptr(gzgt);
+ return false;
+ }
+ return true;
+}