Skip to content

Commit

Permalink
xrUICore: CUITrackBar - Added support for value output via CUIStatic …
Browse files Browse the repository at this point in the history
…(":output_wnd" in xml)
  • Loading branch information
ShokerStlk committed Jan 16, 2019
1 parent f52d576 commit e94970a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/xrUICore/TrackBar/UITrackBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ CUITrackBar::CUITrackBar()
m_pSlider = new CUI3tButton();
AttachChild(m_pSlider);
m_pSlider->SetAutoDelete(true);

m_static = new CUIStatic();
m_static->Enable(false);
AttachChild(m_static);
m_static->SetAutoDelete(true);

m_b_mouse_capturer = false;
}

Expand Down Expand Up @@ -106,6 +112,7 @@ void CUITrackBar::Draw()
{
CUI_IB_FrameLineWnd::Draw();
m_pSlider->Draw();
m_static->Draw();
}

void CUITrackBar::Update()
Expand Down Expand Up @@ -290,6 +297,20 @@ void CUITrackBar::UpdatePos()
pos.x = free_space - pos.x;

m_pSlider->SetWndPos(pos);

if (m_static->IsEnabled())
{
string256 buff;
if (m_b_is_float)
{
xr_sprintf(buff, (m_static_format == nullptr ? "%.1f" : m_static_format.c_str()), m_f_val);
}
else
{
xr_sprintf(buff, (m_static_format == nullptr ? "%d" : m_static_format.c_str()), m_i_val);
}
m_static->TextItemControl()->SetTextST(buff);
}
}

void CUITrackBar::OnMessage(LPCSTR message)
Expand Down
3 changes: 3 additions & 0 deletions src/xrUICore/TrackBar/UITrackBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class XRUICORE_API CUITrackBar : public CUI_IB_FrameLineWnd, public CUIOptionsIt
void SetOptIBounds(int imin, int imax);
void SetOptFBounds(float fmin, float fmax);

CUIStatic* m_static;
shared_str m_static_format;

protected:
void UpdatePos();
void UpdatePosRelativeToMouse();
Expand Down
9 changes: 9 additions & 0 deletions src/xrUICore/XML/UIXmlInitBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,6 +1167,15 @@ bool CUIXmlInitBase::InitTrackBar(CUIXml& xml_doc, LPCSTR path, int index, CUITr
}
}

string512 buf;
strconcat(sizeof(buf), buf, path, ":output_wnd");
if (xml_doc.NavigateToNode(buf, index))
{
InitStatic(xml_doc, buf, index, pWnd->m_static);
pWnd->m_static_format = xml_doc.ReadAttrib(buf, index, "format", nullptr);
pWnd->m_static->Enable(true);
}

return true;
}

Expand Down

0 comments on commit e94970a

Please sign in to comment.