Skip to content

Commit

Permalink
Use Event::Info struct instead of typedef.
Browse files Browse the repository at this point in the history
  • Loading branch information
billyquith committed Jun 23, 2016
1 parent baa1e15 commit 4cad484
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 20 deletions.
3 changes: 1 addition & 2 deletions source/gwork/include/Gwork/ControlList.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ namespace Gwk
class Handler;
struct Information;
struct Packet;

typedef const Gwk::Event::Information& Info;
struct Info;
}

template <typename TYPE>
Expand Down
2 changes: 1 addition & 1 deletion source/gwork/include/Gwork/Controls/Button.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace Gwk

virtual void DoAction() override
{
Event::Information info(this);
Event::Info info(this);
OnPress(info);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Gwk

virtual void DoChanged()
{
Event::Information info(this);
Event::Info info(this);
info.String = GetPropertyValue();
onChange.Call(this, info);
}
Expand Down
10 changes: 4 additions & 6 deletions source/gwork/include/Gwork/Events.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace Gwk
: Control(control)
{}

// TODO - union? variant?
Gwk::Controls::Base *Control;
Gwk::String String;
int Integer;
Expand All @@ -44,11 +45,11 @@ namespace Gwk


/**
* Passed to an event hook
* Passed to an event listener.
*/
struct Information
struct Info
{
Information(Gwk::Controls::Base* ctrl)
Info(Gwk::Controls::Base* ctrl)
: ControlCaller(nullptr)
, Packet(nullptr)
, Control(ctrl)
Expand All @@ -73,9 +74,6 @@ namespace Gwk
int Integer;
};


typedef const Gwk::Event::Information& Info;

/**
* A class wanting to receive events must be derived from this.
*/
Expand Down
8 changes: 4 additions & 4 deletions source/gwork/source/Controls/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Button::OnMouseClickLeft(int /*x*/, int /*y*/, bool bDown)
{
if (IsHovered() && m_bDepressed)
{
OnPress(Event::Information(this));
OnPress(Event::Info(this));
}

SetDepressed(false);
Expand All @@ -83,7 +83,7 @@ void Button::OnMouseClickRight(int /*x*/, int /*y*/, bool bDown)
{
if (IsHovered() && m_bDepressed)
{
OnRightPress(Event::Information(this));
OnRightPress(Event::Info(this));
}

SetDepressed(false);
Expand Down Expand Up @@ -173,15 +173,15 @@ bool Button::OnKeySpace(bool bDown)
{
if (bDown)
{
OnPress(Event::Information(this));
OnPress(Event::Info(this));
}

return true;
}

void Button::AcceleratePressed()
{
OnPress(Event::Information(this));
OnPress(Event::Info(this));
}

void Button::UpdateColours()
Expand Down
2 changes: 1 addition & 1 deletion source/gwork/source/Controls/Dragger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void Dragger::OnMouseMoved(int x, int y, int deltaX, int deltaY)
m_target->MoveTo(p.x, p.y);
}

Gwk::Event::Information info(this);
Gwk::Event::Info info(this);
info.Point = Gwk::Point(deltaX, deltaY);
onDragged.Call(this, info);
}
Expand Down
2 changes: 1 addition & 1 deletion source/gwork/source/Controls/PageControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void PageControl::ShowPage(unsigned int i)
}

{
Event::Information info(this);
Event::Info info(this);
info.Integer = i;
info.Control = m_pages[i];
onPageChanged.Call(this, info);
Expand Down
2 changes: 1 addition & 1 deletion source/gwork/source/Controls/Properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void PropertyRow::SetProperty(Property::Base* prop)

void PropertyRow::OnPropertyValueChanged(Event::Info info)
{
Event::Information sinfo(info);
Event::Info sinfo(info);
sinfo.String = GetProperty()->GetPropertyValue();
onChange.Call(this, sinfo);
}
Expand Down
2 changes: 1 addition & 1 deletion source/gwork/source/Controls/TabControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void TabControl::AddPage(TabButton* button)
button->onPress.Add(this, &TabControl::OnTabPressed);

if (!m_currentButton)
button->OnPress(Event::Information(this));
button->OnPress(Event::Info(this));

onAddTab.Call(this);
Invalidate();
Expand Down
4 changes: 2 additions & 2 deletions source/gwork/source/Events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ void Listener::CleanLinks()

void Listener::Call(Controls::Base* pThis)
{
Event::Information info(pThis);
Event::Info info(pThis);
info.Control = pThis;
Call(pThis, info);
}

void Listener::Call(Controls::Base* pThis, Event::Info information)
{
Event::Information info(nullptr);
Event::Info info(nullptr);
info = information;
info.ControlCaller = pThis;
std::list<HandlerInstance>::iterator iter;
Expand Down

0 comments on commit 4cad484

Please sign in to comment.