2015-12-03 03:26:50 +00:00
|
|
|
#include <LogVisor/LogVisor.hpp>
|
|
|
|
#include "Specter/Toolbar.hpp"
|
|
|
|
#include "Specter/ViewResources.hpp"
|
|
|
|
|
2015-12-05 00:42:46 +00:00
|
|
|
#define TOOLBAR_PADDING 10
|
2015-12-04 01:35:01 +00:00
|
|
|
|
2015-12-03 03:26:50 +00:00
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
static LogVisor::LogModule Log("Specter::Space");
|
|
|
|
|
2016-01-10 06:40:23 +00:00
|
|
|
void Toolbar::Resources::init(boo::IGraphicsDataFactory* factory, const IThemeData& theme)
|
2015-12-03 03:26:50 +00:00
|
|
|
{
|
2015-12-05 05:57:51 +00:00
|
|
|
static const Zeus::RGBA32 tex[] =
|
2015-12-03 03:26:50 +00:00
|
|
|
{
|
2015-12-31 04:55:29 +00:00
|
|
|
{{255,255,255,64}},
|
|
|
|
{{255,255,255,64}},
|
|
|
|
{{0,0,0,64}},
|
|
|
|
{{0,0,0,64}}
|
2015-12-03 03:26:50 +00:00
|
|
|
};
|
2015-12-05 05:57:51 +00:00
|
|
|
m_shadingTex = factory->newStaticTexture(4, 1, 1, boo::TextureFormat::RGBA8, tex, 16);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
2015-12-04 01:35:01 +00:00
|
|
|
Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos)
|
2015-12-05 00:42:46 +00:00
|
|
|
: View(res, parentView), m_tbPos(tbPos),
|
2016-01-12 00:44:54 +00:00
|
|
|
m_nomHeight(res.pixelFactor() * SPECTER_TOOLBAR_GAUGE),
|
2015-12-05 00:42:46 +00:00
|
|
|
m_padding(res.pixelFactor() * TOOLBAR_PADDING)
|
2015-12-03 03:26:50 +00:00
|
|
|
{
|
2015-12-04 01:35:01 +00:00
|
|
|
m_tbBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
|
2016-01-08 00:06:21 +00:00
|
|
|
m_vertsBinding.initTex(res, 10, m_tbBlockBuf, res.m_toolbarRes.m_shadingTex);
|
2015-12-04 01:35:01 +00:00
|
|
|
commitResources(res);
|
2016-01-08 00:06:21 +00:00
|
|
|
setBackground(res.themeData().toolbarBackground());
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2015-12-20 21:59:23 +00:00
|
|
|
for (ViewChild<View*>& c : m_children)
|
|
|
|
c.mouseDown(coord, button, mod);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
2015-12-20 21:59:23 +00:00
|
|
|
for (ViewChild<View*>& c : m_children)
|
|
|
|
c.mouseUp(coord, button, mod);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseMove(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-20 21:59:23 +00:00
|
|
|
for (ViewChild<View*>& c : m_children)
|
|
|
|
c.mouseMove(coord);
|
2015-12-05 00:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseEnter(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-20 21:59:23 +00:00
|
|
|
for (ViewChild<View*>& c : m_children)
|
|
|
|
c.mouseEnter(coord);
|
2015-12-05 00:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseLeave(const boo::SWindowCoord& coord)
|
|
|
|
{
|
2015-12-20 21:59:23 +00:00
|
|
|
for (ViewChild<View*>& c : m_children)
|
|
|
|
c.mouseLeave(coord);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
|
|
|
{
|
|
|
|
View::resized(root, sub);
|
|
|
|
setHorizontalVerts(sub.size[0]);
|
2016-01-08 00:06:21 +00:00
|
|
|
m_vertsBinding.load(m_tbVerts, sizeof(m_tbVerts));
|
2015-12-04 01:35:01 +00:00
|
|
|
m_tbBlock.setViewRect(root, sub);
|
|
|
|
m_tbBlockBuf->load(&m_tbBlock, sizeof(ViewBlock));
|
2015-12-05 00:42:46 +00:00
|
|
|
|
|
|
|
boo::SWindowRect childRect = sub;
|
2015-12-20 21:59:23 +00:00
|
|
|
for (ViewChild<View*>& c : m_children)
|
2015-12-05 00:42:46 +00:00
|
|
|
{
|
|
|
|
childRect.size[0] = c.m_view->nominalWidth();
|
|
|
|
childRect.size[1] = c.m_view->nominalHeight();
|
|
|
|
childRect.location[0] += m_padding;
|
2015-12-05 05:57:51 +00:00
|
|
|
childRect.location[1] = sub.location[1] + (m_nomHeight - childRect.size[1]) / 2 - 1;
|
2015-12-05 00:42:46 +00:00
|
|
|
c.m_view->resized(root, childRect);
|
|
|
|
childRect.location[0] += childRect.size[0];
|
|
|
|
}
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|
|
|
{
|
|
|
|
View::draw(gfxQ);
|
2016-01-08 00:06:21 +00:00
|
|
|
gfxQ->setShaderDataBinding(m_vertsBinding);
|
2015-12-04 01:35:01 +00:00
|
|
|
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
|
|
|
gfxQ->draw(0, 10);
|
2015-12-05 00:42:46 +00:00
|
|
|
|
2015-12-20 21:59:23 +00:00
|
|
|
for (ViewChild<View*>& c : m_children)
|
2015-12-05 00:42:46 +00:00
|
|
|
c.m_view->draw(gfxQ);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|