56 #define SLIDE_PIXEL_DISTANCE (300.0f * U.dpi_fac)
57 #define OVERSHOOT_RANGE_DELTA 0.2f
92 const bool facing_right,
102 const float triangle_side_length = facing_right ? 6 *
U.pixelsize : -6 *
U.pixelsize;
103 const float triangle_offset = facing_right ? 2 *
U.pixelsize : -2 *
U.pixelsize;
106 immVertex2f(shdr_pos_2d,
x + triangle_offset + triangle_side_length,
y);
107 immVertex2f(shdr_pos_2d,
x + triangle_offset,
y + triangle_side_length / 2);
108 immVertex2f(shdr_pos_2d,
x + triangle_offset,
y - triangle_side_length / 2);
117 const float end_factor,
118 const float line_start[2],
119 const float base_tick_height,
120 const float line_width,
121 const uint8_t color_overshoot[4],
125 const int tick_increment = 10;
128 int tick_percentage =
ceil((start_factor * 100) / tick_increment) * tick_increment;
130 while (tick_percentage <= (
int)(end_factor * 100)) {
134 if (tick_percentage % 100 == 0) {
135 tick_height = base_tick_height;
137 else if (tick_percentage % 50 == 0) {
138 tick_height = base_tick_height * 0.8;
141 tick_height = base_tick_height * 0.5;
144 const float x = line_start[0] +
146 const rctf tick_rect = {
147 .
xmin =
x - (line_width / 2),
148 .xmax =
x + (line_width / 2),
149 .ymin = line_start[1] - (tick_height / 2),
150 .ymax = line_start[1] + (tick_height / 2),
153 if (tick_percentage < 0 || tick_percentage > 100) {
159 tick_percentage += tick_increment;
165 const bool overshoot,
166 const uint8_t color_overshoot[4],
171 const float line_zero_percent = main_line_rect->
xmin -
175 const float clamped_line_zero_percent =
clamp_f(
176 line_zero_percent, main_line_rect->
xmin, main_line_rect->
xmax);
177 const float clamped_line_hundred_percent =
clamp_f(
180 const rctf left_overshoot_line_rect = {
182 .xmax = clamped_line_zero_percent,
183 .ymin = main_line_rect->
ymin,
184 .ymax = main_line_rect->
ymax,
186 const rctf right_overshoot_line_rect = {
187 .
xmin = clamped_line_hundred_percent,
188 .xmax = main_line_rect->
xmax,
189 .ymin = main_line_rect->
ymin,
190 .ymax = main_line_rect->
ymax,
195 const rctf non_overshoot_line_rect = {
196 .
xmin = clamped_line_zero_percent,
197 .xmax = clamped_line_hundred_percent,
198 .ymin = main_line_rect->
ymin,
199 .ymax = main_line_rect->
ymax,
209 const rctf *main_line_rect,
211 const short region_y_size,
212 const float base_tick_height)
214 float string_pixel_size[2];
215 const char *percentage_string_placeholder =
"000%%";
217 percentage_string_placeholder,
218 sizeof(percentage_string_placeholder),
219 &string_pixel_size[0],
220 &string_pixel_size[1]);
221 const float pad[2] = {(region_y_size - base_tick_height) / 2, 2.0f *
U.pixelsize};
222 const rctf backdrop_rect = {
223 .
xmin = main_line_rect->
xmin - string_pixel_size[0] -
pad[0],
224 .xmax = main_line_rect->
xmax +
pad[0],
226 .ymax = region_y_size -
pad[1],
256 color_overshoot[0] = color_overshoot[0] * 0.8;
257 color_overshoot[1] = color_overshoot[1] * 0.8;
258 color_overshoot[2] = color_overshoot[2] * 0.8;
268 const float line_width = 1.5 *
U.pixelsize;
269 const float base_tick_height = 12.0 *
U.pixelsize;
270 const float line_y = region->
winy / 2;
272 rctf main_line_rect = {
275 .ymin = line_y - line_width / 2,
276 .ymax = line_y + line_width / 2,
278 float line_start_factor = 0;
285 handle_pos_x = region->
winx / 2;
293 const float line_start_position[2] = {main_line_rect.
xmin, line_y};
295 line_start_factor + factor_range,
313 char percentage_string[256];
316 const rctf handle_rect = {
317 .
xmin = handle_pos_x - (line_width),
318 .xmax = handle_pos_x + (line_width),
319 .ymin = line_y - (base_tick_height / 2),
320 .ymax = line_y + (base_tick_height / 2),
324 BLI_snprintf(percentage_string,
sizeof(percentage_string),
"%.0f%%", slider->
factor * 100);
327 float percentage_string_pixel_size[2];
330 sizeof(percentage_string),
331 &percentage_string_pixel_size[0],
332 &percentage_string_pixel_size[1]);
335 main_line_rect.
xmin - 24.0 *
U.pixelsize - percentage_string_pixel_size[0] / 2,
336 (region->
winy / 2) - percentage_string_pixel_size[1] / 2,
338 BLF_draw(fontid, percentage_string,
sizeof(percentage_string));
393 bool event_handled =
true;
395 switch (event->
type) {
415 event_handled =
false;
421 return event_handled;
426 const size_t size_of_status_string)
429 char overshoot_str[50];
430 char precision_str[50];
431 char increments_str[50];
435 STRNCPY(overshoot_str,
TIP_(
"[E] - Disable overshoot"));
438 STRNCPY(overshoot_str,
TIP_(
"[E] - Enable overshoot"));
442 STRNCPY(overshoot_str,
TIP_(
"Overshoot disabled"));
446 STRNCPY(precision_str,
TIP_(
"[Shift] - Precision active"));
449 STRNCPY(precision_str,
TIP_(
"Shift - Hold for precision"));
453 STRNCPY(increments_str,
TIP_(
"[Ctrl] - Increments active"));
456 STRNCPY(increments_str,
TIP_(
"Ctrl - Hold for 10% increments"));
460 size_of_status_string,
508 const float *mval_src = (
float *)arg_info;
509 const float mval_dst[2] = {
521 float viewport_size[4];
538 #define MAX_METADATA_STR 1024
565 if (
STREQ(field,
"BlenderMultiChannel")) {
570 if (
STREQ(field,
"type")) {
590 SNPRINTF(temp_str,
"%s: %s", field, value);
601 const float margin =
height / 8;
602 const float vertical_offset = (
height + margin);
606 const float xmin = (rect->
xmin + margin);
607 const float xmax = (rect->
xmax - margin);
608 const float ymin = (rect->
ymin + margin) - descender;
609 const float ymax = (rect->
ymax - margin) - descender;
612 for (
int i = 0; i < 4; i++) {
615 bool do_newline =
false;
618 BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
619 BLF_draw(fontid, temp_str,
sizeof(temp_str));
625 int line_width =
BLF_width(fontid, temp_str,
sizeof(temp_str));
626 BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
627 BLF_draw(fontid, temp_str,
sizeof(temp_str));
632 ofs_y += vertical_offset;
635 else if (
ELEM(i, 1, 2)) {
638 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
639 BLF_draw(fontid, temp_str,
sizeof(temp_str));
640 ofs_y += vertical_offset;
649 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
650 BLF_draw_ex(fontid, temp_str,
sizeof(temp_str), &info);
653 ofs_y += vertical_offset * info.
lines;
659 int line_width =
BLF_width(fontid, temp_str,
sizeof(temp_str));
660 BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
661 BLF_draw(fontid, temp_str,
sizeof(temp_str));
662 ofs_y += vertical_offset;
677 for (
int i = 5; i < 10; i++) {
681 BLF_draw(fontid, temp_str,
sizeof(temp_str));
705 const float margin = (
height / 8);
713 for (
int i = 2; i < 5; i++) {
736 for (
int i = 5; i < 10; i++) {
756 int x,
int y,
ImBuf *ibuf,
const rctf *frame,
float zoomx,
float zoomy)
827 #undef MAX_METADATA_STR
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct wmWindow * CTX_wm_window(const bContext *C)
bool BKE_stamp_is_known_field(const char *field_name)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_color3ubv(int fontid, const unsigned char rgb[3])
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
void BLF_boundbox_ex(int fontid, const char *str, size_t str_len, struct rcti *box, struct ResultBLF *r_info) ATTR_NONNULL(2)
void BLF_disable(int fontid, int option)
void BLF_rotation(int fontid, float angle)
void BLF_draw_ex(int fontid, const char *str, size_t str_len, struct ResultBLF *r_info) ATTR_NONNULL(2)
float BLF_width(int fontid, const char *str, size_t str_len) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void BLF_draw(int fontid, const char *str, size_t str_len) ATTR_NONNULL(2)
void BLF_enable(int fontid, int option)
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_size(int fontid, float size, int dpi)
void BLF_wordwrap(int fontid, int wrap_width)
void BLF_position(int fontid, float x, float y, float z)
#define LISTBASE_FOREACH(type, var, list)
MINLINE float clamp_f(float value, float min, float max)
MINLINE void copy_v2fl_v2i(float r[2], const int a[2])
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
#define STRNCPY(dst, src)
#define SNPRINTF(dst, format,...)
#define SNPRINTF_RLEN(dst, format,...)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void ED_area_status_text(ScrArea *area, const char *str)
void ED_region_tag_redraw(struct ARegion *region)
void ED_workspace_status_text(struct bContext *C, const char *str)
void * ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type)
#define REGION_DRAW_POST_PIXEL
bool ED_region_draw_cb_exit(struct ARegionType *art, void *handle)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void GPU_matrix_pop(void)
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_push(void)
void GPU_matrix_translate_2f(float x, float y)
@ GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_2D_UNIFORM_COLOR
void GPU_blend(eGPUBlend blend)
void GPU_line_width(float width)
void GPU_viewport_size_get_f(float coords[4])
void GPU_polygon_smooth(bool enable)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert a color
const struct uiStyle * UI_style_get_dpi(void)
const struct uiStyle * UI_style_get(void)
void UI_draw_roundbox_3ub_alpha(const struct rctf *rect, bool filled, float rad, const unsigned char col[3], unsigned char alpha)
void UI_FontThemeColor(int fontid, int colorid)
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
int pad[32 - sizeof(int)]
void ED_region_image_metadata_draw(int x, int y, ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
static void draw_backdrop(const int fontid, const rctf *main_line_rect, const uint8_t color_bg[4], const short region_y_size, const float base_tick_height)
struct MetadataCustomCountContext MetadataCustomCountContext
void ED_slider_allow_overshoot_set(struct tSlider *slider, const bool value)
static void metadata_custom_count_fields(const char *field, const char *UNUSED(value), void *ctx_v)
static void draw_overshoot_triangle(const uint8_t color[4], const bool facing_right, const float x, const float y)
static void draw_ticks(const float start_factor, const float end_factor, const float line_start[2], const float base_tick_height, const float line_width, const uint8_t color_overshoot[4], const uint8_t color_line[4])
static void metadata_custom_draw_fields(const char *field, const char *value, void *ctx_v)
static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top)
#define SLIDE_PIXEL_DISTANCE
float ED_slider_factor_get(struct tSlider *slider)
static const char * meta_data_list[]
BLI_INLINE bool metadata_is_custom_drawable(const char *field)
struct MetadataCustomDrawContext MetadataCustomDrawContext
static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
bool ED_slider_allow_overshoot_get(struct tSlider *slider)
static void slider_draw(const struct bContext *UNUSED(C), ARegion *region, void *arg)
void ED_slider_factor_set(struct tSlider *slider, const float factor)
static void draw_main_line(const rctf *main_line_rect, const float factor, const bool overshoot, const uint8_t color_overshoot[4], const uint8_t color_line[4])
BLI_INLINE bool metadata_is_valid(ImBuf *ibuf, char *r_str, short index, int offset)
bool ED_slider_modal(tSlider *slider, const wmEvent *event)
void ED_slider_destroy(struct bContext *C, tSlider *slider)
#define OVERSHOOT_RANGE_DELTA
void ED_slider_status_string_get(const struct tSlider *slider, char *status_string, const size_t size_of_status_string)
void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_info)
tSlider * ED_slider_create(struct bContext *C)
static void slider_update_factor(tSlider *slider, const wmEvent *event)
void ED_slider_init(struct tSlider *slider, const wmEvent *event)
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
ccl_device_inline float3 ceil(const float3 &a)
static struct PartialUpdateUser * wrap(PartialUpdateUserImpl *user)
struct ARegionType * type
struct IDProperty * metadata
struct ARegion * region_header
struct wmEvent * eventstate