Polyphase Game Engine
Loading...
Searching...
No Matches
GitWorkspaceWindow.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include "GitTypes.h"
6#include <string>
7#include <vector>
8#include <cstdint>
9
10class GitWorkspaceWindow
11{
12public:
13 void Open();
14 void Close();
15 bool IsOpen() const;
16 void Draw();
17
18private:
19 bool mIsOpen = false;
20
21 // Selection state shared across sub-views
22 int32_t mSelectedCommitIndex = -1;
23 std::string mSelectedCommitOid;
24 std::string mSelectedFilePath;
25 int32_t mActiveSidebarSection = 0; // 0=FileStatus, 1=History, 2=Branches, 3=Tags, 4=Remotes
26 char mHistoryFilterText[256] = {0};
27 bool mShowAllBranches = false;
28 int32_t mHistoryPageCount = 100;
29
30 // Sub-view draw methods (all inline in the .cpp)
31 void DrawToolbar();
32 void DrawSidebar(float width, float height);
33 void DrawMainArea(float width, float height);
34 void DrawHistoryView(float width, float height);
35 void DrawStatusView(float width, float height);
36 void DrawDiffInspector(float width, float height);
37 void DrawCommitComposer(float width, float height);
38 void DrawOutputLog(float width, float height);
39
40 // Commit composer state
41 char mCommitSummary[256] = {0};
42 char mCommitBody[4096] = {0};
43 bool mAmendCommit = false;
44
45 // Output log
46 struct LogEntry { std::string mText; int32_t mLevel; }; // 0=info, 1=warn, 2=error
47 std::vector<LogEntry> mLogEntries;
48 bool mLogAutoScroll = true;
49
50 // Cached diff for display
51 GitFileDiff mCurrentDiff;
52 bool mDiffDirty = true;
53
54 // Checkout choice popup state
55 bool mCheckoutChoiceOpen = false;
56 std::string mCheckoutChoiceOid;
57 std::vector<std::string> mCheckoutChoiceBranches;
58 int32_t mCheckoutChoiceSelected = 0;
59
60 void DrawCheckoutChoicePopup();
61
62 // ---- Repo switcher (toolbar dropdown) ----
63 // Cached list of repos the user can switch into:
64 // [0] = current project (if it's a git repo)
65 // [1..N-1] = each addon under <Project>/Packages/ that resolves to
66 // a git repo (via AddonCreator::HasGitRepo).
67 // Refreshed when the active project changes OR when the user clicks
68 // the dropdown (cheap rescan — addon list is typically <20 entries).
69 struct RepoEntry
70 {
71 std::string mLabel; // dropdown display ("Current Project", "Addon: foo")
72 std::string mPath; // working-tree root passed to GitService::OpenRepository
73 };
74 std::vector<RepoEntry> mRepoChoices;
75 std::string mRepoChoicesProjectDir;
76 bool mRepoComboWasOpen = false;
77 // Deferred repo switch: the Selectable handler stores the target path
78 // here and the actual OpenRepository call happens at the top of the
79 // NEXT Draw(). This lets the combo close cleanly first and gives the
80 // rest of the window one frame to clear stale per-repo state (diff,
81 // selected commit, etc.) before re-rendering against the new repo.
82 std::string mPendingRepoSwitch;
83 void RefreshRepoChoices();
84 void DrawRepoSwitcher();
85 void ProcessPendingRepoSwitch();
86};
87
88GitWorkspaceWindow* GetGitWorkspaceWindow();
89
90#endif