#ifndef __OPENGLPLAYGROUND_VIEW_HH__ #define __OPENGLPLAYGROUND_VIEW_HH__ #include #include #include #include #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 child); Widget& getChildByName(std::string name); Widget const& getChildByName(std::string name) const; std::unique_ptr removeChild(std::string name); std::unique_ptr removeChild(Widget& child); void render(SDL_Surface *dst, SDL_Rect *dstRect) const override; protected: SDL_Rect childrenBB_; std::vector, SDL_Rect > > children_; }; #endif