mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-07-05 05:15:53 +00:00
Initial RootView-hosted boundary action menu
This commit is contained in:
parent
08b288039d
commit
a5954a9d7c
@ -54,6 +54,7 @@ list(APPEND SPECTER_HEADERS
|
|||||||
include/Specter/TextField.hpp
|
include/Specter/TextField.hpp
|
||||||
include/Specter/NumericField.hpp
|
include/Specter/NumericField.hpp
|
||||||
include/Specter/Menu.hpp
|
include/Specter/Menu.hpp
|
||||||
|
include/Specter/IMenuNode.hpp
|
||||||
include/Specter/Node.hpp
|
include/Specter/Node.hpp
|
||||||
include/Specter/NodeSocket.hpp
|
include/Specter/NodeSocket.hpp
|
||||||
include/Specter/PathButtons.hpp
|
include/Specter/PathButtons.hpp
|
||||||
|
20
specter/include/Specter/IMenuNode.hpp
Normal file
20
specter/include/Specter/IMenuNode.hpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef SPECTER_IMENUNODE_HPP
|
||||||
|
#define SPECTER_IMENUNODE_HPP
|
||||||
|
|
||||||
|
#include "View.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;}
|
||||||
|
virtual void activated(const boo::SWindowCoord& coord) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SPECTER_IMENUNODE_HPP
|
@ -4,19 +4,11 @@
|
|||||||
#include "View.hpp"
|
#include "View.hpp"
|
||||||
#include "TextView.hpp"
|
#include "TextView.hpp"
|
||||||
#include "ScrollView.hpp"
|
#include "ScrollView.hpp"
|
||||||
|
#include "IMenuNode.hpp"
|
||||||
|
|
||||||
namespace Specter
|
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;}
|
|
||||||
virtual void activated(const boo::SWindowCoord& coord) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Menu : public View
|
class Menu : public View
|
||||||
{
|
{
|
||||||
IMenuNode* m_rootNode;
|
IMenuNode* m_rootNode;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "SplitView.hpp"
|
#include "SplitView.hpp"
|
||||||
#include "Tooltip.hpp"
|
#include "Tooltip.hpp"
|
||||||
#include "FontCache.hpp"
|
#include "FontCache.hpp"
|
||||||
|
#include "IMenuNode.hpp"
|
||||||
#include "DeferredWindowEvents.hpp"
|
#include "DeferredWindowEvents.hpp"
|
||||||
#include "IViewManager.hpp"
|
#include "IViewManager.hpp"
|
||||||
#include <boo/boo.hpp>
|
#include <boo/boo.hpp>
|
||||||
@ -29,7 +30,7 @@ class RootView : public View
|
|||||||
Button* m_activeMenuButton = nullptr;
|
Button* m_activeMenuButton = nullptr;
|
||||||
|
|
||||||
ViewChild<std::unique_ptr<View>> m_rightClickMenu;
|
ViewChild<std::unique_ptr<View>> m_rightClickMenu;
|
||||||
boo::SWindowCoord m_rightClickMenuCoord;
|
boo::SWindowRect m_rightClickMenuRootAndLoc;
|
||||||
|
|
||||||
SplitView* m_hoverSplitDragView = nullptr;
|
SplitView* m_hoverSplitDragView = nullptr;
|
||||||
bool m_activeSplitDragView = false;
|
bool m_activeSplitDragView = false;
|
||||||
@ -37,6 +38,48 @@ class RootView : public View
|
|||||||
|
|
||||||
DeferredWindowEvents<RootView> m_events;
|
DeferredWindowEvents<RootView> m_events;
|
||||||
|
|
||||||
|
struct SplitMenuNode : IMenuNode
|
||||||
|
{
|
||||||
|
RootView& m_rv;
|
||||||
|
std::string m_text;
|
||||||
|
SplitView* m_splitView = nullptr;
|
||||||
|
SplitMenuNode(RootView& rv)
|
||||||
|
: m_rv(rv), m_text(rv.m_viewMan.translateOr("boundary_action", "Boundary Action")),
|
||||||
|
m_splitActionNode(*this), m_joinActionNode(*this) {}
|
||||||
|
const std::string* text() const {return &m_text;}
|
||||||
|
size_t subNodeCount() const {return 2;}
|
||||||
|
IMenuNode* subNode(size_t idx)
|
||||||
|
{
|
||||||
|
if (idx)
|
||||||
|
return &m_joinActionNode;
|
||||||
|
else
|
||||||
|
return &m_splitActionNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct SplitActionNode : IMenuNode
|
||||||
|
{
|
||||||
|
SplitMenuNode& m_smn;
|
||||||
|
std::string m_text;
|
||||||
|
SplitActionNode(SplitMenuNode& smn)
|
||||||
|
: m_smn(smn), m_text(smn.m_rv.m_viewMan.translateOr("split", "Split")) {}
|
||||||
|
const std::string* text() const {return &m_text;}
|
||||||
|
void activated(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
} m_splitActionNode;
|
||||||
|
struct JoinActionNode : IMenuNode
|
||||||
|
{
|
||||||
|
SplitMenuNode& m_smn;
|
||||||
|
std::string m_text;
|
||||||
|
JoinActionNode(SplitMenuNode& smn)
|
||||||
|
: m_smn(smn), m_text(smn.m_rv.m_viewMan.translateOr("join", "Join")) {}
|
||||||
|
const std::string* text() const {return &m_text;}
|
||||||
|
void activated(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
} m_joinActionNode;
|
||||||
|
} m_splitMenuNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* window);
|
RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* window);
|
||||||
|
|
||||||
@ -77,7 +120,10 @@ public:
|
|||||||
void adoptRightClickMenu(std::unique_ptr<View>&& menu, const boo::SWindowCoord& coord)
|
void adoptRightClickMenu(std::unique_ptr<View>&& menu, const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
m_rightClickMenu.m_view = std::move(menu);
|
m_rightClickMenu.m_view = std::move(menu);
|
||||||
m_rightClickMenuCoord = coord;
|
m_rightClickMenuRootAndLoc = subRect();
|
||||||
|
m_rightClickMenuRootAndLoc.location[0] = coord.pixel[0];
|
||||||
|
m_rightClickMenuRootAndLoc.location[1] = coord.pixel[1];
|
||||||
|
updateSize();
|
||||||
}
|
}
|
||||||
View* getRightClickMenu() {return m_rightClickMenu.m_view.get();}
|
View* getRightClickMenu() {return m_rightClickMenu.m_view.get();}
|
||||||
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
#include "Specter/RootView.hpp"
|
#include "Specter/RootView.hpp"
|
||||||
#include "Specter/ViewResources.hpp"
|
#include "Specter/ViewResources.hpp"
|
||||||
#include "Specter/Space.hpp"
|
#include "Specter/Space.hpp"
|
||||||
|
#include "Specter/Menu.hpp"
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
static LogVisor::LogModule Log("Specter::RootView");
|
static LogVisor::LogModule Log("Specter::RootView");
|
||||||
|
|
||||||
RootView::RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* window)
|
RootView::RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* window)
|
||||||
: View(res), m_window(window), m_viewMan(viewMan), m_viewRes(&res), m_events(*this)
|
: View(res), m_window(window), m_viewMan(viewMan), m_viewRes(&res), m_events(*this),
|
||||||
|
m_splitMenuNode(*this)
|
||||||
{
|
{
|
||||||
window->setCallback(&m_events);
|
window->setCallback(&m_events);
|
||||||
boo::SWindowRect rect = window->getWindowFrame();
|
boo::SWindowRect rect = window->getWindowFrame();
|
||||||
@ -31,6 +33,16 @@ void RootView::resized(const boo::SWindowRect& root, const boo::SWindowRect&)
|
|||||||
v->resized(m_rootRect, m_rootRect);
|
v->resized(m_rootRect, m_rootRect);
|
||||||
if (m_tooltip)
|
if (m_tooltip)
|
||||||
m_tooltip->resized(m_rootRect, m_rootRect);
|
m_tooltip->resized(m_rootRect, m_rootRect);
|
||||||
|
if (m_rightClickMenu.m_view)
|
||||||
|
{
|
||||||
|
float wr = root.size[0] / float(m_rightClickMenuRootAndLoc.size[0]);
|
||||||
|
float hr = root.size[1] / float(m_rightClickMenuRootAndLoc.size[1]);
|
||||||
|
m_rightClickMenuRootAndLoc.size[0] = root.size[0];
|
||||||
|
m_rightClickMenuRootAndLoc.size[1] = root.size[1];
|
||||||
|
m_rightClickMenuRootAndLoc.location[0] *= wr;
|
||||||
|
m_rightClickMenuRootAndLoc.location[1] *= hr;
|
||||||
|
m_rightClickMenu.m_view->resized(root, m_rightClickMenuRootAndLoc);
|
||||||
|
}
|
||||||
m_resizeRTDirty = true;
|
m_resizeRTDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,8 +65,16 @@ void RootView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton butto
|
|||||||
|
|
||||||
if (m_hoverSplitDragView)
|
if (m_hoverSplitDragView)
|
||||||
{
|
{
|
||||||
m_activeSplitDragView = true;
|
if (button == boo::EMouseButton::Primary)
|
||||||
m_hoverSplitDragView->startDragSplit(coord);
|
{
|
||||||
|
m_activeSplitDragView = true;
|
||||||
|
m_hoverSplitDragView->startDragSplit(coord);
|
||||||
|
}
|
||||||
|
else if (button == boo::EMouseButton::Secondary)
|
||||||
|
{
|
||||||
|
m_splitMenuNode.m_splitView = m_hoverSplitDragView;
|
||||||
|
adoptRightClickMenu(std::make_unique<Specter::Menu>(*m_viewRes, *this, &m_splitMenuNode), coord);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,12 +134,18 @@ void RootView::mouseMove(const boo::SWindowCoord& coord)
|
|||||||
{
|
{
|
||||||
if (m_rightClickMenu.m_view)
|
if (m_rightClickMenu.m_view)
|
||||||
{
|
{
|
||||||
|
m_hSplitHover = false;
|
||||||
|
m_vSplitHover = false;
|
||||||
|
_updateCursor();
|
||||||
m_rightClickMenu.mouseMove(coord);
|
m_rightClickMenu.mouseMove(coord);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_activeMenuButton)
|
if (m_activeMenuButton)
|
||||||
{
|
{
|
||||||
|
m_hSplitHover = false;
|
||||||
|
m_vSplitHover = false;
|
||||||
|
_updateCursor();
|
||||||
ViewChild<std::unique_ptr<View>>& mv = m_activeMenuButton->getMenu();
|
ViewChild<std::unique_ptr<View>>& mv = m_activeMenuButton->getMenu();
|
||||||
mv.mouseMove(coord);
|
mv.mouseMove(coord);
|
||||||
return;
|
return;
|
||||||
@ -308,7 +334,7 @@ void RootView::displayTooltip(const std::string& name, const std::string& help)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RootView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
void RootView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
{
|
{
|
||||||
if (m_resizeRTDirty)
|
if (m_resizeRTDirty)
|
||||||
{
|
{
|
||||||
gfxQ->resizeRenderTexture(m_renderTex, m_rootRect.size[0], m_rootRect.size[1]);
|
gfxQ->resizeRenderTexture(m_renderTex, m_rootRect.size[0], m_rootRect.size[1]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user