WIP: GUI Toolkit
This commit is contained in:
51
View.hh
Normal file
51
View.hh
Normal 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
|
||||
Reference in New Issue
Block a user