Skip to content

Commit

Permalink
Hiding Window internals
Browse files Browse the repository at this point in the history
All members (with the notable exception of `CloseFlag`) became private, since they are only accessed by the `Window` implementation itself. Likewise most instance methods became protected since windows are now constructed by subclasses instead of application code.
  • Loading branch information
ooxi committed Jan 17, 2016
1 parent 56858b4 commit c359640
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#include "windows/HighscoresWindow.h"
#include "windows/MainMenuWindow.h"
#include "windows/OptionsWindow.h"
#include "windows/Window.h"

using namespace std;
using namespace violet;
Expand Down
13 changes: 11 additions & 2 deletions src/windows/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,31 @@
#include <boost/function.hpp>
#include <map>
#include <string>

#include "../system/graphic/text/TextObject.h"
#include "../system/graphic/text/TextManager.h"
#include "../system/InputHandler.h"

namespace violet {

class Window {
protected:

private:
float m_left, m_top, m_right, m_bottom, m_r, m_g, m_b, m_a;
std::map<std::string, TextObject*> m_elements;

std::map<std::string, boost::function<void (std::string)> > m_lcHandlers;
std::map<std::string, boost::function<void (std::string)> > m_rcHandlers;
std::map<std::string, boost::function<void (std::string)> > m_mvHandlers;
public:

protected:

enum HandlerType {
hdl_all = 0, hdl_click, hdl_lclick, hdl_rclick, hdl_move
};

Window(float x, float y, int w, int h, float r, float g, float b, float a);

void addElement(std::string id, TextObject* element);
void addElement(std::string id, std::string text, TextManager const* manager,
int x, int y, TextManager::TextHAlignFlag halign,
Expand All @@ -36,6 +42,9 @@ class Window {
void removeElement(std::string name, bool remainHandler);
void addHandler(HandlerType hdl, std::string elementName, boost::function<void (std::string)> handler);
void removeHandler(HandlerType hdl, std::string elementName);

public:

void process(InputHandler* input);
void draw();
bool CloseFlag;
Expand Down

0 comments on commit c359640

Please sign in to comment.