Files
openglplayground/View.hh
2015-03-10 00:48:25 +01:00

55 lines
1.3 KiB
C++

#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 const& name);
Widget const& getChildByName(std::string const& name) const;
Widget& getPath(std::string const& path);
Widget const& getPath(std::string const& path) const;
std::unique_ptr<Widget> removeChild(std::string const& 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