Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / space_view3d / view3d_gizmo_preselect.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * ***** END GPL LICENSE BLOCK *****
19  */
20
21 /** \file blender/editors/space_view3d/view3d_gizmo_preselect.c
22  *  \ingroup spview3d
23  */
24
25 #include "MEM_guardedalloc.h"
26
27 #include "BLI_blenlib.h"
28 #include "BLI_math.h"
29 #include "BLI_utildefines.h"
30
31 #include "BKE_context.h"
32
33 #include "ED_gizmo_utils.h"
34 #include "ED_screen.h"
35
36 #include "UI_resources.h"
37
38 #include "WM_api.h"
39 #include "WM_types.h"
40 #include "WM_toolsystem.h"
41
42 #include "view3d_intern.h"  /* own include */
43
44 /* -------------------------------------------------------------------- */
45 /** \name Mesh Pre-Select Element Gizmo
46  *
47  * \{ */
48
49 struct GizmoGroupPreSelElem {
50         wmGizmo *gizmo;
51 };
52
53 static void WIDGETGROUP_mesh_preselect_elem_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
54 {
55         const wmGizmoType *gzt_presel = WM_gizmotype_find("GIZMO_GT_mesh_preselect_elem_3d", true);
56         struct GizmoGroupPreSelElem *ggd = MEM_callocN(sizeof(struct GizmoGroupPreSelElem), __func__);
57         gzgroup->customdata = ggd;
58
59         wmGizmo *gz = ggd->gizmo = WM_gizmo_new_ptr(gzt_presel, gzgroup, NULL);
60         UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
61         UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
62 }
63
64 void VIEW3D_GGT_mesh_preselect_elem(wmGizmoGroupType *gzgt)
65 {
66         gzgt->name = "Mesh Preselect Element";
67         gzgt->idname = "VIEW3D_GGT_mesh_preselect_elem";
68
69         gzgt->flag = WM_GIZMOGROUPTYPE_3D;
70
71         gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
72         gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
73
74         gzgt->poll = ED_gizmo_poll_or_unlink_delayed_from_tool;
75         gzgt->setup = WIDGETGROUP_mesh_preselect_elem_setup;
76 }
77
78 /** \} */
79
80 /* -------------------------------------------------------------------- */
81 /** \name Mesh Pre-Select Edge Ring Gizmo
82  *
83  * \{ */
84
85 struct GizmoGroupPreSelEdgeRing {
86         wmGizmo *gizmo;
87 };
88
89 static void WIDGETGROUP_mesh_preselect_edgering_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
90 {
91         const wmGizmoType *gzt_presel = WM_gizmotype_find("GIZMO_GT_mesh_preselect_edgering_3d", true);
92         struct GizmoGroupPreSelEdgeRing *ggd = MEM_callocN(sizeof(struct GizmoGroupPreSelEdgeRing), __func__);
93         gzgroup->customdata = ggd;
94
95         wmGizmo *gz = ggd->gizmo = WM_gizmo_new_ptr(gzt_presel, gzgroup, NULL);
96         UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
97         UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
98 }
99
100 void VIEW3D_GGT_mesh_preselect_edgering(wmGizmoGroupType *gzgt)
101 {
102         gzgt->name = "Mesh Preselect Edge Ring";
103         gzgt->idname = "VIEW3D_GGT_mesh_preselect_edgering";
104
105         gzgt->flag = WM_GIZMOGROUPTYPE_3D;
106
107         gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
108         gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
109
110         gzgt->poll = ED_gizmo_poll_or_unlink_delayed_from_tool;
111         gzgt->setup = WIDGETGROUP_mesh_preselect_edgering_setup;
112 }
113
114 /** \} */