Skip to content

Commit cb514e8

Browse files
committed
Add Window Dummy
1 parent d03c8b0 commit cb514e8

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

src/core/OSTreeTUI.cpp

+41-8
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@ std::vector<std::string> OSTreeTUI::parseVisibleCommitMap(cpplibostree::OSTreeRe
4545
return visibleCommitViewMap;
4646
}
4747

48+
/// tempoorary place holder from FTXUI window example:
49+
/// https://arthursonzogni.github.io/FTXUI/examples_2component_2window_8cpp-example.html
50+
ftxui::Component DummyWindowContent() {
51+
using namespace ftxui;
52+
class Impl : public ComponentBase {
53+
private:
54+
bool checked[3] = {false, false, false};
55+
float slider = 50;
56+
public:
57+
Impl() {
58+
Add(Container::Vertical({
59+
Checkbox("Check me", &checked[0]),
60+
Slider("Slider", &slider, 0.f, 100.f),
61+
}));
62+
}
63+
};
64+
return Make<Impl>();
65+
}
66+
4867
int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& startupBranches, bool showTooltips) {
4968
using namespace ftxui;
5069

@@ -158,14 +177,28 @@ int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& sta
158177
* > Snappy Windows should be an abstracted element, similar to windows, but snapping back to their
159178
* place after being dropped.
160179
*/
161-
Component logRenderer = Scroller(&selectedCommit, CommitRender::COMMIT_DETAIL_LEVEL, Renderer([&] {
162-
visibleCommitViewMap = parseVisibleCommitMap(ostreeRepo, visibleBranches);
163-
selectedCommit = std::min(selectedCommit, visibleCommitViewMap.size() - 1);
164-
return CommitRender::commitRender(ostreeRepo, visibleCommitViewMap, visibleBranches, branchColorMap, selectedCommit);
165-
}));
180+
Components windows;
181+
for (int i{0}; i < 20; i++) {
182+
windows.push_back(Window({
183+
.inner = DummyWindowContent(),
184+
.title = "Commit " + std::to_string(i),
185+
.left = 20,
186+
.top = i * 5,
187+
.width = 20,
188+
.height = 5,
189+
}));
190+
}
191+
192+
Component commitTree = Container::Stacked(windows);
193+
194+
//Component logRenderer = Scroller(&selectedCommit, CommitRender::COMMIT_DETAIL_LEVEL, Renderer([&] {
195+
// visibleCommitViewMap = parseVisibleCommitMap(ostreeRepo, visibleBranches);
196+
// selectedCommit = std::min(selectedCommit, visibleCommitViewMap.size() - 1);
197+
// return CommitRender::commitRender(ostreeRepo, visibleCommitViewMap, visibleBranches, branchColorMap, selectedCommit);
198+
//}));
166199

167200
// window specific shortcuts
168-
logRenderer = CatchEvent(logRenderer, [&](Event event) {
201+
commitTree = CatchEvent(commitTree, [&](Event event) {
169202
// switch through commits
170203
if (event == Event::ArrowUp || event == Event::Character('k') || (event.is_mouse() && event.mouse().button == Mouse::WheelUp)) {
171204
return prev_commit();
@@ -184,10 +217,10 @@ int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& sta
184217
int logSize{45};
185218
int footerSize{1};
186219
Component container{managerRenderer};
187-
container = ResizableSplitLeft(logRenderer, container, &logSize);
220+
container = ResizableSplitLeft(commitTree, container, &logSize);
188221
container = ResizableSplitBottom(footerRenderer, container, &footerSize);
189222

190-
logRenderer->TakeFocus();
223+
commitTree->TakeFocus();
191224

192225
// add application shortcuts
193226
Component mainContainer = CatchEvent(container | border, [&](const Event& event) {

0 commit comments

Comments
 (0)