38#define MIN_MAJOR_LINE_DISTANCE (U.v2d_min_gridsize * UI_SCALE_FAC)
47 if (
IS_EQF(view_width, 0.0f)) {
48 return possible_distances[0];
51 const float pixels_per_view_unit = pixel_width / view_width;
53 for (
uint i = 0;
i < amount;
i++) {
54 const float distance = possible_distances[
i];
59 return possible_distances[amount - 1];
63 1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000};
66 5, 10, 20, 50, 100, 200, 500, 1000,
67 2000, 5000, 10000, 20000, 50000, 100000};
95 const double fps =
FPS;
103 for (
int i = 0;
i <= 5;
i++) {
105 possible_distances.
append(fac * fps);
106 possible_distances.
append(fac * 2 * fps);
107 possible_distances.
append(fac * 5 * fps);
108 possible_distances.
append(fac * 10 * fps);
109 possible_distances.
append(fac * 30 * fps);
110 possible_distances.
append(fac * 60 * fps);
114 possible_distances.
size(),
135 if (region_start >= region_end) {
147 if (region_start <= *r_first && region_end >= *r_first) {
148 *r_steps = std::max(0.0f,
floorf((region_end - *r_first) / lines->
distance)) + 1;
160 const rcti *rect_mask,
161 const uchar color[3],
167 if (direction ==
'v') {
190 if (
U.pixelsize > 1.0f) {
206 if (direction ==
'v') {
208 const float xpos = first +
i * lines->
distance;
215 const float ypos = first +
i * lines->
distance;
227 const uchar color[3],
237 float major_distance,
238 bool display_minor_lines,
242 uchar major_color[3];
245 major_lines.
distance = major_distance;
250 if (display_minor_lines) {
251 uchar minor_color[3];
254 minor_lines.
distance = major_distance;
255 minor_lines.
offset = major_distance / 2.0f;
264 void (*)(
void *user_data,
float v2d_pos,
float v2d_step,
char *r_str,
uint str_maxncpy);
271 void *to_string_data,
304 const float xmin = rect->
xmin;
305 const float xmax = rect->
xmax;
312 to_string(to_string_data, start, 0, text,
sizeof(text));
313 const float left_text_width =
BLF_width(font_id, text, strlen(text));
315 const float right_text_width =
BLF_width(font_id, text, strlen(text));
316 const float max_text_width =
max_ff(left_text_width, right_text_width);
318 draw_frequency =
ceil(
float(
steps) / max_label_count);
321 if (draw_frequency != 0) {
322 const int start_index =
abs(
int(start /
distance)) % draw_frequency;
323 for (
uint i = start_index;
i <
steps;
i += draw_frequency) {
324 const float xpos_view = start +
i *
distance;
327 const float text_width =
BLF_width(font_id, text, strlen(text));
329 if (xpos_region - text_width / 2.0f >= xmin && xpos_region + text_width / 2.0f <= xmax) {
331 xpos_region - std::trunc(text_width / 2.0f), ypos, 0.0f, text,
sizeof(text));
343 float display_offset,
346 void *to_string_data,
379 float shadow_color[4];
384 const float x_offset = 8.0f;
386 const float ymin = rect->
ymin;
387 const float ymax = rect->
ymax;
388 const float y_offset = (
BLF_height(font_id,
"0", 1) / 2.0f) -
U.pixelsize;
391 const float ypos_view = start +
i *
distance;
396 if (ypos_region - y_offset >= ymin && ypos_region + y_offset <= ymax) {
409 void * ,
float v2d_pos,
float ,
char *r_str,
uint str_maxncpy)
415 void *user_data,
float v2d_pos,
float v2d_step,
char *r_str,
uint str_maxncpy)
417 const Scene *scene = (
const Scene *)user_data;
419 int brevity_level = -1;
425 r_str, str_maxncpy, brevity_level, v2d_pos /
float(
FPS),
FPS,
U.timecode_style);
429 void * ,
float v2d_pos,
float v2d_step,
char *r_str,
uint str_maxncpy)
431 if (v2d_step >= 1.0f) {
434 else if (v2d_step >= 0.1f) {
437 else if (v2d_step >= 0.01f) {
450 bool display_seconds)
452 if (display_seconds) {
470 v2d, major_line_distance, display_minor_lines && (major_line_distance > 1),
'v');
487 bool display_minor_lines)
491 v2d, major_line_distance, display_minor_lines && (major_line_distance > 1),
'v');
496 bool display_seconds,
497 bool display_minor_lines)
499 if (display_seconds) {
509 bool display_seconds)
511 if (display_seconds) {
573 bool display_seconds,
576 if (display_seconds) {
588 bool display_seconds,
591 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])
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)
static const char * to_string(const Interpolation &interp)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float distance(VecOp< float, D >, VecOp< float, D >) RET
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)