2015-12-03 03:26:50 +00:00
|
|
|
#include <LogVisor/LogVisor.hpp>
|
|
|
|
#include "Specter/Space.hpp"
|
|
|
|
#include "Specter/ViewResources.hpp"
|
|
|
|
|
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
static LogVisor::LogModule Log("Specter::Space");
|
|
|
|
|
|
|
|
Space::Space(ViewResources& res, View& parentView, Toolbar::Position tbPos)
|
|
|
|
: View(res, parentView), m_tbPos(tbPos)
|
|
|
|
{
|
|
|
|
commitResources(res);
|
|
|
|
m_toolbar.reset(new Toolbar(res, *this, tbPos));
|
|
|
|
}
|
|
|
|
|
2015-12-10 03:14:38 +00:00
|
|
|
View* Space::setContentView(View* view)
|
2015-12-03 03:26:50 +00:00
|
|
|
{
|
2015-12-10 03:14:38 +00:00
|
|
|
View* ret = m_contentView;
|
|
|
|
m_contentView = view;
|
2015-12-03 03:26:50 +00:00
|
|
|
updateSize();
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Space::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2015-12-05 00:42:46 +00:00
|
|
|
if (m_contentView && !m_contentMouseDown &&
|
|
|
|
m_contentView->subRect().coordInRect(coord))
|
|
|
|
{
|
|
|
|
m_contentView->mouseDown(coord, button, mod);
|
|
|
|
m_contentMouseDown = true;
|
|
|
|
}
|
|
|
|
if (m_toolbar && !m_toolbarMouseDown &&
|
|
|
|
m_toolbar->subRect().coordInRect(coord))
|
|
|
|
{
|
|
|
|
m_toolbar->mouseDown(coord, button, mod);
|
|
|
|
m_toolbarMouseDown = true;
|
|
|
|
}
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Space::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2015-12-05 00:42:46 +00:00
|
|
|
if (m_contentView && m_contentMouseDown)
|
|
|
|
{
|
|
|
|
m_contentView->mouseUp(coord, button, mod);
|
|
|
|
m_contentMouseDown = false;
|
|
|
|
}
|
|
|
|
if (m_toolbar && m_toolbarMouseDown)
|
|
|
|
{
|
|
|
|
m_toolbar->mouseUp(coord, button, mod);
|
|
|
|
m_toolbarMouseDown = false;
|
|
|
|
}
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Space::mouseMove(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-05 00:42:46 +00:00
|
|
|
if (m_contentView)
|
|
|
|
{
|
|
|
|
if (m_contentView->subRect().coordInRect(coord))
|
|
|
|
{
|
|
|
|
if (!m_contentMouseIn)
|
|
|
|
{
|
|
|
|
m_contentView->mouseEnter(coord);
|
|
|
|
m_contentMouseIn = true;
|
|
|
|
}
|
|
|
|
m_contentView->mouseMove(coord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_contentMouseIn)
|
|
|
|
{
|
|
|
|
m_contentView->mouseLeave(coord);
|
|
|
|
m_contentMouseIn = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_toolbar)
|
|
|
|
{
|
|
|
|
if (m_toolbar->subRect().coordInRect(coord))
|
|
|
|
{
|
|
|
|
if (!m_toolbarMouseIn)
|
|
|
|
{
|
|
|
|
m_toolbar->mouseEnter(coord);
|
|
|
|
m_toolbarMouseIn = true;
|
|
|
|
}
|
|
|
|
m_toolbar->mouseMove(coord);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (m_toolbarMouseIn)
|
|
|
|
{
|
|
|
|
m_toolbar->mouseLeave(coord);
|
|
|
|
m_toolbarMouseIn = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Space::mouseEnter(const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Space::mouseLeave(const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
if (m_contentView && m_contentMouseIn)
|
|
|
|
{
|
|
|
|
m_contentView->mouseLeave(coord);
|
|
|
|
m_contentMouseIn = false;
|
|
|
|
}
|
|
|
|
if (m_toolbar && m_toolbarMouseIn)
|
|
|
|
{
|
|
|
|
m_toolbar->mouseLeave(coord);
|
|
|
|
m_toolbarMouseIn = false;
|
|
|
|
}
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Space::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
|
|
|
{
|
|
|
|
View::resized(root, sub);
|
2015-12-04 01:35:01 +00:00
|
|
|
|
|
|
|
boo::SWindowRect tbRect = sub;
|
2015-12-05 05:57:51 +00:00
|
|
|
tbRect.size[1] = m_toolbar->nominalHeight();
|
|
|
|
if (m_tbPos == Toolbar::Position::Top)
|
|
|
|
tbRect.location[1] += sub.size[1] - tbRect.size[1];
|
2015-12-04 01:35:01 +00:00
|
|
|
m_toolbar->resized(root, tbRect);
|
|
|
|
|
|
|
|
if (m_contentView)
|
|
|
|
{
|
2015-12-05 05:57:51 +00:00
|
|
|
if (m_tbPos == Toolbar::Position::Top)
|
|
|
|
tbRect.location[1] = sub.location[1];
|
|
|
|
else
|
|
|
|
tbRect.location[1] += tbRect.size[1];
|
2015-12-04 01:35:01 +00:00
|
|
|
tbRect.size[1] = sub.size[1] - tbRect.size[1];
|
|
|
|
tbRect.size[1] = std::max(tbRect.size[1], 0);
|
|
|
|
m_contentView->resized(root, tbRect);
|
|
|
|
}
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Space::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|
|
|
{
|
|
|
|
View::draw(gfxQ);
|
2015-12-04 01:35:01 +00:00
|
|
|
if (m_contentView)
|
|
|
|
m_contentView->draw(gfxQ);
|
|
|
|
m_toolbar->draw(gfxQ);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|