77 printf(
"%s: cannot cycle button '%s'\n", __func__, but->
str.c_str());
110 static uint mem[256];
111 static bool first =
true;
118 memset(mem, -1,
sizeof(mem));
294 int offset[2] = {0, 0};
296 uiBut *but_activate =
nullptr;
302 if (!handle->refresh) {
321 offset[0] =
min_ii(offset[0],
329 but_activate = but_iter;
394 const bool can_refresh)
408 status.
item(
IFACE_(
"Search"), ICON_EVENT_SPACEKEY);
422 handle->popup =
true;
439 [menu_func, arg](
bContext *C,
uiLayout *layout) { menu_func(C, layout, arg); },
457 block,
UI_BTYPE_LABEL, 0, icon, titlestr, 0, 0, 200,
UI_UNIT_Y,
nullptr, 0.0, 0.0,
"");
461 block,
UI_BTYPE_LABEL, 0, title, 0, 0, 200,
UI_UNIT_Y,
nullptr, 0.0, 0.0,
"");
470 const char *block_name,
480 pup->
block->
handle = MEM_cnew<uiPopupBlockHandle>(__func__);
508 uiBut *but =
nullptr;
562 const char *msg, *msg_next;
568 if (pup ==
nullptr) {
570 SNPRINTF(title,
"%s: %s",
RPT_(
"Report"), report->typestr);
580 msg = report->message;
584 msg_next = strchr(msg,
'\n');
587 BLI_strncpy(buf, msg, std::min(
sizeof(buf),
size_t(msg_next - msg)));
592 }
while ((msg = msg_next) && *msg);
613 if (title && title[0]) {
624 status.
range(
IFACE_(
"Search"), ICON_EVENT_A, ICON_EVENT_Z);
627 status.
item(
IFACE_(
"Search"), ICON_EVENT_SPACEKEY);
646 const bool allow_refresh =
true;
675 C,
nullptr,
nullptr, func,
nullptr, arg, arg_free, can_refresh);
676 handle->popup =
true;
680 status.
item(
" ", ICON_NONE);
684 C, handle->region,
static_cast<uiBlock *
>(handle->region->uiblocks.first));
703 C,
nullptr,
nullptr, func,
nullptr, arg,
nullptr,
true);
704 handle->popup =
true;
705 handle->retvalue = 1;
707 handle->popup_op = op;
708 handle->popup_arg = arg;
709 handle->popup_func = popup_func;
710 handle->cancel_func = cancel_func;
715 status.
item(
" ", ICON_NONE);
719 C, handle->region,
static_cast<uiBlock *
>(handle->region->uiblocks.first));
728 if (handle ==
nullptr) {
729 printf(
"Error: used outside of a popup!\n");
736 if (handle->cancel_func) {
737 handle->cancel_func(C, handle->popup_arg);
752 const bool cancel_default,
757 const bool windows_layout =
true;
759 const bool windows_layout =
false;
762 if (windows_layout) {
769 for (
int i = 0; i <
ARRAY_SIZE(button_functions); i++) {
771 if (
uiBut *but = (*but_fn)()) {
772 const bool is_cancel = (but_fn == &cancel_fn);
776 if (is_cancel == cancel_default) {
788 const char *confirm_text,
789 const char *cancel_text,
796 if (confirm_text ==
nullptr) {
797 confirm_text =
IFACE_(
"OK");
799 if (cancel_text ==
nullptr) {
800 cancel_text =
IFACE_(
"Cancel");
804 const bool show_confirm = confirm_text[0] !=
'\0';
805 const bool show_cancel = cancel_text[0] !=
'\0';
810 cancel_default =
true;
813 auto confirm_fn = [&row, &
ot, &confirm_text, &icon, &r_ptr, &show_confirm]() ->
uiBut * {
834 auto cancel_fn = [&row, &cancel_text, &show_cancel]() ->
uiBut * {
869 handle->retvalue = 1;
871 handle->popup_arg = op;
872 handle->popup_func = operator_cb;
873 handle->cancel_func = confirm_cancel_operator;
874 handle->opcontext = opcontext;
906 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)
#define LISTBASE_FOREACH(type, var, list)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
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 STRNCPY(dst, src)
#define SNPRINTF(dst, format,...)
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)
void(*)(void *arg) uiFreeArgFunc
void UI_popup_menu_retval_set(const uiBlock *block, int retval, bool enable)
void UI_block_theme_style_set(uiBlock *block, char theme_style)
@ UI_BLOCK_MOVEMOUSE_QUIT
int UI_icon_from_report_type(int type)
void(*)(bContext *C, uiLayout *layout, void *arg1) uiMenuCreateFunc
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, const char *tip)
void uiItemL(uiLayout *layout, const char *name, int icon)
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)
const uiStyle * UI_style_get_dpi()
float uiLayoutGetUnitsX(uiLayout *layout)
void(*)(bContext *C, void *arg1) uiBlockCancelFunc
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, eUIEmbossType emboss)
void uiItemS(uiLayout *layout)
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, const char *tip)
bool UI_block_active_only_flagged_buttons(const bContext *C, ARegion *region, uiBlock *block)
wmOperatorCallContext uiLayoutGetOperatorContext(uiLayout *layout)
bool UI_block_has_active_default_button(const uiBlock *block)
void uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, wmOperatorCallContext context, eUI_Item_Flag flag, PointerRNA *r_opptr)
void(*)(bContext *C, void *arg, int event) uiBlockHandleFunc
void UI_menutype_draw(bContext *C, MenuType *mt, uiLayout *layout)
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)
@ UI_BLOCK_THEME_STYLE_POPUP
void UI_popup_handlers_add(bContext *C, ListBase *handlers, uiPopupBlockHandle *popup, char flag)
uiLayout * uiLayoutSplit(uiLayout *layout, float percentage, bool align)
void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
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 uiLayoutSetOperatorContext(uiLayout *layout, wmOperatorCallContext opcontext)
void UI_popup_handlers_remove(ListBase *handlers, uiPopupBlockHandle *popup)
void uiLayoutContextCopy(uiLayout *layout, const bContextStore *context)
void UI_but_flag_enable(uiBut *but, int flag)
@ WM_OP_INVOKE_REGION_WIN
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
constexpr StringRef substr(int64_t start, int64_t size) const
void ui_but_activate_over(bContext *C, ARegion *region, uiBut *but)
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
void MEM_freeN(void *vmemh)
uint64_t get_default_hash(const T &v)
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)
uiPopupBlockHandle * handle
const bContextStore * context
uiMenuStepFunc menu_step_func
struct wmEvent * eventstate
void WM_event_add_mousemove(wmWindow *win)
bScreen * WM_window_get_active_screen(const wmWindow *win)