VGUIWindow: migrate non Window specific bits into its own class: VGUIView
This commit is contained in:
parent
d66ebc4fd9
commit
da194e8eed
3 changed files with 77 additions and 34 deletions
|
@ -7,6 +7,7 @@
|
|||
../vgui/ui_menubutton.qc
|
||||
../vgui/ui_radio.qc
|
||||
../vgui/ui_checkbox.qc
|
||||
../vgui/ui_view.qc
|
||||
../vgui/ui_window.qc
|
||||
../vgui/ui_frame.qc
|
||||
../vgui/ui_label.qc
|
||||
|
|
73
src/vgui/ui_view.qc
Normal file
73
src/vgui/ui_view.qc
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* Copyright (c) 2016-2022 Vera Visions LLC.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
class VGUIView:VGUIWidget
|
||||
{
|
||||
public:
|
||||
void VGUIView(void);
|
||||
|
||||
/* overrides */
|
||||
virtual void Add(VGUIWidget);
|
||||
virtual void Draw(void);
|
||||
virtual bool Input(float, float, float, float);
|
||||
};
|
||||
|
||||
void
|
||||
VGUIView::VGUIView(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
VGUIView::Add(VGUIWidget wNew)
|
||||
{
|
||||
VGUIWidget wNext = this;
|
||||
VGUIWidget wParent;
|
||||
do {
|
||||
wParent = wNext;
|
||||
wNext = wNext.m_children;
|
||||
} while (wNext);
|
||||
wParent.m_children = wNew;
|
||||
wNew.m_parent = this;
|
||||
}
|
||||
|
||||
void VGUIView::Draw(void)
|
||||
{
|
||||
VGUIWidget wNext = this;
|
||||
g_vguiWidgetCount = 0;
|
||||
do {
|
||||
wNext = wNext.m_children;
|
||||
if (wNext && wNext.Visible() && wNext.m_parent.Visible()) {
|
||||
g_vguiWidgetCount++;
|
||||
wNext.Draw();
|
||||
}
|
||||
} while (wNext);
|
||||
}
|
||||
|
||||
bool VGUIView::Input (float flEVType, float flKey, float flChar, float flDevID)
|
||||
{
|
||||
float ret = false;
|
||||
|
||||
VGUIWidget wNext = this;
|
||||
do {
|
||||
wNext = wNext.m_children;
|
||||
if (wNext && wNext.Visible() && wNext.m_parent.Visible()) {
|
||||
ret = wNext.Input(flEVType, flKey, flChar, flDevID);
|
||||
}
|
||||
|
||||
if (ret == true)
|
||||
return true;
|
||||
} while (wNext);
|
||||
}
|
|
@ -41,7 +41,7 @@ typedef enumflags
|
|||
.void(void) tmpVGUIWindow2;
|
||||
|
||||
/** Top-most window class in VGUILib */
|
||||
class VGUIWindow:VGUIWidget
|
||||
class VGUIWindow:VGUIView
|
||||
{
|
||||
public:
|
||||
void VGUIWindow(void);
|
||||
|
@ -75,7 +75,6 @@ public:
|
|||
virtual void WindowDidClose(void);
|
||||
|
||||
/* overrides */
|
||||
virtual void Add(VGUIWidget);
|
||||
virtual void Draw(void);
|
||||
virtual void SizeChanged(vector, vector);
|
||||
virtual bool Input(float, float, float, float);
|
||||
|
@ -107,19 +106,6 @@ VGUIWindow::NowVisible(void)
|
|||
Focus();
|
||||
}
|
||||
|
||||
void
|
||||
VGUIWindow::Add(VGUIWidget wNew)
|
||||
{
|
||||
VGUIWidget wNext = this;
|
||||
VGUIWidget wParent;
|
||||
do {
|
||||
wParent = wNext;
|
||||
wNext = wNext.m_children;
|
||||
} while (wNext);
|
||||
wParent.m_children = wNew;
|
||||
wNew.m_parent = this;
|
||||
}
|
||||
|
||||
bool
|
||||
VGUIWindow::Focus(void)
|
||||
{
|
||||
|
@ -303,15 +289,7 @@ void VGUIWindow::Draw(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
VGUIWidget wNext = this;
|
||||
g_vguiWidgetCount = 0;
|
||||
do {
|
||||
wNext = wNext.m_children;
|
||||
if (wNext && wNext.Visible() && wNext.m_parent.Visible()) {
|
||||
g_vguiWidgetCount++;
|
||||
wNext.Draw();
|
||||
}
|
||||
} while (wNext);
|
||||
super::Draw();
|
||||
|
||||
#ifdef UI_DEVELOPER
|
||||
if (m_iFlags & WINDOW_DRAGGING) {
|
||||
|
@ -370,16 +348,7 @@ bool VGUIWindow::Input (float flEVType, float flKey, float flChar, float flDevID
|
|||
}
|
||||
|
||||
if (ret == false) {
|
||||
VGUIWidget wNext = this;
|
||||
do {
|
||||
wNext = wNext.m_children;
|
||||
if (wNext && wNext.Visible() && wNext.m_parent.Visible()) {
|
||||
ret = wNext.Input(flEVType, flKey, flChar, flDevID);
|
||||
}
|
||||
|
||||
if (ret == true)
|
||||
return true;
|
||||
} while (wNext);
|
||||
ret = super::Input(flEVType, flKey, flChar, flDevID);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
|
|
Loading…
Reference in a new issue