Refactor: remove yscale from bAnimContext

`bAnimContext` had a float property called `yscale_fac` that was used to define the height of the keyframe channels.

However the property was never set, only read so there really is no need to have it in the struct.

Moreover it complicated getting the channel height because `bAnimContext` had to be passed in.

Speaking of getting the channel height. This was done with macros. I ripped them all out and replaced them with function calls.

Originally it was introduced in this patch: https://developer.blender.org/rB095c8dbe6919857ea322b213a1e240161cd7c843

Co-authored-by: Christoph Lendenfeld <chris.lenden@gmail.com>
Pull Request #104500
This commit is contained in:
2023-02-09 14:28:04 +01:00
parent ca183993a5
commit 666c2ea012
8 changed files with 133 additions and 109 deletions

View File

@@ -94,8 +94,6 @@ typedef struct bAnimContext {
/** pointer to current reports list */
struct ReportList *reports;
/** Scale factor for height of channels (i.e. based on the size of keyframes). */
float yscale_fac;
} bAnimContext;
/* Main Data container types */
@@ -430,28 +428,6 @@ ENUM_OPERATORS(eAnimFilter_Flags, ANIMFILTER_TMP_IGNORE_ONLYSEL);
/** \} */
/* -------------------------------------------------------------------- */
/** \name Channel Defines
* \{ */
/** Channel heights. */
#define ACHANNEL_FIRST_TOP(ac) \
(UI_view2d_scale_get_y(&(ac)->region->v2d) * -UI_TIME_SCRUB_MARGIN_Y - ACHANNEL_SKIP)
#define ACHANNEL_HEIGHT(ac) (0.8f * (ac)->yscale_fac * U.widget_unit)
#define ACHANNEL_SKIP (0.1f * U.widget_unit)
#define ACHANNEL_STEP(ac) (ACHANNEL_HEIGHT(ac) + ACHANNEL_SKIP)
/** Additional offset to give some room at the end. */
#define ACHANNEL_TOT_HEIGHT(ac, item_amount) \
(-ACHANNEL_FIRST_TOP(ac) + ACHANNEL_STEP(ac) * (item_amount + 1))
/** Channel widths. */
#define ACHANNEL_NAMEWIDTH (10 * U.widget_unit)
/** Channel toggle-buttons. */
#define ACHANNEL_BUTTON_WIDTH (0.8f * U.widget_unit)
/** \} */
/* -------------------------------------------------------------------- */
/** \name NLA Channel Defines
* \{ */
@@ -612,6 +588,20 @@ typedef struct bAnimChannelType {
void *(*setting_ptr)(bAnimListElem *ale, eAnimChannel_Settings setting, short *type);
} bAnimChannelType;
/** \} */
/* -------------------------------------------------------------------- */
/** \name Channel dimensions API
* \{ */
float ANIM_UI_get_keyframe_scale_factor(void);
float ANIM_UI_get_channel_height(void);
float ANIM_UI_get_channel_skip(void);
float ANIM_UI_get_first_channel_top(View2D *v2d);
float ANIM_UI_get_channel_step(void);
float ANIM_UI_get_channels_total_height(View2D *v2d, int item_count);
float ANIM_UI_get_channel_name_width(void);
float ANIM_UI_get_channel_button_width(void);
/** \} */
/* -------------------------------------------------------------------- */