aboutsummaryrefslogtreecommitdiffstats
path: root/src/menu
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2012-03-22 17:07:36 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2013-01-05 17:17:52 +0100
commite53dba73eca8238775df52e4177d83eb0a473de2 (patch)
tree52bf6e5800bc7e777769b5e57692cbb5719fb6e8 /src/menu
parent1c39e66f571fb9767257740ee74889ce0eb78993 (diff)
downloadusdx-e53dba73eca8238775df52e4177d83eb0a473de2.tar.gz
usdx-e53dba73eca8238775df52e4177d83eb0a473de2.tar.xz
usdx-e53dba73eca8238775df52e4177d83eb0a473de2.zip
menu: keep frame in container
before the current frame was stored in application, now every container could keep a frame and paint it before all other content
Diffstat (limited to 'src/menu')
-rw-r--r--src/menu/application.cpp22
-rw-r--r--src/menu/application.hpp6
-rw-r--r--src/menu/container.cpp16
-rw-r--r--src/menu/container.hpp6
4 files changed, 23 insertions, 27 deletions
diff --git a/src/menu/application.cpp b/src/menu/application.cpp
index 28862a8c..7e6c9216 100644
--- a/src/menu/application.cpp
+++ b/src/menu/application.cpp
@@ -70,25 +70,6 @@ namespace usdx
return instance;
}
- void Application::draw(void)
- {
- if (frame) {
- frame->repaint();
- }
-
- Container::draw();
- }
-
- const Frame *Application::get_current_frame(void) const
- {
- return frame;
- }
-
- void Application::set_current_frame(Frame* new_frame)
- {
- frame = new_frame;
- }
-
void Application::main_loop(SDL_Surface* display)
{
SDL_Event event;
@@ -97,8 +78,7 @@ namespace usdx
DrawableControl *p = new SoftwareMousePointer(this, &event_manager);
p->repaint();
- LoadingFrame frame;
- set_current_frame(&frame);
+ LoadingFrame frame(this);
running = true;
while (running) {
diff --git a/src/menu/application.hpp b/src/menu/application.hpp
index 72e5f3a3..de23cf6d 100644
--- a/src/menu/application.hpp
+++ b/src/menu/application.hpp
@@ -44,7 +44,6 @@ namespace usdx
static Application* instance;
SDL_Surface* display;
- Frame* frame;
FPSmanager* fps_manager;
bool running;
@@ -61,8 +60,6 @@ namespace usdx
protected:
Application(Container* parent);
- void draw(void);
-
public:
virtual ~Application();
@@ -70,9 +67,6 @@ namespace usdx
void run(void);
- const Frame* get_current_frame(void) const;
- void set_current_frame(Frame* new_frame);
-
const int get_frames_per_second(void) const;
void set_frames_per_second(int fps);
};
diff --git a/src/menu/container.cpp b/src/menu/container.cpp
index a5519f0d..379dd7c1 100644
--- a/src/menu/container.cpp
+++ b/src/menu/container.cpp
@@ -25,6 +25,7 @@
*/
#include "container.hpp"
+#include "frame.hpp"
namespace usdx
{
@@ -43,6 +44,10 @@ namespace usdx
void Container::draw(void)
{
+ if (frame) {
+ frame->repaint();
+ }
+
for (std::list<DrawableControl*>::iterator it =
controls.begin(); it != controls.end(); it++) {
(*it)->repaint();
@@ -58,4 +63,15 @@ namespace usdx
{
controls.remove(child);
}
+
+ void Container::setFrame(Frame *f)
+ {
+ f->set_size(get_size());
+ frame = f;
+ }
+
+ void Container::removeFrame(void)
+ {
+ frame = NULL;
+ }
};
diff --git a/src/menu/container.hpp b/src/menu/container.hpp
index ce12ce39..dd5a8a32 100644
--- a/src/menu/container.hpp
+++ b/src/menu/container.hpp
@@ -34,11 +34,14 @@
namespace usdx
{
+ class Frame;
+
class Container : public DrawableControl
{
private:
static log4cpp::Category& log;
+ Frame* frame;
std::list<DrawableControl*> controls;
protected:
@@ -50,6 +53,9 @@ namespace usdx
virtual void add(DrawableControl*);
virtual void remove(DrawableControl*);
+
+ virtual void setFrame(Frame*);
+ virtual void removeFrame(void);
};
};