UI: Optional Complex Layout for Workspace Status #120595
|
@ -160,6 +160,9 @@ bool BKE_workspace_owner_id_check(const WorkSpace *workspace, const char *owner_
|
|||
|
||||
void BKE_workspace_id_tag_all_visible(Main *bmain, int tag) ATTR_NONNULL();
|
||||
|
||||
/**
|
||||
* Empty the Workspace status items to clear the status bar.
|
||||
*/
|
||||
void BKE_workspace_status_clear(struct WorkSpace *workspace);
|
||||
|
||||
#undef GETTER_ATTRS
|
||||
|
|
|
@ -461,27 +461,22 @@ void ED_workspace_status_item(bContext *C,
|
|||
|
||||
/* Adds a horizontal space to the status bar. */
|
||||
Harley marked this conversation as resolved
Outdated
|
||||
void ED_workspace_status_space(bContext *C, float space_factor = 1.0f);
|
||||
/* Adds one ormore icons to the status bar. */
|
||||
|
||||
/* Adds one or more icons to the status bar. */
|
||||
void ED_workspace_status_icons(bContext *C, const int icon);
|
||||
void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2);
|
||||
|
||||
/* Adds two icons, and text, indicating a range between the icons like A-Z. */
|
||||
Harley marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
Can this just be a single function?
Can this just be a single function?
```
void ED_workspace_status_icons(bContext *C, const int icon1, const int icon2 = 0);
```
|
||||
void ED_workspace_status_range(bContext *C,
|
||||
const std::string text,
|
||||
const int icon1,
|
||||
const int icon2);
|
||||
|
||||
void ED_workspace_status_key(bContext *C,
|
||||
const std::string text,
|
||||
const int icon,
|
||||
const bool shift = false,
|
||||
const bool ctrl = false,
|
||||
const bool alt = false,
|
||||
const bool oskey = false);
|
||||
|
||||
void ED_workspace_status_operator(bContext *C,
|
||||
const std::string text,
|
||||
wmOperatorType *ot,
|
||||
const int propvalue);
|
||||
/* Modal operator. */
|
||||
void ED_workspace_status_operator_modal(bContext *C,
|
||||
const std::string text,
|
||||
wmOperatorType *ot,
|
||||
const int propvalue);
|
||||
|
||||
/* Ends complex layout and requests a redraw of the status bar. */
|
||||
void ED_workspace_status_end(bContext *C);
|
||||
|
|
|
@ -1106,20 +1106,21 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k
|
|||
|
||||
std::string desc;
|
||||
|
||||
ED_workspace_status_operator(C, TIP_("Cut"), op->type, KNF_MODAL_ADD_CUT);
|
||||
ED_workspace_status_operator(C, TIP_("Stop"), op->type, KNF_MODAL_NEW_CUT);
|
||||
ED_workspace_status_operator(C, TIP_("Confirm"), op->type, KNF_MODAL_CONFIRM);
|
||||
ED_workspace_status_operator(C, TIP_("Cancel"), op->type, KNF_MODAL_CANCEL);
|
||||
ED_workspace_status_operator(C, TIP_("Undo"), op->type, KNF_MODAL_UNDO);
|
||||
ED_workspace_status_operator(C, "Pan View", op->type, KNF_MODAL_PANNING);
|
||||
ED_workspace_status_operator_modal(C, TIP_("Cut"), op->type, KNF_MODAL_ADD_CUT);
|
||||
ED_workspace_status_operator_modal(C, TIP_("Close"), op->type, KNF_MODAL_ADD_CUT_CLOSED);
|
||||
ED_workspace_status_operator_modal(C, TIP_("Stop"), op->type, KNF_MODAL_NEW_CUT);
|
||||
ED_workspace_status_operator_modal(C, TIP_("Confirm"), op->type, KNF_MODAL_CONFIRM);
|
||||
ED_workspace_status_operator_modal(C, TIP_("Cancel"), op->type, KNF_MODAL_CANCEL);
|
||||
ED_workspace_status_operator_modal(C, TIP_("Undo"), op->type, KNF_MODAL_UNDO);
|
||||
ED_workspace_status_operator_modal(C, "Pan View", op->type, KNF_MODAL_PANNING);
|
||||
|
||||
desc = IFACE_("Midpoint Snap: ");
|
||||
desc += WM_bool_as_string(kcd->snap_midpoints);
|
||||
ED_workspace_status_operator(C, desc, op->type, KNF_MODAL_MIDPOINT_ON);
|
||||
ED_workspace_status_operator_modal(C, desc, op->type, KNF_MODAL_MIDPOINT_ON);
|
||||
|
||||
desc = IFACE_("Ignore Snap: ");
|
||||
desc += WM_bool_as_string(kcd->ignore_edge_snapping);
|
||||
ED_workspace_status_operator(C, desc, op->type, KNF_MODAL_IGNORE_SNAP_ON);
|
||||
ED_workspace_status_operator_modal(C, desc, op->type, KNF_MODAL_IGNORE_SNAP_ON);
|
||||
|
||||
const std::string angle = fmt::format(
|
||||
"{}: {:.2f}({:.2f}) ({}{}{}{})",
|
||||
|
@ -1141,26 +1142,26 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k
|
|||
"",
|
||||
(kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? ": cycle edge" : "");
|
||||
|
||||
ED_workspace_status_operator(C, angle, op->type, KNF_MODAL_ANGLE_SNAP_TOGGLE);
|
||||
ED_workspace_status_operator_modal(C, angle, op->type, KNF_MODAL_ANGLE_SNAP_TOGGLE);
|
||||
|
||||
desc = IFACE_("Cut Through: ");
|
||||
desc += WM_bool_as_string(kcd->cut_through);
|
||||
ED_workspace_status_operator(C, desc, op->type, KNF_MODAL_CUT_THROUGH_TOGGLE);
|
||||
ED_workspace_status_operator_modal(C, desc, op->type, KNF_MODAL_CUT_THROUGH_TOGGLE);
|
||||
|
||||
ED_workspace_status_operator(C, "", op->type, KNF_MODAL_X_AXIS);
|
||||
ED_workspace_status_operator(C, "", op->type, KNF_MODAL_Y_AXIS);
|
||||
ED_workspace_status_operator(C, "", op->type, KNF_MODAL_Z_AXIS);
|
||||
ED_workspace_status_operator_modal(C, "", op->type, KNF_MODAL_X_AXIS);
|
||||
ED_workspace_status_operator_modal(C, "", op->type, KNF_MODAL_Y_AXIS);
|
||||
ED_workspace_status_operator_modal(C, "", op->type, KNF_MODAL_Z_AXIS);
|
||||
desc = IFACE_("Axis: ");
|
||||
desc += kcd->axis_constrained ? kcd->axis_string : WM_bool_as_string(kcd->axis_constrained);
|
||||
ED_workspace_status_item(C, desc);
|
||||
|
||||
desc = IFACE_("Measure: ");
|
||||
desc += WM_bool_as_string(kcd->show_dist_angle);
|
||||
ED_workspace_status_operator(C, desc, op->type, KNF_MODAL_SHOW_DISTANCE_ANGLE_TOGGLE);
|
||||
ED_workspace_status_operator_modal(C, desc, op->type, KNF_MODAL_SHOW_DISTANCE_ANGLE_TOGGLE);
|
||||
|
||||
desc = IFACE_("X-Ray: ");
|
||||
desc += WM_bool_as_string(!kcd->depth_test);
|
||||
ED_workspace_status_operator(C, desc, op->type, KNF_MODAL_DEPTH_TEST_TOGGLE);
|
||||
ED_workspace_status_operator_modal(C, desc, op->type, KNF_MODAL_DEPTH_TEST_TOGGLE);
|
||||
|
||||
ED_workspace_status_end(C);
|
||||
}
|
||||
|
|
|
@ -905,50 +905,41 @@ void ED_workspace_status_range(bContext *C,
|
|||
ED_workspace_status_space(C, 0.7f);
|
||||
}
|
||||
|
||||
void ED_workspace_status_key(bContext *C,
|
||||
const std::string text,
|
||||
const int icon,
|
||||
const bool shift,
|
||||
const bool ctrl,
|
||||
const bool alt,
|
||||
const bool oskey)
|
||||
{
|
||||
if (shift) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_SHIFT);
|
||||
}
|
||||
if (ctrl) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_CTRL);
|
||||
}
|
||||
if (alt) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_ALT);
|
||||
}
|
||||
if (oskey) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_OS);
|
||||
}
|
||||
ED_workspace_status_item(C, {}, icon);
|
||||
if (!text.empty()) {
|
||||
ED_workspace_status_space(C, 0.6f);
|
||||
ED_workspace_status_item(C, text, ICON_NONE);
|
||||
ED_workspace_status_space(C, 0.7f);
|
||||
}
|
||||
}
|
||||
|
||||
void ED_workspace_status_operator(bContext *C,
|
||||
const std::string text,
|
||||
wmOperatorType *ot,
|
||||
const int propvalue)
|
||||
void ED_workspace_status_operator_modal(bContext *C,
|
||||
const std::string text,
|
||||
wmOperatorType *ot,
|
||||
const int propvalue)
|
||||
{
|
||||
wmKeyMap *keymap = WM_keymap_active(CTX_wm_manager(C), ot->modalkeymap);
|
||||
if (keymap) {
|
||||
const wmKeyMapItem *kmi = WM_modalkeymap_find_propvalue(keymap, propvalue);
|
||||
if (kmi) {
|
||||
ED_workspace_status_key(C,
|
||||
text,
|
||||
UI_icon_from_event_type(kmi->type, kmi->val),
|
||||
!ELEM(kmi->shift, KM_NOTHING, KM_ANY),
|
||||
!ELEM(kmi->ctrl, KM_NOTHING, KM_ANY),
|
||||
!ELEM(kmi->alt, KM_NOTHING, KM_ANY),
|
||||
!ELEM(kmi->oskey, KM_NOTHING, KM_ANY));
|
||||
int icon = UI_icon_from_event_type(kmi->type, kmi->val);
|
||||
|
||||
if (!ELEM(kmi->shift, KM_NOTHING, KM_ANY)) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_SHIFT);
|
||||
}
|
||||
if (!ELEM(kmi->ctrl, KM_NOTHING, KM_ANY)) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_CTRL);
|
||||
}
|
||||
if (!ELEM(kmi->alt, KM_NOTHING, KM_ANY)) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_ALT);
|
||||
}
|
||||
if (!ELEM(kmi->oskey, KM_NOTHING, KM_ANY)) {
|
||||
ED_workspace_status_item(C, {}, ICON_EVENT_OS);
|
||||
}
|
||||
|
||||
if (kmi->val == KM_DBL_CLICK) {
|
||||
ED_workspace_status_item(C, "2x", ICON_NONE);
|
||||
ED_workspace_status_space(C, -0.8f);
|
||||
}
|
||||
|
||||
ED_workspace_status_item(C, {}, icon);
|
||||
if (!text.empty()) {
|
||||
ED_workspace_status_space(C, 0.6f);
|
||||
ED_workspace_status_item(C, text, ICON_NONE);
|
||||
ED_workspace_status_space(C, 0.7f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -801,16 +801,19 @@ static void applyEdgeSlide(TransInfo *t)
|
|||
|
||||
ED_workspace_status_begin(t->context);
|
||||
|
||||
ED_workspace_status_operator(t->context, TIP_("Confirm"), op->type, TFM_MODAL_CONFIRM);
|
||||
ED_workspace_status_operator(t->context, TIP_("Cancel"), op->type, TFM_MODAL_CONFIRM);
|
||||
ED_workspace_status_operator(
|
||||
ED_workspace_status_operator_modal(t->context, TIP_("Confirm"), op->type, TFM_MODAL_CONFIRM);
|
||||
Harley marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
Some text uses Some text uses `TIP_`, while other text uses `IFACE_`. I would expect it to use one or the other consistently?
Damien Picard
commented
This was changed recently (!117234), and the decision was to use This was changed recently (!117234), and the decision was to use `IFACE_` for the status bar.
|
||||
ED_workspace_status_operator_modal(t->context, TIP_("Cancel"), op->type, TFM_MODAL_CONFIRM);
|
||||
ED_workspace_status_operator_modal(
|
||||
t->context, TIP_("Set Snap Base"), op->type, TFM_MODAL_EDIT_SNAP_SOURCE_ON);
|
||||
ED_workspace_status_operator(+t->context, TIP_("Snap Invert"), op->type, TFM_MODAL_SNAP_INV_ON);
|
||||
ED_workspace_status_operator(t->context, TIP_("Snap Invert"), op->type, TFM_MODAL_SNAP_TOGGLE);
|
||||
ED_workspace_status_operator(t->context, TIP_("Move"), op->type, TFM_MODAL_TRANSLATE);
|
||||
ED_workspace_status_operator(t->context, TIP_("Rotate"), op->type, TFM_MODAL_ROTATE);
|
||||
ED_workspace_status_operator(t->context, TIP_("Resize"), op->type, TFM_MODAL_RESIZE);
|
||||
ED_workspace_status_operator(+t->context, TIP_("Precision Mode"), op->type, TFM_MODAL_PRECISION);
|
||||
ED_workspace_status_operator_modal(
|
||||
+t->context, TIP_("Snap Invert"), op->type, TFM_MODAL_SNAP_INV_ON);
|
||||
ED_workspace_status_operator_modal(
|
||||
t->context, TIP_("Snap Invert"), op->type, TFM_MODAL_SNAP_TOGGLE);
|
||||
ED_workspace_status_operator_modal(t->context, TIP_("Move"), op->type, TFM_MODAL_TRANSLATE);
|
||||
ED_workspace_status_operator_modal(t->context, TIP_("Rotate"), op->type, TFM_MODAL_ROTATE);
|
||||
ED_workspace_status_operator_modal(t->context, TIP_("Resize"), op->type, TFM_MODAL_RESIZE);
|
||||
ED_workspace_status_operator_modal(
|
||||
+t->context, TIP_("Precision Mode"), op->type, TFM_MODAL_PRECISION);
|
||||
|
||||
std::string desc;
|
||||
desc = IFACE_("Clamp: ");
|
||||
|
|
|
@ -136,7 +136,7 @@ typedef struct WorkSpace {
|
|||
/** Number for workspace tab reordering in the UI. */
|
||||
int order;
|
||||
|
||||
/** Info text from modal operators (runtime). */
|
||||
/** Info from modal operators to display in status bar (runtime). WorkSpaceStatusItem. */
|
||||
ListBase status;
|
||||
Harley marked this conversation as resolved
Outdated
Brecht Van Lommel
commented
I think we are trying to move away from using I think we are trying to move away from using `ListBase` and use `Vector` instead. That would involve creating a `WorkspaceRuntime` structure that contains this vector. And then having a `WorkspaceRuntime *runtime;` here.
|
||||
|
||||
/** Workspace-wide active asset library, for asset UIs to use (e.g. asset view UI template). The
|
||||
|
|
Loading…
Reference in New Issue
I'm not sure about overloading a function like this where one is a float and the other a boolean, it seems error prone. I would rather expect this to be a single function with 5 parameters, or two functions with different names.
Yes, I think the larger error here is that the base function that creates a new WorkSpaceStatusItem should probably be a local static function. The others are more like formatted output instead. This overload confuses these.