Refactor yscale of bAnimContext #104500
|
@ -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;
|
||||
ChrisLend marked this conversation as resolved
|
||||
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
ChrisLend marked this conversation as resolved
Sybren A. Stüvel
commented
Here remove 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);
|
||||
|
||||
/** \} */
|
||||
|
||||
|
|
|
@ -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();
|
||||
ChrisLend marked this conversation as resolved
Sybren A. Stüvel
commented
`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) ||
|
||||
|
@ -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 */
|
||||
|
|
|
@ -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? */
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) ||
|
||||
|
|
Loading…
Reference in New Issue
can be
const