78 printf(
"%s: cannot cycle button '%s'\n", __func__, but->
str.c_str());
98 str.substr(0, sep_index);
111 static uint mem[256];
112 static bool first =
true;
119 memset(mem, -1,
sizeof(mem));
130 for (
const std::unique_ptr<uiBut> &but_iter : block->
buttons) {
139 return but_iter.get();
295 int offset[2] = {0, 0};
297 uiBut *but_activate =
nullptr;
321 for (
const std::unique_ptr<uiBut> &but_iter : block->
buttons) {
322 offset[0] =
min_ii(offset[0],
328 for (
const std::unique_ptr<uiBut> &but_iter : block->
buttons) {
330 but_activate = but_iter.get();
395 const bool can_refresh)
409 status.
item(
IFACE_(
"Search"), ICON_EVENT_SPACEKEY);
423 handle->
popup =
true;
458 block,
UI_BTYPE_LABEL, 0, icon, titlestr, 0, 0, 200,
UI_UNIT_Y,
nullptr, 0.0, 0.0,
"");
462 block,
UI_BTYPE_LABEL, 0, title, 0, 0, 200,
UI_UNIT_Y,
nullptr, 0.0, 0.0,
"");
471 const char *block_name,
481 pup->
block->
handle = MEM_new<uiPopupBlockHandle>(__func__);
509 uiBut *but =
nullptr;
563 const char *msg, *msg_next;
565 if (report->type <
reports->printlevel) {
569 if (pup ==
nullptr) {
571 SNPRINTF(title,
"%s: %s",
RPT_(
"Report"), report->typestr);
581 msg = report->message;
585 msg_next = strchr(msg,
'\n');
588 BLI_strncpy(buf, msg, std::min(
sizeof(buf),
size_t(msg_next - msg)));
591 layout->
label(msg, icon);
593 }
while ((msg = msg_next) && *msg);
614 if (title && title[0]) {
625 status.
range(
IFACE_(
"Search"), ICON_EVENT_A, ICON_EVENT_Z);
628 status.
item(
IFACE_(
"Search"), ICON_EVENT_SPACEKEY);
647 const bool allow_refresh =
true;
676 C,
nullptr,
nullptr, func,
nullptr, arg, arg_free, can_refresh);
677 handle->
popup =
true;
681 status.
item(
" ", ICON_NONE);
704 C,
nullptr,
nullptr, func,
nullptr, arg,
nullptr,
true);
705 handle->
popup =
true;
716 status.
item(
" ", ICON_NONE);
729 if (handle ==
nullptr) {
730 printf(
"Error: used outside of a popup!\n");
753 const bool cancel_default,
758 const bool windows_layout =
true;
760 const bool windows_layout =
false;
763 if (windows_layout) {
772 if (
uiBut *but = (*but_fn)()) {
773 const bool is_cancel = (but_fn == &cancel_fn);
777 if (is_cancel == cancel_default) {
789 const std::optional<StringRef> confirm_text_opt,
790 const std::optional<StringRef> cancel_text_opt,
797 const StringRef confirm_text = confirm_text_opt.value_or(
IFACE_(
"OK"));
798 const StringRef cancel_text = cancel_text_opt.value_or(
IFACE_(
"Cancel"));
801 const bool show_confirm = !confirm_text.
is_empty();
802 const bool show_cancel = !cancel_text.
is_empty();
803 uiLayout *row = (show_confirm && show_cancel) ? &layout->
split(0.5f,
false) : layout;
807 cancel_default =
true;
810 auto confirm_fn = [&row, &
ot, &confirm_text, &icon, &r_ptr, &show_confirm]() ->
uiBut * {
824 auto cancel_fn = [&row, &cancel_text, &show_cancel]() ->
uiBut * {
864 handle->opcontext = opcontext;
896 if (block->
name == name) {
wmWindow * CTX_wm_window(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
void BKE_reports_unlock(ReportList *reports)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_reports_lock(ReportList *reports)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
MINLINE int min_ii(int a, int b)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
#define SNPRINTF(dst, format,...)
char * STRNCPY(char(&dst)[N], const char *src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define ARRAY_SET_ITEMS(...)
#define CTX_IFACE_(context, msgid)
#define RGN_ALIGN_ENUM_FROM_MASK(align)
#define RGN_TYPE_IS_HEADER_ANY(regiontype)
void ED_region_tag_refresh_ui(ARegion *region)
void ED_workspace_status_text(bContext *C, const char *str)
Read Guarded memory(de)allocation.
void UI_but_func_set(uiBut *but, std::function< void(bContext &)> func)
uiBut * uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_popup_menu_retval_set(const uiBlock *block, int retval, bool enable)
void UI_block_theme_style_set(uiBlock *block, char theme_style)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, blender::ui::EmbossType emboss)
int UI_icon_from_report_type(int type)
uiBut * uiDefBut(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
const uiStyle * UI_style_get_dpi()
void(*)(bContext *C, void *arg1) uiBlockCancelFunc
bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, uiBlock *block)
bool UI_block_has_active_default_button(const uiBlock *block)
@ UI_BLOCK_THEME_STYLE_POPUP
void(*)(bContext *C, void *arg, int event) uiBlockHandleFunc
void UI_block_bounds_set_menu(uiBlock *block, int addval, const int bounds_offset[2])
bool UI_block_is_empty_ex(const uiBlock *block, bool skip_title)
void UI_block_bounds_set_text(uiBlock *block, int addval)
void UI_popup_handlers_add(bContext *C, ListBase *handlers, uiPopupBlockHandle *popup, char flag)
void UI_block_free(const bContext *C, uiBlock *block)
void UI_block_region_set(uiBlock *block, ARegion *region)
void UI_block_direction_set(uiBlock *block, char direction)
uiBlock *(*)(bContext *C, ARegion *region, void *arg1) uiBlockCreateFunc
void UI_block_flag_enable(uiBlock *block, int flag)
void UI_popup_handlers_remove(ListBase *handlers, uiPopupBlockHandle *popup)
@ UI_BLOCK_MOVEMOUSE_QUIT
void UI_but_flag_enable(uiBut *but, int flag)
uiBlock * uiLayoutGetBlock(uiLayout *layout)
uiLayout * UI_block_layout(uiBlock *block, int dir, int type, int x, int y, int size, int em, int padding, const uiStyle *style)
float uiLayoutGetUnitsX(uiLayout *layout)
wmOperatorCallContext uiLayoutGetOperatorContext(uiLayout *layout)
void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
void uiLayoutSetOperatorContext(uiLayout *layout, wmOperatorCallContext opcontext)
void uiLayoutContextCopy(uiLayout *layout, const bContextStore *context)
void(*)(void *arg) uiFreeArgFunc
void(*)(bContext *C, uiLayout *layout, void *arg1) uiMenuCreateFunc
@ WM_OP_INVOKE_REGION_WIN
const T & last(const int64_t n=0) const
void range(std::string text, int icon1, int icon2)
void item(std::string text, int icon1, int icon2=0)
static constexpr int64_t not_found
constexpr bool is_empty() const
void ui_but_activate_over(bContext *C, ARegion *region, uiBut *but)
uiBut * ui_popup_menu_memory_get(uiBlock *block)
void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt)
uiPopupBlockHandle * ui_popup_block_create(bContext *C, ARegion *butregion, uiBut *but, uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg, uiFreeArgFunc arg_free, bool can_refresh)
void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle)
bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT
bool ui_but_is_editable(const uiBut *but) ATTR_WARN_UNUSED_RESULT
#define UI_MENU_WIDTH_MIN
uint64_t get_default_hash(const T &v, const Args &...args)
PropertyType RNA_property_type(PropertyRNA *prop)
int RNA_property_enum_step(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, int from_value, int step)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
ARegionRuntimeHandle * runtime
blender::Vector< std::unique_ptr< uiBut > > buttons
uiPopupBlockHandle * handle
const bContextStore * context
uiMenuStepFunc menu_step_func
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, wmOperatorCallContext context, eUI_Item_Flag flag)
void label(blender::StringRef name, int icon)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
uiLayout & split(float percentage, bool align)
void(* popup_func)(bContext *C, void *arg, int event)
void(* cancel_func)(bContext *C, void *arg)
int prev_bounds_offset[2]
struct wmEvent * eventstate
void WM_event_add_mousemove(wmWindow *win)
bScreen * WM_window_get_active_screen(const wmWindow *win)