mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Add tooltip support for editboxes in editor
Add tooltips for envelope name, point value and point time.
This commit is contained in:
parent
cf32aa95f9
commit
c86ef06c5c
|
@ -307,17 +307,19 @@ void CEditor::EnvelopeEval(int TimeOffsetMillis, int Env, ColorRGBA &Channels, v
|
|||
OTHER
|
||||
*********************************************************/
|
||||
|
||||
bool CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners)
|
||||
bool CEditor::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners, const char *pToolTip)
|
||||
{
|
||||
if(UI()->LastActiveItem() == pID)
|
||||
m_EditBoxActive = 2;
|
||||
UpdateTooltip(pID, pRect, pToolTip);
|
||||
return UI()->DoEditBox(pID, pRect, pStr, StrSize, FontSize, pOffset, Hidden, Corners);
|
||||
}
|
||||
|
||||
bool CEditor::DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners)
|
||||
bool CEditor::DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners, const char *pToolTip)
|
||||
{
|
||||
if(UI()->LastActiveItem() == pID)
|
||||
m_EditBoxActive = 2;
|
||||
UpdateTooltip(pID, pRect, pToolTip);
|
||||
return UI()->DoClearableEditBox(pID, pClearID, pRect, pStr, StrSize, FontSize, pOffset, Hidden, Corners);
|
||||
}
|
||||
|
||||
|
@ -370,23 +372,22 @@ ColorRGBA CEditor::GetButtonColor(const void *pID, int Checked)
|
|||
}
|
||||
}
|
||||
|
||||
void CEditor::UpdateTooltip(const void *pID, const CUIRect *pRect, const char *pToolTip)
|
||||
{
|
||||
if((UI()->MouseInside(pRect) && m_pTooltip) || (UI()->HotItem() == pID && pToolTip))
|
||||
m_pTooltip = pToolTip;
|
||||
}
|
||||
|
||||
int CEditor::DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip)
|
||||
{
|
||||
if(UI()->MouseInside(pRect))
|
||||
{
|
||||
if(Flags & BUTTON_CONTEXT)
|
||||
ms_pUiGotContext = pID;
|
||||
if(m_pTooltip)
|
||||
m_pTooltip = pToolTip;
|
||||
}
|
||||
|
||||
if(UI()->HotItem() == pID && pToolTip)
|
||||
m_pTooltip = pToolTip;
|
||||
|
||||
UpdateTooltip(pID, pRect, pToolTip);
|
||||
return UI()->DoButtonLogic(pID, Checked, pRect);
|
||||
|
||||
// Draw here
|
||||
//return UI()->DoButton(id, text, checked, r, draw_func, 0);
|
||||
}
|
||||
|
||||
int CEditor::DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int AlignVert)
|
||||
|
@ -4924,7 +4925,7 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
ToolBar.VSplitLeft(80.0f, &Button, &ToolBar);
|
||||
|
||||
static float s_NameBox = 0;
|
||||
if(DoEditBox(&s_NameBox, &Button, pEnvelope->m_aName, sizeof(pEnvelope->m_aName), 10.0f, &s_NameBox))
|
||||
if(DoEditBox(&s_NameBox, &Button, pEnvelope->m_aName, sizeof(pEnvelope->m_aName), 10.0f, &s_NameBox, false, IGraphics::CORNER_ALL, "The name of the selected envelope"))
|
||||
{
|
||||
m_Map.m_Modified = true;
|
||||
}
|
||||
|
@ -5309,9 +5310,9 @@ void CEditor::RenderEnvelopeEditor(CUIRect View)
|
|||
}
|
||||
|
||||
static float s_ValNumber = 0;
|
||||
DoEditBox(&s_ValNumber, &ToolBar1, s_aStrCurValue, sizeof(s_aStrCurValue), 10.0f, &s_ValNumber);
|
||||
DoEditBox(&s_ValNumber, &ToolBar1, s_aStrCurValue, sizeof(s_aStrCurValue), 10.0f, &s_ValNumber, false, IGraphics::CORNER_ALL, "The value of the selected envelope point");
|
||||
static float s_TimeNumber = 0;
|
||||
DoEditBox(&s_TimeNumber, &ToolBar2, s_aStrCurTime, sizeof(s_aStrCurTime), 10.0f, &s_TimeNumber);
|
||||
DoEditBox(&s_TimeNumber, &ToolBar2, s_aStrCurTime, sizeof(s_aStrCurTime), 10.0f, &s_TimeNumber, false, IGraphics::CORNER_ALL, "The time of the selected envelope point");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1065,6 +1065,8 @@ public:
|
|||
char m_aSettingsCommand[256];
|
||||
|
||||
void PlaceBorderTiles();
|
||||
|
||||
void UpdateTooltip(const void *pID, const CUIRect *pRect, const char *pToolTip);
|
||||
int DoButton_Editor_Common(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip);
|
||||
int DoButton_Editor(const void *pID, const char *pText, int Checked, const CUIRect *pRect, int Flags, const char *pToolTip, int AlignVert = 1);
|
||||
int DoButton_Env(const void *pID, const char *pText, int Checked, const CUIRect *pRect, const char *pToolTip, ColorRGBA Color);
|
||||
|
@ -1082,8 +1084,8 @@ public:
|
|||
|
||||
int DoButton_ColorPicker(const void *pID, const CUIRect *pRect, ColorRGBA *pColor, const char *pToolTip = nullptr);
|
||||
|
||||
bool DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL);
|
||||
bool DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden, int Corners);
|
||||
bool DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const char *pToolTip = nullptr);
|
||||
bool DoClearableEditBox(void *pID, void *pClearID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *pOffset, bool Hidden = false, int Corners = IGraphics::CORNER_ALL, const char *pToolTip = nullptr);
|
||||
|
||||
void RenderBackground(CUIRect View, IGraphics::CTextureHandle Texture, float Size, float Brightness);
|
||||
|
||||
|
|
Loading…
Reference in a new issue