58#define SLIDE_PIXEL_DISTANCE (300.0f * UI_SCALE_FAC)
59#define OVERSHOOT_RANGE_DELTA 0.2f
60#define SLIDER_UNIT_STRING_SIZE 64
119 const bool facing_right,
129 const float triangle_side_length = facing_right ? 6 *
U.pixelsize : -6 *
U.pixelsize;
130 const float triangle_offset = facing_right ? 2 *
U.pixelsize : -2 *
U.pixelsize;
133 immVertex2f(shdr_pos_2d,
x + triangle_offset + triangle_side_length,
y);
134 immVertex2f(shdr_pos_2d,
x + triangle_offset,
y + triangle_side_length / 2);
135 immVertex2f(shdr_pos_2d,
x + triangle_offset,
y - triangle_side_length / 2);
144 const float end_factor,
145 const float line_start[2],
146 const float base_tick_height,
147 const float line_width,
148 const uint8_t color_overshoot[4],
149 const uint8_t color_line[4])
152 const int tick_increment = 10;
155 int tick_percentage =
ceil((start_factor * 100) / tick_increment) * tick_increment;
157 while (tick_percentage <=
int(end_factor * 100)) {
161 if (tick_percentage % 100 == 0) {
162 tick_height = base_tick_height;
164 else if (tick_percentage % 50 == 0) {
165 tick_height = base_tick_height * 0.8;
168 tick_height = base_tick_height * 0.5;
171 const float x = line_start[0] +
174 tick_rect.
xmin =
x - (line_width / 2);
175 tick_rect.xmax =
x + (line_width / 2);
176 tick_rect.ymin = line_start[1] - (tick_height / 2);
177 tick_rect.ymax = line_start[1] + (tick_height / 2);
179 if (tick_percentage < 0 || tick_percentage > 100) {
185 tick_percentage += tick_increment;
191 const bool overshoot,
192 const uint8_t color_overshoot[4],
193 const uint8_t color_line[4])
197 const float line_zero_percent = main_line_rect->
xmin -
201 const float clamped_line_zero_percent =
clamp_f(
202 line_zero_percent, main_line_rect->
xmin, main_line_rect->
xmax);
203 const float clamped_line_hundred_percent =
clamp_f(
206 rctf left_overshoot_line_rect{};
207 left_overshoot_line_rect.
xmin = main_line_rect->
xmin;
208 left_overshoot_line_rect.
xmax = clamped_line_zero_percent;
209 left_overshoot_line_rect.
ymin = main_line_rect->
ymin;
210 left_overshoot_line_rect.
ymax = main_line_rect->
ymax;
212 rctf right_overshoot_line_rect{};
213 right_overshoot_line_rect.
xmin = clamped_line_hundred_percent;
214 right_overshoot_line_rect.
xmax = main_line_rect->
xmax;
215 right_overshoot_line_rect.
ymin = main_line_rect->
ymin;
216 right_overshoot_line_rect.
ymax = main_line_rect->
ymax;
221 rctf non_overshoot_line_rect{};
222 non_overshoot_line_rect.
xmin = clamped_line_zero_percent;
223 non_overshoot_line_rect.
xmax = clamped_line_hundred_percent;
224 non_overshoot_line_rect.
ymin = main_line_rect->
ymin;
225 non_overshoot_line_rect.
ymax = main_line_rect->
ymax;
234 const rctf *main_line_rect,
235 const uint8_t color_bg[4],
236 const short region_y_size,
237 const float base_tick_height,
238 const std::string &property_label)
240 float percent_string_pixel_size[2];
241 const char *percentage_string_placeholder =
"000%%";
243 percentage_string_placeholder,
244 sizeof(percentage_string_placeholder),
245 &percent_string_pixel_size[0],
246 &percent_string_pixel_size[1]);
248 float property_name_pixel_size[2];
250 property_label.c_str(),
251 property_label.size(),
252 &property_name_pixel_size[0],
253 &property_name_pixel_size[1]);
254 const float pad[2] = {(region_y_size - base_tick_height) / 2 + 12.0f *
U.pixelsize,
256 rctf backdrop_rect{};
257 backdrop_rect.
xmin = main_line_rect->
xmin - property_name_pixel_size[0] -
pad[0];
258 backdrop_rect.
xmax = main_line_rect->
xmax + percent_string_pixel_size[0] +
pad[0];
260 backdrop_rect.
ymax = region_y_size -
pad[1];
276 uint8_t color_text[4];
277 uint8_t color_line[4];
278 uint8_t color_handle[4];
279 uint8_t color_overshoot[4];
289 color_overshoot[0] = color_overshoot[0] * 0.8;
290 color_overshoot[1] = color_overshoot[1] * 0.8;
291 color_overshoot[2] = color_overshoot[2] * 0.8;
301 const float line_width = 1.5 *
U.pixelsize;
302 const float base_tick_height = 12.0 *
U.pixelsize;
303 const float line_y = region->
winy / 2;
305 rctf main_line_rect{};
308 main_line_rect.
ymin = line_y - line_width / 2;
309 main_line_rect.
ymax = line_y + line_width / 2;
311 float line_start_factor = 0;
317 handle_pos_x = region->
winx / 2;
336 const float line_start_position[2] = {main_line_rect.
xmin, line_y};
338 line_start_factor + factor_range,
358 handle_rect.
xmin = handle_pos_x - (line_width);
359 handle_rect.
xmax = handle_pos_x + (line_width);
360 handle_rect.
ymin = line_y - (base_tick_height / 2);
361 handle_rect.
ymax = line_y + (base_tick_height / 2);
365 char factor_string[256];
376 float factor_string_pixel_size[2];
379 sizeof(factor_string),
380 &factor_string_pixel_size[0],
381 &factor_string_pixel_size[1]);
383 const float text_padding = 12.0 *
U.pixelsize;
384 const float factor_string_pos_x = main_line_rect.
xmax + text_padding;
386 fontid, factor_string_pos_x, (region->
winy / 2) - factor_string_pixel_size[1] / 2, 0.0f);
387 BLF_draw(fontid, factor_string,
sizeof(factor_string));
390 float property_name_pixel_size[2];
394 &property_name_pixel_size[0],
395 &property_name_pixel_size[1]);
397 main_line_rect.
xmin - text_padding - property_name_pixel_size[0],
398 (region->
winy / 2) - property_name_pixel_size[1] / 2,
409 const float factor_delta = (
event->xy[0] - slider->
last_cursor[0]) /
435 tSlider *slider = MEM_new<tSlider>(__func__);
484 bool event_handled =
true;
486 switch (event->
type) {
506 event_handled =
false;
512 return event_handled;
517 const size_t size_of_status_string)
520 char overshoot_str[50];
521 char precision_str[50];
522 char increments_str[50];
552 increments_str[0] =
'\0';
556 size_of_status_string,
608 if (increment_step == 0) {
633 float factor_bound_lower,
634 float factor_bound_upper)
665 const float *mval_src = (
float *)arg_info;
666 const float mval_dst[2] = {
678 float viewport_size[4];
695#define MAX_METADATA_STR 1024
722 if (
STREQ(field,
"BlenderMultiChannel")) {
727 if (
STREQ(field,
"type")) {
758 const float margin = height / 8;
759 const float vertical_offset = (height + margin);
763 const float xmin = (rect->
xmin + margin);
764 const float xmax = (rect->
xmax - margin);
765 const float ymin = (rect->
ymin + margin) - descender;
766 const float ymax = (rect->
ymax - margin) - descender;
769 for (
int i = 0;
i < 4;
i++) {
772 bool do_newline =
false;
775 BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
776 BLF_draw(fontid, temp_str,
sizeof(temp_str));
782 int line_width =
BLF_width(fontid, temp_str,
sizeof(temp_str));
783 BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
784 BLF_draw(fontid, temp_str,
sizeof(temp_str));
789 ofs_y += vertical_offset;
792 else if (
ELEM(
i, 1, 2)) {
795 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
796 BLF_draw(fontid, temp_str,
sizeof(temp_str));
797 ofs_y += vertical_offset;
806 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
807 BLF_draw(fontid, temp_str,
sizeof(temp_str), &info);
810 ofs_y += vertical_offset * info.
lines;
816 int line_width =
BLF_width(fontid, temp_str,
sizeof(temp_str));
817 BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
818 BLF_draw(fontid, temp_str,
sizeof(temp_str));
819 ofs_y += vertical_offset;
834 for (
int i = 5;
i < 10;
i++) {
838 BLF_draw(fontid, temp_str,
sizeof(temp_str));
862 const float margin = (height / 8);
870 for (
int i = 2;
i < 5;
i++) {
893 for (
int i = 5;
i < 10;
i++) {
906 return (height + margin) *
count;
927 const float shadow_color[4] = {0.0f, 0.0f, 0.0f, 0.8f};
937 BLF_draw(font_id, draw_text,
sizeof(draw_text));
943 const int render_size_y,
945 const int viewer_size_x,
946 const int viewer_size_y,
948 const int draw_offset_x,
949 const int draw_offset_y)
955 const char render_size_name[
MAX_NAME] =
"Render Size";
956 const char viewer_size_name[
MAX_NAME] =
"Image Size";
958 const int render_size_width =
BLF_width(font_id, render_size_name,
sizeof(render_size_name));
959 const int viewer_size_width =
BLF_width(font_id, viewer_size_name,
sizeof(viewer_size_name));
960 int longest_label =
max_ii(render_size_width, viewer_size_width);
962 int col1 = draw_offset_x;
963 int col2 = draw_offset_x + longest_label + (0.5 *
U.widget_unit);
966 sizeof(render_size_name),
969 draw_offset_y - overlay_lineheight,
974 sizeof(viewer_size_name),
977 draw_offset_y - overlay_lineheight * 2,
983 int x,
int y,
const rcti *frame,
float zoomx,
float zoomy,
float passepartout_alpha)
999 const float x1 = frame->
xmin - frame_width / 2;
1000 const float x2 = frame->
xmax - frame_width / 2;
1001 const float y1 = frame->
ymin - frame_height / 2;
1002 const float y2 = frame->
ymax - frame_height / 2;
1005 if (passepartout_alpha > 0) {
1008 constexpr float inf = 10e5;
1016 float wire_color[3];
1031 int x,
int y,
const ImBuf *ibuf,
const rctf *frame,
float zoomx,
float zoomy)
1102#undef MAX_METADATA_STR
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
bool BKE_stamp_is_known_field(const char *field_name)
void BLF_size(int fontid, float size)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_enable(int fontid, FontFlags flag)
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
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_color4fv(int fontid, const float rgba[4])
void BLF_shadow_offset(int fontid, int x, int y)
void BLF_boundbox(int fontid, const char *str, size_t str_len, rcti *r_box, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
void BLF_rotation(int fontid, float angle)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode=BLFWrapMode::Minimal)
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_disable(int fontid, FontFlags flag)
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
void BLF_position(int fontid, float x, float y, float z)
#define BLI_assert_unreachable()
#define LISTBASE_FOREACH(type, var, list)
MINLINE float max_ff(float a, float b)
MINLINE float clamp_f(float value, float min, float max)
MINLINE float min_ff(float a, float b)
MINLINE int max_ii(int a, int b)
MINLINE void copy_v2fl_v2i(float r[2], const int a[2])
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define SNPRINTF_UTF8(dst, format,...)
#define SNPRINTF_UTF8_RLEN(dst, format,...)
#define STRNCPY_UTF8(dst, src)
void ED_area_status_text(ScrArea *area, const char *str)
void ED_workspace_status_text(bContext *C, const char *str)
void ED_region_tag_redraw(ARegion *region)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
#define REGION_DRAW_POST_PIXEL
void GPU_matrix_scale_2f(float x, float y)
void GPU_matrix_translate_2f(float x, float y)
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
@ GPU_SHADER_3D_UNIFORM_COLOR
void GPU_line_width(float width)
void GPU_blend(GPUBlend blend)
void GPU_viewport_size_get_f(float coords[4])
void GPU_polygon_smooth(bool enable)
Read Guarded memory(de)allocation.
void UI_draw_roundbox_3ub_alpha(const rctf *rect, bool filled, float rad, const unsigned char col[3], unsigned char alpha)
const uiStyle * UI_style_get_dpi()
const uiStyle * UI_style_get()
void UI_GetThemeColor3fv(int colorid, float col[3])
void UI_GetThemeColor4fv(int colorid, float col[4])
void UI_FontThemeColor(int fontid, int colorid)
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
int pad[32 - sizeof(int)]
void ED_slider_allow_overshoot_set(tSlider *slider, const bool lower, const bool upper)
static void draw_overshoot_triangle(const uint8_t color[4], const bool facing_right, const float x, const float y)
static void metadata_draw_imbuf(const ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
static void text_info_row(const char *text, const int text_len, int col1, int col2, int row, const int size_x, const int size_y)
void ED_slider_init(tSlider *slider, const wmEvent *event)
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)
#define SLIDER_UNIT_STRING_SIZE
static void metadata_custom_count_fields(const char *field, const char *, void *ctx_v)
void ED_slider_factor_set(tSlider *slider, const float factor)
void ED_region_image_metadata_draw(int x, int y, const ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
SliderMode ED_slider_mode_get(const tSlider *slider)
void ED_slider_unit_set(tSlider *slider, const char *unit)
void ED_slider_mode_set(tSlider *slider, SliderMode mode)
void ED_slider_allow_increments_set(tSlider *slider, const bool value)
void ED_region_image_render_region_draw(int x, int y, const rcti *frame, float zoomx, float zoomy, float passepartout_alpha)
#define SLIDE_PIXEL_DISTANCE
void ED_slider_property_label_set(tSlider *slider, const char *property_label)
void ED_slider_destroy(bContext *C, tSlider *slider)
static const char * meta_data_list[]
BLI_INLINE bool metadata_is_custom_drawable(const char *field)
void ED_slider_increment_step_set(tSlider *slider, const float increment_step)
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])
tSlider * ED_slider_create(bContext *C)
void ED_region_image_overlay_info_text_draw(const int render_size_x, const int render_size_y, const int viewer_size_x, const int viewer_size_y, const int draw_offset_x, const int draw_offset_y)
bool ED_slider_modal(tSlider *slider, const wmEvent *event)
#define OVERSHOOT_RANGE_DELTA
void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status)
void ED_slider_factor_bounds_set(tSlider *slider, float factor_bound_lower, float factor_bound_upper)
bool ED_slider_allow_increments_get(const tSlider *slider)
static void slider_draw(const bContext *, ARegion *region, void *arg)
void ED_slider_status_string_get(const 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)
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, const std::string &property_label)
float ED_slider_factor_get(const tSlider *slider)
static float metadata_box_height_get(const ImBuf *ibuf, int fontid, const bool is_top)
BLI_INLINE bool metadata_is_valid(const ImBuf *ibuf, char *r_str, short index, int offset)
static void slider_update_factor(tSlider *slider, const wmEvent *event)
float wrap(float value, float max, float min)
ARegionRuntimeHandle * runtime
char unit_string[SLIDER_UNIT_STRING_SIZE]
bool allow_overshoot_upper
bool allow_overshoot_lower
std::string property_label
struct wmEvent * eventstate