Skip to content

Commit 8a4e79c

Browse files
committed
add activity indicator on the slider
1 parent 177b89c commit 8a4e79c

File tree

3 files changed

+63
-28
lines changed

3 files changed

+63
-28
lines changed

Framework/Core/include/Framework/DeviceControl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ struct DeviceControl {
5252
int logStreams = 0;
5353
/// An incremental number to identify the device state
5454
int requestedState = 0;
55-
/// The first slot in the records buffer to display in GUI
56-
int firstSlot = 0;
55+
/// The first window in the records buffer to display in GUI
56+
int firstWnd = 1;
5757
};
5858

5959
} // namespace o2::framework

Framework/GUISupport/src/FrameworkGUIDataRelayerUsage.cxx

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,69 @@ struct HeatMapHelper {
4141
std::function<ImU32(int value)> const& getColor,
4242
std::function<void(int row, int column)> const& describeCell)
4343
{
44-
ImVec2 size = ImVec2(sizeHint.x, std::min(sizeHint.y, 16.f * getNumItems(0) + 2));
44+
float padding = 1;
45+
// add slider to scroll between the grid display windows
46+
size_t nw = getNumRecords() / WND;
47+
ImGui::PushItemWidth(sizeHint.x);
48+
ImGui::SliderInt("##window", &v, 1, nw, "wnd: %d", ImGuiSliderFlags_AlwaysClamp);
49+
ImVec2 sliderMin = ImGui::GetItemRectMin();
50+
51+
constexpr float MAX_BOX_X_SIZE = 16.f;
52+
constexpr float MAX_BOX_Y_SIZE = 32.f;
53+
54+
ImVec2 size = ImVec2(sizeHint.x, std::min(sizeHint.y, MAX_BOX_Y_SIZE * getNumItems(0) + 2));
4555
ImU32 BORDER_COLOR = ImColor(200, 200, 200, 255);
4656
ImU32 BACKGROUND_COLOR = ImColor(20, 20, 20, 255);
47-
constexpr float MAX_BOX_X_SIZE = 16.f;
48-
constexpr float MAX_BOX_Y_SIZE = 16.f;
57+
ImU32 BORDER_COLOR_A = ImColor(200, 200, 200, 0);
58+
ImU32 BACKGROUND_COLOR_A = ImColor(0, 0, 0, 0);
59+
4960
ImDrawList* drawList = ImGui::GetWindowDrawList();
50-
ImVec2 winPos = ImGui::GetCursorScreenPos() + ImVec2{0, 7};
51-
size_t recordsWindow = v + WND;
61+
ImVec2 winPos = sliderMin;
62+
63+
// overlay activity indicator on the slider
64+
auto xsz = size.x / nw;
65+
drawList->AddRectFilled(
66+
ImVec2{0., 0.} + winPos,
67+
ImVec2{size.x, size.y} + winPos,
68+
BACKGROUND_COLOR_A);
69+
drawList->AddRect(
70+
ImVec2{0. - 1, -1} + winPos,
71+
ImVec2{size.x + 1, size.y - 1} + winPos,
72+
BORDER_COLOR_A);
73+
74+
const static auto colorA = ImColor(ImVec4{0.945, 0.096, 0.278, 0.5});
75+
const static auto colorE = ImColor(ImVec4{0, 0, 0, 0});
76+
77+
drawList->PrimReserve(nw * 6, nw * 4);
78+
for (size_t iw = 0; iw < nw; ++iw) {
79+
ImVec2 xOffset{iw * xsz + 2 * padding, 0};
80+
ImVec2 xSize{xsz - 2 * padding, 0};
81+
ImVec2 yOffset{0, 2 * padding};
82+
ImVec2 ySize{0, 16 - 4 * padding};
83+
bool active = 0;
84+
for (size_t ir = iw; ir < ((iw + WND > getNumRecords()) ? getNumRecords() : iw + WND); ++ir) {
85+
for (size_t i = 0; i < getNumItems(ir); ++i) {
86+
active = getValue(*getItem(ir, i)) > 0;
87+
if (active) {
88+
break;
89+
}
90+
}
91+
}
92+
drawList->PrimRect(
93+
xOffset + yOffset + winPos,
94+
xOffset + xSize + yOffset + ySize + winPos,
95+
active ? colorA : colorE);
96+
}
97+
98+
// display the grid
99+
size_t recordsWindow = v * WND;
52100
auto boxSizeX = std::min(size.x / WND, MAX_BOX_X_SIZE);
53101
auto numInputs = getNumInputs();
54-
102+
winPos = ImGui::GetCursorScreenPos() + ImVec2{0, 7};
55103
ImGui::InvisibleButton("sensible area", ImVec2(size.x, size.y));
56104
if (ImGui::IsItemHovered()) {
57105
auto pos = ImGui::GetMousePos() - winPos;
58-
auto slot = v + std::lround(std::trunc(pos.x / size.x * WND));
106+
auto slot = (v - 1) * WND + std::lround(std::trunc(pos.x / size.x * WND));
59107
auto row = std::lround(std::trunc(pos.y / size.y * numInputs));
60108
describeCell(row, slot);
61109
}
@@ -68,18 +116,17 @@ struct HeatMapHelper {
68116
ImVec2(0. - 1, -1) + winPos,
69117
ImVec2{size.x + 1, size.y - 1} + winPos,
70118
BORDER_COLOR);
71-
float padding = 1;
72119

73120
size_t totalRects = 0;
74-
for (size_t ri = v; ri < recordsWindow; ri++) {
121+
for (size_t ri = (v - 1) * WND; ri < recordsWindow; ri++) {
75122
auto record = getRecord(ri);
76123
totalRects += getNumItems(record);
77124
}
78125

79126
drawList->PrimReserve(totalRects * 6, totalRects * 4);
80-
for (size_t ri = v; ri < recordsWindow; ri++) {
127+
for (size_t ri = (v - 1) * WND; ri < recordsWindow; ri++) {
81128
auto record = getRecord(ri);
82-
ImVec2 xOffset{((ri - v) * boxSizeX) + padding, 0};
129+
ImVec2 xOffset{((ri - (v - 1) * WND) * boxSizeX) + padding, 0};
83130
ImVec2 xSize{boxSizeX - 2 * padding, 0};
84131
auto me = getNumItems(record);
85132
auto boxSizeY = std::min(size.y / me, MAX_BOX_Y_SIZE);

Framework/GUISupport/src/FrameworkGUIDevicesGraph.cxx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ void showTopologyNodeGraph(WorkspaceGUIState& state,
692692
bool old_any_active = ImGui::IsAnyItemActive();
693693
ImGui::SetCursorScreenPos(node_rect_min + NODE_WINDOW_PADDING);
694694
ImGui::BeginGroup(); // Lock horizontal position
695+
ImGui::PushItemWidth(200.);
695696
ImGui::TextUnformatted(node->Name);
696697
switch (info.maxLogLevel) {
697698
case LogLevel::Critical:
@@ -713,21 +714,8 @@ void showTopologyNodeGraph(WorkspaceGUIState& state,
713714
default:
714715
break;
715716
}
716-
static int v = 0;
717-
auto records = [states = allStates[node->ID]]() -> size_t {
718-
auto& view = states.statesViews[(int)ProcessingStateId::DATA_RELAYER_BASE];
719-
if (view.size == 0) {
720-
return 0;
721-
}
722-
// The first number is the size of the pipeline
723-
int numRecords = strtoul(states.statesBuffer.data() + view.first, nullptr, 10);
724-
return numRecords;
725-
}();
726-
if (records > 0) {
727-
ImGui::PushItemWidth(140);
728-
ImGui::SliderInt("##window", &controls[node->ID].firstSlot, 0, records - gui::WND, "start: %d", ImGuiSliderFlags_AlwaysClamp);
729-
}
730-
gui::displayDataRelayer(metricsInfos[node->ID], infos[node->ID], specs[node->ID], allStates[node->ID], ImVec2(140., 90.), controls[node->ID].firstSlot);
717+
718+
gui::displayDataRelayer(metricsInfos[node->ID], infos[node->ID], specs[node->ID], allStates[node->ID], ImVec2(160., 90.), controls[node->ID].firstWnd);
731719
ImGui::EndGroup();
732720

733721
// Save the size of what we have emitted and whether any of the widgets are being used

0 commit comments

Comments
 (0)