style improvements in Window.cpp / Window.h

This commit is contained in:
jacob1 2015-07-09 22:59:01 -04:00
parent f65c4363b1
commit 67bcd5e863
2 changed files with 125 additions and 152 deletions

View File

@ -36,7 +36,6 @@ Window::~Window()
void Window::AddComponent(Component* c)
{
// TODO: do a check if component was already added?
if (c->GetParentWindow() == NULL)
{
c->SetParentWindow(this);
@ -48,7 +47,7 @@ void Window::AddComponent(Component* c)
}
else
{
//Component already has a state, don't sad it
//Component already in a window
}
}
@ -121,32 +120,27 @@ void Window::FocusComponent(Component* c)
void Window::DoExit()
{
OnExit();
}
void Window::DoInitialized()
{
OnInitialized();
}
void Window::DoBlur()
{
OnBlur();
}
void Window::DoFocus()
{
OnFocus();
}
void Window::DoDraw()
{
OnDraw();
//draw
for (int i = 0, sz = Components.size(); i < sz; ++i)
if (Components[i]->Visible && ((Components[i] != focusedComponent_ && Components[i] != hoverComponent) || Components[i]->GetParent()))
{
@ -157,13 +151,12 @@ void Window::DoDraw()
}
else
{
if( Components[i]->Position.X+Position.X + Components[i]->Size.X >= 0 &&
Components[i]->Position.Y+Position.Y + Components[i]->Size.Y >= 0 &&
Components[i]->Position.X+Position.X < ui::Engine::Ref().GetWidth() &&
Components[i]->Position.Y+Position.Y < ui::Engine::Ref().GetHeight() )
if (scrpos.X + Components[i]->Size.X >= 0 &&
scrpos.Y + Components[i]->Size.Y >= 0 &&
scrpos.X < ui::Engine::Ref().GetWidth() &&
scrpos.Y < ui::Engine::Ref().GetHeight())
{
Point scrpos(Components[i]->Position.X + Position.X, Components[i]->Position.Y + Position.Y);
Components[i]->Draw( Point(scrpos) );
Components[i]->Draw(scrpos);
}
}
#ifdef DEBUG
@ -456,8 +449,8 @@ void Window::DoMouseMove(int x_, int y_, int dx, int dy)
{
if (!Components[i]->Locked && Components[i]->Visible)
{
Point local (x - Components[i]->Position.X, y - Components[i]->Position.Y)
, a (local.X - dx, local.Y - dy);
Point local(x - Components[i]->Position.X, y - Components[i]->Position.Y);
Point a(local.X - dx, local.Y - dy);
Components[i]->OnMouseMoved(local.X, local.Y, dx, dy);
@ -469,8 +462,7 @@ void Window::DoMouseMove(int x_, int y_, int dx, int dy)
Components[i]->OnMouseMovedInside(local.X, local.Y, dx, dy);
// entering?
if(!(
a.X >= 0 &&
if (!(a.X >= 0 &&
a.Y >= 0 &&
a.X < Components[i]->Size.X &&
a.Y < Components[i]->Size.Y ))

View File

@ -12,12 +12,12 @@ enum ChromeStyle
{
None, Title, Resizable
};
//class State;
class Engine;
class Component;
class Button;
/* class State
/* class Window
*
* A UI state. Contains all components.
*/
@ -35,19 +35,19 @@ enum ChromeStyle
bool AllowExclusiveDrawing; //false will not call draw on objects outside of bounds
// Add Component to state
// Add Component to window
void AddComponent(Component* c);
// Get the number of components this state has.
// Get the number of components this window has.
unsigned GetComponentCount();
// Get component by index. (See GetComponentCount())
Component* GetComponent(unsigned idx);
// Remove a component from state. NOTE: This DOES NOT free component from memory.
// Remove a component from window. NOTE: This DOES NOT free component from memory.
void RemoveComponent(Component* c);
// Remove a component from state. NOTE: This WILL free component from memory.
// Remove a component from window. NOTE: This WILL free component from memory.
void RemoveComponent(unsigned idx);
virtual void ToolTip(ui::Point senderPosition, std::string toolTip) {}
@ -113,24 +113,5 @@ enum ChromeStyle
bool stop;
};
/*class Window : public State
{
private:
ChromeStyle chrome;
public:
Window(Point _position, Point _size);
Point Position;
Point Size;
virtual void DoTick(float dt);
virtual void DoDraw();
virtual void DoMouseMove(int x, int y, int dx, int dy);
virtual void DoMouseDown(int x, int y, unsigned button);
virtual void DoMouseUp(int x, int y, unsigned button);
virtual void DoMouseWheel(int x, int y, int d);
};*/
}
#endif // WINDOW_H