Cleanup: Replace term "radial" with "pie menu" in UI code
Code was often referring to pie menus using the term "radial" which just obfuscates that it relates to pie menus. Just call it what it is directly. Doesn't replace usages of the term for names that are not strictly tied to pie menus. Also doesn't change instances of the term in the Python API to keep compatibility, noted in #110461. Pull Request: https://projects.blender.org/blender/blender/pulls/122825
This commit is contained in:
committed by
Julian Eisel
parent
5372fe2d16
commit
e425faf696
@@ -128,7 +128,7 @@ enum eUIEmbossType {
|
||||
/** Pull-down menu style */
|
||||
UI_EMBOSS_PULLDOWN = 2,
|
||||
/** Pie Menu */
|
||||
UI_EMBOSS_RADIAL = 3,
|
||||
UI_EMBOSS_PIE_MENU = 3,
|
||||
/**
|
||||
* The same as #UI_EMBOSS_NONE, unless the button has
|
||||
* a coloring status like an animation state or red alert.
|
||||
@@ -171,7 +171,7 @@ enum {
|
||||
|
||||
UI_BLOCK_POPUP_HOLD = 1 << 18,
|
||||
UI_BLOCK_LIST_ITEM = 1 << 19,
|
||||
UI_BLOCK_RADIAL = 1 << 20,
|
||||
UI_BLOCK_PIE_MENU = 1 << 20,
|
||||
UI_BLOCK_POPOVER = 1 << 21,
|
||||
UI_BLOCK_POPOVER_ONCE = 1 << 22,
|
||||
/** Always show key-maps, even for non-menus. */
|
||||
@@ -2351,6 +2351,7 @@ uiLayout *uiLayoutAbsolute(uiLayout *layout, bool align);
|
||||
uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, bool align);
|
||||
uiLayout *uiLayoutOverlap(uiLayout *layout);
|
||||
uiBlock *uiLayoutAbsoluteBlock(uiLayout *layout);
|
||||
/** Pie menu layout: Buttons are arranged around a center. */
|
||||
uiLayout *uiLayoutRadial(uiLayout *layout);
|
||||
|
||||
/* templates */
|
||||
|
||||
@@ -335,7 +335,7 @@ static void ui_update_window_matrix(const wmWindow *window, const ARegion *regio
|
||||
void ui_region_winrct_get_no_margin(const ARegion *region, rcti *r_rect)
|
||||
{
|
||||
uiBlock *block = static_cast<uiBlock *>(region->uiblocks.first);
|
||||
if (block && (block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_RADIAL) == 0) {
|
||||
if (block && (block->flag & UI_BLOCK_LOOP) && (block->flag & UI_BLOCK_PIE_MENU) == 0) {
|
||||
BLI_rcti_rctf_copy_floor(r_rect, &block->rect);
|
||||
BLI_rcti_translate(r_rect, region->winrct.xmin, region->winrct.ymin);
|
||||
}
|
||||
@@ -1551,7 +1551,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block)
|
||||
return;
|
||||
}
|
||||
|
||||
if (block->flag & UI_BLOCK_RADIAL) {
|
||||
if (block->flag & UI_BLOCK_PIE_MENU) {
|
||||
LISTBASE_FOREACH (uiBut *, but, &block->buttons) {
|
||||
if (but->pie_dir != UI_RADIAL_NONE) {
|
||||
const std::string str = ui_but_pie_direction_string(but);
|
||||
@@ -2059,7 +2059,7 @@ void UI_block_draw(const bContext *C, uiBlock *block)
|
||||
wmOrtho2_region_pixelspace(region);
|
||||
|
||||
/* back */
|
||||
if (block->flag & UI_BLOCK_RADIAL) {
|
||||
if (block->flag & UI_BLOCK_PIE_MENU) {
|
||||
ui_draw_pie_center(block);
|
||||
}
|
||||
else if (block->flag & UI_BLOCK_POPOVER) {
|
||||
@@ -4125,7 +4125,7 @@ static uiBut *ui_def_but(uiBlock *block,
|
||||
}
|
||||
}
|
||||
|
||||
if (block->flag & UI_BLOCK_RADIAL) {
|
||||
if (block->flag & UI_BLOCK_PIE_MENU) {
|
||||
but->drawflag |= UI_BUT_TEXT_LEFT;
|
||||
if (!but->str.empty()) {
|
||||
but->drawflag |= UI_BUT_ICON_LEFT;
|
||||
|
||||
@@ -11435,7 +11435,7 @@ static int ui_handle_menus_recursive(bContext *C,
|
||||
bool inside = false;
|
||||
/* root pie menus accept the key that spawned
|
||||
* them as double click to improve responsiveness */
|
||||
const bool do_recursion = (!(block->flag & UI_BLOCK_RADIAL) ||
|
||||
const bool do_recursion = (!(block->flag & UI_BLOCK_PIE_MENU) ||
|
||||
event->type != block->pie_data.event_type);
|
||||
|
||||
if (do_recursion) {
|
||||
@@ -11507,7 +11507,7 @@ static int ui_handle_menus_recursive(bContext *C,
|
||||
else {
|
||||
uiBlock *block = static_cast<uiBlock *>(menu->region->uiblocks.first);
|
||||
|
||||
if (block->flag & UI_BLOCK_RADIAL) {
|
||||
if (block->flag & UI_BLOCK_PIE_MENU) {
|
||||
retval = ui_pie_handler(C, event, menu);
|
||||
}
|
||||
else if (event->type == LEFTMOUSE || event->val != KM_DBL_CLICK) {
|
||||
@@ -11764,7 +11764,7 @@ static int ui_popup_handler(bContext *C, const wmEvent *event, void *userdata)
|
||||
uiBlock *block = static_cast<uiBlock *>(menu->region->uiblocks.first);
|
||||
|
||||
/* set last pie event to allow chained pie spawning */
|
||||
if (block->flag & UI_BLOCK_RADIAL) {
|
||||
if (block->flag & UI_BLOCK_PIE_MENU) {
|
||||
win->pie_event_type_last = block->pie_data.event_type;
|
||||
reset_pie = true;
|
||||
}
|
||||
|
||||
@@ -4056,7 +4056,7 @@ static void ui_litem_layout_radial(uiLayout *litem)
|
||||
bitem->but->rect.xmax += 1.5f * UI_UNIT_X;
|
||||
/* Enable drawing as pie item if supported by widget. */
|
||||
if (ui_item_is_radial_drawable(bitem)) {
|
||||
bitem->but->emboss = UI_EMBOSS_RADIAL;
|
||||
bitem->but->emboss = UI_EMBOSS_PIE_MENU;
|
||||
bitem->but->drawflag |= UI_BUT_ICON_LEFT;
|
||||
}
|
||||
|
||||
|
||||
@@ -648,7 +648,7 @@ bool ui_block_is_popover(const uiBlock *block)
|
||||
|
||||
bool ui_block_is_pie_menu(const uiBlock *block)
|
||||
{
|
||||
return ((block->flag & UI_BLOCK_RADIAL) != 0);
|
||||
return ((block->flag & UI_BLOCK_PIE_MENU) != 0);
|
||||
}
|
||||
|
||||
bool ui_block_is_popup_any(const uiBlock *block)
|
||||
|
||||
@@ -91,7 +91,7 @@ enum uiWidgetTypeEnum {
|
||||
* widget. To be used when multiple menu items should be displayed close to each other
|
||||
* horizontally. */
|
||||
UI_WTYPE_MENU_ITEM_UNPADDED,
|
||||
UI_WTYPE_MENU_ITEM_RADIAL,
|
||||
UI_WTYPE_MENU_ITEM_PIE,
|
||||
UI_WTYPE_MENU_BACK,
|
||||
|
||||
/* specials */
|
||||
@@ -2315,7 +2315,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle,
|
||||
/* pass (even if its a menu toolbar) */
|
||||
}
|
||||
else if (ui_block_is_pie_menu(but->block)) {
|
||||
if (but->emboss == UI_EMBOSS_RADIAL) {
|
||||
if (but->emboss == UI_EMBOSS_PIE_MENU) {
|
||||
rect->xmin += 0.3f * U.widget_unit;
|
||||
}
|
||||
}
|
||||
@@ -4169,12 +4169,12 @@ static void widget_menu_itembut_unpadded(uiWidgetColors *wcol,
|
||||
widgetbase_draw(&wtb, wcol);
|
||||
}
|
||||
|
||||
static void widget_menu_radial_itembut(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
const uiWidgetStateInfo * /*state*/,
|
||||
int /*roundboxalign*/,
|
||||
const float zoom)
|
||||
static void widget_menu_pie_itembut(uiBut *but,
|
||||
uiWidgetColors *wcol,
|
||||
rcti *rect,
|
||||
const uiWidgetStateInfo * /*state*/,
|
||||
int /*roundboxalign*/,
|
||||
const float zoom)
|
||||
{
|
||||
const float fac = but->block->pie_data.alphafac;
|
||||
|
||||
@@ -4712,9 +4712,9 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
|
||||
wt.custom = widget_nodesocket;
|
||||
break;
|
||||
|
||||
case UI_WTYPE_MENU_ITEM_RADIAL:
|
||||
case UI_WTYPE_MENU_ITEM_PIE:
|
||||
wt.wcol_theme = &btheme->tui.wcol_pie_menu;
|
||||
wt.custom = widget_menu_radial_itembut;
|
||||
wt.custom = widget_menu_pie_itembut;
|
||||
wt.state = widget_state_pie_menu_item;
|
||||
break;
|
||||
}
|
||||
@@ -4843,8 +4843,8 @@ void ui_draw_but(const bContext *C, ARegion *region, uiStyle *style, uiBut *but,
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (but->emboss == UI_EMBOSS_RADIAL) {
|
||||
wt = widget_type(UI_WTYPE_MENU_ITEM_RADIAL);
|
||||
else if (but->emboss == UI_EMBOSS_PIE_MENU) {
|
||||
wt = widget_type(UI_WTYPE_MENU_ITEM_PIE);
|
||||
}
|
||||
else {
|
||||
BLI_assert(but->emboss == UI_EMBOSS);
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* \{ */
|
||||
|
||||
struct uiPieMenu {
|
||||
uiBlock *block_radial; /* radial block of the pie menu (more could be added later) */
|
||||
uiBlock *pie_block; /* radial block of the pie menu (more could be added later) */
|
||||
uiLayout *layout;
|
||||
int mx, my;
|
||||
};
|
||||
@@ -54,7 +54,7 @@ static uiBlock *ui_block_func_PIE(bContext * /*C*/, uiPopupBlockHandle *handle,
|
||||
int minwidth, width, height;
|
||||
|
||||
minwidth = UI_MENU_WIDTH_MIN;
|
||||
block = pie->block_radial;
|
||||
block = pie->pie_block;
|
||||
|
||||
/* in some cases we create the block before the region,
|
||||
* so we set it delayed here if necessary */
|
||||
@@ -76,7 +76,7 @@ static uiBlock *ui_block_func_PIE(bContext * /*C*/, uiPopupBlockHandle *handle,
|
||||
block->pie_data.pie_center_spawned[0] = pie->mx;
|
||||
block->pie_data.pie_center_spawned[1] = pie->my;
|
||||
|
||||
return pie->block_radial;
|
||||
return pie->pie_block;
|
||||
}
|
||||
|
||||
static float ui_pie_menu_title_width(const char *name, int icon)
|
||||
@@ -94,18 +94,18 @@ uiPieMenu *UI_pie_menu_begin(bContext *C, const char *title, int icon, const wmE
|
||||
|
||||
uiPieMenu *pie = MEM_cnew<uiPieMenu>(__func__);
|
||||
|
||||
pie->block_radial = UI_block_begin(C, nullptr, __func__, UI_EMBOSS);
|
||||
pie->pie_block = UI_block_begin(C, nullptr, __func__, UI_EMBOSS);
|
||||
/* may be useful later to allow spawning pies
|
||||
* from old positions */
|
||||
// pie->block_radial->flag |= UI_BLOCK_POPUP_MEMORY;
|
||||
pie->block_radial->puphash = ui_popup_menu_hash(title);
|
||||
pie->block_radial->flag |= UI_BLOCK_RADIAL;
|
||||
// pie->pie_block->flag |= UI_BLOCK_POPUP_MEMORY;
|
||||
pie->pie_block->puphash = ui_popup_menu_hash(title);
|
||||
pie->pie_block->flag |= UI_BLOCK_PIE_MENU;
|
||||
|
||||
/* if pie is spawned by a left click, release or click event,
|
||||
* it is always assumed to be click style */
|
||||
if (event->type == LEFTMOUSE || ELEM(event->val, KM_RELEASE, KM_CLICK)) {
|
||||
pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE;
|
||||
pie->block_radial->pie_data.event_type = EVENT_NONE;
|
||||
pie->pie_block->pie_data.flags |= UI_PIE_CLICK_STYLE;
|
||||
pie->pie_block->pie_data.event_type = EVENT_NONE;
|
||||
win->pie_event_type_lock = EVENT_NONE;
|
||||
}
|
||||
else {
|
||||
@@ -113,7 +113,7 @@ uiPieMenu *UI_pie_menu_begin(bContext *C, const char *title, int icon, const wmE
|
||||
/* original pie key has been released, so don't propagate the event */
|
||||
if (win->pie_event_type_lock == EVENT_NONE) {
|
||||
event_type = EVENT_NONE;
|
||||
pie->block_radial->pie_data.flags |= UI_PIE_CLICK_STYLE;
|
||||
pie->pie_block->pie_data.flags |= UI_PIE_CLICK_STYLE;
|
||||
}
|
||||
else {
|
||||
event_type = win->pie_event_type_last;
|
||||
@@ -123,12 +123,12 @@ uiPieMenu *UI_pie_menu_begin(bContext *C, const char *title, int icon, const wmE
|
||||
event_type = event->type;
|
||||
}
|
||||
|
||||
pie->block_radial->pie_data.event_type = event_type;
|
||||
pie->pie_block->pie_data.event_type = event_type;
|
||||
win->pie_event_type_lock = event_type;
|
||||
}
|
||||
|
||||
pie->layout = UI_block_layout(
|
||||
pie->block_radial, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style);
|
||||
pie->pie_block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PIEMENU, 0, 0, 200, 0, 0, style);
|
||||
|
||||
/* NOTE: #wmEvent.xy is where we started dragging in case of #KM_CLICK_DRAG. */
|
||||
pie->mx = event->xy[0];
|
||||
@@ -142,7 +142,7 @@ uiPieMenu *UI_pie_menu_begin(bContext *C, const char *title, int icon, const wmE
|
||||
if (icon) {
|
||||
SNPRINTF(titlestr, " %s", title);
|
||||
w = ui_pie_menu_title_width(titlestr, icon);
|
||||
but = uiDefIconTextBut(pie->block_radial,
|
||||
but = uiDefIconTextBut(pie->pie_block,
|
||||
UI_BTYPE_LABEL,
|
||||
0,
|
||||
icon,
|
||||
@@ -159,12 +159,12 @@ uiPieMenu *UI_pie_menu_begin(bContext *C, const char *title, int icon, const wmE
|
||||
else {
|
||||
w = ui_pie_menu_title_width(title, 0);
|
||||
but = uiDefBut(
|
||||
pie->block_radial, UI_BTYPE_LABEL, 0, title, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, "");
|
||||
pie->pie_block, UI_BTYPE_LABEL, 0, title, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, "");
|
||||
}
|
||||
/* do not align left */
|
||||
but->drawflag &= ~UI_BUT_TEXT_LEFT;
|
||||
pie->block_radial->pie_data.title = but->str.c_str();
|
||||
pie->block_radial->pie_data.icon = icon;
|
||||
pie->pie_block->pie_data.title = but->str.c_str();
|
||||
pie->pie_block->pie_data.icon = icon;
|
||||
}
|
||||
|
||||
return pie;
|
||||
|
||||
@@ -708,7 +708,7 @@ uiBlock *ui_popup_block_refresh(bContext *C,
|
||||
BLI_addhead(&block->saferct, saferct);
|
||||
}
|
||||
|
||||
if (block->flag & UI_BLOCK_RADIAL) {
|
||||
if (block->flag & UI_BLOCK_PIE_MENU) {
|
||||
const int win_width = UI_SCREEN_MARGIN;
|
||||
|
||||
const int winx = WM_window_pixels_x(window);
|
||||
|
||||
@@ -1659,7 +1659,7 @@ static void rna_def_ui_layout(BlenderRNA *brna)
|
||||
{UI_EMBOSS, "NORMAL", 0, "Regular", "Draw standard button emboss style"},
|
||||
{UI_EMBOSS_NONE, "NONE", 0, "None", "Draw only text and icons"},
|
||||
{UI_EMBOSS_PULLDOWN, "PULLDOWN_MENU", 0, "Pulldown Menu", "Draw pulldown menu style"},
|
||||
{UI_EMBOSS_RADIAL, "RADIAL_MENU", 0, "Radial Menu", "Draw radial menu style"},
|
||||
{UI_EMBOSS_PIE_MENU, "RADIAL_MENU", 0, "Pie Menu", "Draw radial menu style"},
|
||||
{UI_EMBOSS_NONE_OR_STATUS,
|
||||
"NONE_OR_STATUS",
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user