WIP: GUI Toolkit

This commit is contained in:
2015-03-09 01:11:13 +01:00
parent ffbc59140a
commit 9d7dd452c7
24 changed files with 1003 additions and 134 deletions

51
View.hh Normal file
View File

@@ -0,0 +1,51 @@
#ifndef __OPENGLPLAYGROUND_VIEW_HH__
#define __OPENGLPLAYGROUND_VIEW_HH__
#include <memory>
#include <vector>
#include <tuple>
#include <string>
#include "Widget.hh"
#include "common.hh"
class ChildNotFoundException : public Exception {
public:
ChildNotFoundException() : Exception() {
}
std::string toString() const override {
return "ChildNotFoundException"s;
}
};
/* Base class for all Widgets containing user-specified other Widgets
(i.e. Views/Layouts) */
class View : public Widget {
public:
View(int width = WRAP_CONTENT, int height = WRAP_CONTENT, std::string name = "");
View(View const& copy) = delete;
View& operator=(View const& copy) = delete;
~View();
void addChild(std::unique_ptr<Widget> child);
Widget& getChildByName(std::string name);
Widget const& getChildByName(std::string name) const;
std::unique_ptr<Widget> removeChild(std::string name);
std::unique_ptr<Widget> removeChild(Widget& child);
void render(SDL_Surface *dst, SDL_Rect *dstRect) const override;
protected:
SDL_Rect childrenBB_;
std::vector<std::tuple<std::string, std::unique_ptr<Widget>, SDL_Rect > > children_;
};
#endif