2015-11-21 01:14:49 +00:00
|
|
|
#include "Specter/RootView.hpp"
|
2015-12-02 01:32:15 +00:00
|
|
|
#include "Specter/ViewResources.hpp"
|
2015-12-04 01:35:01 +00:00
|
|
|
#include "Specter/Space.hpp"
|
2015-11-21 01:14:49 +00:00
|
|
|
|
2015-11-21 23:45:02 +00:00
|
|
|
namespace Specter
|
|
|
|
{
|
2015-11-30 00:21:42 +00:00
|
|
|
static LogVisor::LogModule Log("Specter::RootView");
|
2015-11-21 01:14:49 +00:00
|
|
|
|
2015-12-06 01:24:51 +00:00
|
|
|
RootView::RootView(IViewManager& viewMan, ViewResources& res, boo::IWindow* window)
|
|
|
|
: View(res), m_window(window), m_events(*this), m_viewMan(viewMan), m_viewRes(&res)
|
2015-11-21 23:45:02 +00:00
|
|
|
{
|
2015-12-01 00:35:45 +00:00
|
|
|
window->setCallback(&m_events);
|
2015-11-26 07:35:43 +00:00
|
|
|
boo::SWindowRect rect = window->getWindowFrame();
|
2015-12-02 01:43:54 +00:00
|
|
|
m_renderTex = res.m_factory->newRenderTexture(rect.size[0], rect.size[1], 1);
|
|
|
|
commitResources(res);
|
2015-12-01 00:35:45 +00:00
|
|
|
resized(rect, rect);
|
2015-11-26 23:03:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::destroyed()
|
|
|
|
{
|
|
|
|
m_destroyed = true;
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
2015-11-27 22:20:22 +00:00
|
|
|
void RootView::resized(const boo::SWindowRect& root, const boo::SWindowRect&)
|
2015-11-26 23:03:56 +00:00
|
|
|
{
|
2015-12-01 00:35:45 +00:00
|
|
|
boo::SWindowRect old = m_rootRect;
|
2015-11-26 23:03:56 +00:00
|
|
|
m_rootRect = root;
|
2015-11-26 07:35:43 +00:00
|
|
|
m_rootRect.location[0] = 0;
|
|
|
|
m_rootRect.location[1] = 0;
|
2015-11-26 23:03:56 +00:00
|
|
|
View::resized(m_rootRect, m_rootRect);
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->resized(m_rootRect, m_rootRect);
|
2015-12-01 00:35:45 +00:00
|
|
|
if (old != m_rootRect)
|
|
|
|
m_resizeRTDirty = true;
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods)
|
|
|
|
{
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->mouseDown(coord, button, mods);
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mods)
|
|
|
|
{
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->mouseUp(coord, button, mods);
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::mouseMove(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->mouseMove(coord);
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::mouseEnter(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->mouseEnter(coord);
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::mouseLeave(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->mouseLeave(coord);
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::scroll(const boo::SWindowCoord& coord, const boo::SScrollDelta& scroll)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::touchDown(const boo::STouchCoord& coord, uintptr_t tid)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::touchUp(const boo::STouchCoord& coord, uintptr_t tid)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::touchMove(const boo::STouchCoord& coord, uintptr_t tid)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::charKeyDown(unsigned long charCode, boo::EModifierKey mods, bool isRepeat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::charKeyUp(unsigned long charCode, boo::EModifierKey mods)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::specialKeyDown(boo::ESpecialKey key, boo::EModifierKey mods, bool isRepeat)
|
|
|
|
{
|
2015-12-02 06:13:43 +00:00
|
|
|
if (key == boo::ESpecialKey::Enter && (mods & boo::EModifierKey::Alt) != boo::EModifierKey::None)
|
|
|
|
m_window->setFullscreen(!m_window->isFullscreen());
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::specialKeyUp(boo::ESpecialKey key, boo::EModifierKey mods)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::modKeyDown(boo::EModifierKey mod, bool isRepeat)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::modKeyUp(boo::EModifierKey mod)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-02 21:11:50 +00:00
|
|
|
void RootView::resetResources(ViewResources& res)
|
|
|
|
{
|
2015-12-05 00:42:46 +00:00
|
|
|
m_viewRes = &res;
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->resetResources(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::setContentView(std::unique_ptr<View>&& view)
|
|
|
|
{
|
|
|
|
m_view = std::move(view);
|
|
|
|
updateSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RootView::displayTooltip(const std::string& name, const std::string& help)
|
|
|
|
{
|
2015-12-02 21:11:50 +00:00
|
|
|
}
|
|
|
|
|
2015-11-21 23:45:02 +00:00
|
|
|
void RootView::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|
|
|
{
|
2015-11-26 07:35:43 +00:00
|
|
|
if (m_resizeRTDirty)
|
2015-11-26 23:03:56 +00:00
|
|
|
{
|
2015-11-26 07:35:43 +00:00
|
|
|
gfxQ->resizeRenderTexture(m_renderTex, m_rootRect.size[0], m_rootRect.size[1]);
|
2015-11-26 23:03:56 +00:00
|
|
|
m_resizeRTDirty = false;
|
|
|
|
}
|
2015-11-26 07:35:43 +00:00
|
|
|
gfxQ->setRenderTarget(m_renderTex);
|
|
|
|
gfxQ->setViewport(m_rootRect);
|
2015-11-27 22:20:22 +00:00
|
|
|
gfxQ->setScissor(m_rootRect);
|
2015-11-26 00:24:01 +00:00
|
|
|
View::draw(gfxQ);
|
2015-12-06 01:24:51 +00:00
|
|
|
if (m_view)
|
|
|
|
m_view->draw(gfxQ);
|
2015-11-26 07:35:43 +00:00
|
|
|
gfxQ->resolveDisplay(m_renderTex);
|
2015-11-21 23:45:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|