Skip to content

Commit

Permalink
Add debug facility for CUIScrollBar and CUIScrollView
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Jan 9, 2025
1 parent eabe172 commit 002ab6a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/xrUICore/ScrollBar/UIScrollBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,29 @@ void CUIScrollBar::Draw()
}

void CUIScrollBar::Refresh() { SendMessage(m_ScrollBox, SCROLLBOX_MOVE, nullptr); }

void CUIScrollBar::FillDebugInfo()
{
#ifndef MASTER_GOLD
CUIWindow::FillDebugInfo();

if (!ImGui::CollapsingHeader(CUIScrollBar::GetDebugType()))
return;

ImGui::DragFloat("Hold delay", &m_hold_delay);
if (ImGui::DragInt("Scroll position", &m_iScrollPos, 1.0f, m_iMinPos, ScrollSize()))
{
UpdateScrollBar();
Refresh();
}
ImGui::DragInt("Step size", &m_iStepSize);
ImGui::DragInt("Min position", &m_iMinPos);
ImGui::DragInt("Max position", &m_iMaxPos);
ImGui::DragInt("Page size", &m_iPageSize);
ImGui::DragInt("Scroll work area", &m_ScrollWorkArea);

ImGui::Checkbox("Enabled##CUIScrollbar", &m_b_enabled);
ImGui::SameLine();
ImGui::Checkbox("Horizontal", &m_bIsHorizontal);
#endif
}
1 change: 1 addition & 0 deletions src/xrUICore/ScrollBar/UIScrollBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ class XRUICORE_API CUIScrollBar : public CUIWindow
void TryScrollDec(bool by_scrollbox = false);

pcstr GetDebugType() override { return "CUIScrollBar"; }
void FillDebugInfo() override;
};
44 changes: 44 additions & 0 deletions src/xrUICore/ScrollView/UIScrollView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,3 +400,47 @@ void CUIScrollView::UpdateChildrenLenght()
it->SetWidth(len);
}
}

void CUIScrollView::FillDebugInfo()
{
#ifndef MASTER_GOLD
CUIWindow::FillDebugInfo();

if (!ImGui::CollapsingHeader(CUIScrollView::GetDebugType()))
return;

ImGui::DragFloat("Up indent", &m_upIndent);
ImGui::DragFloat("Down indent", &m_downIndent);
ImGui::DragFloat("Left indent", &m_leftIndent);
ImGui::DragFloat("Right indent", &m_rightIndent);

ImGui::DragFloat("Vertical interval", &m_vertInterval);

ImGui::Separator();
ImGui::Text("Flags:");

if (ImGui::Button("Recalculate"))
m_flags.set(eNeedRecalc, true);

const auto addFlag = [this](pcstr text, u16 flag)
{
ImGui::SameLine();
bool value = m_flags.test(flag);
if (ImGui::Checkbox(text, &value))
m_flags.set(flag, value);
};

addFlag("Vertical flip", eVertFlip);
addFlag("Fixed scrollbar", eFixedScrollBar);
addFlag("Items selectable", eItemsSelectabe);
addFlag("Inverse direction", eInverseDir);

ImGui::Separator();
ImGui::LabelText("Scrollbar profile", "%s", m_scrollbar_profile.empty() ? "" : m_scrollbar_profile.c_str());
ImGui::Separator();

ImGui::BeginDisabled();
ImGui::DragInt2("Visible region", (int*)&m_visible_rgn);
ImGui::EndDisabled();
#endif
}
1 change: 1 addition & 0 deletions src/xrUICore/ScrollView/UIScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class XRUICORE_API CUIScrollView : public CUIWindow, public CUIWndCallback
CUIScrollBar* ScrollBar() { return m_VScrollBar; }

pcstr GetDebugType() override { return "CUIScrollView"; }
void FillDebugInfo() override;

typedef fastdelegate::FastDelegate2<CUIWindow*, CUIWindow*, bool> cmp_function;
cmp_function m_sort_function;
Expand Down

0 comments on commit 002ab6a

Please sign in to comment.