80 butrct.
ymax +=
U.pixelsize;
83 butrct.
xmin -=
U.pixelsize;
116 const float max_radius = (0.5f *
U.widget_unit);
118 if (delta >= 0 && delta < max_radius) {
121 if (bt.rect.xmax == block->
rect.
xmax) {
122 bt.rect.xmax -= delta;
157 short dir1 = 0, dir2 = 0;
160 bool left =
false, right =
false, top =
false, down =
false;
163 if (butrct.
xmin - max_size[0] + center_x > 0.0f) {
166 if (butrct.
xmax + max_size[0] - center_x < win_size[0]) {
169 if (butrct.
ymin - max_size[1] + center_y > 0.0f) {
172 if (butrct.
ymax + max_size[1] - center_y < win_size[1]) {
176 if (top == 0 && down == 0) {
177 if (butrct.
ymin - max_size[1] < win_size[1] - butrct.
ymax - max_size[1]) {
246 float offset_x = 0, offset_y = 0;
249 const float offset_overlap =
max_ff(
U.pixelsize, 1.0f);
252 offset_x = (butrct.
xmin - block->
rect.
xmax) + offset_overlap;
261 offset_x = (butrct.
xmax - block->
rect.
xmin) - offset_overlap;
270 offset_y = (butrct.
ymax - block->
rect.
ymin) - offset_overlap;
290 offset_y = (butrct.
ymin - block->
rect.
ymax) + offset_overlap;
336 if (midx < block->rect.xmin) {
351 if (midy < block->rect.ymin) {
366 if (dir1 && (dir1 & block->
direction) == 0) {
377 const bool off_screen_left = (block->
rect.
xmin < 0);
378 const bool off_screen_right = (block->
rect.
xmax > win_size[0]);
380 if (fully_aligned_with_button) {
384 else if (off_screen_left || off_screen_right) {
394 block->
direction = no_2nd_dir ? dir1 : (dir1 | dir2);
398 SafetyRect *saferct = MEM_new<SafetyRect>(__func__);
401 block->
saferct.free_no_destruct();
431 if (handle_ctx_area) {
434 if (handle_ctx_region) {
480 const float xmin_orig = block->
rect.
xmin;
490 if (block->
rect.
xmax > win_size[0] - margin) {
491 const float xofs = win_size[0] - margin - block->
rect.
xmax;
497 const float xofs = (margin - block->
rect.
xmin);
506 const float xofs = block->
rect.
xmin - xmin_orig;
508 bt.rect.xmin += xofs;
509 bt.rect.xmax += xofs;
533 if (bt.rect.ymax < block->
rect.
ymin) {
536 if (bt.rect.ymin > block->
rect.
ymax) {
604 if (!panel || dy == 0.0f) {
635 MEM_delete(
state.idname);
654 popup_states.
add_new(std::make_unique<PopupLayoutPanelStates>(idname));
673 block->
panel = panel;
689 handle->
refresh = (block_old !=
nullptr);
701 block = create_func(
C, region, arg);
704 block = handle_create_func(
C, handle, arg);
744 if (but ==
nullptr) {
774 SafetyRect *saferct = MEM_new<SafetyRect>(__func__);
790 x_offset += win_width - block->
rect.
xmin;
792 if (block->
rect.
xmax > win_size[0] - win_width) {
793 x_offset += win_size[0] - win_width - block->
rect.
xmax;
800 y_offset += win_width - block->
rect.
ymin;
802 if (block->
rect.
ymax > win_size[1] - win_width) {
803 y_offset += win_size[1] - win_width - block->
rect.
ymax;
808 if ((x_offset != 0) || (y_offset != 0)) {
809 block->
pie_data->pie_center_spawned[0] += x_offset;
810 block->
pie_data->pie_center_spawned[1] += y_offset;
814 if (
U.pie_initial_timeout > 0) {
827 if (
U.pie_animation_timeout > 0) {
839 const float unit_size =
U.widget_unit / block->
aspect;
873 ymin =
min_ff(ymin, bt.rect.ymin);
874 ymax =
max_ff(ymax, bt.rect.ymax);
931 const bool can_refresh)
998 ARegion *region_popup_prev =
nullptr;
1025 bool is_submenu =
false;
1030 if (region !=
nullptr) {
1060#ifdef WITH_INPUT_IME
1102 const int max_width = int((
data->compact ? 250.0f : 350.0f) *
UI_SCALE_FAC);
1112 if (
data->mouse_move_quit) {
1125 for (
auto &st_ref : messages) {
1126 const std::string &st = st_ref;
1127 text_width = std::max(text_width,
1131 int dialog_width = std::max(text_width +
int(style->
columnspace * 2.5), min_width);
1144 for (
auto &st : messages) {
1145 content.
label(st, ICON_NONE);
1148 if (
data->okay_button) {
1155 const float pad = std::max((1.0f - ((200.0f *
UI_SCALE_FAC) /
float(text_width))) / 2.0f,
1164 buttons_block,
ButtonType::But,
"OK", 0, 0, 0,
UI_UNIT_Y,
nullptr, 0, 0,
"");
1171 if (
data->mouse_move_quit) {
1172 const float button_center_x = -0.5f;
1173 const float button_center_y =
data->okay_button ? 4.0f : 2.0f;
1174 const int bounds_offset[2] = {int(button_center_x * layout.
width()),
1192 data->title = title;
1193 data->message = message;
1195 data->compact = compact;
1196 data->okay_button =
true;
1197 data->mouse_move_quit = compact;
Read Blender memory allocation and freeing.
int pad[32 - sizeof(int)]
const Key & lookup_key_as(const ForwardKey &key) const
bool contains_as(const ForwardKey &key) const
void add_new(const Key &key)
#define UI_POPUP_MENU_TOP
#define UI_MENU_SUBMENU_PADDING
#define UI_MENU_SCROLL_MOUSE
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Block * popup_block_refresh(bContext *C, PopupBlockHandle *handle, ARegion *butregion, Button *but)
void layout_panel_popup_scroll_apply(Panel *panel, const float dy)
void popup_block_close(bContext *C, wmWindow *win, Block *block)
@ BLOCK_THEME_STYLE_POPUP
bool button_menu_draw_as_popover(const Button *but)
static void block_region_draw(const bContext *C, ARegion *region)
void button_func_set(Button *but, std::function< void(bContext &)> func)
static Block * alert_create(bContext *C, ARegion *region, void *user_data)
void block_translate(Block *block, float x, float y)
void popup_block_ex(bContext *C, BlockCreateFunc func, BlockHandleFunc popup_func, BlockCancelFunc cancel_func, void *arg, wmOperator *op)
static void alert_cancel(bContext *, void *user_data)
void popup_block_free(bContext *C, PopupBlockHandle *handle)
void block_update_from_old(const bContext *C, Block *block)
void popup_block_scrolltest(Block *block)
void(*)(void *arg) FreeArgFunc
void region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
void fontstyle_set(const uiFontStyle *fs)
@ BLOCK_CONTAINS_SUBMENU_BUT
void block_end_ex(const bContext *C, Main *bmain, wmWindow *window, Scene *scene, ARegion *region, Depsgraph *depsgraph, Block *block, const int xy[2]=nullptr, int r_xy[2]=nullptr, bool postpone_callbacks=false)
void block_flag_enable(Block *block, int flag)
Layout * uiItemsAlertBox(Block *block, const uiStyle *style, const int dialog_width, const AlertIcon icon, const int icon_size)
bool block_is_menu(const Block *block) ATTR_WARN_UNUSED_RESULT
const uiStyle * style_get_dpi()
@ BLOCK_NO_ACCELERATOR_KEYS
ARegion * region_temp_add(bScreen *screen)
void alert(bContext *C, StringRef title, StringRef message, AlertIcon icon, bool compact)
void button_flag_enable(Button *but, int64_t flag)
Block * block_begin(const bContext *C, ARegion *region, std::string name, EmbossType emboss)
Button * uiDefBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< StringRef > tip)
void block_to_window_rctf(const ARegion *region, const Block *block, rctf *rct_dst, const rctf *rct_src)
Block *(*)(bContext *C, ARegion *region, void *arg1) BlockCreateFunc
static void block_region_refresh(const bContext *C, ARegion *region)
void block_theme_style_set(Block *block, char theme_style)
ListBaseT< LayoutPanelState > & popup_persistent_layout_panel_states(StringRef idname)
void blocklist_free_inactive(const bContext *C, ARegion *region)
Block *(*)(bContext *C, PopupBlockHandle *handle, void *arg1) BlockHandleCreateFunc
static void popup_block_position(wmWindow *window, ARegion *butregion, Button *but, Block *block)
void popup_menu_retval_set(const Block *block, int retval, bool enable)
PopupBlockHandle * popup_block_create(bContext *C, ARegion *butregion, Button *but, BlockCreateFunc create_func, BlockHandleCreateFunc handle_create_func, void *arg, FreeArgFunc arg_free, bool can_refresh)
void button_tooltip_timer_remove(bContext *C, Button *but)
void block_emboss_set(Block *block, EmbossType emboss)
void block_func_set(Block *block, ButtonHandleFunc func, void *arg1, void *arg2)
void block_flag_disable(Block *block, int flag)
Button * uiItemL_ex(Layout *layout, StringRef name, int icon, bool highlight, bool redalert)
void block_draw(const bContext *C, Block *block)
float block_calc_pie_segment(Block *block, const float event_xy[2])
static void block_region_popup_window_listener(const wmRegionListenerParams *params)
void block_bounds_set_popup(Block *block, int addval, const int bounds_offset[2])
static void alert_ok_cb(bContext *C, void *arg1, void *arg2)
static void alert_ok(bContext *, void *arg, int)
Button * context_active_but_get(const bContext *C)
@ BLOCK_BOUNDS_POPUP_CENTER
void popup_dummy_panel_set(ARegion *region, Block *block, StringRef idname)
void popup_translate(ARegion *region, const int mdiff[2])
void region_handlers_add(ListBaseT< wmEventHandler > *handlers)
void block_bounds_set_centered(Block *block, int addval)
void button_update(Button *but)
static void popup_block_clip(wmWindow *window, Block *block)
static void popup_block_remove(bContext *C, PopupBlockHandle *handle)
MINLINE float min_ff(float a, float b)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ScrArea * CTX_wm_area(const bContext *C)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
uint padding(uint offset, uint alignment)
void ED_region_update_rect(ARegion *region)
Panel * BKE_panel_new(PanelType *panel_type)
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void void void void void void BLI_duplicatelist(ListBase *dst, const ListBase *src) ATTR_NONNULL(1
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
MINLINE void copy_v2_v2(float r[2], const float a[2])
void CTX_wm_window_set(bContext *C, wmWindow *win)
wmWindow * CTX_wm_window(const bContext *C)
void ED_region_tag_redraw(ARegion *region)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
void ED_region_tag_refresh_ui(ARegion *region)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
BMesh const char void * data
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
wmWindowManager * CTX_wm_manager(const bContext *C)
VectorSet< T, InlineBufferCapacity, DefaultProbingStrategy, CustomIDHash< T, GetIDFn >, CustomIDEqual< T, GetIDFn > > CustomIDVectorSet
void BLI_rcti_translate(struct rcti *rect, int x, int y)
void BLI_rctf_init_minmax(struct rctf *rect)
Vector< StringRef > BLF_string_wrap(int fontid, StringRef str, const int max_pixel_width, BLFWrapMode mode=BLFWrapMode::Minimal)
void ED_region_floating_init(ARegion *region)
void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
void BKE_panel_free(Panel *panel)
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
Main * CTX_data_main(const bContext *C)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
int2 WM_window_native_pixel_size(const wmWindow *win)
MINLINE float max_ff(float a, float b)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
ARegion * CTX_wm_region_popup(const bContext *C)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
void wmGetProjectionMatrix(float mat[4][4], const rcti *winrct)
Scene * CTX_data_scene(const bContext *C)
bScreen * CTX_wm_screen(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
void WM_cursor_set(wmWindow *win, int curs)
void WM_event_timer_remove(wmWindowManager *wm, wmWindow *, wmTimer *timer)
bScreen * WM_window_get_active_screen(const wmWindow *win)
void WM_window_dpi_set_userdef(const wmWindow *win)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
void CTX_wm_area_set(bContext *C, ScrArea *area)
void(*) draw(const bContext *C, ARegion *region)
void(*) listener(const wmRegionListenerParams *params)
void(*) layout(const bContext *C, ARegion *region)
bke::ARegionRuntime * runtime
Vector< LayoutPanelBody > bodies
Vector< LayoutPanelHeader > headers
LayoutPanels layout_panels
ListBaseT< LayoutPanelState > * layout_panel_states_storage
struct Panel_Runtime * runtime
ListBaseT< ARegion > regionbase
ListBaseT< wmEventHandler > handlers
ListBaseT< ui::Block > uiblocks
Panel * popup_block_panel
struct ARegionType * type
wmEvent * event_last_handled
ListBaseT< SafetyRect > saferct
Vector< std::unique_ptr< Button > > buttons_ptrs
BlockBoundsCalc bounds_type
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
std::unique_ptr< PieMenuData > pie_data
PopupBlockHandle * handle
void label(StringRef name, int icon)
Layout & split(float percentage, bool align)
Layout & column(bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void scale_y_set(float scale)
wmTimer * keep_open_timer
PopupBlockCreate popup_create_vars
ARegion * ctx_region_popup
const wmNotifier * notifier
bke::WindowRuntime * runtime