62#define SLIDE_PIXEL_DISTANCE (300.0f * UI_SCALE_FAC)
63#define OVERSHOOT_RANGE_DELTA 0.2f
64#define SLIDER_UNIT_STRING_SIZE 64
123 const bool facing_right,
137 immVertex2f(shdr_pos_2d,
x + triangle_offset + triangle_side_length,
y);
138 immVertex2f(shdr_pos_2d,
x + triangle_offset,
y + triangle_side_length / 2);
139 immVertex2f(shdr_pos_2d,
x + triangle_offset,
y - triangle_side_length / 2);
148 const float end_factor,
149 const float line_start[2],
150 const float base_tick_height,
151 const float line_width,
152 const uint8_t color_overshoot[4],
156 const int tick_increment = 10;
159 int tick_percentage =
ceil((start_factor * 100) / tick_increment) * tick_increment;
161 while (tick_percentage <=
int(end_factor * 100)) {
165 if (tick_percentage % 100 == 0) {
166 tick_height = base_tick_height;
168 else if (tick_percentage % 50 == 0) {
169 tick_height = base_tick_height * 0.8;
172 tick_height = base_tick_height * 0.5;
175 const float x = line_start[0] +
178 tick_rect.
xmin =
x - (line_width / 2);
179 tick_rect.xmax =
x + (line_width / 2);
180 tick_rect.ymin = line_start[1] - (tick_height / 2);
181 tick_rect.ymax = line_start[1] + (tick_height / 2);
183 if (tick_percentage < 0 || tick_percentage > 100) {
189 tick_percentage += tick_increment;
195 const bool overshoot,
196 const uint8_t color_overshoot[4],
201 const float line_zero_percent = main_line_rect->
xmin -
205 const float clamped_line_zero_percent =
clamp_f(
206 line_zero_percent, main_line_rect->
xmin, main_line_rect->
xmax);
207 const float clamped_line_hundred_percent =
clamp_f(
210 rctf left_overshoot_line_rect{};
211 left_overshoot_line_rect.
xmin = main_line_rect->
xmin;
212 left_overshoot_line_rect.
xmax = clamped_line_zero_percent;
213 left_overshoot_line_rect.
ymin = main_line_rect->
ymin;
214 left_overshoot_line_rect.
ymax = main_line_rect->
ymax;
216 rctf right_overshoot_line_rect{};
217 right_overshoot_line_rect.
xmin = clamped_line_hundred_percent;
218 right_overshoot_line_rect.
xmax = main_line_rect->
xmax;
219 right_overshoot_line_rect.
ymin = main_line_rect->
ymin;
220 right_overshoot_line_rect.
ymax = main_line_rect->
ymax;
225 rctf non_overshoot_line_rect{};
226 non_overshoot_line_rect.
xmin = clamped_line_zero_percent;
227 non_overshoot_line_rect.
xmax = clamped_line_hundred_percent;
228 non_overshoot_line_rect.
ymin = main_line_rect->
ymin;
229 non_overshoot_line_rect.
ymax = main_line_rect->
ymax;
238 const rctf *main_line_rect,
240 const short region_y_size,
241 const float base_tick_height,
242 const std::string &property_label)
244 float percent_string_pixel_size[2];
245 const char *percentage_string_placeholder =
"000%%";
247 percentage_string_placeholder,
248 sizeof(percentage_string_placeholder),
249 &percent_string_pixel_size[0],
250 &percent_string_pixel_size[1]);
252 float property_name_pixel_size[2];
254 property_label.c_str(),
255 property_label.size(),
256 &property_name_pixel_size[0],
257 &property_name_pixel_size[1]);
258 const float pad[2] = {(region_y_size - base_tick_height) / 2 + 12.0f *
UI_SCALE_FAC,
260 rctf backdrop_rect{};
261 backdrop_rect.
xmin = main_line_rect->
xmin - property_name_pixel_size[0] -
pad[0];
262 backdrop_rect.
xmax = main_line_rect->
xmax + percent_string_pixel_size[0] +
pad[0];
264 backdrop_rect.
ymax = region_y_size -
pad[1];
294 color_overshoot[0] = color_overshoot[0] * 0.8;
295 color_overshoot[1] = color_overshoot[1] * 0.8;
296 color_overshoot[2] = color_overshoot[2] * 0.8;
308 const float line_y = region->
winy / 2;
310 rctf main_line_rect{};
313 main_line_rect.
ymin = line_y - line_width / 2;
314 main_line_rect.
ymax = line_y + line_width / 2;
316 float line_start_factor = 0;
322 handle_pos_x = region->
winx / 2;
341 const float line_start_position[2] = {main_line_rect.
xmin, line_y};
343 line_start_factor + factor_range,
363 handle_rect.
xmin = handle_pos_x - (line_width);
364 handle_rect.
xmax = handle_pos_x + (line_width);
365 handle_rect.
ymin = line_y - (base_tick_height / 2);
366 handle_rect.
ymax = line_y + (base_tick_height / 2);
370 char factor_string[256];
381 float factor_string_pixel_size[2];
384 sizeof(factor_string),
385 &factor_string_pixel_size[0],
386 &factor_string_pixel_size[1]);
389 const float factor_string_pos_x = main_line_rect.
xmax + text_padding;
391 fontid, factor_string_pos_x, (region->
winy / 2) - factor_string_pixel_size[1] / 2, 0.0f);
392 BLF_draw(fontid, factor_string,
sizeof(factor_string));
395 float property_name_pixel_size[2];
399 &property_name_pixel_size[0],
400 &property_name_pixel_size[1]);
402 main_line_rect.
xmin - text_padding - property_name_pixel_size[0],
403 (region->
winy / 2) - property_name_pixel_size[1] / 2,
414 const float factor_delta = (
event->xy[0] - slider->
last_cursor[0]) /
440 tSlider *slider = MEM_new<tSlider>(__func__);
494 bool event_handled =
true;
496 switch (event->
type) {
516 event_handled =
false;
522 return event_handled;
527 const size_t size_of_status_string)
530 char overshoot_str[50];
531 char precision_str[50];
532 char increments_str[50];
562 increments_str[0] =
'\0';
566 size_of_status_string,
579 status.
item(
IFACE_(
"Overshoot Disabled"), ICON_STATUS_INFO);
618 if (increment_step == 0) {
643 float factor_bound_lower,
644 float factor_bound_upper)
675 const float *mval_src =
static_cast<float *
>(arg_info);
676 const float mval_dst[2] = {
688 float viewport_size[4];
705#define MAX_METADATA_STR 1024
733 if (
STREQ(field,
"BlenderMultiChannel")) {
738 if (
STREQ(field,
"type")) {
769 const float margin = height / 8;
770 const float vertical_offset = (height + margin);
774 const float xmin = (rect->
xmin + margin);
775 const float xmax = (rect->
xmax - margin);
776 const float ymin = (rect->
ymin + margin) - descender;
777 const float ymax = (rect->
ymax - margin) - descender;
780 for (
int i = 0; i < 4; i++) {
783 bool do_newline =
false;
786 BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
787 BLF_draw(fontid, temp_str,
sizeof(temp_str));
793 int line_width =
BLF_width(fontid, temp_str,
sizeof(temp_str));
794 BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
795 BLF_draw(fontid, temp_str,
sizeof(temp_str));
800 ofs_y += vertical_offset;
803 else if (
ELEM(i, 1, 2)) {
806 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
807 BLF_draw(fontid, temp_str,
sizeof(temp_str));
808 ofs_y += vertical_offset;
817 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
818 BLF_draw(fontid, temp_str,
sizeof(temp_str), &info);
821 ofs_y += vertical_offset * info.
lines;
827 int line_width =
BLF_width(fontid, temp_str,
sizeof(temp_str));
828 BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
829 BLF_draw(fontid, temp_str,
sizeof(temp_str));
830 ofs_y += vertical_offset;
845 for (
int i = 5; i < 10; i++) {
849 BLF_draw(fontid, temp_str,
sizeof(temp_str));
873 const float margin = (height / 8);
881 for (
int i = 2; i < 5; i++) {
895 count +=
wrap.info.lines;
904 for (
int i = 5; i < 10; i++) {
917 return (height + margin) * count;
938 const float shadow_color[4] = {0.0f, 0.0f, 0.0f, 0.8f};
948 BLF_draw(font_id, draw_text,
sizeof(draw_text));
954 const int render_size_y,
955 const int viewer_size_x,
956 const int viewer_size_y,
957 const int draw_offset_x,
958 const int draw_offset_y)
969 int longest_label =
max_ii(render_size_width, viewer_size_width);
971 int col1 = draw_offset_x;
972 int col2 = draw_offset_x + longest_label + (0.5 *
U.widget_unit);
975 render_size_name.
size(),
978 draw_offset_y - overlay_lineheight,
983 viewer_size_name.
size(),
986 draw_offset_y - overlay_lineheight * 2,
992 int x,
int y,
const rcti *frame,
float zoomx,
float zoomy,
float passepartout_alpha)
1008 const float x1 = frame->
xmin - frame_width / 2;
1009 const float x2 = frame->
xmax - frame_width / 2;
1010 const float y1 = frame->
ymin - frame_height / 2;
1011 const float y2 = frame->
ymax - frame_height / 2;
1014 if (passepartout_alpha > 0) {
1017 constexpr float inf = 10e5;
1020 immRectf(pos, -inf, y1, inf, -inf);
1025 float wire_color[3];
1040 int x,
int y,
const ImBuf *ibuf,
const rctf *frame,
float zoomx,
float zoomy)
1115#define M_GOLDEN_RATIO_CONJUGATE 0.618033988749895f
1119 float x3, y3, x4, y4;
1123 x4 = rect.
xmin + (1.0f - fac) * (rect.
xmax - rect.
xmin);
1124 y4 = rect.
ymin + (1.0f - fac) * (rect.
ymax - rect.
ymin);
1199 const float color[4])
1259#undef MAX_METADATA_STR
#define SNPRINTF_UTF8(dst, format,...)
#define SNPRINTF_UTF8_RLEN(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define REGION_DRAW_POST_PIXEL
Read Blender memory allocation and freeing.
int pad[32 - sizeof(int)]
#define BLI_assert_unreachable()
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void item(std::string text, int icon1, int icon2=0)
void item_bool(std::string text, bool inverted, int icon1, int icon2=0)
constexpr int64_t size() const
constexpr const char * data() const
#define SLIDER_UNIT_STRING_SIZE
#define SLIDE_PIXEL_DISTANCE
#define OVERSHOOT_RANGE_DELTA
#define M_GOLDEN_RATIO_CONJUGATE
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
BLI_INLINE Texture * wrap(MTLTexture *texture)
void font_theme_color_set(int fontid, int colorid)
void get_color_4ubv(int colorid, unsigned char col[4])
void get_color_3fv(int colorid, float col[3])
void get_color_4fv(int colorid, float col[4])
const uiStyle * style_get()
const uiStyle * style_get_dpi()
void draw_roundbox_corner_set(int type)
void draw_roundbox_3ub_alpha(const rctf *rect, bool filled, float rad, const unsigned char col[3], unsigned char alpha)
MINLINE float min_ff(float a, float b)
static void drawviewborder_triangle(uint shdr_pos, rctf rect, const bool golden, const char dir)
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLF_boundbox(int fontid, const char *str, size_t str_len, rcti *r_box, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
bool ED_slider_modal(tSlider *slider, const wmEvent *event)
@ COMPOSITION_GUIDES_THIRDS
@ COMPOSITION_GUIDES_GOLDEN
@ COMPOSITION_GUIDES_CENTER_DIAG
@ COMPOSITION_GUIDES_HARMONY_TRI_B
@ COMPOSITION_GUIDES_GOLDEN_TRI_A
@ COMPOSITION_GUIDES_HARMONY_TRI_A
@ COMPOSITION_GUIDES_CENTER
@ COMPOSITION_GUIDES_GOLDEN_TRI_B
ScrArea * CTX_wm_area(const bContext *C)
static void metadata_custom_count_fields(const char *field, const char *, void *ctx_v)
bool BKE_stamp_is_known_field(const char *field_name)
void ED_slider_status_string_get(const tSlider *slider, char *status_string, size_t size_of_status_string)
void BLF_shadow_offset(int fontid, int x, int y)
void BLF_position(int fontid, float x, float y, float z)
void ED_draw_composition_guides(uint shdr_pos, eCompositionGuideFlags flag, const rctf *rect, const float color[4])
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
static void slider_update_factor(tSlider *slider, const wmEvent *event)
void GPU_polygon_smooth(bool enable)
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
void ED_slider_init(tSlider *slider, const wmEvent *event)
void immUniform2f(const char *name, float x, float y)
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode=BLFWrapMode::Minimal)
GPUVertFormat * immVertexFormat()
void ED_slider_factor_set(tSlider *slider, float factor)
float ED_slider_factor_get(const tSlider *slider)
void ED_region_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)
void immBegin(GPUPrimType, uint vertex_len)
void ED_slider_mode_set(tSlider *slider, SliderMode mode)
wmWindow * CTX_wm_window(const bContext *C)
MINLINE int max_ii(int a, int b)
void immUniformColor4fv(const float rgba[4])
void immUniformThemeColorAlpha(int color_id, float a)
void ED_region_tag_redraw(ARegion *region)
void BLF_disable(int fontid, FontFlags flag)
BLI_INLINE bool metadata_is_custom_drawable(const char *field)
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])
void GPU_line_width(float width)
BLI_INLINE bool metadata_is_valid(const ImBuf *ibuf, char *r_str, short index, int offset)
void GPU_matrix_scale_2f(float x, float y)
tSlider * ED_slider_create(bContext *C)
SliderMode ED_slider_mode_get(const tSlider *slider)
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 immBindBuiltinProgram(GPUBuiltinShader shader_id)
void ED_slider_allow_increments_set(tSlider *slider, bool value)
void BLF_size(int fontid, float size)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
static void draw_overshoot_triangle(const uint8_t color[4], const bool facing_right, const float x, const float y)
void immUniform1f(const char *name, float x)
void immVertex2f(uint attr_id, float x, float y)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void GPU_viewport_size_get_f(float coords[4])
void BLF_color3ubv(int fontid, const unsigned char rgb[3])
void ED_slider_unit_set(tSlider *slider, const char *unit)
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)
@ GPU_SHADER_3D_UNIFORM_COLOR
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
void immUniformThemeColor3(int color_id)
static void metadata_custom_draw_fields(const char *field, const char *value, void *ctx_v)
void immUniformColor4f(float r, float g, float b, float a)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
void ED_region_image_metadata_draw(int x, int y, const ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
void ED_area_status_text(ScrArea *area, const char *str)
void GPU_matrix_translate_2f(float x, float y)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void ED_slider_allow_overshoot_set(tSlider *slider, bool lower, bool upper)
static void drawviewborder_grid3(uint shdr_pos, rctf rect, float fac)
void ED_slider_factor_bounds_set(tSlider *slider, float factor_bound_lower, float factor_bound_upper)
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
static void slider_draw(const bContext *, ARegion *region, void *arg)
static void metadata_draw_imbuf(const ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
MINLINE float max_ff(float a, float b)
void IMB_metadata_foreach(const ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status)
bool IMB_metadata_get_field(const IDProperty *metadata, const char *key, char *value, size_t value_maxncpy)
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])
Scene * CTX_data_scene(const bContext *C)
void GPU_blend(GPUBlend blend)
void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_info)
void immUniform1i(const char *name, int x)
bool ED_slider_allow_increments_get(const tSlider *slider)
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
MINLINE void copy_v2fl_v2i(float r[2], const int a[2])
void immVertex2fv(uint attr_id, const float data[2])
void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a)
void BLF_rotation(int fontid, float angle)
void ED_slider_property_label_set(tSlider *slider, const char *property_label)
void ED_slider_increment_step_set(tSlider *slider, float increment_step)
void immRectf(uint pos, float x1, float y1, float x2, float y2)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
static float metadata_box_height_get(const ImBuf *ibuf, int fontid, const bool is_top)
void ED_slider_destroy(bContext *C, tSlider *slider)
void BLF_enable(int fontid, FontFlags flag)
void ED_region_render_region_draw(int x, int y, const rcti *frame, float zoomx, float zoomy, float passepartout_alpha)
void BLF_color4fv(int fontid, const float rgba[4])
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
MINLINE float clamp_f(float value, float min, float max)
static const char * meta_data_list[]
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ARegionRuntime * runtime
const IDProperty * metadata() const
ListBaseT< ARegion > regionbase
struct ARegionType * type
bool allow_overshoot_upper
bool allow_overshoot_lower
std::string property_label
char unit_string[SLIDER_UNIT_STRING_SIZE]
bke::WindowRuntime * runtime