Skip to content

Commit

Permalink
enhance rough demo version
Browse files Browse the repository at this point in the history
  • Loading branch information
forgottosave committed Oct 21, 2024
1 parent e25674b commit 1e2c598
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
48 changes: 34 additions & 14 deletions src/core/OSTreeTUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,24 @@ std::vector<std::string> OSTreeTUI::parseVisibleCommitMap(cpplibostree::OSTreeRe
return visibleCommitViewMap;
}

/// tempoorary place holder from FTXUI window example:
/// https://arthursonzogni.github.io/FTXUI/examples_2component_2window_8cpp-example.html
ftxui::Component DummyWindowContent() {
/// temporary place holder commit entry
/// modified dummy window from FTXUI window example: https://arthursonzogni.github.io/FTXUI/examples_2component_2window_8cpp-example.html
ftxui::Component DummyWindowContent(cpplibostree::Commit commit) {
using namespace ftxui;
class Impl : public ComponentBase {
private:
bool checked[3] = {false, false, false};
float slider = 50;
public:
Impl() {
Impl(cpplibostree::Commit commit) {
Add(Container::Vertical({
Checkbox("Check me", &checked[0]),
Slider("Slider", &slider, 0.f, 100.f),
Checkbox(commit.subject, &checked[0]),
Checkbox(std::format("{:%Y-%m-%d %T %Ez}", std::chrono::time_point_cast<std::chrono::seconds>(commit.timestamp)), &checked[0]),
//Slider("Slider", &slider, 0.f, 100.f),
}));
}
};
return Make<Impl>();
return Make<Impl>(commit);
}

int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& startupBranches, bool showTooltips) {
Expand Down Expand Up @@ -176,21 +177,40 @@ int OSTreeTUI::main(const std::string& repo, const std::vector<std::string>& sta
* a drag & drop funcitonality.
* > Snappy Windows should be an abstracted element, similar to windows, but snapping back to their
* place after being dropped. Possibly also omit the window border (only show when dragged).
* > There should obviously still be a commit tree on the left side. How the exact implementation
* would go is still to be figured out. It this would be one, or many different elements mainly
* depends on how the overlap detection with branches would work, when dragging commits.
*/
Components windows;
for (int i{0}; i < 20; i++) {
// TODO parse actual commits
if (ostreeRepo.getCommitList().size() <= 0) {
windows.push_back(Renderer([&] {
return text("no commits to show");
}));
}

int i{0};
for (auto& [hash,commit] : ostreeRepo.getCommitList()) {
windows.push_back(Window({
.inner = DummyWindowContent(),
.title = "Commit " + std::to_string(i),
.left = 20,
.top = i * 5,
.width = 30,
.height = 5,
.inner = DummyWindowContent(commit),
.title = hash.substr(0, 8),
.left = 20,
.top = i * 4,
.width = 30,
.height = 4,
.resize_left = false,
.resize_right = false,
.resize_top = false,
.resize_down = false,
}));
i++;
}

Component commitTree = Container::Stacked(windows);

// TODO add commit tree

// old component:
//Component logRenderer = Scroller(&selectedCommit, CommitRender::COMMIT_DETAIL_LEVEL, Renderer([&] {
// visibleCommitViewMap = parseVisibleCommitMap(ostreeRepo, visibleBranches);
// selectedCommit = std::min(selectedCommit, visibleCommitViewMap.size() - 1);
Expand Down
14 changes: 4 additions & 10 deletions src/core/snappyWindow.hpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,17 @@
#ifndef SCROLLER_H
#define SCROLLER_H
#ifndef SNAPPYWINDOW_H
#define SNAPPYWINDOW_H

#include <ftxui/component/component.hpp>

#include "ftxui/component/component_base.hpp" // for Component

namespace ftxui {
/**
* @brief This Scroller Element is a modified version of the Scroller in the following repository:
* Title: git-tui
* Author: Arthur Sonzogni
* Date: 2021
* Availability: https://github.com/ArthurSonzogni/git-tui/blob/master/src/scroller.cpp
* @brief
*
* @param selectedCommit
* @param child
* @return Component
*/
Component SnappyWindow();

} // namespace ftxui
#endif /* end of include guard: SCROLLER_H */
#endif /* end of include guard: SNAPPYWINDOW_H */

0 comments on commit 1e2c598

Please sign in to comment.