From 5a452884fca73f6e10fadd354565daae9fc72159 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 20 Jan 2025 02:35:01 +0100 Subject: [PATCH] UI: Improve Status Bar Display for GP Lines When adding Grease Pencil lines, circles, curves, etc this PR updates how the status bar shows options. No big changes just substituting icons for text. Pull Request: https://projects.blender.org/blender/blender/pulls/133279 --- .../intern/grease_pencil_primitive.cc | 64 ++++--------------- 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_primitive.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_primitive.cc index e7ca5deaedf..a958cae0eaf 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_primitive.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_primitive.cc @@ -586,51 +586,17 @@ static void grease_pencil_primitive_status_indicators(bContext *C, wmOperator *op, PrimitiveToolOperation &ptd) { - std::string header; - - switch (ptd.type) { - case PrimitiveType::Line: { - header += RPT_("Line: "); - break; - } - case (PrimitiveType::Polyline): { - header += RPT_("Polyline: "); - break; - } - case (PrimitiveType::Box): { - header += RPT_("Rectangle: "); - break; - } - case (PrimitiveType::Circle): { - header += RPT_("Circle: "); - break; - } - case (PrimitiveType::Arc): { - header += RPT_("Arc: "); - break; - } - case (PrimitiveType::Curve): { - header += RPT_("Curve: "); - break; - } - } - - auto get_modal_key_str = [&](ModalKeyMode id) { - return WM_modalkeymap_operator_items_to_string(op->type, int(id), true).value_or(""); - }; - - header += fmt::format(fmt::runtime(IFACE_("{}: confirm, {}: cancel, {}: panning, Shift: align")), - get_modal_key_str(ModalKeyMode::Confirm), - get_modal_key_str(ModalKeyMode::Cancel), - get_modal_key_str(ModalKeyMode::Panning)); - - header += fmt::format(fmt::runtime(IFACE_(", {}/{}: adjust subdivisions: {}")), - get_modal_key_str(ModalKeyMode::IncreaseSubdivision), - get_modal_key_str(ModalKeyMode::DecreaseSubdivision), - int(ptd.subdivision)); + WorkspaceStatus status(C); + status.opmodal(IFACE_("Confirm"), op->type, int(ModalKeyMode::Confirm)); + status.opmodal(IFACE_("Cancel"), op->type, int(ModalKeyMode::Cancel)); + status.opmodal(IFACE_("Panning"), op->type, int(ModalKeyMode::Panning)); + status.item(IFACE_("Align"), ICON_EVENT_SHIFT); + status.opmodal("", op->type, int(ModalKeyMode::IncreaseSubdivision)); + status.opmodal("", op->type, int(ModalKeyMode::DecreaseSubdivision)); + status.item(fmt::format("{} ({})", IFACE_("subdivisions"), int(ptd.subdivision)), ICON_NONE); if (ptd.segments == 1) { - header += IFACE_(", Alt: center"); + status.item(IFACE_("Center"), ICON_EVENT_ALT); } if (ELEM(ptd.type, @@ -639,16 +605,12 @@ static void grease_pencil_primitive_status_indicators(bContext *C, PrimitiveType::Arc, PrimitiveType::Curve)) { - header += fmt::format(fmt::runtime(IFACE_(", {}: extrude")), - get_modal_key_str(ModalKeyMode::Extrude)); + status.opmodal(IFACE_("Extrude"), op->type, int(ModalKeyMode::Extrude)); } - header += fmt::format(fmt::runtime(IFACE_(", {}: grab, {}: rotate, {}: scale")), - get_modal_key_str(ModalKeyMode::Grab), - get_modal_key_str(ModalKeyMode::Rotate), - get_modal_key_str(ModalKeyMode::Scale)); - - ED_workspace_status_text(C, header.c_str()); + status.opmodal(IFACE_("Grab"), op->type, int(ModalKeyMode::Grab)); + status.opmodal(IFACE_("Rotate"), op->type, int(ModalKeyMode::Rotate)); + status.opmodal(IFACE_("Scale"), op->type, int(ModalKeyMode::Scale)); } static void grease_pencil_primitive_update_view(bContext *C, PrimitiveToolOperation &ptd)