Skip to content

Commit 799b756

Browse files
committed
refactor: extract export selection menu item
1 parent ffa3556 commit 799b756

4 files changed

Lines changed: 37 additions & 22 deletions

File tree

NEXT.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ before when explicitly requested (`SYS-W14-##` rows).
9999

100100
## 2. Current status
101101

102-
- **Last full build: clean after the current Phase 13 File-merge-scene
102+
- **Last full build: clean after the current Phase 13 File-export-selection
103103
slice.** Testing is enabled in the current Ninja Release tree, and
104104
`CCACHE_DISABLE=1 cmake --build b-release -j4` linked all targets successfully
105105
on EASYGL. Alternate-backend runtime qualification remains blocked.
@@ -790,8 +790,8 @@ Edit-snap-selection-to-grid, Edit-mirror-selection, Edit-group-scale,
790790
Edit-linear-array, Edit-scatter-along-curve, Edit-batch-rename,
791791
Edit-find-replace-names, Edit-randomize-transform, Edit-macro-recording,
792792
Edit-play-macro, Edit-macro-editor, Edit-lock-selection, Edit-reset-transform,
793-
Edit-transform-clipboard, Edit-isolate-selection, Edit-hide-selection, and
794-
Edit-show-all-hidden and File-merge-scene slices.
793+
Edit-transform-clipboard, Edit-isolate-selection, Edit-hide-selection,
794+
Edit-show-all-hidden, File-merge-scene, and File-export-selection slices.
795795
`EditHistoryContext` exposes only `canUndo`/`canRedo` plus Undo, Redo, and
796796
Open History callbacks; `Editor::UndoManager`, document replacement,
797797
selection restoration, dialog state, and keyboard handling remain
@@ -958,15 +958,15 @@ dispatch.
958958
buffers, source-file loading, document merging, undo, title and status updates,
959959
and error handling remain in their existing owners; `MenuBar` owns only the
960960
unchanged label and click dispatch.
961+
`FileExportSelectionContext` exposes only current-selection availability and one
962+
open-dialog callback. Selection state, dialog state and buffers, export
963+
implementation, document and error handling remain in their existing owners;
964+
`MenuBar` owns only the unchanged label, availability, and click dispatch.
961965

962-
**Next candidate, not yet authorized:** continue Phase 13 with the single
963-
File-menu Export Selection… item, passing only current-selection availability
964-
and one open-dialog callback. Selection state, dialog state and buffers, export
965-
implementation, document and error handling would remain in their existing
966-
owners; `MenuBar` would own only the unchanged label, availability, and click
967-
dispatch. Other File items, later controls, and the View-menu Bloom/SSAO block
968-
remain outside that slice. Per `CLAUDE.md`, describe and confirm the
969-
Export-Selection item before implementing it.
966+
**Next candidate, not yet authorized:** identify the next narrow File-menu
967+
item before implementation. The remaining File controls and the View-menu
968+
Bloom/SSAO block remain outside this completed slice. Per `CLAUDE.md`, describe
969+
and confirm any next item before implementing it.
970970

971971
## 9. Do not do yet
972972

include/MeshCraft/Application/UI/MenuBar.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ struct FileMergeSceneContext {
3434
std::function<void()> openDialog;
3535
};
3636

37+
struct FileExportSelectionContext {
38+
bool canExport;
39+
std::function<void()> openDialog;
40+
};
41+
3742
struct EditHistoryContext {
3843
bool canUndo;
3944
bool canRedo;
@@ -220,6 +225,7 @@ class MenuBar final {
220225
public:
221226
static void drawAddMenu(const std::function<void(Mc3::ObjectType)>& addPrimitive);
222227
static void drawFileMergeScene(const FileMergeSceneContext& context);
228+
static void drawFileExportSelection(const FileExportSelectionContext& context);
223229
static void drawEditClipboard(const EditClipboardContext& context);
224230
static void drawEditCopyProperties(const EditCopyPropertiesContext& context);
225231
static void drawEditGrouping(const EditGroupingContext& context);

plan.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,9 @@ still internally consistent.
174174
Edit-find-replace-names, Edit-randomize-transform, Edit-macro-recording,
175175
Edit-play-macro, Edit-macro-editor, Edit-lock-selection,
176176
Edit-reset-transform, Edit-transform-clipboard, Edit-isolate-selection,
177-
Edit-hide-selection, Edit-show-all-hidden, and File-merge-scene menu slices
178-
are implemented and verified. Their state remains in the existing
177+
Edit-hide-selection, Edit-show-all-hidden, File-merge-scene, and
178+
File-export-selection menu slices are implemented and verified. Their state
179+
remains in the existing
179180
editor/application owners;
180181
`Application::UI::MenuBar` receives only the read-only values and callbacks
181182
required for presentation. Any further slice requires its own confirmation
@@ -774,8 +775,9 @@ _All items in this workstream are DONE — archived to [`docs/history/plan_20260
774775
Edit-find-replace-names, Edit-randomize-transform, Edit-macro-recording,
775776
Edit-play-macro, Edit-macro-editor, Edit-lock-selection,
776777
Edit-reset-transform, Edit-transform-clipboard, Edit-isolate-selection,
777-
Edit-hide-selection, Edit-show-all-hidden, and File-merge-scene slices, each
778-
incremental Release link and the same 147/147 + 34/34 partitions pass again.
778+
Edit-hide-selection, Edit-show-all-hidden, File-merge-scene, and
779+
File-export-selection slices, each incremental Release link and the same
780+
147/147 + 34/34 partitions pass again.
779781
For the current MenuBar slices, the public UI header also compiles as a
780782
self-contained C++23 include, `undo_snapshot_lint_test.py` passes, and
781783
`git diff --check` is clean. A further Phase 13 slice requires separate

src/MeshCraft/Application/UI/MenuBar.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,15 @@ float MeshCraftApplication::drawMenuBar()
9090
// black box (see runObjExport()'s own comment) rather than a
9191
// second from-scratch scene-traversal implementation.
9292
if (ImGui::MenuItem("Export OBJ...")) exportObj();
93-
{
94-
bool hasSel = !selection_.selection().empty();
95-
if (!hasSel) ImGui::BeginDisabled();
96-
if (ImGui::MenuItem("Export Selection...", nullptr, false, hasSel)) {
93+
const UI::FileExportSelectionContext fileExportSelectionContext{
94+
.canExport = !selection_.selection().empty(),
95+
.openDialog = [this] {
9796
selExportBuf_[0] = '\0';
9897
selExportErr_[0] = '\0';
9998
selExportOpen_ = true;
100-
}
101-
if (!hasSel) ImGui::EndDisabled();
102-
}
99+
},
100+
};
101+
UI::MenuBar::drawFileExportSelection(fileExportSelectionContext);
103102
const UI::FileMergeSceneContext fileMergeSceneContext{
104103
.openDialog = [this] {
105104
mergeSceneBuf_[0] = '\0';
@@ -586,6 +585,14 @@ void MenuBar::drawFileMergeScene(const FileMergeSceneContext& context) {
586585
if (ImGui::MenuItem("Merge Scene...")) context.openDialog();
587586
}
588587

588+
void MenuBar::drawFileExportSelection(const FileExportSelectionContext& context) {
589+
if (!context.canExport) ImGui::BeginDisabled();
590+
if (ImGui::MenuItem("Export Selection...", nullptr, false, context.canExport)) {
591+
context.openDialog();
592+
}
593+
if (!context.canExport) ImGui::EndDisabled();
594+
}
595+
589596
void MenuBar::drawEditHistory(const EditHistoryContext& context) {
590597
if (ImGui::MenuItem("Undo", "Ctrl+Z", false, context.canUndo)) context.undo();
591598
if (ImGui::MenuItem("Redo", "Ctrl+Y", false, context.canRedo)) context.redo();

0 commit comments

Comments
 (0)