Refactor yscale of bAnimContext #104500

Merged
Christoph Lendenfeld merged 8 commits from ChrisLend/blender:refactor_channel_yscale into main 2023-02-09 14:28:06 +01:00
5 changed files with 10 additions and 10 deletions
Showing only changes of commit 35923b22e0 - Show all commits

View File

@ -4376,7 +4376,7 @@ static bool achannel_is_being_renamed(const bAnimContext *ac,
float ANIM_UI_get_keyframe_scale_factor(void)
{
bTheme *btheme = UI_GetTheme();
float yscale_fac = btheme->space_action.keyframe_scale_fac;
const float yscale_fac = btheme->space_action.keyframe_scale_fac;
ChrisLend marked this conversation as resolved

can be const

can be `const`
/* clamp to avoid problems with uninitialized values... */
if (yscale_fac < 0.1f) {

View File

@ -598,7 +598,7 @@ 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, const int item_count);
float ANIM_UI_get_channels_total_height(View2D *v2d, int item_count);
ChrisLend marked this conversation as resolved

Here remove const, it has no meaning in a function declaration for pass-by-value types.

Here remove `const`, it has no meaning in a function declaration for pass-by-value types.
float ANIM_UI_get_channel_name_width(void);
float ANIM_UI_get_channel_button_width(void);

View File

@ -73,7 +73,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
float ymin = ymax - ANIM_UI_get_channel_height();
const float ymin = ymax - ANIM_UI_get_channel_height();
ChrisLend marked this conversation as resolved

const float -- it doesn't change value within its scope, so it can be const even when it's different on every loop iteration. Same with some others below.

`const float` -- it doesn't change value within its scope, so it can be `const` even when it's different on every loop iteration. Same with some others below.
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
@ -89,7 +89,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
float ymin = ymax - ANIM_UI_get_channel_height();
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
@ -125,7 +125,7 @@ static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d)
/* Walk through channels, grouping contiguous spans referencing the same action. */
float ymax = ANIM_UI_get_first_channel_top(v2d) + ANIM_UI_get_channel_skip() / 2;
float ystep = ANIM_UI_get_channel_step();
const float ystep = ANIM_UI_get_channel_step();
float ymin = ymax - ystep;
for (bAnimListElem *ale = anim_data->first; ale; ale = ale->next, ymax = ymin, ymin -= ystep) {
@ -215,7 +215,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
float ymax = ANIM_UI_get_first_channel_top(v2d);
const float channel_step = ANIM_UI_get_channel_step();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
float ymin = ymax - ANIM_UI_get_channel_height();
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
@ -374,7 +374,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region
const float scale_factor = ANIM_UI_get_keyframe_scale_factor();
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) {
float ymin = ymax - ANIM_UI_get_channel_height();
const float ymin = ymax - ANIM_UI_get_channel_height();
float ycenter = (ymin + ymax) / 2.0f;
/* check if visible */

View File

@ -728,7 +728,7 @@ static void region_select_action_keys(
AnimData *adt = ANIM_nla_mapping_get(ac, ale);
/* get new vertical minimum extent of channel */
float ymin = ymax - channel_step;
const float ymin = ymax - channel_step;
/* compute midpoint of channel (used for testing if the key is in the region or not) */
sel_data.ked.channel_y = (ymin + ymax) / 2.0f;

View File

@ -1408,7 +1408,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
float ymax = ANIM_UI_get_first_channel_top(v2d);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
float ymin = ymax - ANIM_UI_get_channel_height();
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||
@ -1427,7 +1427,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region)
GPU_blend(GPU_BLEND_ALPHA);
for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) {
float ymin = ymax - ANIM_UI_get_channel_height();
const float ymin = ymax - ANIM_UI_get_channel_height();
/* check if visible */
if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) ||