40#define MIN_MAJOR_LINE_DISTANCE (U.v2d_min_gridsize * UI_SCALE_FAC)
49 if (
IS_EQF(view_width, 0.0f)) {
50 return possible_distances[0];
53 const float pixels_per_view_unit = pixel_width / view_width;
55 for (
uint i = 0; i < amount; i++) {
56 const float distance = possible_distances[i];
61 return possible_distances[amount - 1];
65 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000};
68 5, 10, 20, 50, 100, 200, 500, 1000,
69 2000, 5000, 10000, 20000, 50000, 100000};
97 const double fps =
FPS;
101 for (
int step = 1; step < fps; step *= 2) {
102 possible_distances.
append(step);
105 for (
int i = 0; i <= 5; i++) {
107 possible_distances.
append(fac * fps);
108 possible_distances.
append(fac * 2 * fps);
109 possible_distances.
append(fac * 5 * fps);
110 possible_distances.
append(fac * 10 * fps);
111 possible_distances.
append(fac * 30 * fps);
112 possible_distances.
append(fac * 60 * fps);
116 possible_distances.
size(),
137 if (region_start >= region_end) {
149 if (region_start <= *r_first && region_end >= *r_first) {
150 *r_steps = std::max(0.0f,
floorf((region_end - *r_first) / lines->
distance)) + 1;
162 const rcti *rect_mask,
163 const uchar color[3],
169 if (direction ==
'v') {
192 if (
U.pixelsize > 1.0f) {
208 if (direction ==
'v') {
210 const float xpos = first + i * lines->
distance;
217 const float ypos = first + i * lines->
distance;
229 const uchar color[3],
239 float major_distance,
240 bool display_minor_lines,
244 uchar major_color[3];
247 major_lines.
distance = major_distance;
252 if (display_minor_lines) {
253 uchar minor_color[3];
256 minor_lines.
distance = major_distance;
257 minor_lines.
offset = major_distance / 2.0f;
266 void (*)(
void *user_data,
float v2d_pos,
float v2d_step,
char *r_str,
uint str_maxncpy);
273 void *to_string_data,
306 const float xmin = rect->
xmin;
307 const float xmax = rect->
xmax;
314 to_string(to_string_data, start, 0, text,
sizeof(text));
315 const float left_text_width =
BLF_width(font_id, text, strlen(text));
316 to_string(to_string_data, start +
steps * distance, 0, text,
sizeof(text));
317 const float right_text_width =
BLF_width(font_id, text, strlen(text));
318 const float max_text_width =
max_ff(left_text_width, right_text_width);
320 draw_frequency =
ceil(
float(
steps) / max_label_count);
323 if (draw_frequency != 0) {
324 const int start_index =
abs(
int(start / distance)) % draw_frequency;
325 for (
uint i = start_index; i <
steps; i += draw_frequency) {
326 const float xpos_view = start + i *
distance;
328 to_string(to_string_data, xpos_view, distance, text,
sizeof(text));
329 const float text_width =
BLF_width(font_id, text, strlen(text));
331 if (xpos_region - text_width / 2.0f >= xmin && xpos_region + text_width / 2.0f <= xmax) {
332 BLF_draw_default(xpos_region - text_width / 2.0f, ypos, 0.0f, text,
sizeof(text));
344 float display_offset,
347 void *to_string_data,
380 float shadow_color[4];
385 const float x_offset = 8.0f;
387 const float ymin = rect->
ymin;
388 const float ymax = rect->
ymax;
389 const float y_offset = (
BLF_height(font_id,
"0", 1) / 2.0f) -
U.pixelsize;
392 const float ypos_view = start + i *
distance;
395 to_string(to_string_data, ypos_view, distance, text,
sizeof(text));
397 if (ypos_region - y_offset >= ymin && ypos_region + y_offset <= ymax) {
410 void * ,
float v2d_pos,
float ,
char *r_str,
uint str_maxncpy)
416 void *user_data,
float v2d_pos,
float v2d_step,
char *r_str,
uint str_maxncpy)
418 const Scene *scene = (
const Scene *)user_data;
420 int brevity_level = -1;
426 r_str, str_maxncpy, brevity_level, v2d_pos /
float(
FPS),
FPS,
U.timecode_style);
430 void * ,
float v2d_pos,
float v2d_step,
char *r_str,
uint str_maxncpy)
432 if (v2d_step >= 1.0f) {
435 else if (v2d_step >= 0.1f) {
438 else if (v2d_step >= 0.01f) {
451 bool display_seconds)
453 if (display_seconds) {
471 v2d, major_line_distance, display_minor_lines && (major_line_distance > 1),
'v');
488 bool display_minor_lines)
492 v2d, major_line_distance, display_minor_lines && (major_line_distance > 1),
'v');
497 bool display_seconds,
498 bool display_minor_lines)
500 if (display_seconds) {
510 bool display_seconds)
512 if (display_seconds) {
574 bool display_seconds,
577 if (display_seconds) {
589 bool display_seconds,
592 if (display_seconds) {
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void BLF_shadow_offset(int fontid, int x, int y)
void BLF_batch_draw_begin()
void BLF_disable(int fontid, int option)
void BLF_batch_draw_end()
void BLF_enable(int fontid, int option)
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL()
MINLINE float max_ff(float a, float b)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
size_t BLI_snprintf(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
size_t BLI_timecode_string_from_time(char *str, size_t maxncpy, int brevity_level, float time_seconds, double fps, short timecode_style) ATTR_NONNULL()
void GPU_matrix_push_projection()
void GPU_matrix_pop_projection()
@ GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_viewport_size_get_f(float coords[4])
Read Guarded memory(de)allocation.
void UI_GetThemeColor3ubv(int colorid, unsigned char col[3])
void UI_GetThemeColor4fv(int colorid, float col[4])
void UI_FontThemeColor(int fontid, int colorid)
void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3])
float UI_view2d_region_to_view_y(const View2D *v2d, float y)
float UI_view2d_view_to_region_y(const View2D *v2d, float y)
void UI_view2d_view_ortho(const View2D *v2d)
float UI_view2d_scale_get_y(const View2D *v2d)
float UI_view2d_region_to_view_x(const View2D *v2d, float x)
float UI_view2d_view_to_region_x(const View2D *v2d, float x)
float UI_view2d_scale_get_x(const View2D *v2d)
void append(const T &value)
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
static const char * to_string(const Interpolation &interp)
ccl_device_inline float3 ceil(const float3 a)
float distance(float a, float b)
ccl_device_inline int abs(int x)
static void draw_vertical_scale_indicators(const ARegion *region, const View2D *v2d, float distance, float display_offset, const rcti *rect, PositionToString to_string, void *to_string_data, int colorid)
static void draw_horizontal_scale_indicators(const ARegion *region, const View2D *v2d, float distance, const rcti *rect, PositionToString to_string, void *to_string_data, int colorid)
float UI_view2d_grid_resolution_x__frames_or_seconds(const View2D *v2d, const Scene *scene, bool display_seconds)
void UI_view2d_draw_scale_x__discrete_frames_or_seconds(const ARegion *region, const View2D *v2d, const rcti *rect, const Scene *scene, bool display_seconds, int colorid)
void UI_view2d_draw_lines_x__values(const View2D *v2d)
static float select_major_distance(const float *possible_distances, uint amount, float pixel_width, float view_width)
void(*)(void *user_data, float v2d_pos, float v2d_step, char *r_str, uint str_maxncpy) PositionToString
static void UI_view2d_draw_scale_x__values(const ARegion *region, const View2D *v2d, const rcti *rect, int colorid)
#define MIN_MAJOR_LINE_DISTANCE
static void view_to_string__frame_number(void *, float v2d_pos, float, char *r_str, uint str_maxncpy)
void UI_view2d_draw_lines_x__frames_or_seconds(const View2D *v2d, const Scene *scene, bool display_seconds)
static float view2d_major_step_x__continuous(const View2D *v2d)
static void view2d_draw_lines(const View2D *v2d, float major_distance, bool display_minor_lines, char direction)
void UI_view2d_draw_scale_x__frames_or_seconds(const ARegion *region, const View2D *v2d, const rcti *rect, const Scene *scene, bool display_seconds, int colorid)
static void view_to_string__time(void *user_data, float v2d_pos, float v2d_step, char *r_str, uint str_maxncpy)
void UI_view2d_draw_lines_y__values(const View2D *v2d)
static const float discrete_value_scales[]
static float view2d_major_step_x__time(const View2D *v2d, const Scene *scene)
void UI_view2d_draw_lines_x__discrete_frames_or_seconds(const View2D *v2d, const Scene *scene, bool display_seconds, bool display_minor_lines)
void UI_view2d_draw_lines_x__discrete_values(const View2D *v2d, bool display_minor_lines)
void UI_view2d_draw_lines_x__discrete_time(const View2D *v2d, const Scene *scene, bool display_minor_lines)
float UI_view2d_grid_resolution_y__values(const View2D *v2d)
static void UI_view2d_draw_scale_x__discrete_time(const ARegion *region, const View2D *v2d, const rcti *rect, const Scene *scene, int colorid)
void UI_view2d_draw_scale_y__values(const ARegion *region, const View2D *v2d, const rcti *rect, int colorid)
static void view2d_draw_lines_internal(const View2D *v2d, const ParallelLinesSet *lines, const uchar color[3], char direction)
void UI_view2d_draw_scale_y__block(const ARegion *region, const View2D *v2d, const rcti *rect, int colorid)
static void UI_view2d_draw_scale_x__discrete_values(const ARegion *region, const View2D *v2d, const rcti *rect, int colorid)
static float view2d_major_step_y__continuous(const View2D *v2d)
static uint view2d_major_step_x__discrete(const View2D *v2d)
static void view_to_string__value(void *, float v2d_pos, float v2d_step, char *r_str, uint str_maxncpy)
static void draw_parallel_lines(const ParallelLinesSet *lines, const rctf *rect, const rcti *rect_mask, const uchar color[3], char direction)
static const float continuous_value_scales[]
static void get_parallel_lines_draw_steps(const ParallelLinesSet *lines, float region_start, float region_end, float *r_first, uint *r_steps)
void wmOrtho2_region_pixelspace(const ARegion *region)