77 printf(
"%s: cannot cycle button '%s'\n", __func__, but->
str.c_str());
97 str.substr(0, sep_index);
110 static uint mem[256];
111 static bool first =
true;
118 memset(mem, -1,
sizeof(mem));
299 int offset[2] = {0, 0};
301 Button *but_activate =
nullptr;
326 offset[0] =
min_ii(offset[0],
334 but_activate = &but_iter;
399 const bool can_refresh)
403 PopupMenu *pup = MEM_new<PopupMenu>(__func__);
413 status.
item(
IFACE_(
"Search"), ICON_EVENT_SPACEKEY);
427 handle->
popup =
true;
441 const bool can_refresh)
448 [menu_func, arg](
bContext *
C,
Layout *layout) { menu_func(
C, layout, arg); },
469 block,
ButtonType::Label, title, 0, 0, 200,
UI_UNIT_Y,
nullptr, 0.0, 0.0,
"");
478 PopupMenu *pup = MEM_new<PopupMenu>(__func__);
485 pup->
block->
handle = MEM_new<PopupBlockHandle>(__func__);
567 const char *msg, *msg_next;
573 if (pup ==
nullptr) {
589 msg_next = strchr(msg,
'\n');
595 layout->
label(msg, icon);
597 }
while ((msg = msg_next) && *msg);
618 if (title && title[0]) {
629 status.
range(
IFACE_(
"Search"), ICON_EVENT_A, ICON_EVENT_Z);
632 status.
item(
IFACE_(
"Search"), ICON_EVENT_SPACEKEY);
651 const bool allow_refresh =
true;
678 const bool can_refresh,
684 C,
nullptr,
nullptr, func,
nullptr, arg, arg_free, can_refresh);
685 handle->
popup =
true;
690 status.
item(
" ", ICON_NONE);
713 C,
nullptr,
nullptr, func,
nullptr, arg,
nullptr,
true);
714 handle->
popup =
true;
728 status.
item(
" ", ICON_NONE);
740 if (handle ==
nullptr) {
741 printf(
"Error: used outside of a popup!\n");
764 const bool cancel_default,
769 const bool windows_layout =
true;
771 const bool windows_layout =
false;
774 if (windows_layout) {
781 for (
int i = 0; i <
ARRAY_SIZE(button_functions); i++) {
783 if (
Button *but = (*but_fn)()) {
784 const bool is_cancel = (but_fn == &cancel_fn);
788 if (is_cancel == cancel_default) {
800 const std::optional<StringRef> confirm_text_opt,
801 const std::optional<StringRef> cancel_text_opt,
808 const StringRef confirm_text = confirm_text_opt.value_or(
IFACE_(
"OK"));
809 const StringRef cancel_text = cancel_text_opt.value_or(
IFACE_(
"Cancel"));
812 const bool show_confirm = !confirm_text.
is_empty();
813 const bool show_cancel = !cancel_text.
is_empty();
814 Layout &row = (show_confirm && show_cancel) ? layout->
split(0.5f,
false) : *layout;
818 cancel_default =
true;
821 auto confirm_fn = [&row, &ot, &confirm_text, &icon, &r_ptr, &show_confirm]() ->
Button * {
835 auto cancel_fn = [&row, &cancel_text, &show_cancel]() ->
Button * {
858 uiBlockCreateFunc func,
864 PopupBlockHandle *handle =
popup_block_create(
C,
nullptr,
nullptr, func,
nullptr, op,
nullptr,
true);
866 handle->retvalue = 1;
868 handle->popup_arg = op;
869 handle->popup_func = operator_cb;
870 handle->cancel_func = confirm_cancel_operator;
871 handle->opcontext = opcontext;
903 if (block.
name == name) {
917 if (!(block && block->
handle)) {
#define SNPRINTF_UTF8(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define CTX_IFACE_(context, msgid)
#define RGN_ALIGN_ENUM_FROM_MASK(align)
#define RGN_TYPE_IS_HEADER_ANY(regiontype)
Read Blender memory allocation and freeing.
#define ARRAY_SET_ITEMS(...)
void item(std::string text, int icon1, int icon2=0)
void range(std::string text, int icon1, int icon2)
static constexpr int64_t not_found
constexpr bool is_empty() const
#define UI_MENU_WIDTH_MIN
Button * uiDefIconTextBut(Block *block, ButtonTypeWithPointerType but_and_ptr_type, int icon, StringRef str, int x, int y, short width, short height, void *poin, std::optional< StringRef > tip)
void item_menutype_func(bContext *C, Layout *layout, void *arg_mt)
int icon_from_report_type(int type)
void block_direction_set(Block *block, char direction)
void(*)(bContext *C, Layout *layout, void *arg1) MenuCreateFunc
void popup_block_close(bContext *C, wmWindow *win, Block *block)
static Block * block_func_POPUP(bContext *C, PopupBlockHandle *handle, void *arg_pup)
@ BLOCK_THEME_STYLE_POPUP
void button_func_set(Button *but, std::function< void(bContext &)> func)
bool button_menu_step_poll(const Button *but)
void popup_block_template_confirm_op(Layout *layout, wmOperatorType *ot, std::optional< StringRef > confirm_text, std::optional< StringRef > cancel_text, const int icon, bool cancel_default, PointerRNA *r_ptr)
void popup_block_ex(bContext *C, BlockCreateFunc func, BlockHandleFunc popup_func, BlockCancelFunc cancel_func, void *arg, wmOperator *op)
void popup_block_free(bContext *C, PopupBlockHandle *handle)
static PopupBlockHandle * popup_menu_create_impl(bContext *C, ARegion *butregion, Button *but, const char *title, std::function< void(bContext *, Layout *)> menu_func, const bool can_refresh)
void popup_menu_but_set(PopupMenu *pup, ARegion *butregion, Button *but)
wmOperatorStatus popup_menu_invoke(bContext *C, const char *idname, ReportList *reports) ATTR_NONNULL(1
PopupMenu * popup_menu_begin_ex(bContext *C, const char *title, const char *block_name, int icon) ATTR_NONNULL()
void(*)(void *arg) FreeArgFunc
void block_free(const bContext *C, Block *block)
PopupMenu * popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
static void popup_block_template_close_cb(bContext *C, void *arg1, void *)
bool popup_menu_end_or_cancel(bContext *C, PopupMenu *pup)
void block_flag_enable(Block *block, int flag)
Button * popup_menu_memory_get(Block *block)
bool block_is_menu(const Block *block) ATTR_WARN_UNUSED_RESULT
const uiStyle * style_get_dpi()
void popup_block_invoke(bContext *C, BlockCreateFunc func, void *arg, FreeArgFunc arg_free, StructRNA *srna_owner=nullptr)
PopupBlockHandle * popup_menu_create(bContext *C, ARegion *butregion, Button *but, MenuCreateFunc menu_func, void *arg, bool can_refresh)
void block_bounds_set_text(Block *block, int addval)
bool block_active_only_flagged_buttons(const bContext *C, ARegion *region, Block *block)
wmOperatorStatus void popup_menu_close(const Block *block, bool is_cancel=false)
void button_flag_enable(Button *but, int64_t flag)
bool block_has_active_default_button(const Block *block)
void popup_handlers_add(bContext *C, ListBaseT< wmEventHandler > *handlers, PopupBlockHandle *popup, char flag)
Block * block_begin(const bContext *C, ARegion *region, std::string name, EmbossType emboss)
Layout * popup_menu_layout(PopupMenu *pup)
void(*)(bContext *C, void *arg, int event) BlockHandleFunc
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)
static void block_free_func_POPUP(void *arg_pup)
Block *(*)(bContext *C, ARegion *region, void *arg1) BlockCreateFunc
void popup_handlers_remove(ListBaseT< wmEventHandler > *handlers, PopupBlockHandle *popup)
void block_theme_style_set(Block *block, char theme_style)
static void popup_menu_create_block(bContext *C, PopupMenu *pup, const StringRef title, const StringRef block_name)
bool popup_region_from_operator(const bScreen *screen, const ARegion *region)
void popup_menu_retval_set(const Block *block, int retval, bool enable)
int button_menu_step(Button *but, int direction)
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)
bool popup_block_template_confirm_is_supported(const Block *block)
static uint popup_string_hash(const StringRef str, const bool use_sep)
bool button_is_editable(const Button *but) ATTR_WARN_UNUSED_RESULT
void popup_menu_reports(bContext *C, ReportList *reports) ATTR_NONNULL()
int2 block_layout_resolve(Block *block)
void menutype_draw(bContext *C, MenuType *mt, Layout *layout)
bool block_is_empty_ex(const Block *block, bool skip_title)
void(*)(bContext *C, void *arg1) BlockCancelFunc
static Button * popup_menu_memory__internal(Block *block, Button *but)
void popup_block_invoke_ex(bContext *C, BlockCreateFunc func, void *arg, FreeArgFunc arg_free, bool can_refresh, StructRNA *srna_owner=nullptr)
uint popup_menu_hash(const StringRef str)
void button_activate_over(bContext *C, ARegion *region, Button *but)
void block_region_set(Block *block, ARegion *region)
void block_bounds_set_menu(Block *block, int addval, const int bounds_offset[2])
void popup_menu_memory_set(Block *block, Button *but)
static void create_title_button(Layout &layout, const char *title, int icon)
Layout & block_layout(Block *block, LayoutDirection direction, LayoutType type, int x, int y, int size, int em, int padding, const uiStyle *style)
void popup_menu_end(bContext *C, PopupMenu *pup)
void popup_block_template_confirm(Block *block, bool cancel_default, FunctionRef< Button *()> confirm_fn, FunctionRef< Button *()> cancel_fn)
static void popup_menu_create_from_menutype(bContext *C, MenuType *mt, const char *title, const int icon)
bool popup_block_name_exists(const bScreen *screen, StringRef name)
void popup_menu_close_from_but(const Button *but, bool is_cancel=false)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
MINLINE void copy_v2_v2_int(int r[2], const int a[2])
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
MenuType * WM_menutype_find(const StringRef idname, bool quiet)
char * BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
wmWindow * CTX_wm_window(const bContext *C)
PropertyType RNA_property_type(PropertyRNA *prop)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void ED_region_tag_refresh_ui(ARegion *region)
void BKE_reports_unlock(ReportList *reports)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
bool WM_menutype_poll(bContext *C, MenuType *mt)
int RNA_property_enum_step(const bContext *C, PointerRNA *ptr, PropertyRNA *prop, int from_value, int step)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
void BKE_reports_lock(ReportList *reports)
void WM_event_add_mousemove(wmWindow *win)
bScreen * WM_window_get_active_screen(const wmWindow *win)
MINLINE int min_ii(int a, int b)
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
bke::ARegionRuntime * runtime
eRegion_Alignment alignment
ListBaseT< ARegion > regionbase
ListBaseT< ui::Block > uiblocks
ListBaseT< wmEventHandler > modalhandlers
Button * last_but() const
Vector< std::unique_ptr< Button > > buttons_ptrs
std::ranges::transform_view< std::ranges::ref_view< const Vector< std::unique_ptr< Button > > >, Button &(*)(const std::unique_ptr< Button > &)> buttons() const
PopupBlockHandle * handle
void operator_context_set(wm::OpCallContext opcontext)
wm::OpCallContext operator_context() const
void label(StringRef name, int icon)
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
Layout & split(float percentage, bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void context_copy(const bContextStore *context)
void(*) cancel_func(bContext *C, void *arg)
void(*) popup_func(bContext *C, void *arg, int event)
int prev_bounds_offset[2]
ARegion * ctx_region_popup
struct wmOperatorType * type
bke::WindowRuntime * runtime