2015-11-21 01:14:49 +00:00
|
|
|
#ifndef SPECTER_MENU_HPP
|
|
|
|
#define SPECTER_MENU_HPP
|
|
|
|
|
2016-01-13 01:31:50 +00:00
|
|
|
#include "View.hpp"
|
|
|
|
#include "TextView.hpp"
|
|
|
|
#include "ScrollView.hpp"
|
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
|
|
|
|
struct IMenuNode
|
|
|
|
{
|
|
|
|
virtual boo::ITexture* icon() const {return nullptr;}
|
|
|
|
virtual const std::string* text() const {return nullptr;}
|
|
|
|
virtual size_t subNodeCount() const {return 0;}
|
|
|
|
virtual IMenuNode* subNode(size_t idx) {return nullptr;}
|
2016-01-16 03:57:11 +00:00
|
|
|
virtual void activated(const boo::SWindowCoord& coord) {}
|
2016-01-13 01:31:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Menu : public View
|
|
|
|
{
|
|
|
|
IMenuNode* m_rootNode;
|
|
|
|
IMenuNode* m_thisNode;
|
|
|
|
std::unique_ptr<Menu> m_subMenu;
|
|
|
|
std::unique_ptr<TextView> m_headText;
|
|
|
|
|
2016-01-15 23:32:14 +00:00
|
|
|
int m_cWidth, m_cHeight, m_cTop;
|
2016-01-13 01:31:50 +00:00
|
|
|
|
2016-01-15 23:32:14 +00:00
|
|
|
SolidShaderVert m_verts[8];
|
2016-01-13 01:31:50 +00:00
|
|
|
VertexBufferBinding m_vertsBinding;
|
2016-01-16 03:57:11 +00:00
|
|
|
void setVerts(int width, int height, float pf);
|
2016-01-13 01:31:50 +00:00
|
|
|
|
|
|
|
struct ContentView : View
|
|
|
|
{
|
2016-01-15 23:32:14 +00:00
|
|
|
Menu& m_menu;
|
|
|
|
ContentView(ViewResources& res, Menu& menu);
|
|
|
|
|
|
|
|
boo::SWindowRect m_scissorRect;
|
|
|
|
SolidShaderVert m_hlVerts[4];
|
|
|
|
VertexBufferBinding m_hlVertsBinding;
|
|
|
|
|
|
|
|
size_t m_highlightedItem = -1;
|
|
|
|
void setHighlightedItem(size_t idx);
|
|
|
|
void unsetHighlightedItem(size_t idx)
|
|
|
|
{
|
|
|
|
if (m_highlightedItem == idx)
|
|
|
|
setHighlightedItem(-1);
|
|
|
|
}
|
2016-01-13 01:31:50 +00:00
|
|
|
|
|
|
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseMove(const boo::SWindowCoord&);
|
|
|
|
void mouseLeave(const boo::SWindowCoord&);
|
|
|
|
|
2016-01-15 23:32:14 +00:00
|
|
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub,
|
|
|
|
const boo::SWindowRect& scissor);
|
2016-01-13 01:31:50 +00:00
|
|
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
2016-01-15 23:32:14 +00:00
|
|
|
|
|
|
|
int nominalWidth() const {return m_menu.m_cWidth;}
|
|
|
|
int nominalHeight() const {return m_menu.m_cHeight;}
|
2016-01-13 01:31:50 +00:00
|
|
|
};
|
|
|
|
std::unique_ptr<ContentView> m_content;
|
|
|
|
ViewChild<std::unique_ptr<ScrollView>> m_scroll;
|
|
|
|
|
|
|
|
struct ItemView : View
|
|
|
|
{
|
|
|
|
Menu& m_menu;
|
|
|
|
std::unique_ptr<TextView> m_textView;
|
2016-01-15 23:32:14 +00:00
|
|
|
size_t m_idx;
|
2016-01-16 03:57:11 +00:00
|
|
|
IMenuNode& m_node;
|
|
|
|
ItemView(ViewResources& res, Menu& menu, const std::string& text, size_t idx, IMenuNode& node);
|
2016-01-13 01:31:50 +00:00
|
|
|
|
|
|
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseEnter(const boo::SWindowCoord&);
|
|
|
|
void mouseLeave(const boo::SWindowCoord&);
|
2016-01-15 23:32:14 +00:00
|
|
|
|
|
|
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
|
|
|
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
2016-01-13 01:31:50 +00:00
|
|
|
};
|
|
|
|
std::vector<ViewChild<std::unique_ptr<ItemView>>> m_items;
|
|
|
|
|
|
|
|
Menu(ViewResources& res, View& parentView, IMenuNode* rootNode, IMenuNode* thisNode);
|
|
|
|
|
|
|
|
public:
|
|
|
|
Menu(ViewResources& res, View& parentView, IMenuNode* rootNode);
|
|
|
|
void reset(IMenuNode* rootNode);
|
|
|
|
|
|
|
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
|
|
|
void mouseMove(const boo::SWindowCoord&);
|
|
|
|
void mouseLeave(const boo::SWindowCoord&);
|
|
|
|
void scroll(const boo::SWindowCoord&, const boo::SScrollDelta&);
|
|
|
|
|
2016-01-15 23:32:14 +00:00
|
|
|
void think();
|
2016-01-13 01:31:50 +00:00
|
|
|
void resized(const boo::SWindowRect& root, const boo::SWindowRect& sub);
|
|
|
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-11-21 01:14:49 +00:00
|
|
|
#endif // SPECTER_MENU_HPP
|