Blender V5.0
ed_draw.cc File Reference
#include <cmath>
#include <cstdlib>
#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_listbase.h"
#include "BLI_math_vector.h"
#include "BLI_rect.h"
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BLT_translation.hh"
#include "BKE_context.hh"
#include "BKE_global.hh"
#include "BKE_image.hh"
#include "BKE_screen.hh"
#include "BLF_api.hh"
#include "IMB_imbuf_types.hh"
#include "IMB_metadata.hh"
#include "ED_screen.hh"
#include "ED_space_api.hh"
#include "ED_util.hh"
#include "GPU_immediate.hh"
#include "GPU_matrix.hh"
#include "GPU_state.hh"
#include "UI_interface.hh"
#include "UI_resources.hh"
#include "WM_api.hh"
#include "WM_types.hh"

Go to the source code of this file.

Classes

struct  tSlider
struct  MetadataCustomDrawContext
struct  MetadataCustomCountContext

Macros

#define MAX_METADATA_STR   1024

Functions

void ED_region_draw_mouse_line_cb (const bContext *C, ARegion *region, void *arg_info)
BLI_INLINE bool metadata_is_valid (const ImBuf *ibuf, char *r_str, short index, int offset)
BLI_INLINE bool metadata_is_custom_drawable (const char *field)
static void metadata_custom_draw_fields (const char *field, const char *value, void *ctx_v)
static void metadata_draw_imbuf (const ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
static void metadata_custom_count_fields (const char *field, const char *, void *ctx_v)
static float metadata_box_height_get (const ImBuf *ibuf, 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_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)
void ED_region_image_render_region_draw (int x, int y, const rcti *frame, float zoomx, float zoomy, float passepartout_alpha)
void ED_region_image_metadata_draw (int x, int y, const ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)

Variables

static const char * meta_data_list []

Generic Slider

The generic slider is supposed to be called during modal operations. It calculates a factor value based on mouse position and draws a visual representation. In order to use it, you need to store a reference to a tSlider in your operator which you get by calling ED_slider_create. Then you need to update it during modal operations by calling ED_slider_modal", which will update tSlider.factor for you to use. To remove drawing and free the memory, call ED_slider_destroy.

#define SLIDE_PIXEL_DISTANCE   (300.0f * UI_SCALE_FAC)
#define OVERSHOOT_RANGE_DELTA   0.2f
#define SLIDER_UNIT_STRING_SIZE   64
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 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])
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)
static void slider_draw (const bContext *, ARegion *region, void *arg)
static void slider_update_factor (tSlider *slider, const wmEvent *event)
tSliderED_slider_create (bContext *C)
void ED_slider_init (tSlider *slider, const wmEvent *event)
bool ED_slider_modal (tSlider *slider, const wmEvent *event)
void ED_slider_status_string_get (const tSlider *slider, char *status_string, const size_t size_of_status_string)
void ED_slider_status_get (const tSlider *slider, WorkspaceStatus &status)
void ED_slider_destroy (bContext *C, tSlider *slider)
float ED_slider_factor_get (const tSlider *slider)
void ED_slider_factor_set (tSlider *slider, const float factor)
void ED_slider_increment_step_set (tSlider *slider, const float increment_step)
void ED_slider_allow_overshoot_set (tSlider *slider, const bool lower, const bool upper)
bool ED_slider_allow_increments_get (const tSlider *slider)
void ED_slider_allow_increments_set (tSlider *slider, const bool value)
void ED_slider_factor_bounds_set (tSlider *slider, float factor_bound_lower, float factor_bound_upper)
void ED_slider_mode_set (tSlider *slider, SliderMode mode)
SliderMode ED_slider_mode_get (const tSlider *slider)
void ED_slider_unit_set (tSlider *slider, const char *unit)
void ED_slider_property_label_set (tSlider *slider, const char *property_label)

Macro Definition Documentation

◆ MAX_METADATA_STR

#define MAX_METADATA_STR   1024

◆ OVERSHOOT_RANGE_DELTA

#define OVERSHOOT_RANGE_DELTA   0.2f

Definition at line 59 of file ed_draw.cc.

Referenced by draw_main_line(), and slider_draw().

◆ SLIDE_PIXEL_DISTANCE

#define SLIDE_PIXEL_DISTANCE   (300.0f * UI_SCALE_FAC)

Definition at line 58 of file ed_draw.cc.

Referenced by draw_main_line(), draw_ticks(), slider_draw(), and slider_update_factor().

◆ SLIDER_UNIT_STRING_SIZE

#define SLIDER_UNIT_STRING_SIZE   64

Definition at line 60 of file ed_draw.cc.

Function Documentation

◆ draw_backdrop()

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 )
static

◆ draw_main_line()

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] )
static

◆ draw_overshoot_triangle()

void draw_overshoot_triangle ( const uint8_t color[4],
const bool facing_right,
const float x,
const float y )
static

◆ draw_ticks()

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

Definition at line 143 of file ed_draw.cc.

References ceil, float, SLIDE_PIXEL_DISTANCE, UI_draw_roundbox_3ub_alpha(), x, and rctf::xmin.

Referenced by slider_draw().

◆ ED_region_draw_mouse_line_cb()

◆ ED_region_image_metadata_draw()

◆ ED_region_image_overlay_info_text_draw()

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 )

◆ ED_region_image_render_region_draw()

◆ ED_slider_allow_increments_get()

bool ED_slider_allow_increments_get ( const tSlider * slider)

Definition at line 622 of file ed_draw.cc.

References tSlider::allow_increments.

◆ ED_slider_allow_increments_set()

void ED_slider_allow_increments_set ( tSlider * slider,
const bool value )

Definition at line 627 of file ed_draw.cc.

References tSlider::allow_increments.

Referenced by poselib_blend_init_data().

◆ ED_slider_allow_overshoot_set()

void ED_slider_allow_overshoot_set ( tSlider * slider,
bool lower,
bool upper )

One bool value for each side of the slider. Allows to enable overshoot only on one side.

Definition at line 616 of file ed_draw.cc.

References tSlider::allow_overshoot_lower, and tSlider::allow_overshoot_upper.

Referenced by blend_to_ease_invoke(), btw_smooth_invoke(), decimate_invoke(), ease_invoke(), ease_modal(), gaussian_smooth_invoke(), match_slope_invoke(), and poselib_blend_init_data().

◆ ED_slider_create()

◆ ED_slider_destroy()

◆ ED_slider_factor_bounds_set()

void ED_slider_factor_bounds_set ( tSlider * slider,
float factor_bound_lower,
float factor_bound_upper )

◆ ED_slider_factor_get()

◆ ED_slider_factor_set()

◆ ED_slider_increment_step_set()

void ED_slider_increment_step_set ( tSlider * slider,
float increment_step )

By default the increment step is 0.1, which depending on the factor bounds might not be desired. Only has an effect if increment is allowed and enabled. See ED_slider_allow_increments_set.

Parameters
increment_stepcannot be 0.

Definition at line 606 of file ed_draw.cc.

References BLI_assert_unreachable, and tSlider::increment_step.

Referenced by btw_smooth_invoke(), and time_offset_invoke().

◆ ED_slider_init()

void ED_slider_init ( tSlider * slider,
const wmEvent * event )

For modal operations so the percentage doesn't pop on the first mouse movement.

Definition at line 477 of file ed_draw.cc.

References copy_v2fl_v2i(), tSlider::last_cursor, and wmEvent::xy.

Referenced by graph_slider_invoke(), pose_slide_invoke_common(), and poselib_blend_init_data().

◆ ED_slider_modal()

◆ ED_slider_mode_get()

SliderMode ED_slider_mode_get ( const tSlider * slider)

Definition at line 645 of file ed_draw.cc.

References tSlider::slider_mode.

Referenced by graph_slider_modal().

◆ ED_slider_mode_set()

void ED_slider_mode_set ( tSlider * slider,
SliderMode mode )

Definition at line 640 of file ed_draw.cc.

References tSlider::slider_mode.

Referenced by btw_smooth_invoke(), ease_modal(), and time_offset_invoke().

◆ ED_slider_property_label_set()

void ED_slider_property_label_set ( tSlider * slider,
const char * property_label )

Definition at line 655 of file ed_draw.cc.

References tSlider::property_label.

Referenced by ease_invoke(), graph_slider_modal(), and pose_slide_draw_status().

◆ ED_slider_status_get()

◆ ED_slider_status_string_get()

void ED_slider_status_string_get ( const tSlider * slider,
char * status_string,
size_t size_of_status_string )

◆ ED_slider_unit_set()

void ED_slider_unit_set ( tSlider * slider,
const char * unit )

Definition at line 650 of file ed_draw.cc.

References STRNCPY_UTF8, and tSlider::unit_string.

Referenced by btw_smooth_invoke(), ease_modal(), and time_offset_invoke().

◆ metadata_box_height_get()

◆ metadata_custom_count_fields()

void metadata_custom_count_fields ( const char * field,
const char * ,
void * ctx_v )
static

◆ metadata_custom_draw_fields()

◆ metadata_draw_imbuf()

◆ metadata_is_custom_drawable()

BLI_INLINE bool metadata_is_custom_drawable ( const char * field)

◆ metadata_is_valid()

BLI_INLINE bool metadata_is_valid ( const ImBuf * ibuf,
char * r_str,
short index,
int offset )

◆ slider_draw()

◆ slider_update_factor()

◆ text_info_row()

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 )
static

Variable Documentation

◆ meta_data_list

const char* meta_data_list[]
static
Initial value:
= {
"File",
"Strip",
"Date",
"RenderTime",
"Note",
"Marker",
"Time",
"Frame",
"Camera",
"Scene",
}

Definition at line 697 of file ed_draw.cc.

Referenced by metadata_draw_imbuf(), and metadata_is_valid().