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-08-21 12:02:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-08-21 12:05:07 +0300
commit79ecfc99fd75f897a6140639474a7b0e5910a9ff (patch)
treea0256e83713f4d866e10a43e87c2ebf84d998f6a /source/blender/editors/space_view3d/view3d_gizmo_preselect.c
parentf7162d214ec31daf886acf3618fa9aa567c7521d (diff)
Tool System: loopcut preview & activate on click
The loop cut tool now works as expected for the tool-system, where hovering previews the loop and clicking activates. This uses a new gizmo type to pre-select the edge.
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_gizmo_preselect.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_gizmo_preselect.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect.c
new file mode 100644
index 00000000000..aebad326a57
--- /dev/null
+++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect.c
@@ -0,0 +1,89 @@
+/*
+ * ***** 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 blender/editors/space_view3d/view3d_gizmo_preselect.c
+ * \ingroup spview3d
+ */
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+
+#include "ED_screen.h"
+
+#include "UI_resources.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+#include "WM_toolsystem.h"
+
+#include "view3d_intern.h" /* own include */
+
+/* -------------------------------------------------------------------- */
+/** \name Mesh Pre-Select Edge Ring Gizmo
+ *
+ * \{ */
+
+struct GizmoGroupPreSelEdgeRing {
+ wmGizmo *gizmo;
+};
+
+static bool WIDGETGROUP_mesh_preselect_edgering_poll(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;
+}
+
+static void WIDGETGROUP_mesh_preselect_edgering_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
+{
+ const wmGizmoType *gzt_presel = WM_gizmotype_find("GIZMO_GT_preselect_edgering_3d", true);
+ struct GizmoGroupPreSelEdgeRing *man = MEM_callocN(sizeof(struct GizmoGroupPreSelEdgeRing), __func__);
+ gzgroup->customdata = man;
+
+ wmGizmo *gz = man->gizmo = WM_gizmo_new_ptr(gzt_presel, gzgroup, NULL);
+ UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
+ UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
+}
+
+void VIEW3D_GGT_mesh_preselect_edgering(wmGizmoGroupType *gzgt)
+{
+ gzgt->name = "Mesh Preselect Edge Ring";
+ gzgt->idname = "VIEW3D_GGT_mesh_preselect_edgering";
+
+ gzgt->flag = WM_GIZMOGROUPTYPE_3D;
+
+ gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
+ gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
+
+ gzgt->poll = WIDGETGROUP_mesh_preselect_edgering_poll;
+ gzgt->setup = WIDGETGROUP_mesh_preselect_edgering_setup;
+}
+
+/** \} */