UI: Optional Complex Layout for Workspace Status #120595

Merged
Harley Acheson merged 51 commits from Harley/blender:WorkspaceStatus into main 2024-05-06 23:52:47 +02:00
5 changed files with 61 additions and 81 deletions
Showing only changes of commit 1bfdf913d7 - Show all commits

View File

@ -403,8 +403,7 @@ static uiPopupBlockHandle *ui_popup_menu_create(
pup->but = but;
if (but->type == UI_BTYPE_PULLDOWN) {
WorkspaceStatus status(C);
status.item(IFACE_("Search"), ICON_EVENT_SPACEKEY);
ED_workspace_status_text(C, IFACE_("Press spacebar to search..."));
}
}
@ -611,12 +610,11 @@ static void ui_popup_menu_create_from_menutype(bContext *C,
STRNCPY(handle->menu_idname, mt->idname);
handle->can_refresh = true;
WorkspaceStatus status(C);
if (bool(mt->flag & MenuTypeFlag::SearchOnKeyPress)) {
status.range(IFACE_("Search"), ICON_EVENT_A, ICON_EVENT_Z);
ED_workspace_status_text(C, IFACE_("Type to search..."));
}
else if (mt->idname[0]) {
status.item(IFACE_("Search"), ICON_EVENT_SPACEKEY);
ED_workspace_status_text(C, IFACE_("Press spacebar to search..."));
}
}

View File

@ -72,11 +72,17 @@ struct InsetData {
static void edbm_inset_update_header(wmOperator *op, bContext *C)
{
InsetData *opdata = static_cast<InsetData *>(op->customdata);
const char *str = IFACE_(
"Confirm: Enter/LMB, Cancel: (Esc/RMB), Thickness: %s, "
"Depth (Ctrl to tweak): %s (%s), Outset (O): (%s), Boundary (B): (%s), Individual (I): "
"(%s)");
char msg[UI_MAX_DRAW_STR];
ScrArea *area = CTX_wm_area(C);
Scene *sce = CTX_data_scene(C);
if (area) {
char msg[UI_MAX_DRAW_STR];
char flts_str[NUM_STR_REP_LEN * 2];
if (hasNumInput(&opdata->num_input)) {
outputNumInput(&opdata->num_input, flts_str, &sce->unit);
@ -97,17 +103,16 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C)
&sce->unit,
true);
}
SNPRINTF(msg, IFACE_("Thickness: %s, Depth: %s"), flts_str, flts_str + NUM_STR_REP_LEN);
SNPRINTF(msg,
str,
flts_str,
flts_str + NUM_STR_REP_LEN,
WM_bool_as_string(opdata->modify_depth),
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_outset")),
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")),
WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual")));
ED_area_status_text(area, msg);
}
WorkspaceStatus status(C);
status.item(IFACE_("Confirm"), ICON_EVENT_RETURN, ICON_MOUSE_LMB);
status.item(IFACE_("Cancel"), ICON_EVENT_ESC, ICON_MOUSE_RMB);
status.item_bool(IFACE_("Tweak"), opdata->modify_depth, ICON_EVENT_CTRL);
status.item_bool(IFACE_("Outset"), RNA_boolean_get(op->ptr, "use_outset"), ICON_EVENT_O);
status.item_bool(IFACE_("Boundary"), RNA_boolean_get(op->ptr, "use_boundary"), ICON_EVENT_B);
status.item_bool(IFACE_("Individual"), RNA_boolean_get(op->ptr, "use_individual"), ICON_EVENT_I);
}
static bool edbm_inset_init(bContext *C, wmOperator *op, const bool is_modal)
@ -195,7 +200,6 @@ static void edbm_inset_exit(bContext *C, wmOperator *op)
if (area) {
ED_area_status_text(area, nullptr);
}
ED_workspace_status_text(C, nullptr);
MEM_SAFE_FREE(opdata->ob_store);
MEM_SAFE_FREE(op->customdata);

View File

@ -1102,29 +1102,25 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k
return WM_modalkeymap_operator_items_to_string(op->type, id, true).value_or("");
};
WorkspaceStatus status(C);
status.opmodal(IFACE_("Cut"), op->type, KNF_MODAL_ADD_CUT);
status.opmodal(IFACE_("Close"), op->type, KNF_MODAL_ADD_CUT_CLOSED);
status.opmodal(IFACE_("Stop"), op->type, KNF_MODAL_NEW_CUT);
status.opmodal(IFACE_("Confirm"), op->type, KNF_MODAL_CONFIRM);
status.opmodal(IFACE_("Cancel"), op->type, KNF_MODAL_CANCEL);
status.opmodal(IFACE_("Undo"), op->type, KNF_MODAL_UNDO);
status.opmodal("Pan View", op->type, KNF_MODAL_PANNING);
status.opmodal(IFACE_("Midpoint Snap"), op->type, KNF_MODAL_MIDPOINT_ON, kcd->snap_midpoints);
status.opmodal(
IFACE_("Ignore Snap"), op->type, KNF_MODAL_IGNORE_SNAP_ON, kcd->ignore_edge_snapping);
status.opmodal(IFACE_("Cut Through"), op->type, KNF_MODAL_CUT_THROUGH_TOGGLE, kcd->cut_through);
status.opmodal({}, op->type, KNF_MODAL_X_AXIS, kcd->constrain_axis == 1);
status.opmodal({}, op->type, KNF_MODAL_Y_AXIS, kcd->constrain_axis == 2);
status.opmodal({}, op->type, KNF_MODAL_Z_AXIS, kcd->constrain_axis == 3);
status.item(IFACE_("Axis"), ICON_NONE);
status.opmodal(
IFACE_("Measure"), op->type, KNF_MODAL_SHOW_DISTANCE_ANGLE_TOGGLE, kcd->show_dist_angle);
status.opmodal(IFACE_("X-Ray"), op->type, KNF_MODAL_DEPTH_TEST_TOGGLE, !kcd->depth_test);
const std::string angle = fmt::format(
"{}: {:.2f}({:.2f}) ({}{}{}{})",
IFACE_("Angle Constraint"),
const std::string header = fmt::format(
IFACE_("{}: confirm, {}: cancel, {}: undo, "
"{}: start/define cut, {}: close cut, {}: new cut, "
"{}: midpoint snap ({}), {}: ignore snap ({}), "
"{}: angle constraint {:.2f}({:.2f}) ({}{}{}{}), {}: cut through ({}), "
"{}: panning, {}{}{}: orientation lock ({}), "
"{}: distance/angle measurements ({}), "
"{}: x-ray ({})"),
get_modal_key_str(KNF_MODAL_CONFIRM),
get_modal_key_str(KNF_MODAL_CANCEL),
get_modal_key_str(KNF_MODAL_UNDO),
get_modal_key_str(KNF_MODAL_ADD_CUT),
get_modal_key_str(KNF_MODAL_ADD_CUT_CLOSED),
get_modal_key_str(KNF_MODAL_NEW_CUT),
get_modal_key_str(KNF_MODAL_MIDPOINT_ON),
WM_bool_as_string(kcd->snap_midpoints),
get_modal_key_str(KNF_MODAL_IGNORE_SNAP_ON),
WM_bool_as_string(kcd->ignore_edge_snapping),
get_modal_key_str(KNF_MODAL_ANGLE_SNAP_TOGGLE),
(kcd->angle >= 0.0f) ? RAD2DEGF(kcd->angle) : 360.0f + RAD2DEGF(kcd->angle),
(kcd->angle_snapping_increment > KNIFE_MIN_ANGLE_SNAPPING_INCREMENT &&
kcd->angle_snapping_increment <= KNIFE_MAX_ANGLE_SNAPPING_INCREMENT) ?
@ -1137,9 +1133,20 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k
(kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ?
get_modal_key_str(KNF_MODAL_CYCLE_ANGLE_SNAP_EDGE) :
"",
(kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? ": cycle edge" : "");
(kcd->angle_snapping_mode == KNF_CONSTRAIN_ANGLE_MODE_RELATIVE) ? ": cycle edge" : "", /**/
get_modal_key_str(KNF_MODAL_CUT_THROUGH_TOGGLE),
WM_bool_as_string(kcd->cut_through),
get_modal_key_str(KNF_MODAL_PANNING),
get_modal_key_str(KNF_MODAL_X_AXIS),
get_modal_key_str(KNF_MODAL_Y_AXIS),
get_modal_key_str(KNF_MODAL_Z_AXIS),
(kcd->axis_constrained ? kcd->axis_string : WM_bool_as_string(kcd->axis_constrained)),
get_modal_key_str(KNF_MODAL_SHOW_DISTANCE_ANGLE_TOGGLE),
WM_bool_as_string(kcd->show_dist_angle),
get_modal_key_str(KNF_MODAL_DEPTH_TEST_TOGGLE),
WM_bool_as_string(!kcd->depth_test));
status.opmodal(angle, op->type, KNF_MODAL_ANGLE_SNAP_TOGGLE);
ED_workspace_status_text(C, header.c_str());
}
/** \} */

View File

@ -21,7 +21,6 @@
#include "BKE_editmesh.hh"
#include "BKE_layer.hh"
#include "BKE_mask.h"
#include "BKE_workspace.hh"
#include "GPU_state.hh"
@ -541,10 +540,6 @@ static void viewRedrawForce(const bContext *C, TransInfo *t)
static void viewRedrawPost(bContext *C, TransInfo *t)
{
ED_area_status_text(t->area, nullptr);
WorkSpace *workspace = CTX_wm_workspace(C);
if (workspace) {
BKE_workspace_status_clear(workspace);
}
if (t->spacetype == SPACE_VIEW3D) {
/* If auto-keying is enabled, send notifiers that keyframes were added. */
@ -1436,11 +1431,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
WM_window_status_area_tag_redraw(CTX_wm_window(t->context));
}
WorkSpace *workspace = CTX_wm_workspace(t->context);
if (workspace) {
BKE_workspace_status_clear(workspace);
}
if (!is_navigating && (handled || t->redraw)) {
return 0;
}

View File

@ -80,7 +80,6 @@ struct EdgeSlideData {
};
struct EdgeSlideParams {
wmOperator *op = nullptr;
float perc;
/** When un-clamped - use this index: #TransDataEdgeSlideVert.dir_side. */
@ -786,6 +785,14 @@ static void applyEdgeSlide(TransInfo *t)
else {
ofs += BLI_snprintf_rlen(str + ofs, sizeof(str) - ofs, "%.4f ", final);
}
ofs += BLI_snprintf_rlen(
str + ofs, sizeof(str) - ofs, RPT_("(E)ven: %s, "), WM_bool_as_string(use_even));
if (use_even) {
ofs += BLI_snprintf_rlen(
str + ofs, sizeof(str) - ofs, RPT_("(F)lipped: %s, "), WM_bool_as_string(flipped));
}
ofs += BLI_snprintf_rlen(
str + ofs, sizeof(str) - ofs, RPT_("Alt or (C)lamp: %s"), WM_bool_as_string(is_clamp));
/* Done with header string. */
Harley marked this conversation as resolved Outdated

It's not ideal to get the operator from a global context.

Can you store op->type in EdgeSlideParams in initEdgeSlide perhaps?

It's not ideal to get the operator from a global context. Can you store `op->type` in `EdgeSlideParams` in `initEdgeSlide` perhaps?
/* Do stuff here. */
@ -794,27 +801,6 @@ static void applyEdgeSlide(TransInfo *t)
recalc_data(t);
ED_area_status_text(t->area, str);
wmOperator *op = slp->op;
if (!op) {
return;
}
WorkspaceStatus status(t->context);
status.opmodal(IFACE_("Confirm"), op->type, TFM_MODAL_CONFIRM);
status.opmodal(IFACE_("Cancel"), op->type, TFM_MODAL_CONFIRM);
status.opmodal(IFACE_("Set Snap Base"), op->type, TFM_MODAL_EDIT_SNAP_SOURCE_ON);
status.opmodal(IFACE_("Snap Invert"), op->type, TFM_MODAL_SNAP_INV_ON);
status.opmodal(IFACE_("Snap Invert"), op->type, TFM_MODAL_SNAP_TOGGLE);
status.opmodal(IFACE_("Move"), op->type, TFM_MODAL_TRANSLATE);
status.opmodal(IFACE_("Rotate"), op->type, TFM_MODAL_ROTATE);
status.opmodal(IFACE_("Resize"), op->type, TFM_MODAL_RESIZE);
status.opmodal(IFACE_("Precision Mode"), op->type, TFM_MODAL_PRECISION);
status.item_bool(IFACE_("Clamp"), is_clamp, ICON_EVENT_C, ICON_EVENT_ALT);
status.item_bool(IFACE_("Even"), use_even, ICON_EVENT_E);
if (use_even) {
status.item_bool(IFACE_("Flipped"), flipped, ICON_EVENT_F);
}
}
Harley marked this conversation as resolved Outdated

Some text uses TIP_, while other text uses IFACE_. I would expect it to use one or the other consistently?

Some text uses `TIP_`, while other text uses `IFACE_`. I would expect it to use one or the other consistently?

This was changed recently (!117234), and the decision was to use IFACE_ for the status bar.

This was changed recently (!117234), and the decision was to use `IFACE_` for the status bar.
static void edge_slide_transform_matrix_fn(TransInfo *t, float mat_xform[4][4])
@ -852,12 +838,8 @@ static void edge_slide_transform_matrix_fn(TransInfo *t, float mat_xform[4][4])
add_v3_v3(mat_xform[3], delta);
}
static void initEdgeSlide_ex(TransInfo *t,
wmOperator *op,
bool use_double_side,
bool use_even,
bool flipped,
bool use_clamp)
static void initEdgeSlide_ex(
TransInfo *t, bool use_double_side, bool use_even, bool flipped, bool use_clamp)
{
EdgeSlideData *sld;
bool ok = false;
@ -866,7 +848,6 @@ static void initEdgeSlide_ex(TransInfo *t,
{
EdgeSlideParams *slp = static_cast<EdgeSlideParams *>(MEM_callocN(sizeof(*slp), __func__));
slp->op = op;
slp->use_even = use_even;
slp->flipped = flipped;
/* Happens to be best for single-sided. */
@ -923,7 +904,7 @@ static void initEdgeSlide(TransInfo *t, wmOperator *op)
flipped = RNA_boolean_get(op->ptr, "flipped");
use_clamp = RNA_boolean_get(op->ptr, "use_clamp");
}
initEdgeSlide_ex(t, op, use_double_side, use_even, flipped, use_clamp);
initEdgeSlide_ex(t, use_double_side, use_even, flipped, use_clamp);
}
/** \} */