SatDump 2.0.0-alpha-76a915210
Loading...
Searching...
No Matches
tree.h
Go to the documentation of this file.
1#pragma once
2
6
7#include "core/style.h"
8
9namespace satdump
10{
11 namespace handlers
12 {
19 {
20 float SmallOffsetX = 11.0f - 22; // for now, a hardcoded value; should take into account tree indent size
21
22 ImDrawList *drawList = nullptr;
23
24 ImVec2 verticalLineStart = {0, 0};
25
26 ImVec2 verticalLineEnd = {0, 0};
27
28 void start()
29 {
30 drawList = ImGui::GetWindowDrawList();
31
32 verticalLineStart = ImGui::GetCursorScreenPos();
33 verticalLineStart.x += SmallOffsetX * ui_scale; // to nicely line up with the arrow symbol
34 verticalLineEnd = verticalLineStart;
35 }
36
37 bool node(std::string icon)
38 {
39 const float HorizontalTreeLineSize = 8.0f * ui_scale; // chosen arbitrarily
40 const float minY = ImGui::GetCursorScreenPos().y - 20 * ui_scale;
41 const float midpoint = minY + HorizontalTreeLineSize;
42 drawList->AddLine(ImVec2(verticalLineStart.x, midpoint), ImVec2(verticalLineStart.x + HorizontalTreeLineSize, midpoint), style::theme.treeview_icon);
43 drawList->AddText(ImVec2(verticalLineStart.x + HorizontalTreeLineSize * 2.0f, minY), style::theme.treeview_icon, icon.c_str());
44 verticalLineEnd.y = midpoint;
45 return false;
46 }
47
48 float end()
49 {
50 drawList->AddLine(verticalLineStart, verticalLineEnd, style::theme.treeview_icon);
51
52 return verticalLineEnd.y - verticalLineStart.y;
53 }
54 };
55 } // namespace handlers
56} // namespace satdump
Handler Tree Drawer.
Definition tree.h:19