Cleanup: rename active to modal

This matches operators naming and should avoid confusion in future if we
want to use active as term for last-selected.
This commit is contained in:
Campbell Barton 2017-07-25 22:22:12 +10:00
parent 762fa7bee3
commit f848374e49
14 changed files with 62 additions and 64 deletions

View File

@ -121,7 +121,7 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator *m
static void manipulator_arrow2d_setup(wmManipulator *mpr)
{
mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE;
mpr->flag |= WM_MANIPULATOR_DRAW_MODAL;
}
static void manipulator_arrow2d_invoke(

View File

@ -356,7 +356,7 @@ static void manipulator_arrow_setup(wmManipulator *mpr)
{
ArrowManipulator3D *arrow = (ArrowManipulator3D *)mpr;
arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_ACTIVE;
arrow->manipulator.flag |= WM_MANIPULATOR_DRAW_MODAL;
arrow->data.range_fac = 1.0f;
}

View File

@ -413,7 +413,7 @@ static bool manipulator_rect_transform_get_prop_value(
static void manipulator_rect_transform_setup(wmManipulator *mpr)
{
mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE;
mpr->flag |= WM_MANIPULATOR_DRAW_MODAL;
}
static void manipulator_rect_transform_invoke(

View File

@ -286,7 +286,7 @@ static void dial_draw_intern(
/* draw rotation indicator arc first */
if ((mpr->flag & WM_MANIPULATOR_DRAW_VALUE) &&
(mpr->state & WM_MANIPULATOR_STATE_ACTIVE))
(mpr->state & WM_MANIPULATOR_STATE_MODAL))
{
const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */
@ -351,11 +351,11 @@ static void manipulator_dial_draw_select(const bContext *C, wmManipulator *mpr,
static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
{
const bool active = mpr->state & WM_MANIPULATOR_STATE_ACTIVE;
const bool highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL;
const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
float clip_plane_buf[4];
const int draw_options = RNA_enum_get(mpr->ptr, "draw_options");
float *clip_plane = (!active && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL;
float *clip_plane = (!is_modal && (draw_options & ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL;
/* enable clipping if needed */
if (clip_plane) {
@ -370,7 +370,7 @@ static void manipulator_dial_draw(const bContext *C, wmManipulator *mpr)
}
glEnable(GL_BLEND);
dial_draw_intern(C, mpr, false, highlight, clip_plane);
dial_draw_intern(C, mpr, false, is_highlight, clip_plane);
glDisable(GL_BLEND);
if (clip_plane) {

View File

@ -176,13 +176,13 @@ static void manipulator_grab_draw_select(const bContext *C, wmManipulator *mpr,
static void manipulator_grab_draw(const bContext *C, wmManipulator *mpr)
{
const bool active = mpr->state & WM_MANIPULATOR_STATE_ACTIVE;
const bool highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
const bool is_modal = mpr->state & WM_MANIPULATOR_STATE_MODAL;
const bool is_highlight = (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) != 0;
(void)active;
(void)is_modal;
glEnable(GL_BLEND);
grab3d_draw_intern(C, mpr, false, highlight);
grab3d_draw_intern(C, mpr, false, is_highlight);
glDisable(GL_BLEND);
}

View File

@ -148,7 +148,7 @@ static void manipulator_primitive_draw(const bContext *UNUSED(C), wmManipulator
static void manipulator_primitive_setup(wmManipulator *mpr)
{
mpr->flag |= WM_MANIPULATOR_DRAW_ACTIVE;
mpr->flag |= WM_MANIPULATOR_DRAW_MODAL;
}
static void manipulator_primitive_invoke(

View File

@ -366,13 +366,13 @@ RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(scale_basis, scale_basis);
RNA_MANIPULATOR_GENERIC_FLOAT_RW_DEF(line_width, line_width);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_hover, flag, WM_MANIPULATOR_DRAW_HOVER);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_active, flag, WM_MANIPULATOR_DRAW_ACTIVE);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_modal, flag, WM_MANIPULATOR_DRAW_MODAL);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_use_draw_value, flag, WM_MANIPULATOR_DRAW_VALUE);
RNA_MANIPULATOR_GENERIC_FLAG_RW_DEF(flag_hide, flag, WM_MANIPULATOR_HIDDEN);
/* wmManipulator.state */
RNA_MANIPULATOR_FLAG_RO_DEF(state_is_highlight, state, WM_MANIPULATOR_STATE_HIGHLIGHT);
RNA_MANIPULATOR_FLAG_RO_DEF(state_is_active, state, WM_MANIPULATOR_STATE_ACTIVE);
RNA_MANIPULATOR_FLAG_RO_DEF(state_is_modal, state, WM_MANIPULATOR_STATE_MODAL);
RNA_MANIPULATOR_FLAG_RO_DEF(state_select, state, WM_MANIPULATOR_STATE_SELECT);
static void rna_Manipulator_name_get(PointerRNA *ptr, char *value)
@ -1067,10 +1067,10 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
prop, "rna_Manipulator_flag_use_draw_hover_get", "rna_Manipulator_flag_use_draw_hover_set");
RNA_def_property_ui_text(prop, "Draw Hover", "");
RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
/* WM_MANIPULATOR_DRAW_ACTIVE */
prop = RNA_def_property(srna, "use_draw_active", PROP_BOOLEAN, PROP_NONE);
/* WM_MANIPULATOR_DRAW_MODAL */
prop = RNA_def_property(srna, "use_draw_modal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(
prop, "rna_Manipulator_flag_use_draw_active_get", "rna_Manipulator_flag_use_draw_active_set");
prop, "rna_Manipulator_flag_use_draw_modal_get", "rna_Manipulator_flag_use_draw_modal_set");
RNA_def_property_ui_text(prop, "Draw Active", "Draw while dragging");
RNA_def_property_update(prop, NC_SCREEN | NA_EDITED, NULL);
/* WM_MANIPULATOR_DRAW_VALUE */
@ -1086,9 +1086,9 @@ static void rna_def_manipulator(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_highlight_get", NULL);
RNA_def_property_ui_text(prop, "Highlight", "");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
/* WM_MANIPULATOR_STATE_ACTIVE */
prop = RNA_def_property(srna, "is_active", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_active_get", NULL);
/* WM_MANIPULATOR_STATE_MODAL */
prop = RNA_def_property(srna, "is_modal", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_Manipulator_state_is_modal_get", NULL);
RNA_def_property_ui_text(prop, "Highlight", "");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
/* WM_MANIPULATOR_STATE_SELECT */
@ -1170,7 +1170,7 @@ static void rna_def_manipulatorgroup(BlenderRNA *brna)
"Supports selection"},
{WM_MANIPULATORGROUPTYPE_PERSISTENT, "PERSISTENT", 0, "Persistent",
""},
{WM_MANIPULATORGROUPTYPE_ACTIVE_ALL, "ACTIVE_ALL", 0, "Active All",
{WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL, "SHOW_MODAL_ALL", 0, "Show Modal All",
"Show all while interacting"},
{0, NULL, 0, NULL, NULL}
};

View File

@ -2196,7 +2196,7 @@ static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers
wm_region_mouse_co(C, event);
/* handle manipulator highlighting */
if (event->type == MOUSEMOVE && !wm_manipulatormap_active_get(mmap)) {
if (event->type == MOUSEMOVE && !wm_manipulatormap_modal_get(mmap)) {
int part;
mpr = wm_manipulatormap_highlight_find(mmap, C, event, &part);
wm_manipulatormap_highlight_set(mmap, C, mpr, part);

View File

@ -170,7 +170,7 @@ struct wmManipulatorMapType_Params {
* Flags for individual manipulators. */
enum {
WM_MANIPULATOR_DRAW_HOVER = (1 << 0), /* draw *only* while hovering */
WM_MANIPULATOR_DRAW_ACTIVE = (1 << 1), /* draw while dragging */
WM_MANIPULATOR_DRAW_MODAL = (1 << 1), /* draw while dragging */
WM_MANIPULATOR_DRAW_VALUE = (1 << 2), /* draw an indicator for the current value while dragging */
WM_MANIPULATOR_HIDDEN = (1 << 3),
};
@ -178,7 +178,7 @@ enum {
/* wmManipulator.state */
enum {
WM_MANIPULATOR_STATE_HIGHLIGHT = (1 << 0), /* while hovered */
WM_MANIPULATOR_STATE_ACTIVE = (1 << 1), /* while dragging */
WM_MANIPULATOR_STATE_MODAL = (1 << 1), /* while dragging */
WM_MANIPULATOR_STATE_SELECT = (1 << 2),
};
@ -350,7 +350,7 @@ enum {
/* The manipulator group is to be kept (not removed on loading a new file for eg). */
WM_MANIPULATORGROUPTYPE_PERSISTENT = (1 << 4),
/* Show all other manipulators when interacting. */
WM_MANIPULATORGROUPTYPE_ACTIVE_ALL = (1 << 5),
WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL = (1 << 5),
};

View File

@ -197,8 +197,8 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
if (mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT) {
wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
}
if (mpr->state & WM_MANIPULATOR_STATE_ACTIVE) {
wm_manipulatormap_active_set(mmap, C, NULL, NULL);
if (mpr->state & WM_MANIPULATOR_STATE_MODAL) {
wm_manipulatormap_modal_set(mmap, C, NULL, NULL);
}
if (mpr->state & WM_MANIPULATOR_STATE_SELECT) {
wm_manipulator_deselect(mmap, mpr);
@ -228,7 +228,7 @@ void WM_manipulator_free(ListBase *manipulatorlist, wmManipulatorMap *mmap, wmMa
}
BLI_assert(mmap->mmap_context.highlight != mpr);
BLI_assert(mmap->mmap_context.active != mpr);
BLI_assert(mmap->mmap_context.modal != mpr);
MEM_freeN(mpr);
}
@ -509,10 +509,10 @@ int wm_manipulator_is_visible(wmManipulator *mpr)
if (mpr->flag & WM_MANIPULATOR_HIDDEN) {
return 0;
}
if ((mpr->state & WM_MANIPULATOR_STATE_ACTIVE) &&
!(mpr->flag & (WM_MANIPULATOR_DRAW_ACTIVE | WM_MANIPULATOR_DRAW_VALUE)))
if ((mpr->state & WM_MANIPULATOR_STATE_MODAL) &&
!(mpr->flag & (WM_MANIPULATOR_DRAW_MODAL | WM_MANIPULATOR_DRAW_VALUE)))
{
/* don't draw while active (while dragging) */
/* don't draw while modal (dragging) */
return 0;
}
if ((mpr->flag & WM_MANIPULATOR_DRAW_HOVER) &&

View File

@ -288,7 +288,7 @@ void MANIPULATORGROUP_OT_manipulator_select(wmOperatorType *ot)
typedef struct ManipulatorTweakData {
wmManipulatorMap *mmap;
wmManipulator *active;
wmManipulator *mpr_modal;
int init_event; /* initial event type */
int flag; /* tweak flags */
@ -297,17 +297,17 @@ typedef struct ManipulatorTweakData {
static void manipulator_tweak_finish(bContext *C, wmOperator *op, const bool cancel)
{
ManipulatorTweakData *mtweak = op->customdata;
if (mtweak->active->type->exit) {
mtweak->active->type->exit(C, mtweak->active, cancel);
if (mtweak->mpr_modal->type->exit) {
mtweak->mpr_modal->type->exit(C, mtweak->mpr_modal, cancel);
}
wm_manipulatormap_active_set(mtweak->mmap, C, NULL, NULL);
wm_manipulatormap_modal_set(mtweak->mmap, C, NULL, NULL);
MEM_freeN(mtweak);
}
static int manipulator_tweak_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
ManipulatorTweakData *mtweak = op->customdata;
wmManipulator *mpr = mtweak->active;
wmManipulator *mpr = mtweak->mpr_modal;
if (mpr == NULL) {
BLI_assert(0);
@ -375,7 +375,7 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *
/* activate highlighted manipulator */
wm_manipulatormap_active_set(mmap, C, event, mpr);
wm_manipulatormap_modal_set(mmap, C, event, mpr);
/* XXX temporary workaround for modal manipulator operator
* conflicting with modal operator attached to manipulator */
@ -389,7 +389,7 @@ static int manipulator_tweak_invoke(bContext *C, wmOperator *op, const wmEvent *
ManipulatorTweakData *mtweak = MEM_mallocN(sizeof(ManipulatorTweakData), __func__);
mtweak->init_event = WM_userdef_event_type_from_keymap_type(event->type);
mtweak->active = mmap->mmap_context.highlight;
mtweak->mpr_modal = mmap->mmap_context.highlight;
mtweak->mmap = mmap;
mtweak->flag = 0;

View File

@ -99,8 +99,8 @@ struct wmManipulatorMap {
struct {
/* we redraw the manipulator-map when this changes */
struct wmManipulator *highlight;
/* user has clicked this manipulator and it gets all input */
struct wmManipulator *active;
/* User has clicked this manipulator and it gets all input. */
struct wmManipulator *modal;
/* array for all selected manipulators
* TODO check on using BLI_array */
struct wmManipulator **selected;

View File

@ -236,12 +236,12 @@ static void manipulatormap_prepare_drawing(
{
if (!mmap || BLI_listbase_is_empty(&mmap->groups))
return;
wmManipulator *active_manipulator = mmap->mmap_context.active;
wmManipulator *mpr_modal = mmap->mmap_context.modal;
/* only active manipulator needs updating */
if (active_manipulator) {
if ((active_manipulator->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_ACTIVE_ALL) == 0) {
if (manipulator_prepare_drawing(mmap, active_manipulator, C, draw_manipulators)) {
if (mpr_modal) {
if ((mpr_modal->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_DRAW_MODAL_ALL) == 0) {
if (manipulator_prepare_drawing(mmap, mpr_modal, C, draw_manipulators)) {
manipulatormap_tag_updated(mmap);
}
/* don't draw any other manipulators */
@ -348,7 +348,7 @@ void WM_manipulatormap_draw(wmManipulatorMap *mmap, const bContext *C, const int
BLI_assert(BLI_listbase_is_empty(&draw_manipulators));
}
static void manipulator_find_active_3D_loop(const bContext *C, ListBase *visible_manipulators)
static void manipulator_draw_select_3D_loop(const bContext *C, ListBase *visible_manipulators)
{
int selectionbase = 0;
wmManipulator *mpr;
@ -410,13 +410,13 @@ static int manipulator_find_intersected_3d_intern(
else
GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_ALL, 0);
/* do the drawing */
manipulator_find_active_3D_loop(C, visible_manipulators);
manipulator_draw_select_3D_loop(C, visible_manipulators);
hits = GPU_select_end();
if (do_passes && (hits > 0)) {
GPU_select_begin(buffer, ARRAY_SIZE(buffer), &rect, GPU_SELECT_NEAREST_SECOND_PASS, hits);
manipulator_find_active_3D_loop(C, visible_manipulators);
manipulator_draw_select_3D_loop(C, visible_manipulators);
GPU_select_end();
}
@ -510,7 +510,7 @@ void wm_manipulatormaps_handled_modal_update(
}
wmManipulatorMap *mmap = handler->op_region->manipulator_map;
wmManipulator *mpr = wm_manipulatormap_active_get(mmap);
wmManipulator *mpr = wm_manipulatormap_modal_get(mmap);
ScrArea *area = CTX_wm_area(C);
ARegion *region = CTX_wm_region(C);
@ -532,7 +532,7 @@ void wm_manipulatormaps_handled_modal_update(
/* operator not running anymore */
else {
wm_manipulatormap_highlight_set(mmap, C, NULL, 0);
wm_manipulatormap_active_set(mmap, C, event, NULL);
wm_manipulatormap_modal_set(mmap, C, event, NULL);
}
/* restore the area */
@ -727,12 +727,12 @@ wmManipulator *wm_manipulatormap_highlight_get(wmManipulatorMap *mmap)
return mmap->mmap_context.highlight;
}
void wm_manipulatormap_active_set(
void wm_manipulatormap_modal_set(
wmManipulatorMap *mmap, bContext *C, const wmEvent *event, wmManipulator *mpr)
{
if (mpr && C) {
mpr->state |= WM_MANIPULATOR_STATE_ACTIVE;
mmap->mmap_context.active = mpr;
mpr->state |= WM_MANIPULATOR_STATE_MODAL;
mmap->mmap_context.modal = mpr;
if (mpr->op_data.type) {
/* first activate the manipulator itself */
@ -745,9 +745,8 @@ void wm_manipulatormap_active_set(
WM_operator_name_call_ptr(C, mpr->op_data.type, WM_OP_INVOKE_DEFAULT, &mpr->op_data.ptr);
/* we failed to hook the manipulator to the operator handler or operator was cancelled, return */
if (!mmap->mmap_context.active) {
mpr->state &= ~WM_MANIPULATOR_STATE_ACTIVE;
/* first activate the manipulator itself */
if (!mmap->mmap_context.modal) {
mpr->state &= ~WM_MANIPULATOR_STATE_MODAL;
MEM_SAFE_FREE(mpr->interaction_data);
}
return;
@ -762,15 +761,14 @@ void wm_manipulatormap_active_set(
WM_cursor_grab_enable(CTX_wm_window(C), true, true, NULL);
}
else {
mpr = mmap->mmap_context.active;
mpr = mmap->mmap_context.modal;
/* deactivate, manipulator but first take care of some stuff */
if (mpr) {
mpr->state &= ~WM_MANIPULATOR_STATE_ACTIVE;
/* first activate the manipulator itself */
mpr->state &= ~WM_MANIPULATOR_STATE_MODAL;
MEM_SAFE_FREE(mpr->interaction_data);
}
mmap->mmap_context.active = NULL;
mmap->mmap_context.modal = NULL;
if (C) {
WM_cursor_grab_disable(CTX_wm_window(C), NULL);
@ -780,9 +778,9 @@ void wm_manipulatormap_active_set(
}
}
wmManipulator *wm_manipulatormap_active_get(wmManipulatorMap *mmap)
wmManipulator *wm_manipulatormap_modal_get(wmManipulatorMap *mmap)
{
return mmap->mmap_context.active;
return mmap->mmap_context.modal;
}
wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len)

View File

@ -81,10 +81,10 @@ void wm_manipulatormap_highlight_set(
struct wmManipulatorMap *mmap, const bContext *C,
struct wmManipulator *mpr, int part);
struct wmManipulator *wm_manipulatormap_highlight_get(struct wmManipulatorMap *mmap);
void wm_manipulatormap_active_set(
void wm_manipulatormap_modal_set(
struct wmManipulatorMap *mmap, bContext *C,
const struct wmEvent *event, struct wmManipulator *mpr);
struct wmManipulator *wm_manipulatormap_active_get(struct wmManipulatorMap *mmap);
struct wmManipulator *wm_manipulatormap_modal_get(struct wmManipulatorMap *mmap);
struct wmManipulator **wm_manipulatormap_selected_get(wmManipulatorMap *mmap, int *r_selected_len);
struct ListBase *wm_manipulatormap_groups_get(wmManipulatorMap *mmap);