UI: Collapse XYZ Operations in Status Bar #120148

Merged
Harley Acheson merged 12 commits from Harley/blender:StatusBarXYZ into main 2024-04-22 20:03:23 +02:00
3 changed files with 31 additions and 46 deletions
Showing only changes of commit 5ca614d575 - Show all commits

View File

@ -2546,10 +2546,12 @@ bool uiTemplateEventFromKeymapItem(uiLayout *layout,
bool text_fallback);
/**
* Draw keymap items that are TFM_MODAL_AXIS_X, TFM_MODAL_AXIS_Y, TFM_MODAL_AXIS_Z
* in a way that requires less horizontal space.
* Draw keymap items TFM_MODAL_AXIS_X, TFM_MODAL_AXIS_Y, TFM_MODAL_AXIS_Z, TFM_MODAL_PLANE_X,
* TFM_MODAL_PLANE_Y, TFM_MODAL_PLANE_Z, in a way that requires less horizontal space.
*/
bool uiTemplateEventFromKeymapItemXYZ(uiLayout *layout, std::string text, const wmKeyMapItem *kmi);
bool uiTemplateEventFromKeymapItemXYZ(uiLayout *layout,
EnumPropertyItem item,
const wmKeyMapItem *kmi);
void uiTemplateComponentMenu(uiLayout *layout,
PointerRNA *ptr,

View File

@ -6519,44 +6519,32 @@ void uiTemplateKeymapItemProperties(uiLayout *layout, PointerRNA *ptr)
/** \name Event Icon Template
* \{ */
bool uiTemplateEventFromKeymapItemXYZ(uiLayout *layout, std::string text, const wmKeyMapItem *kmi)
bool uiTemplateEventFromKeymapItemXYZ(uiLayout *layout,
EnumPropertyItem item,
const wmKeyMapItem *kmi)
{
if (!ELEM(kmi->type, EVT_XKEY, EVT_YKEY, EVT_ZKEY)) {
return false;
if (STR_ELEM(item.identifier, "AXIS_Y", "AXIS_Z", "PLANE_X", "PLANE_Y", "PLANE_Z")) {
return true; /* Swallow these. */
}
if (!STREQ(item.identifier, "AXIS_X")) {
return false; /* Reject all others. */
}
if (kmi->type != EVT_ZKEY) {
/* Swallow X and Y. */
return true;
}
/* Modifier icons. */
if (!ELEM(kmi->shift, KM_NOTHING, KM_ANY)) {
uiItemL(layout, "", ICON_EVENT_SHIFT);
}
if (!ELEM(kmi->ctrl, KM_NOTHING, KM_ANY)) {
uiItemL(layout, "", ICON_EVENT_CTRL);
}
if (!ELEM(kmi->alt, KM_NOTHING, KM_ANY)) {
uiItemL(layout, "", ICON_EVENT_ALT);
}
if (!ELEM(kmi->oskey, KM_NOTHING, KM_ANY)) {
uiItemL(layout, "", ICON_EVENT_OS);
}
/* All three X, Y, Z icons. */
uiItemL(layout, "", ICON_EVENT_X);
uiItemL(layout, "", ICON_EVENT_Y);
uiItemL(layout, "", ICON_EVENT_Z);
uiItemS_ex(layout, 0.6f);
const int index = text.find("Z ");
if (index != std::string::npos) {
text.erase(index, 2);
}
uiItemL(layout, CTX_IFACE_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, text.c_str()), ICON_NONE);
uiItemL(layout, IFACE_("Axis"), ICON_NONE);
uiItemS_ex(layout, 0.7f);
uiItemL(layout, "", ICON_EVENT_SHIFT);
uiItemL(layout, "", ICON_EVENT_X);
uiItemL(layout, "", ICON_EVENT_Y);
uiItemL(layout, "", ICON_EVENT_Z);
uiItemS_ex(layout, 0.6f);
uiItemL(layout, IFACE_("Plane"), ICON_NONE);
uiItemS_ex(layout, 0.7f);
return true;
}

View File

@ -6377,20 +6377,15 @@ bool WM_window_modal_keymap_status_draw(bContext *C, wmWindow *win, uiLayout *la
}
const EnumPropertyItem *items = static_cast<const EnumPropertyItem *>(keymap->modal_items);
#ifdef WITH_HEADLESS
const bool collapse_xyz = false;
#else
bool axis_x = false;
bool axis_y = false;
bool axis_z = false;
/* If all the following are present we can collapse them into a compact form. */
int axis_items_count = 0;
for (int i = 0; items[i].identifier; i++) {
axis_x |= STREQ(items[i].identifier, "AXIS_X");
axis_y |= STREQ(items[i].identifier, "AXIS_Y");
axis_z |= STREQ(items[i].identifier, "AXIS_Z");
if (STR_ELEM(
items[i].identifier, "AXIS_X", "AXIS_Y", "AXIS_Z", "PLANE_X", "PLANE_Y", "PLANE_Z"))
{
axis_items_count++;
}
}
/* Only collapse these if all three are present. */
const bool collapse_xyz = axis_x && axis_y && axis_z;
#endif
uiLayout *row = uiLayoutRow(layout, true);
for (int i = 0; items[i].identifier; i++) {
@ -6418,7 +6413,7 @@ bool WM_window_modal_keymap_status_draw(bContext *C, wmWindow *win, uiLayout *la
/* Assume release events just disable something which was toggled on. */
continue;
}
if (collapse_xyz && uiTemplateEventFromKeymapItemXYZ(row, items[i].name, kmi)) {
if ((axis_items_count == 6) && uiTemplateEventFromKeymapItemXYZ(row, items[i], kmi)) {
continue;
}
if (uiTemplateEventFromKeymapItem(row, items[i].name, kmi, false)) {