Cleanup: remove ED_types.h & ACTIVE, DESELECT definitions

- ACTIVE flag is no longer in use.

- DESELECT was used in some places as an alias for false,
  even though this could arguably help readability, in practice this
  was often passed with a selection flag leading to confusing calls
  such as `select_beztriple(bezt, DESELECT, SELECT, HIDDEN)`.
  Replace SELECT/DESELECT with true/false in these cases.

- Remove ED_types.h. Add a 'SELECT' definition to DNA_anim_types.h,
  for fcurve_test, we could use a shared DNA header, or remove use of
  the define entirely in favor of typed enums.
This commit is contained in:
Campbell Barton 2022-09-08 12:04:36 +10:00
parent c2c369ebe6
commit 17bc292530
11 changed files with 71 additions and 94 deletions

View File

@ -7,7 +7,6 @@
#include "BKE_fcurve.h"
#include "ED_keyframing.h"
#include "ED_types.h" /* For SELECT. */
#include "DNA_anim_types.h"

View File

@ -51,7 +51,6 @@
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "ED_types.h"
#include "ED_util.h"
#include "DEG_depsgraph.h"

View File

@ -47,7 +47,6 @@
#include "ED_select_utils.h"
#include "ED_transform.h"
#include "ED_transform_snap_object_context.h"
#include "ED_types.h"
#include "ED_view3d.h"
#include "curve_intern.h"
@ -2088,7 +2087,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag)
const int copy_from = intvls_u[i - 1];
const int copy_to = intvls_u[i];
const int copy_count = copy_to - copy_from + 1;
const bool sel_status = selected_u || selected_v ? SELECT : DESELECT;
const bool sel_status = selected_u || selected_v ? true : false;
ED_curve_bpcpy(editnurb, new_bp_u_v, old_bp_v + copy_from, copy_count);
select_bpoints(new_bp_u_v, 1, copy_count, sel_status, flag, HIDDEN);
new_bp_u_v += copy_count;
@ -2154,7 +2153,7 @@ static void adduplicateflagNurb(
starta = a;
while ((bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag)) {
if (!split) {
select_beztriple(bezt, DESELECT, flag, HIDDEN);
select_beztriple(bezt, false, flag, HIDDEN);
}
enda = a;
if (a >= nu->pntsu - 1) {
@ -2194,7 +2193,7 @@ static void adduplicateflagNurb(
}
for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, SELECT, flag, HIDDEN);
select_beztriple(bezt1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2212,7 +2211,7 @@ static void adduplicateflagNurb(
newnu->flagu &= ~CU_NURB_CYCLIC;
for (b = 0, bezt1 = newnu->bezt; b < newnu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, SELECT, flag, HIDDEN);
select_beztriple(bezt1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2224,7 +2223,7 @@ static void adduplicateflagNurb(
starta = a;
while (bp->f1 & flag) {
if (!split) {
select_bpoint(bp, DESELECT, flag, HIDDEN);
select_bpoint(bp, false, flag, HIDDEN);
}
enda = a;
if (a >= nu->pntsu - 1) {
@ -2264,7 +2263,7 @@ static void adduplicateflagNurb(
}
for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
select_bpoint(bp1, SELECT, flag, HIDDEN);
select_bpoint(bp1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2282,7 +2281,7 @@ static void adduplicateflagNurb(
newnu->flagu &= ~CU_NURB_CYCLIC;
for (b = 0, bp1 = newnu->bp; b < newnu->pntsu; b++, bp1++) {
select_bpoint(bp1, SELECT, flag, HIDDEN);
select_bpoint(bp1, true, flag, HIDDEN);
}
BLI_addtail(newnurb, newnu);
@ -2502,7 +2501,7 @@ static void adduplicateflagNurb(
for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
bp1->f1 &= ~SURF_SEEN;
if (!split) {
select_bpoint(bp1, DESELECT, flag, HIDDEN);
select_bpoint(bp1, false, flag, HIDDEN);
}
}
}
@ -3237,11 +3236,11 @@ static int hide_exec(bContext *C, wmOperator *op)
sel = 0;
while (a--) {
if (invert == 0 && BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
bezt->hide = 1;
}
else if (invert && !BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt)) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
bezt->hide = 1;
}
if (bezt->hide) {
@ -3259,11 +3258,11 @@ static int hide_exec(bContext *C, wmOperator *op)
sel = 0;
while (a--) {
if (invert == 0 && (bp->f1 & SELECT)) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
bp->hide = 1;
}
else if (invert && (bp->f1 & SELECT) == 0) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
bp->hide = 1;
}
if (bp->hide) {
@ -4353,7 +4352,7 @@ static bool merge_2_nurb(Curve *cu, ListBase *editnurb, Nurb *nu1, Nurb *nu2)
keyIndex_updateBP(cu->editnurb, bp1, bp, 1);
*bp = *bp1;
bp1++;
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
}
else {
keyIndex_updateBP(cu->editnurb, bp2, bp, 1);
@ -4808,7 +4807,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 |= SELECT;
}
else {
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
select_beztriple(bezt, true, SELECT, HIDDEN);
}
}
else {
@ -4822,7 +4821,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
else {
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
BKE_curve_nurb_vert_active_set(cu, nu, bp);
}
break;
@ -4834,7 +4833,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 &= ~SELECT;
}
else {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
}
if (bezt == vert) {
cu->actvert = CU_ACT_NONE;
@ -4848,7 +4847,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
}
}
else {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
if (bp == vert) {
cu->actvert = CU_ACT_NONE;
}
@ -4863,7 +4862,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 &= ~SELECT;
}
else {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
}
if (bezt == vert) {
cu->actvert = CU_ACT_NONE;
@ -4874,7 +4873,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 |= SELECT;
}
else {
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
select_beztriple(bezt, true, SELECT, HIDDEN);
}
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
@ -4888,13 +4887,13 @@ bool ED_curve_editnurb_select_pick(bContext *C,
}
else {
if (bp->f1 & SELECT) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
if (bp == vert) {
cu->actvert = CU_ACT_NONE;
}
}
else {
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
BKE_curve_nurb_vert_active_set(cu, nu, bp);
}
}
@ -4910,7 +4909,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
bezt->f2 |= SELECT;
}
else {
select_beztriple(bezt, SELECT, SELECT, HIDDEN);
select_beztriple(bezt, true, SELECT, HIDDEN);
}
}
else {
@ -4924,7 +4923,7 @@ bool ED_curve_editnurb_select_pick(bContext *C,
BKE_curve_nurb_vert_active_set(cu, nu, bezt);
}
else {
select_bpoint(bp, SELECT, SELECT, HIDDEN);
select_bpoint(bp, true, SELECT, HIDDEN);
BKE_curve_nurb_vert_active_set(cu, nu, bp);
}
break;
@ -6407,7 +6406,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
if (split) {
/* deselect for split operator */
for (b = 0, bezt1 = nu->bezt; b < nu->pntsu; b++, bezt1++) {
select_beztriple(bezt1, DESELECT, SELECT, true);
select_beztriple(bezt1, false, SELECT, true);
}
}
@ -6417,7 +6416,7 @@ static bool curve_delete_segments(Object *obedit, View3D *v3d, const bool split)
if (split) {
/* deselect for split operator */
for (b = 0, bp1 = nu->bp; b < nu->pntsu * nu->pntsv; b++, bp1++) {
select_bpoint(bp1, DESELECT, SELECT, HIDDEN);
select_bpoint(bp1, false, SELECT, HIDDEN);
}
}

View File

@ -30,7 +30,6 @@
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
#include "ED_types.h"
#include "ED_view3d.h"
#include "curve_intern.h"
@ -47,7 +46,7 @@
bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Types hidden)
{
if ((bezt->hide == 0) || (hidden == HIDDEN)) {
if (selstatus == SELECT) { /* selects */
if (selstatus) { /* selects */
bezt->f1 |= flag;
bezt->f2 |= flag;
bezt->f3 |= flag;
@ -66,7 +65,7 @@ bool select_beztriple(BezTriple *bezt, bool selstatus, uint8_t flag, eVisible_Ty
bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden)
{
if ((bp->hide == 0) || (hidden == 1)) {
if (selstatus == SELECT) {
if (selstatus) {
bp->f1 |= flag;
return true;
}
@ -80,17 +79,17 @@ bool select_bpoint(BPoint *bp, bool selstatus, uint8_t flag, bool hidden)
static bool swap_selection_beztriple(BezTriple *bezt)
{
if (bezt->f2 & SELECT) {
return select_beztriple(bezt, DESELECT, SELECT, VISIBLE);
return select_beztriple(bezt, false, SELECT, VISIBLE);
}
return select_beztriple(bezt, SELECT, SELECT, VISIBLE);
return select_beztriple(bezt, true, SELECT, VISIBLE);
}
static bool swap_selection_bpoint(BPoint *bp)
{
if (bp->f1 & SELECT) {
return select_bpoint(bp, DESELECT, SELECT, VISIBLE);
return select_bpoint(bp, false, SELECT, VISIBLE);
}
return select_bpoint(bp, SELECT, SELECT, VISIBLE);
return select_bpoint(bp, true, SELECT, VISIBLE);
}
bool ED_curve_nurb_select_check(const View3D *v3d, const Nurb *nu)
@ -336,9 +335,9 @@ static void select_adjacent_cp(ListBase *editnurb,
break;
}
if ((lastsel == false) && (bezt->hide == 0) &&
((bezt->f2 & SELECT) || (selstatus == DESELECT))) {
((bezt->f2 & SELECT) || (selstatus == false))) {
bezt += next;
if (!(bezt->f2 & SELECT) || (selstatus == DESELECT)) {
if (!(bezt->f2 & SELECT) || (selstatus == false)) {
bool sel = select_beztriple(bezt, selstatus, SELECT, VISIBLE);
if (sel && !cont) {
lastsel = true;
@ -363,10 +362,9 @@ static void select_adjacent_cp(ListBase *editnurb,
if (a - abs(next) < 0) {
break;
}
if ((lastsel == false) && (bp->hide == 0) &&
((bp->f1 & SELECT) || (selstatus == DESELECT))) {
if ((lastsel == false) && (bp->hide == 0) && ((bp->f1 & SELECT) || (selstatus == false))) {
bp += next;
if (!(bp->f1 & SELECT) || (selstatus == DESELECT)) {
if (!(bp->f1 & SELECT) || (selstatus == false)) {
bool sel = select_bpoint(bp, selstatus, SELECT, VISIBLE);
if (sel && !cont) {
lastsel = true;
@ -477,7 +475,7 @@ static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, FIRST, true, DESELECT);
selectend_nurb(obedit, FIRST, true, false);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
@ -510,7 +508,7 @@ static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op))
for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
Object *obedit = objects[ob_index];
selectend_nurb(obedit, LAST, true, DESELECT);
selectend_nurb(obedit, LAST, true, false);
DEG_id_tag_update(obedit->data, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
BKE_curve_nurb_vert_active_validate(obedit->data);
@ -780,12 +778,12 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op))
for (b = 0; b < nu->pntsu; b++, bp++) {
if (direction) {
if (a == v) {
select_bpoint(bp, SELECT, SELECT, VISIBLE);
select_bpoint(bp, true, SELECT, VISIBLE);
}
}
else {
if (b == u) {
select_bpoint(bp, SELECT, SELECT, VISIBLE);
select_bpoint(bp, true, SELECT, VISIBLE);
}
}
}
@ -923,7 +921,7 @@ static void curve_select_more(Object *obedit)
if (a % nu->pntsu != 0) {
tempbp = bp - 1;
if (!(tempbp->f1 & SELECT)) {
select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
select_bpoint(tempbp, true, SELECT, VISIBLE);
}
}
@ -932,7 +930,7 @@ static void curve_select_more(Object *obedit)
sel = 0;
tempbp = bp + nu->pntsu;
if (!(tempbp->f1 & SELECT)) {
sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
sel = select_bpoint(tempbp, true, SELECT, VISIBLE);
}
/* make sure selected bpoint is discarded */
if (sel == 1) {
@ -944,7 +942,7 @@ static void curve_select_more(Object *obedit)
if (a + nu->pntsu < nu->pntsu * nu->pntsv) {
tempbp = bp - nu->pntsu;
if (!(tempbp->f1 & SELECT)) {
select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
select_bpoint(tempbp, true, SELECT, VISIBLE);
}
}
@ -953,7 +951,7 @@ static void curve_select_more(Object *obedit)
sel = 0;
tempbp = bp + 1;
if (!(tempbp->f1 & SELECT)) {
sel = select_bpoint(tempbp, SELECT, SELECT, VISIBLE);
sel = select_bpoint(tempbp, true, SELECT, VISIBLE);
}
if (sel) {
bp++;
@ -1080,7 +1078,7 @@ static void curve_select_less(Object *obedit)
}
if (sel != 4) {
select_bpoint(bp, DESELECT, SELECT, VISIBLE);
select_bpoint(bp, false, SELECT, VISIBLE);
BLI_BITMAP_ENABLE(selbpoints, a);
}
}
@ -1130,7 +1128,7 @@ static void curve_select_less(Object *obedit)
}
if (sel != 2) {
select_beztriple(bezt, DESELECT, SELECT, VISIBLE);
select_beztriple(bezt, false, SELECT, VISIBLE);
lastsel = true;
}
else {
@ -1175,7 +1173,7 @@ static void curve_select_less(Object *obedit)
}
if (sel != 2) {
select_bpoint(bp, DESELECT, SELECT, VISIBLE);
select_bpoint(bp, false, SELECT, VISIBLE);
lastsel = true;
}
else {
@ -1359,7 +1357,7 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, const struct CheckerInter
while (a--) {
const int depth = abs(start - a);
if (!WM_operator_properties_checker_interval_test(params, depth)) {
select_beztriple(bezt, DESELECT, SELECT, HIDDEN);
select_beztriple(bezt, false, SELECT, HIDDEN);
}
bezt--;
@ -1382,7 +1380,7 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, const struct CheckerIntervalPara
while (a--) {
const int depth = abs(pnt - startpnt) + abs(row - startrow);
if (!WM_operator_properties_checker_interval_test(params, depth)) {
select_bpoint(bp, DESELECT, SELECT, HIDDEN);
select_bpoint(bp, false, SELECT, HIDDEN);
}
pnt--;
@ -1645,7 +1643,7 @@ static bool curve_nurb_select_similar_type(Object *ob,
}
if (select) {
select_beztriple(bezt, SELECT, SELECT, VISIBLE);
select_beztriple(bezt, true, SELECT, VISIBLE);
changed = true;
}
}
@ -1690,7 +1688,7 @@ static bool curve_nurb_select_similar_type(Object *ob,
}
if (select) {
select_bpoint(bp, SELECT, SELECT, VISIBLE);
select_bpoint(bp, true, SELECT, VISIBLE);
changed = true;
}
}
@ -1898,10 +1896,10 @@ static void curve_select_shortest_path_curve(Nurb *nu, int vert_src, int vert_ds
i = vert_src;
while (true) {
if (nu->type & CU_BEZIER) {
select_beztriple(&nu->bezt[i], SELECT, SELECT, HIDDEN);
select_beztriple(&nu->bezt[i], true, SELECT, HIDDEN);
}
else {
select_bpoint(&nu->bp[i], SELECT, SELECT, HIDDEN);
select_bpoint(&nu->bp[i], true, SELECT, HIDDEN);
}
if (i == vert_dst) {
@ -1979,10 +1977,10 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst
int i = 0;
while (vert_curr != vert_src && i++ < vert_num) {
if (nu->type == CU_BEZIER) {
select_beztriple(&nu->bezt[vert_curr], SELECT, SELECT, HIDDEN);
select_beztriple(&nu->bezt[vert_curr], true, SELECT, HIDDEN);
}
else {
select_bpoint(&nu->bp[vert_curr], SELECT, SELECT, HIDDEN);
select_bpoint(&nu->bp[vert_curr], true, SELECT, HIDDEN);
}
vert_curr = data[vert_curr].vert_prev;
}

View File

@ -1,27 +0,0 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2008 Blender Foundation. All rights reserved. */
/** \file
* \ingroup editors
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
/* **************** GENERAL EDITOR-WIDE TYPES AND DEFINES ************************** */
/* old blender defines... should be deprecated? */
#define DESELECT 0
#define SELECT 1
#define ACTIVE 2
/* proposal = put scene pointers on function calls? */
// #define BASACT (scene->basact)
// #define OBACT (BASACT ? BASACT->object : NULL)
#ifdef __cplusplus
}
#endif

View File

@ -82,7 +82,6 @@ set(SRC
../include/ED_transform.h
../include/ED_transform_snap_object_context.h
../include/ED_transverts.h
../include/ED_types.h
../include/ED_undo.h
../include/ED_userpref.h
../include/ED_util.h

View File

@ -1160,6 +1160,9 @@ typedef struct IdAdtTemplate {
AnimData *adt;
} IdAdtTemplate;
/* From: `DNA_object_types.h`, see it's doc-string there. */
#define SELECT 1
/* ************************************************ */
#ifdef __cplusplus

View File

@ -439,9 +439,9 @@ enum {
/* *************** BEZTRIPLE **************** */
/* BezTriple.f1,2,3 */
/** #BezTriple.f1, #BezTriple.f2, #BezTriple.f3. */
typedef enum eBezTriple_Flag {
/* SELECT */
/* `SELECT = (1 << 0)` */
BEZT_FLAG_TEMP_TAG = (1 << 1), /* always clear. */
/* Can be used to ignore keyframe points for certain operations. */
BEZT_FLAG_IGNORE_TAG = (1 << 2),

View File

@ -477,7 +477,13 @@ typedef struct ObHook {
/* **************** OBJECT ********************* */
/* used many places, should be specialized. */
/**
* This is used as a flag for many kinds of data that use selections, examples include:
* - #BezTriple.f1, #BezTriple.f2, #BezTriple.f3
* - #bNote.flag
* - #MovieTrackingTrack.flag
* And more, ideally this would have a generic location.
*/
#define SELECT 1
/** #Object.type */

View File

@ -522,8 +522,6 @@ typedef struct SequencerScopes {
#define MAXSEQ 128
#define SELECT 1
/** #Editor.overlay_frame_flag */
#define SEQ_EDIT_OVERLAY_FRAME_SHOW 1
#define SEQ_EDIT_OVERLAY_FRAME_ABS 2
@ -549,9 +547,12 @@ typedef struct SequencerScopes {
#define SEQ_NAME_MAXSTR 64
/* From: `DNA_object_types.h`, see it's doc-string there. */
#define SELECT 1
/** #Sequence.flag */
enum {
/* SELECT */
/* `SELECT = (1 << 0)` */
SEQ_LEFTSEL = (1 << 1),
SEQ_RIGHTSEL = (1 << 2),
SEQ_OVERLAP = (1 << 3),

View File

@ -861,7 +861,7 @@ void WM_operator_properties_select_action(struct wmOperatorType *ot,
int default_action,
bool hide_gui);
/**
* Only #SELECT / #DESELECT.
* Only for select/de-select.
*/
void WM_operator_properties_select_action_simple(struct wmOperatorType *ot,
int default_action,