Cleanup: Use an enum to set instanced panel expansion
This commit uses an enum to access expansion for specific panels for each modifier, constraint, etc. Even though these values are quite simple, this can help make the code more explicit when the ui_expand_flag is accessed directly. Also update comments about this bitfield to make them consistent.
This commit is contained in:
parent
81a0fffb2d
commit
6250a8725e
|
@ -45,6 +45,7 @@
|
|||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_modifier_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "DNA_lattice_types.h"
|
||||
#include "DNA_movieclip_types.h"
|
||||
|
@ -5408,7 +5409,7 @@ bool BKE_constraint_remove_ex(ListBase *list, Object *ob, bConstraint *con, bool
|
|||
|
||||
void BKE_constraint_panel_expand(bConstraint *con)
|
||||
{
|
||||
con->ui_expand_flag |= (1 << 0);
|
||||
con->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
|
||||
}
|
||||
|
||||
/* ......... */
|
||||
|
@ -5426,10 +5427,10 @@ static bConstraint *add_new_constraint_internal(const char *name, short type)
|
|||
con->enforce = 1.0f;
|
||||
|
||||
/* Only open the main panel when constraints are created, not the sub-panels. */
|
||||
con->ui_expand_flag = (1 << 0);
|
||||
con->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT;
|
||||
if (ELEM(type, CONSTRAINT_TYPE_ACTION, CONSTRAINT_TYPE_SPLINEIK)) {
|
||||
/* Expand the two sub-panels in the cases where the main panel barely has any properties. */
|
||||
con->ui_expand_flag |= (1 << 1) | (1 << 2);
|
||||
con->ui_expand_flag |= UI_SUBPANEL_DATA_EXPAND_1 | UI_SUBPANEL_DATA_EXPAND_2;
|
||||
}
|
||||
|
||||
/* Determine a basic name, and info */
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_gpencil.h"
|
||||
#include "BKE_gpencil_geom.h"
|
||||
|
@ -413,7 +414,7 @@ void BKE_gpencil_modifierType_panel_id(GpencilModifierType type, char *r_idname)
|
|||
|
||||
void BKE_gpencil_modifier_panel_expand(GpencilModifierData *md)
|
||||
{
|
||||
md->ui_expand_flag |= (1 << 0);
|
||||
md->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "DNA_mesh_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_listbase.h"
|
||||
|
@ -132,7 +133,7 @@ void BKE_modifier_type_panel_id(ModifierType type, char *r_idname)
|
|||
|
||||
void BKE_modifier_panel_expand(ModifierData *md)
|
||||
{
|
||||
md->ui_expand_flag |= (1 << 0);
|
||||
md->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
|
||||
}
|
||||
|
||||
/***/
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "DNA_meshdata_types.h"
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
#include "DNA_shader_fx_types.h"
|
||||
|
||||
#include "BKE_gpencil.h"
|
||||
|
@ -177,7 +178,7 @@ void BKE_shaderfxType_panel_id(ShaderFxType type, char *r_idname)
|
|||
|
||||
void BKE_shaderfx_panel_expand(ShaderFxData *fx)
|
||||
{
|
||||
fx->ui_expand_flag |= (1 << 0);
|
||||
fx->ui_expand_flag |= UI_PANEL_DATA_EXPAND_ROOT;
|
||||
}
|
||||
|
||||
void BKE_shaderfx_copydata_generic(const ShaderFxData *fx_src, ShaderFxData *fx_dst)
|
||||
|
|
|
@ -86,7 +86,7 @@ static void initData(GpencilModifierData *md)
|
|||
MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(ArrayGpencilModifierData), modifier);
|
||||
|
||||
/* Open the first subpanel too, because it's activated by default. */
|
||||
md->ui_expand_flag = (1 << 0) | (1 << 1);
|
||||
md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT | UI_SUBPANEL_DATA_EXPAND_1;
|
||||
}
|
||||
|
||||
static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
|
||||
|
|
|
@ -60,7 +60,7 @@ typedef struct bConstraint {
|
|||
/** Constraint name, MAX_NAME. */
|
||||
char name[64];
|
||||
|
||||
/* Flag for panel and subpanel closed / open state in the UI. */
|
||||
/* An "expand" bit for each of the constraint's (sub)panels (uiPanelDataExpansion). */
|
||||
short ui_expand_flag;
|
||||
|
||||
/** Amount of influence exherted by constraint (0.0-1.0). */
|
||||
|
|
|
@ -74,6 +74,7 @@ typedef struct GpencilModifierData {
|
|||
int type, mode;
|
||||
char _pad0[4];
|
||||
short flag;
|
||||
/* An "expand" bit for each of the modifier's (sub)panels (uiPanelDataExpansion). */
|
||||
short ui_expand_flag;
|
||||
/** MAX_NAME. */
|
||||
char name[64];
|
||||
|
|
|
@ -121,7 +121,7 @@ typedef struct ModifierData {
|
|||
int type, mode;
|
||||
char _pad0[4];
|
||||
short flag;
|
||||
/* An "expand" bit for each of the modifier's (sub)panels. */
|
||||
/* An "expand" bit for each of the modifier's (sub)panels (uiPanelDataExpansion). */
|
||||
short ui_expand_flag;
|
||||
/** MAX_NAME. */
|
||||
char name[64];
|
||||
|
|
|
@ -183,6 +183,34 @@ typedef struct Panel {
|
|||
Panel_Runtime runtime;
|
||||
} Panel;
|
||||
|
||||
/**
|
||||
* Used for passing expansion between instanced panel data and the panels themselves.
|
||||
* There are 16 defines because the expansion data is typically stored in a short.
|
||||
*
|
||||
* \note Expansion for instanced panels is stored in depth first order. For example, the value of
|
||||
* UI_SUBPANEL_DATA_EXPAND_2 correspond to mean the expansion of the second subpanel or the first
|
||||
* subpanel's first subpanel.
|
||||
*/
|
||||
typedef enum uiPanelDataExpansion {
|
||||
UI_PANEL_DATA_EXPAND_ROOT = (1 << 0),
|
||||
UI_SUBPANEL_DATA_EXPAND_1 = (1 << 1),
|
||||
UI_SUBPANEL_DATA_EXPAND_2 = (1 << 2),
|
||||
UI_SUBPANEL_DATA_EXPAND_3 = (1 << 3),
|
||||
UI_SUBPANEL_DATA_EXPAND_4 = (1 << 4),
|
||||
UI_SUBPANEL_DATA_EXPAND_5 = (1 << 5),
|
||||
UI_SUBPANEL_DATA_EXPAND_6 = (1 << 6),
|
||||
UI_SUBPANEL_DATA_EXPAND_7 = (1 << 7),
|
||||
UI_SUBPANEL_DATA_EXPAND_8 = (1 << 8),
|
||||
UI_SUBPANEL_DATA_EXPAND_9 = (1 << 9),
|
||||
UI_SUBPANEL_DATA_EXPAND_10 = (1 << 10),
|
||||
UI_SUBPANEL_DATA_EXPAND_11 = (1 << 11),
|
||||
UI_SUBPANEL_DATA_EXPAND_12 = (1 << 12),
|
||||
UI_SUBPANEL_DATA_EXPAND_13 = (1 << 13),
|
||||
UI_SUBPANEL_DATA_EXPAND_14 = (1 << 14),
|
||||
UI_SUBPANEL_DATA_EXPAND_15 = (1 << 15),
|
||||
UI_SUBPANEL_DATA_EXPAND_16 = (1 << 16),
|
||||
} uiPanelDataExpansion;
|
||||
|
||||
/**
|
||||
* Notes on Panel Categories:
|
||||
*
|
||||
|
|
|
@ -65,7 +65,7 @@ typedef struct ShaderFxData {
|
|||
int type, mode;
|
||||
char _pad0[4];
|
||||
short flag;
|
||||
/* Expansion for shader effect panels and sub-panels. */
|
||||
/* An "expand" bit for each of the constraint's (sub)panels (uiPanelDataExpansion). */
|
||||
short ui_expand_flag;
|
||||
/** MAX_NAME. */
|
||||
char name[64];
|
||||
|
|
|
@ -1529,12 +1529,7 @@ static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr,
|
|||
static void rna_Modifier_show_expanded_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
ModifierData *md = ptr->data;
|
||||
if (value) {
|
||||
md->ui_expand_flag |= (1 << 0);
|
||||
}
|
||||
else {
|
||||
md->ui_expand_flag &= ~(1 << 0);
|
||||
}
|
||||
SET_FLAG_FROM_TEST(md->ui_expand_flag, value, UI_PANEL_DATA_EXPAND_ROOT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1545,7 +1540,7 @@ static void rna_Modifier_show_expanded_set(PointerRNA *ptr, bool value)
|
|||
static bool rna_Modifier_show_expanded_get(PointerRNA *ptr)
|
||||
{
|
||||
ModifierData *md = ptr->data;
|
||||
return md->ui_expand_flag & (1 << 0);
|
||||
return md->ui_expand_flag & UI_PANEL_DATA_EXPAND_ROOT;
|
||||
}
|
||||
|
||||
static int rna_MeshSequenceCacheModifier_has_velocity_get(PointerRNA *ptr)
|
||||
|
|
|
@ -69,7 +69,7 @@ static void initData(ModifierData *md)
|
|||
MEMCPY_STRUCT_AFTER(amd, DNA_struct_default_get(ArrayModifierData), modifier);
|
||||
|
||||
/* Open the first subpanel by default, it corresspnds to Relative offset which is enabled too. */
|
||||
md->ui_expand_flag = (1 << 0) | (1 << 1);
|
||||
md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT | UI_SUBPANEL_DATA_EXPAND_1;
|
||||
}
|
||||
|
||||
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
|
||||
|
|
|
@ -74,7 +74,7 @@ static void initData(ModifierData *md)
|
|||
MEMCPY_STRUCT_AFTER(mmd, DNA_struct_default_get(MultiresModifierData), modifier);
|
||||
|
||||
/* Open subdivision panels by default. */
|
||||
md->ui_expand_flag = (1 << 0) | (1 << 1);
|
||||
md->ui_expand_flag = UI_PANEL_DATA_EXPAND_ROOT | UI_SUBPANEL_DATA_EXPAND_1;
|
||||
}
|
||||
|
||||
static void requiredDataMask(Object *UNUSED(ob),
|
||||
|
|
Loading…
Reference in New Issue