From f3cb0170495197bff1bc0e29a454484aa9867fdc Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 3 Feb 2023 17:11:55 +0100 Subject: [PATCH 1/5] remove macros --- .../editors/animation/anim_channels_defines.c | 51 ++++++++++++++++++- .../editors/animation/anim_channels_edit.c | 18 +++---- source/blender/editors/include/ED_anim_api.h | 35 +++++-------- .../editors/space_action/action_draw.c | 39 +++++++------- .../editors/space_action/action_edit.c | 8 +-- .../editors/space_action/action_select.c | 26 ++++++---- .../blender/editors/space_graph/graph_draw.c | 15 +++--- 7 files changed, 120 insertions(+), 72 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 343fa34b3a5..43bbc72c8ee 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4373,6 +4373,53 @@ static bool achannel_is_being_renamed(const bAnimContext *ac, return false; } +static float get_yscale_fac(void) +{ + bTheme *btheme = UI_GetTheme(); + float yscale_fac = btheme->space_action.keyframe_scale_fac; + + /* clamp to avoid problems with uninitialized values... */ + if (yscale_fac < 0.1f) { + yscale_fac = 1.0f; + } + return yscale_fac; +} + +float ANIM_get_channel_height(void) +{ + return 0.8f * get_yscale_fac() * U.widget_unit; +} + +float ANIM_get_channel_skip(void) +{ + return 0.1f * U.widget_unit; +} + +float ANIM_get_first_channel_top(View2D *v2d) +{ + return UI_view2d_scale_get_y(v2d) * -UI_TIME_SCRUB_MARGIN_Y - ANIM_get_channel_skip(); +} + +float ANIM_get_channel_step(void) +{ + return ANIM_get_channel_height() + ANIM_get_channel_skip(); +} + +float ANIM_get_channels_total_height(View2D *v2d, const int item_count) +{ + return ANIM_get_first_channel_top(v2d) + ANIM_get_channel_step() * (item_count + 1); +} + +float ANIM_get_channel_name_width(void) +{ + return 10 * U.widget_unit; +} + +float ANIM_get_channel_button_width(void) +{ + return 0.8f * U.widget_unit; +} + void ANIM_channel_draw( bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc, size_t channel_index) { @@ -4566,7 +4613,7 @@ void ANIM_channel_draw( } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2)) { + if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_get_channel_button_width() / 2)) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; @@ -5279,7 +5326,7 @@ void ANIM_channel_draw_widgets(const bContext *C, } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ACHANNEL_BUTTON_WIDTH / 2)) { + if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_get_channel_button_width() / 2)) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset -= ICON_WIDTH; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index aa8b5796645..c12a23621dd 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2718,7 +2718,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm ymax = NLACHANNEL_FIRST_TOP(ac); } else { - ymax = ACHANNEL_FIRST_TOP(ac); + ymax = ANIM_get_first_channel_top(v2d); } /* loop over data, doing box select */ @@ -2726,7 +2726,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm float ymin; if (ale->type == ANIMTYPE_GPDATABLOCK) { - ymax -= ACHANNEL_STEP(ac); + ymax -= ANIM_get_channel_step(); continue; } @@ -2734,7 +2734,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm ymin = ymax - NLACHANNEL_STEP(snla); } else { - ymin = ymax - ACHANNEL_STEP(ac); + ymin = ymax - ANIM_get_channel_step(); } /* if channel is within border-select region, alter it */ @@ -2948,10 +2948,10 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2]) &channel_index); } else { - UI_view2d_listview_view_to_cell(ACHANNEL_NAMEWIDTH, - ACHANNEL_STEP(ac), + UI_view2d_listview_view_to_cell(ANIM_get_channel_name_width(), + ANIM_get_channel_step(), 0, - ACHANNEL_FIRST_TOP(ac), + ANIM_get_first_channel_top(v2d), x, y, NULL, @@ -3484,10 +3484,10 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE /* figure out which channel user clicked in */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); - UI_view2d_listview_view_to_cell(ACHANNEL_NAMEWIDTH, - ACHANNEL_STEP(&ac), + UI_view2d_listview_view_to_cell(ANIM_get_channel_name_width(), + ANIM_get_channel_step(), 0, - ACHANNEL_FIRST_TOP(&ac), + ANIM_get_first_channel_top(v2d), x, y, NULL, diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 9eaaff9f7fa..2f4ffe99ef2 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -430,28 +430,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 +590,19 @@ typedef struct bAnimChannelType { void *(*setting_ptr)(bAnimListElem *ale, eAnimChannel_Settings setting, short *type); } bAnimChannelType; +/** \} */ +/* -------------------------------------------------------------------- */ +/** \name Channel dimensions API + * \{ */ + +float ANIM_get_channel_height(void); +float ANIM_get_channel_skip(void); +float ANIM_get_first_channel_top(View2D *v2d); +float ANIM_get_channel_step(void); +float ANIM_get_channels_total_height(View2D *v2d, const int item_count); +float ANIM_get_channel_name_width(void); +float ANIM_get_channel_button_width(void); + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index de3d306a0be..2a02c2b51f3 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -60,19 +60,20 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - int height = ACHANNEL_TOT_HEIGHT(ac, items); + const int height = ANIM_get_channels_total_height(v2d, items); v2d->tot.ymin = -height; /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY); + const float channel_step = ANIM_get_channel_step(); /* Loop through channels, and set up drawing depending on their type. */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - float ymax = ACHANNEL_FIRST_TOP(ac); + float ymax = ANIM_get_first_channel_top(v2d); - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { - float ymin = ymax - ACHANNEL_HEIGHT(ac); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) { + float ymin = ymax - ANIM_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -85,10 +86,10 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS); size_t channel_index = 0; - float ymax = ACHANNEL_FIRST_TOP(ac); + float ymax = ANIM_get_first_channel_top(v2d); - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { - float ymin = ymax - ACHANNEL_HEIGHT(ac); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) { + float ymin = ymax - ANIM_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -115,7 +116,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) #define EXTRA_SCROLL_PAD 100.0f /* Draw manually set intended playback frame ranges for actions. */ -static void draw_channel_action_ranges(bAnimContext *ac, ListBase *anim_data, View2D *v2d) +static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d) { /* Variables for coalescing the Y region of one action. */ bAction *cur_action = NULL; @@ -123,8 +124,8 @@ static void draw_channel_action_ranges(bAnimContext *ac, ListBase *anim_data, Vi float cur_ymax; /* Walk through channels, grouping contiguous spans referencing the same action. */ - float ymax = ACHANNEL_FIRST_TOP(ac) + ACHANNEL_SKIP / 2; - float ystep = ACHANNEL_STEP(ac); + float ymax = ANIM_get_first_channel_top(v2d) + ANIM_get_channel_skip() / 2; + float ystep = ANIM_get_channel_step(); float ymin = ymax - ystep; for (bAnimListElem *ale = anim_data->first; ale; ale = ale->next, ymax = ymin, ymin -= ystep) { @@ -193,13 +194,13 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - int height = ACHANNEL_TOT_HEIGHT(ac, items); + const int height = ANIM_get_channels_total_height(v2d, items); v2d->tot.ymin = -height; /* Draw the manual frame ranges for actions in the background of the dopesheet. * The action editor has already drawn the range for its action so it's not needed. */ if (ac->datatype == ANIMCONT_DOPESHEET) { - draw_channel_action_ranges(ac, &anim_data, v2d); + draw_channel_action_ranges(&anim_data, v2d); } /* Draw the background strips. */ @@ -211,10 +212,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region GPU_blend(GPU_BLEND_ALPHA); /* first backdrop strips */ - float ymax = ACHANNEL_FIRST_TOP(ac); - - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { - float ymin = ymax - ACHANNEL_HEIGHT(ac); + float ymax = ANIM_get_first_channel_top(v2d); + const float channel_step = ANIM_get_channel_step(); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { + float ymin = ymax - ANIM_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -366,12 +367,12 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region action_flag &= ~(SACTION_SHOW_INTERPOLATION | SACTION_SHOW_EXTREMES); } - ymax = ACHANNEL_FIRST_TOP(ac); + ymax = ANIM_get_first_channel_top(v2d); struct AnimKeylistDrawList *draw_list = ED_keylist_draw_list_create(); - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { - float ymin = ymax - ACHANNEL_HEIGHT(ac); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { + float ymin = ymax - ANIM_get_channel_height(); float ycenter = (ymin + ymax) / 2.0f; /* check if visible */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 4c1a86a88e3..45884c98209 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -315,16 +315,16 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through all channels, finding the first one that's selected */ - float ymax = ACHANNEL_FIRST_TOP(ac); - - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { + float ymax = ANIM_get_first_channel_top(&ac->region->v2d); + const float channel_step = ANIM_get_channel_step(); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* must be selected... */ if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ - *r_min = ymax - ACHANNEL_HEIGHT(ac); + *r_min = ymax - ANIM_get_channel_height(); *r_max = ymax; /* is this high enough priority yet? */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index a425026a1ef..2086e2d06d3 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -61,8 +61,14 @@ static bAnimListElem *actkeys_find_list_element_at_position(bAnimContext *ac, float view_x, view_y; int channel_index; UI_view2d_region_to_view(v2d, region_x, region_y, &view_x, &view_y); - UI_view2d_listview_view_to_cell( - 0, ACHANNEL_STEP(ac), 0, ACHANNEL_FIRST_TOP(ac), view_x, view_y, NULL, &channel_index); + UI_view2d_listview_view_to_cell(0, + ANIM_get_channel_step(), + 0, + ANIM_get_first_channel_top(v2d), + view_x, + view_y, + NULL, + &channel_index); ListBase anim_data = {NULL, NULL}; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -152,7 +158,7 @@ static void actkeys_find_key_in_list_element(bAnimContext *ac, AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* standard channel height (to allow for some slop) */ - float key_hsize = ACHANNEL_HEIGHT(ac) * 0.8f; + float key_hsize = ANIM_get_channel_height() * 0.8f; /* half-size (for either side), but rounded up to nearest int (for easier targeting) */ key_hsize = roundf(key_hsize / 2.0f); @@ -462,14 +468,15 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho /* init editing data */ memset(&sel_data.ked, 0, sizeof(KeyframeEditData)); - float ymax = ACHANNEL_FIRST_TOP(ac); + float ymax = ANIM_get_first_channel_top(v2d); + const float channel_step = ANIM_get_channel_step(); /* loop over data, doing box select */ - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ - float ymin = ymax - ACHANNEL_STEP(ac); + float ymin = ymax - channel_step; /* set horizontal range (if applicable) */ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) { @@ -713,14 +720,15 @@ static void region_select_action_keys( sel_data.ked.data = &scaled_rectf; } - float ymax = ACHANNEL_FIRST_TOP(ac); + float ymax = ANIM_get_first_channel_top(v2d); + const float channel_step = ANIM_get_channel_step(); /* loop over data, doing region select */ - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac)) { + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ - float ymin = ymax - ACHANNEL_STEP(ac); + 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; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index a19cbb9b7fa..5816b6b4092 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -1398,16 +1398,17 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first */ - height = ACHANNEL_TOT_HEIGHT(ac, items); + height = ANIM_get_channels_total_height(v2d, items); v2d->tot.ymin = -height; + const float channel_step = ANIM_get_channel_step(); /* Loop through channels, and set up drawing depending on their type. */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - float ymax = ACHANNEL_FIRST_TOP(ac); + float ymax = ANIM_get_first_channel_top(v2d); - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { - float ymin = ymax - ACHANNEL_HEIGHT(ac); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) { + float ymin = ymax - ANIM_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -1420,13 +1421,13 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS); size_t channel_index = 0; - float ymax = ACHANNEL_FIRST_TOP(ac); + float ymax = ANIM_get_first_channel_top(v2d); /* set blending again, as may not be set in previous step */ GPU_blend(GPU_BLEND_ALPHA); - for (ale = anim_data.first; ale; ale = ale->next, ymax -= ACHANNEL_STEP(ac), channel_index++) { - float ymin = ymax - ACHANNEL_HEIGHT(ac); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) { + float ymin = ymax - ANIM_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || -- 2.30.2 From 2db1575c77859024ef0cf9b033bed3de4fa0f92a Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Feb 2023 09:43:31 +0100 Subject: [PATCH 2/5] refactor --- .../editors/animation/anim_channels_defines.c | 4 ++-- .../blender/editors/animation/anim_filter.c | 23 ------------------- source/blender/editors/include/ED_anim_api.h | 3 +-- .../editors/space_action/action_draw.c | 22 ++++++++---------- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 43bbc72c8ee..3e519e376c5 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4373,7 +4373,7 @@ static bool achannel_is_being_renamed(const bAnimContext *ac, return false; } -static float get_yscale_fac(void) +float ANIM_get_keyframe_scale_factor(void) { bTheme *btheme = UI_GetTheme(); float yscale_fac = btheme->space_action.keyframe_scale_fac; @@ -4387,7 +4387,7 @@ static float get_yscale_fac(void) float ANIM_get_channel_height(void) { - return 0.8f * get_yscale_fac() * U.widget_unit; + return 0.8f * ANIM_get_keyframe_scale_factor() * U.widget_unit; } float ANIM_get_channel_skip(void) diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index f619837a3c5..b0257df3cb6 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -92,26 +92,6 @@ /* ************************************************************ */ /* Blender Context <-> Animation Context mapping */ -/* ----------- Private Stuff - General -------------------- */ - -/* Get vertical scaling factor (i.e. typically used for keyframe size) */ -static void animedit_get_yscale_factor(bAnimContext *ac) -{ - bTheme *btheme = UI_GetTheme(); - - /* grab scale factor directly from action editor setting - * NOTE: This theme setting doesn't have an ID, as it cannot be accessed normally - * since it is a float, and the theme settings methods can only handle chars. - */ - ac->yscale_fac = btheme->space_action.keyframe_scale_fac; - - /* clamp to avoid problems with uninitialized values... */ - if (ac->yscale_fac < 0.1f) { - ac->yscale_fac = 1.0f; - } - // printf("yscale_fac = %f\n", ac->yscale_fac); -} - /* ----------- Private Stuff - Action Editor ------------- */ /* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */ @@ -408,9 +388,6 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) ac->spacetype = (area) ? area->spacetype : 0; ac->regiontype = (region) ? region->regiontype : 0; - /* Initialize default y-scale factor. */ - animedit_get_yscale_factor(ac); - /* get data context info */ /* XXX: if the below fails, try to grab this info from context instead... * (to allow for scripting). */ diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 2f4ffe99ef2..9c86cdbdab7 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -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 */ @@ -595,6 +593,7 @@ typedef struct bAnimChannelType { /** \name Channel dimensions API * \{ */ +float ANIM_get_keyframe_scale_factor(void); float ANIM_get_channel_height(void); float ANIM_get_channel_skip(void); float ANIM_get_first_channel_top(View2D *v2d); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 2a02c2b51f3..87840187bb0 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -371,6 +371,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region struct AnimKeylistDrawList *draw_list = ED_keylist_draw_list_create(); + const float scale_factor = ANIM_get_keyframe_scale_factor(); + for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { float ymin = ymax - ANIM_get_channel_height(); float ycenter = (ymin + ymax) / 2.0f; @@ -385,32 +387,28 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { case ALE_ALL: - draw_summary_channel(draw_list, ale->data, ycenter, ac->yscale_fac, action_flag); + draw_summary_channel(draw_list, ale->data, ycenter, scale_factor, action_flag); break; case ALE_SCE: - draw_scene_channel( - draw_list, ads, ale->key_data, ycenter, ac->yscale_fac, action_flag); + draw_scene_channel(draw_list, ads, ale->key_data, ycenter, scale_factor, action_flag); break; case ALE_OB: - draw_object_channel( - draw_list, ads, ale->key_data, ycenter, ac->yscale_fac, action_flag); + draw_object_channel(draw_list, ads, ale->key_data, ycenter, scale_factor, action_flag); break; case ALE_ACT: - draw_action_channel( - draw_list, adt, ale->key_data, ycenter, ac->yscale_fac, action_flag); + draw_action_channel(draw_list, adt, ale->key_data, ycenter, scale_factor, action_flag); break; case ALE_GROUP: - draw_agroup_channel(draw_list, adt, ale->data, ycenter, ac->yscale_fac, action_flag); + draw_agroup_channel(draw_list, adt, ale->data, ycenter, scale_factor, action_flag); break; case ALE_FCURVE: - draw_fcurve_channel( - draw_list, adt, ale->key_data, ycenter, ac->yscale_fac, action_flag); + draw_fcurve_channel(draw_list, adt, ale->key_data, ycenter, scale_factor, action_flag); break; case ALE_GPFRAME: - draw_gpl_channel(draw_list, ads, ale->data, ycenter, ac->yscale_fac, action_flag); + draw_gpl_channel(draw_list, ads, ale->data, ycenter, scale_factor, action_flag); break; case ALE_MASKLAY: - draw_masklay_channel(draw_list, ads, ale->data, ycenter, ac->yscale_fac, action_flag); + draw_masklay_channel(draw_list, ads, ale->data, ycenter, scale_factor, action_flag); break; } } -- 2.30.2 From 8b809e79778d7e64f1d4a6cd114daf73093f06f0 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Feb 2023 10:56:47 +0100 Subject: [PATCH 3/5] implement sybrens changes --- source/blender/editors/animation/anim_channels_defines.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 3e519e376c5..9f7e7e6f180 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4380,7 +4380,7 @@ float ANIM_get_keyframe_scale_factor(void) /* clamp to avoid problems with uninitialized values... */ if (yscale_fac < 0.1f) { - yscale_fac = 1.0f; + return 1.0f; } return yscale_fac; } -- 2.30.2 From 7a59a4670b4c512e61ca54be0af9150fd9c75031 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Feb 2023 11:04:19 +0100 Subject: [PATCH 4/5] rename new functions withg ANIM_UI prefix --- .../editors/animation/anim_channels_defines.c | 30 ++++++++++--------- .../editors/animation/anim_channels_edit.c | 18 +++++------ source/blender/editors/include/ED_anim_api.h | 16 +++++----- .../editors/space_action/action_draw.c | 30 +++++++++---------- .../editors/space_action/action_edit.c | 6 ++-- .../editors/space_action/action_select.c | 14 ++++----- .../blender/editors/space_graph/graph_draw.c | 12 ++++---- 7 files changed, 64 insertions(+), 62 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 9f7e7e6f180..090c031af18 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4373,7 +4373,7 @@ static bool achannel_is_being_renamed(const bAnimContext *ac, return false; } -float ANIM_get_keyframe_scale_factor(void) +float ANIM_UI_get_keyframe_scale_factor(void) { bTheme *btheme = UI_GetTheme(); float yscale_fac = btheme->space_action.keyframe_scale_fac; @@ -4385,37 +4385,37 @@ float ANIM_get_keyframe_scale_factor(void) return yscale_fac; } -float ANIM_get_channel_height(void) +float ANIM_UI_get_channel_height(void) { - return 0.8f * ANIM_get_keyframe_scale_factor() * U.widget_unit; + return 0.8f * ANIM_UI_get_keyframe_scale_factor() * U.widget_unit; } -float ANIM_get_channel_skip(void) +float ANIM_UI_get_channel_skip(void) { return 0.1f * U.widget_unit; } -float ANIM_get_first_channel_top(View2D *v2d) +float ANIM_UI_get_first_channel_top(View2D *v2d) { - return UI_view2d_scale_get_y(v2d) * -UI_TIME_SCRUB_MARGIN_Y - ANIM_get_channel_skip(); + return UI_view2d_scale_get_y(v2d) * -UI_TIME_SCRUB_MARGIN_Y - ANIM_UI_get_channel_skip(); } -float ANIM_get_channel_step(void) +float ANIM_UI_get_channel_step(void) { - return ANIM_get_channel_height() + ANIM_get_channel_skip(); + return ANIM_UI_get_channel_height() + ANIM_UI_get_channel_skip(); } -float ANIM_get_channels_total_height(View2D *v2d, const int item_count) +float ANIM_UI_get_channels_total_height(View2D *v2d, const int item_count) { - return ANIM_get_first_channel_top(v2d) + ANIM_get_channel_step() * (item_count + 1); + return ANIM_UI_get_first_channel_top(v2d) + ANIM_UI_get_channel_step() * (item_count + 1); } -float ANIM_get_channel_name_width(void) +float ANIM_UI_get_channel_name_width(void) { return 10 * U.widget_unit; } -float ANIM_get_channel_button_width(void) +float ANIM_UI_get_channel_button_width(void) { return 0.8f * U.widget_unit; } @@ -4613,7 +4613,8 @@ void ANIM_channel_draw( } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_get_channel_button_width() / 2)) { + if (!(draw_sliders) || + (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2)) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; @@ -5326,7 +5327,8 @@ void ANIM_channel_draw_widgets(const bContext *C, } /* check if there's enough space for the toggles if the sliders are drawn too */ - if (!(draw_sliders) || (BLI_rcti_size_x(&v2d->mask) > ANIM_get_channel_button_width() / 2)) { + if (!(draw_sliders) || + (BLI_rcti_size_x(&v2d->mask) > ANIM_UI_get_channel_button_width() / 2)) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset -= ICON_WIDTH; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index c12a23621dd..7ec701edcb8 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -2718,7 +2718,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm ymax = NLACHANNEL_FIRST_TOP(ac); } else { - ymax = ANIM_get_first_channel_top(v2d); + ymax = ANIM_UI_get_first_channel_top(v2d); } /* loop over data, doing box select */ @@ -2726,7 +2726,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm float ymin; if (ale->type == ANIMTYPE_GPDATABLOCK) { - ymax -= ANIM_get_channel_step(); + ymax -= ANIM_UI_get_channel_step(); continue; } @@ -2734,7 +2734,7 @@ static void box_select_anim_channels(bAnimContext *ac, rcti *rect, short selectm ymin = ymax - NLACHANNEL_STEP(snla); } else { - ymin = ymax - ANIM_get_channel_step(); + ymin = ymax - ANIM_UI_get_channel_step(); } /* if channel is within border-select region, alter it */ @@ -2948,10 +2948,10 @@ static int animchannels_channel_get(bAnimContext *ac, const int mval[2]) &channel_index); } else { - UI_view2d_listview_view_to_cell(ANIM_get_channel_name_width(), - ANIM_get_channel_step(), + UI_view2d_listview_view_to_cell(ANIM_UI_get_channel_name_width(), + ANIM_UI_get_channel_step(), 0, - ANIM_get_first_channel_top(v2d), + ANIM_UI_get_first_channel_top(v2d), x, y, NULL, @@ -3484,10 +3484,10 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, const wmE /* figure out which channel user clicked in */ UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, &y); - UI_view2d_listview_view_to_cell(ANIM_get_channel_name_width(), - ANIM_get_channel_step(), + UI_view2d_listview_view_to_cell(ANIM_UI_get_channel_name_width(), + ANIM_UI_get_channel_step(), 0, - ANIM_get_first_channel_top(v2d), + ANIM_UI_get_first_channel_top(v2d), x, y, NULL, diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 9c86cdbdab7..b9fd9b1a46d 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -593,14 +593,14 @@ typedef struct bAnimChannelType { /** \name Channel dimensions API * \{ */ -float ANIM_get_keyframe_scale_factor(void); -float ANIM_get_channel_height(void); -float ANIM_get_channel_skip(void); -float ANIM_get_first_channel_top(View2D *v2d); -float ANIM_get_channel_step(void); -float ANIM_get_channels_total_height(View2D *v2d, const int item_count); -float ANIM_get_channel_name_width(void); -float ANIM_get_channel_button_width(void); +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, const int item_count); +float ANIM_UI_get_channel_name_width(void); +float ANIM_UI_get_channel_button_width(void); /** \} */ diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 87840187bb0..d27d9dbfcf6 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -60,20 +60,20 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - const int height = ANIM_get_channels_total_height(v2d, items); + const int height = ANIM_UI_get_channels_total_height(v2d, items); v2d->tot.ymin = -height; /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, ac->area, v2d, V2D_LOCK_COPY); - const float channel_step = ANIM_get_channel_step(); + const float channel_step = ANIM_UI_get_channel_step(); /* Loop through channels, and set up drawing depending on their type. */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - float ymax = ANIM_get_first_channel_top(v2d); + 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_get_channel_height(); + float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -86,10 +86,10 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS); size_t channel_index = 0; - float ymax = ANIM_get_first_channel_top(v2d); + 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_get_channel_height(); + float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -124,8 +124,8 @@ static void draw_channel_action_ranges(ListBase *anim_data, View2D *v2d) float cur_ymax; /* Walk through channels, grouping contiguous spans referencing the same action. */ - float ymax = ANIM_get_first_channel_top(v2d) + ANIM_get_channel_skip() / 2; - float ystep = ANIM_get_channel_step(); + float ymax = ANIM_UI_get_first_channel_top(v2d) + ANIM_UI_get_channel_skip() / 2; + 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) { @@ -194,7 +194,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - const int height = ANIM_get_channels_total_height(v2d, items); + const int height = ANIM_UI_get_channels_total_height(v2d, items); v2d->tot.ymin = -height; /* Draw the manual frame ranges for actions in the background of the dopesheet. @@ -212,10 +212,10 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region GPU_blend(GPU_BLEND_ALPHA); /* first backdrop strips */ - float ymax = ANIM_get_first_channel_top(v2d); - const float channel_step = ANIM_get_channel_step(); + 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_get_channel_height(); + float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -367,14 +367,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *region action_flag &= ~(SACTION_SHOW_INTERPOLATION | SACTION_SHOW_EXTREMES); } - ymax = ANIM_get_first_channel_top(v2d); + ymax = ANIM_UI_get_first_channel_top(v2d); struct AnimKeylistDrawList *draw_list = ED_keylist_draw_list_create(); - const float scale_factor = ANIM_get_keyframe_scale_factor(); + 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_get_channel_height(); + float ymin = ymax - ANIM_UI_get_channel_height(); float ycenter = (ymin + ymax) / 2.0f; /* check if visible */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 45884c98209..9b0ef405a6a 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -315,8 +315,8 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through all channels, finding the first one that's selected */ - float ymax = ANIM_get_first_channel_top(&ac->region->v2d); - const float channel_step = ANIM_get_channel_step(); + float ymax = ANIM_UI_get_first_channel_top(&ac->region->v2d); + const float channel_step = ANIM_UI_get_channel_step(); for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { const bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); @@ -324,7 +324,7 @@ static bool actkeys_channels_get_selected_extents(bAnimContext *ac, float *r_min if (acf && acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT) && ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT)) { /* update best estimate */ - *r_min = ymax - ANIM_get_channel_height(); + *r_min = ymax - ANIM_UI_get_channel_height(); *r_max = ymax; /* is this high enough priority yet? */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 0d97db48389..8de89364874 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -62,9 +62,9 @@ static bAnimListElem *actkeys_find_list_element_at_position(bAnimContext *ac, int channel_index; UI_view2d_region_to_view(v2d, region_x, region_y, &view_x, &view_y); UI_view2d_listview_view_to_cell(0, - ANIM_get_channel_step(), + ANIM_UI_get_channel_step(), 0, - ANIM_get_first_channel_top(v2d), + ANIM_UI_get_first_channel_top(v2d), view_x, view_y, NULL, @@ -158,7 +158,7 @@ static void actkeys_find_key_in_list_element(bAnimContext *ac, AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* standard channel height (to allow for some slop) */ - float key_hsize = ANIM_get_channel_height() * 0.8f; + float key_hsize = ANIM_UI_get_channel_height() * 0.8f; /* half-size (for either side), but rounded up to nearest int (for easier targeting) */ key_hsize = roundf(key_hsize / 2.0f); @@ -468,8 +468,8 @@ static void box_select_action(bAnimContext *ac, const rcti rect, short mode, sho /* init editing data */ memset(&sel_data.ked, 0, sizeof(KeyframeEditData)); - float ymax = ANIM_get_first_channel_top(v2d); - const float channel_step = ANIM_get_channel_step(); + float ymax = ANIM_UI_get_first_channel_top(v2d); + const float channel_step = ANIM_UI_get_channel_step(); /* loop over data, doing box select */ for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { @@ -720,8 +720,8 @@ static void region_select_action_keys( sel_data.ked.data = &scaled_rectf; } - float ymax = ANIM_get_first_channel_top(v2d); - const float channel_step = ANIM_get_channel_step(); + float ymax = ANIM_UI_get_first_channel_top(v2d); + const float channel_step = ANIM_UI_get_channel_step(); /* loop over data, doing region select */ for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step) { diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 5816b6b4092..2a52d8320d9 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -1398,17 +1398,17 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) /* Update max-extent of channels here (taking into account scrollers): * - this is done to allow the channel list to be scrollable, but must be done here * to avoid regenerating the list again and/or also because channels list is drawn first */ - height = ANIM_get_channels_total_height(v2d, items); + height = ANIM_UI_get_channels_total_height(v2d, items); v2d->tot.ymin = -height; - const float channel_step = ANIM_get_channel_step(); + const float channel_step = ANIM_UI_get_channel_step(); /* Loop through channels, and set up drawing depending on their type. */ { /* first pass: just the standard GL-drawing for backdrop + text */ size_t channel_index = 0; - float ymax = ANIM_get_first_channel_top(v2d); + 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_get_channel_height(); + float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || @@ -1421,13 +1421,13 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *region) { /* second pass: widgets */ uiBlock *block = UI_block_begin(C, region, __func__, UI_EMBOSS); size_t channel_index = 0; - float ymax = ANIM_get_first_channel_top(v2d); + float ymax = ANIM_UI_get_first_channel_top(v2d); /* set blending again, as may not be set in previous step */ GPU_blend(GPU_BLEND_ALPHA); for (ale = anim_data.first; ale; ale = ale->next, ymax -= channel_step, channel_index++) { - float ymin = ymax - ANIM_get_channel_height(); + float ymin = ymax - ANIM_UI_get_channel_height(); /* check if visible */ if (IN_RANGE(ymin, v2d->cur.ymin, v2d->cur.ymax) || -- 2.30.2 From 35923b22e0de2bda107a21e03f661b3d6be574ce Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Feb 2023 12:37:16 +0100 Subject: [PATCH 5/5] add const to variables --- .../blender/editors/animation/anim_channels_defines.c | 2 +- source/blender/editors/include/ED_anim_api.h | 2 +- source/blender/editors/space_action/action_draw.c | 10 +++++----- source/blender/editors/space_action/action_select.c | 2 +- source/blender/editors/space_graph/graph_draw.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 090c031af18..1b3a84162e4 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -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; /* clamp to avoid problems with uninitialized values... */ if (yscale_fac < 0.1f) { diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index b9fd9b1a46d..a436fa43989 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -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); float ANIM_UI_get_channel_name_width(void); float ANIM_UI_get_channel_button_width(void); diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index d27d9dbfcf6..5e740f897fc 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -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(); /* 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 */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 8de89364874..8dc34964590 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -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; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 2a52d8320d9..fd4282aaaff 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -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) || -- 2.30.2