Gorgon Game Engine
Base.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdexcept>
4 
5 
6 namespace Gorgon { namespace UI {
7 
8  class WidgetContainer;
9 
14  namespace Organizers {
18  class Base {
19  public:
20 
22  virtual ~Base() { }
23 
25  void AttachTo(WidgetContainer &container);
26 
28  void RemoveFrom();
29 
30 
32  bool IsAttached() const {
33  return attachedto != nullptr;
34  }
35 
39  if(!attachedto)
40  throw std::runtime_error("Organizer is not attached to any container");
41 
42  return *attachedto;
43  }
44 
46  void Reorganize();
47 
48  protected:
50  virtual void attachmentchanged() { }
51 
54  virtual void reorganize() = 0;
55 
56  private:
57  WidgetContainer *attachedto = nullptr;
58  bool organizing = false;
59  };
60  }
61 } }
Gorgon::UI::Organizers::Base::IsAttached
bool IsAttached() const
Returns if this organizer is attached to a container.
Definition: Base.h:32
Gorgon::UI::Organizers::Base::attachmentchanged
virtual void attachmentchanged()
Called when the attachment of the organizer is changed.
Definition: Base.h:50
Gorgon::UI::Organizers::Base
Provides the basis for the automatic UI organizers.
Definition: Base.h:18
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::UI::Organizers::Base::reorganize
virtual void reorganize()=0
Should reorganize the contents of the organizer.
Gorgon::UI::Organizers::Base::RemoveFrom
void RemoveFrom()
Removes the organizer from the container.
Definition: Base.cpp:17
Gorgon::UI::Organizers::Base::AttachTo
void AttachTo(WidgetContainer &container)
Attaches this organizer to a container.
Definition: Base.cpp:6
Gorgon::UI::Organizers::Base::~Base
virtual ~Base()
Ensuring correct destruction.
Definition: Base.h:22
Gorgon::UI::Organizers::Base::Reorganize
void Reorganize()
Reorganizes the widgets that are organized by this organizer.
Definition: Base.cpp:31
Gorgon::UI::Organizers::Base::GetAttached
WidgetContainer & GetAttached() const
Returns the container that this organizer is attached to.
Definition: Base.h:38
Gorgon::UI::WidgetContainer
This class is the base class for all widget containers.
Definition: WidgetContainer.h:37