2016-10-07 16:34:55 +02:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup wm
|
2016-10-07 16:34:55 +02:00
|
|
|
*/
|
|
|
|
|
|
2018-07-14 23:16:34 +02:00
|
|
|
#ifndef __WM_GIZMO_INTERN_H__
|
|
|
|
|
#define __WM_GIZMO_INTERN_H__
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2019-05-23 16:33:21 +10:00
|
|
|
struct BLI_Buffer;
|
2019-01-28 21:08:24 +11:00
|
|
|
struct wmGizmoMap;
|
|
|
|
|
struct wmKeyConfig;
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2018-07-14 23:16:34 +02:00
|
|
|
#include "wm_gizmo_fn.h"
|
2017-06-06 22:14:21 +10:00
|
|
|
|
2016-10-07 16:34:55 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
2018-07-14 23:49:00 +02:00
|
|
|
/* wmGizmo */
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
bool wm_gizmo_select_set_ex(
|
2019-04-17 06:17:24 +02:00
|
|
|
struct wmGizmoMap *gzmap, struct wmGizmo *gz, bool select, bool use_array, bool use_callback);
|
2018-07-15 14:24:10 +02:00
|
|
|
bool wm_gizmo_select_and_highlight(bContext *C, struct wmGizmoMap *gzmap, struct wmGizmo *gz);
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2018-07-15 14:24:10 +02:00
|
|
|
void wm_gizmo_calculate_scale(struct wmGizmo *gz, const bContext *C);
|
|
|
|
|
void wm_gizmo_update(struct wmGizmo *gz, const bContext *C, const bool refresh_map);
|
2017-06-23 09:18:53 +10:00
|
|
|
|
2018-07-15 14:24:10 +02:00
|
|
|
int wm_gizmo_is_visible(struct wmGizmo *gz);
|
2017-06-23 09:18:53 +10:00
|
|
|
enum {
|
2019-04-17 06:17:24 +02:00
|
|
|
WM_GIZMO_IS_VISIBLE_UPDATE = (1 << 0),
|
|
|
|
|
WM_GIZMO_IS_VISIBLE_DRAW = (1 << 1),
|
2017-06-23 09:18:53 +10:00
|
|
|
};
|
2016-10-07 16:34:55 +02:00
|
|
|
|
|
|
|
|
/* -------------------------------------------------------------------- */
|
2018-07-14 23:49:00 +02:00
|
|
|
/* wmGizmoGroup */
|
2016-10-07 16:34:55 +02:00
|
|
|
|
|
|
|
|
enum {
|
2019-04-17 06:17:24 +02:00
|
|
|
TWEAK_MODAL_CANCEL = 1,
|
|
|
|
|
TWEAK_MODAL_CONFIRM,
|
|
|
|
|
TWEAK_MODAL_PRECISION_ON,
|
|
|
|
|
TWEAK_MODAL_PRECISION_OFF,
|
|
|
|
|
TWEAK_MODAL_SNAP_ON,
|
|
|
|
|
TWEAK_MODAL_SNAP_OFF,
|
2016-10-07 16:34:55 +02:00
|
|
|
};
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
struct wmGizmoGroup *wm_gizmogroup_new_from_type(struct wmGizmoMap *gzmap,
|
|
|
|
|
struct wmGizmoGroupType *gzgt);
|
2018-07-15 14:24:10 +02:00
|
|
|
void wm_gizmogroup_free(bContext *C, struct wmGizmoGroup *gzgroup);
|
|
|
|
|
void wm_gizmogroup_gizmo_register(struct wmGizmoGroup *gzgroup, struct wmGizmo *gz);
|
2019-06-28 10:04:52 +10:00
|
|
|
struct wmGizmoGroup *wm_gizmogroup_find_by_type(const struct wmGizmoMap *gzmap,
|
|
|
|
|
const struct wmGizmoGroupType *gzgt);
|
2019-05-28 14:33:13 +10:00
|
|
|
struct wmGizmo *wm_gizmogroup_find_intersected_gizmo(wmWindowManager *wm,
|
|
|
|
|
const struct wmGizmoGroup *gzgroup,
|
2019-04-17 06:17:24 +02:00
|
|
|
struct bContext *C,
|
2019-05-28 14:33:13 +10:00
|
|
|
const int event_modifier,
|
2019-05-28 01:19:02 +10:00
|
|
|
const int mval[2],
|
2019-04-17 06:17:24 +02:00
|
|
|
int *r_part);
|
2019-05-28 14:33:13 +10:00
|
|
|
void wm_gizmogroup_intersectable_gizmos_to_list(wmWindowManager *wm,
|
|
|
|
|
const struct wmGizmoGroup *gzgroup,
|
|
|
|
|
const int event_modifier,
|
2019-05-23 16:33:21 +10:00
|
|
|
struct BLI_Buffer *visible_gizmos);
|
2019-04-17 06:17:24 +02:00
|
|
|
bool wm_gizmogroup_is_visible_in_drawstep(const struct wmGizmoGroup *gzgroup,
|
|
|
|
|
const eWM_GizmoFlagMapDrawStep drawstep);
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
void wm_gizmogrouptype_setup_keymap(struct wmGizmoGroupType *gzgt, struct wmKeyConfig *keyconf);
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2019-05-28 15:18:25 +10:00
|
|
|
wmKeyMap *wm_gizmogroup_tweak_modal_keymap(struct wmKeyConfig *keyconf);
|
|
|
|
|
|
2016-10-07 16:34:55 +02:00
|
|
|
/* -------------------------------------------------------------------- */
|
2018-07-14 23:49:00 +02:00
|
|
|
/* wmGizmoMap */
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
typedef struct wmGizmoMapSelectState {
|
2019-04-17 06:17:24 +02:00
|
|
|
struct wmGizmo **items;
|
|
|
|
|
int len, len_alloc;
|
2018-07-14 23:49:00 +02:00
|
|
|
} wmGizmoMapSelectState;
|
2017-07-26 08:12:46 +10:00
|
|
|
|
2018-07-14 23:49:00 +02:00
|
|
|
struct wmGizmoMap {
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
struct wmGizmoMapType *type;
|
|
|
|
|
ListBase groups; /* wmGizmoGroup */
|
|
|
|
|
|
|
|
|
|
/* private, update tagging (enum defined in C source). */
|
|
|
|
|
char update_flag[WM_GIZMOMAP_DRAWSTEP_MAX];
|
|
|
|
|
|
|
|
|
|
/** Private, true when not yet used. */
|
|
|
|
|
bool is_init;
|
|
|
|
|
|
2019-06-28 18:10:43 +10:00
|
|
|
/** When set, one of of the items in 'groups' has #wmGizmoGroup.tag_remove set. */
|
|
|
|
|
bool tag_remove_group;
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/**
|
|
|
|
|
* \brief Gizmo map runtime context
|
|
|
|
|
*
|
|
|
|
|
* Contains information about this gizmo-map. Currently
|
|
|
|
|
* highlighted gizmo, currently selected gizmos, ...
|
|
|
|
|
*/
|
|
|
|
|
struct {
|
|
|
|
|
/* we redraw the gizmo-map when this changes */
|
|
|
|
|
struct wmGizmo *highlight;
|
|
|
|
|
/* User has clicked this gizmo and it gets all input. */
|
|
|
|
|
struct wmGizmo *modal;
|
|
|
|
|
/* array for all selected gizmos */
|
|
|
|
|
struct wmGizmoMapSelectState select;
|
|
|
|
|
/* cursor location at point of entering modal (see: WM_GIZMO_MOVE_CURSOR) */
|
|
|
|
|
int event_xy[2];
|
|
|
|
|
short event_grabcursor;
|
|
|
|
|
/* until we have nice cursor push/pop API. */
|
|
|
|
|
int last_cursor;
|
|
|
|
|
} gzmap_context;
|
2017-02-25 15:23:27 +01:00
|
|
|
};
|
2016-10-07 16:34:55 +02:00
|
|
|
|
|
|
|
|
/**
|
2018-07-14 23:49:00 +02:00
|
|
|
* This is a container for all gizmo types that can be instantiated in a region.
|
2016-10-07 16:34:55 +02:00
|
|
|
* (similar to dropboxes).
|
|
|
|
|
*
|
|
|
|
|
* \note There is only ever one of these for every (area, region) combination.
|
|
|
|
|
*/
|
2018-07-14 23:49:00 +02:00
|
|
|
struct wmGizmoMapType {
|
2019-04-17 06:17:24 +02:00
|
|
|
struct wmGizmoMapType *next, *prev;
|
|
|
|
|
short spaceid, regionid;
|
|
|
|
|
/* types of gizmo-groups for this gizmo-map type */
|
|
|
|
|
ListBase grouptype_refs;
|
2017-06-15 20:48:24 +10:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* eGizmoMapTypeUpdateFlags */
|
|
|
|
|
eWM_GizmoFlagMapTypeUpdateFlag type_update_flag;
|
2017-02-25 15:23:27 +01:00
|
|
|
};
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2018-07-15 14:24:10 +02:00
|
|
|
void wm_gizmomap_select_array_clear(struct wmGizmoMap *gzmap);
|
|
|
|
|
bool wm_gizmomap_deselect_all(struct wmGizmoMap *gzmap);
|
|
|
|
|
void wm_gizmomap_select_array_shrink(struct wmGizmoMap *gzmap, int len_subtract);
|
|
|
|
|
void wm_gizmomap_select_array_push_back(struct wmGizmoMap *gzmap, wmGizmo *gz);
|
|
|
|
|
void wm_gizmomap_select_array_remove(struct wmGizmoMap *gzmap, wmGizmo *gz);
|
2016-10-07 16:34:55 +02:00
|
|
|
|
2017-08-25 15:13:11 +10:00
|
|
|
#endif
|