mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-10-01 01:43:41 +08:00
cabana: prevent signal panel collapse (#38903)
* cabana: keep signal scrolling inside the list * cabana: reserve space for the signal panel
This commit is contained in:
@@ -218,16 +218,17 @@ void DetailWidget::drawTabWidget() {
|
||||
ImGui::BeginChild("page", ImVec2(0, std::max(page_rect.GetHeight() - pill_height - gap, 1.0f)),
|
||||
ImGuiChildFlags_None, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
||||
if (tab_widget_index_ == 0) {
|
||||
// binary_view_ keeps its size hint, signal_view_ takes the rest
|
||||
// Reserve the signal toolbar and rows before giving the byte grid its preferred height.
|
||||
const float min_height = binary_view_->minimumSizeHint().y;
|
||||
const float avail = ImGui::GetContentRegionAvail().y;
|
||||
const float max_height = std::max(avail - style.ItemSpacing.y - 1.0f, 1.0f);
|
||||
const float max_height = std::max(avail - style.ItemSpacing.y - SignalView::minimumHeight(), 1.0f);
|
||||
const float height = std::clamp(min_height, 1.0f, max_height);
|
||||
ImGui::BeginChild("binary_view", ImVec2(0, height), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
binary_view_rect_ = ImGui::GetCurrentWindow()->Rect();
|
||||
binary_view_->draw();
|
||||
ImGui::EndChild();
|
||||
ImGui::BeginChild("signal_view", ImVec2(0, 0));
|
||||
ImGui::BeginChild("signal_view", ImVec2(0, 0), ImGuiChildFlags_None,
|
||||
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
|
||||
signal_view_rect_ = ImGui::GetCurrentWindow()->Rect();
|
||||
signal_view_->draw();
|
||||
ImGui::EndChild();
|
||||
|
||||
@@ -690,9 +690,16 @@ float SignalView::minimumWidth() {
|
||||
return left_width + style.ItemSpacing.x + toolBarRightWidth("00:00") + (style.WindowPadding.x + style.ChildBorderSize) * 2;
|
||||
}
|
||||
|
||||
float SignalView::minimumHeight() {
|
||||
const ImGuiStyle &style = ImGui::GetStyle();
|
||||
return ImGui::GetFrameHeight() + style.ItemSpacing.y + signalRowHeight() * 3 +
|
||||
(style.WindowPadding.y + style.ChildBorderSize + CONTROL_OUTLINE_PADDING) * 2;
|
||||
}
|
||||
|
||||
void SignalView::draw() {
|
||||
ImGui::PushStyleColor(ImGuiCol_ChildBg, palette().surface);
|
||||
if (!ImGui::BeginChild("SignalView", ImVec2(0, 0), ImGuiChildFlags_Borders)) {
|
||||
if (!ImGui::BeginChild("SignalView", ImVec2(0, 0), ImGuiChildFlags_Borders,
|
||||
ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse)) {
|
||||
ImGui::EndChild();
|
||||
ImGui::PopStyleColor();
|
||||
return;
|
||||
@@ -740,8 +747,8 @@ void SignalView::collapseAll() {
|
||||
|
||||
void SignalView::drawTree() {
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(ImGui::GetStyle().ItemSpacing.x, 0.0f));
|
||||
const float min_height = std::max(ImGui::GetContentRegionAvail().y, 300.0f);
|
||||
const bool visible = beginControlChild("tree", ImVec2(0, min_height));
|
||||
// Keep the toolbar fixed; only the signal rows scroll within the remaining space.
|
||||
const bool visible = beginControlChild("tree", ImVec2(0, 0));
|
||||
if (visible) {
|
||||
DrawContext ctx{ImGui::GetWindowDrawList(), ImGui::GetCursorScreenPos().x, ImGui::GetContentRegionAvail().x, rowHeight()};
|
||||
// the press that closes an open editor is consumed by the focus change, the index widgets never see it
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
void setMessage(const MessageId &id);
|
||||
void draw();
|
||||
static float minimumWidth();
|
||||
static float minimumHeight();
|
||||
void signalHovered(const cabana::Signal *sig); // handler for BinaryView::signalHovered
|
||||
void updateChartState();
|
||||
void selectSignal(const cabana::Signal *sig, bool expand = false);
|
||||
|
||||
Reference in New Issue
Block a user