2015-12-03 03:26:50 +00:00
|
|
|
#include <LogVisor/LogVisor.hpp>
|
|
|
|
#include "Specter/Toolbar.hpp"
|
|
|
|
#include "Specter/ViewResources.hpp"
|
|
|
|
|
2015-12-04 01:35:01 +00:00
|
|
|
#define TOOLBAR_GAUGE 28
|
|
|
|
|
2015-12-03 03:26:50 +00:00
|
|
|
namespace Specter
|
|
|
|
{
|
|
|
|
static LogVisor::LogModule Log("Specter::Space");
|
|
|
|
|
2015-12-04 01:35:01 +00:00
|
|
|
void Toolbar::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData& theme)
|
2015-12-03 03:26:50 +00:00
|
|
|
{
|
|
|
|
static const Zeus::RGBA32 tex[3] =
|
|
|
|
{
|
2015-12-04 01:35:01 +00:00
|
|
|
{255,255,255,64},
|
|
|
|
{255,255,255,64},
|
|
|
|
{0,0,0,64}
|
2015-12-03 03:26:50 +00:00
|
|
|
};
|
|
|
|
m_shadingTex = factory->newStaticTexture(3, 1, 1, boo::TextureFormat::RGBA8, tex, 12);
|
|
|
|
}
|
|
|
|
|
2015-12-04 01:35:01 +00:00
|
|
|
Toolbar::Toolbar(ViewResources& res, View& parentView, Position tbPos)
|
|
|
|
: View(res, parentView), m_tbPos(tbPos), m_gauge(res.pixelFactor() * TOOLBAR_GAUGE)
|
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);
|
|
|
|
m_tbVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(ToolbarVert), 10);
|
2015-12-03 03:26:50 +00:00
|
|
|
|
2015-12-04 01:35:01 +00:00
|
|
|
if (!res.m_viewRes.m_texVtxFmt)
|
2015-12-03 03:26:50 +00:00
|
|
|
{
|
|
|
|
boo::VertexElementDescriptor vdescs[] =
|
|
|
|
{
|
|
|
|
{m_tbVertsBuf, nullptr, boo::VertexSemantic::Position4},
|
|
|
|
{m_tbVertsBuf, nullptr, boo::VertexSemantic::UV4}
|
|
|
|
};
|
2015-12-04 01:35:01 +00:00
|
|
|
m_tbVtxFmt = res.m_factory->newVertexFormat(2, vdescs);
|
2015-12-03 03:26:50 +00:00
|
|
|
boo::IGraphicsBuffer* bufs[] = {m_tbBlockBuf};
|
2015-12-04 01:35:01 +00:00
|
|
|
boo::ITexture* texs[] = {res.m_toolbarRes.m_shadingTex};
|
|
|
|
m_tbShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_texShader,
|
|
|
|
m_tbVtxFmt, m_tbVertsBuf, nullptr,
|
|
|
|
nullptr, 1, bufs, 1, texs);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
boo::IGraphicsBuffer* bufs[] = {m_tbBlockBuf};
|
2015-12-04 01:35:01 +00:00
|
|
|
boo::ITexture* texs[] = {res.m_toolbarRes.m_shadingTex};
|
|
|
|
m_tbShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_texShader,
|
|
|
|
res.m_viewRes.m_texVtxFmt,
|
|
|
|
m_tbVertsBuf, nullptr,
|
|
|
|
nullptr, 1, bufs, 1, texs);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
2015-12-04 01:35:01 +00:00
|
|
|
setBackground(res.themeData().toolbarBackground());
|
|
|
|
commitResources(res);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::mouseMove(const boo::SWindowCoord& coord)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::resetResources(ViewResources& res)
|
|
|
|
{
|
2015-12-04 01:35:01 +00:00
|
|
|
m_gauge = res.pixelFactor() * TOOLBAR_GAUGE;
|
|
|
|
setBackground(res.themeData().toolbarBackground());
|
2015-12-03 03:26:50 +00:00
|
|
|
updateSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
|
|
|
{
|
|
|
|
View::resized(root, sub);
|
|
|
|
setHorizontalVerts(sub.size[0]);
|
|
|
|
m_tbVertsBuf->load(&m_tbVerts, sizeof(ToolbarVert) * 10);
|
2015-12-04 01:35:01 +00:00
|
|
|
m_tbBlock.setViewRect(root, sub);
|
|
|
|
m_tbBlockBuf->load(&m_tbBlock, sizeof(ViewBlock));
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Toolbar::draw(boo::IGraphicsCommandQueue* gfxQ)
|
|
|
|
{
|
|
|
|
View::draw(gfxQ);
|
2015-12-04 01:35:01 +00:00
|
|
|
gfxQ->setShaderDataBinding(m_tbShaderBinding);
|
|
|
|
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
|
|
|
gfxQ->draw(0, 10);
|
2015-12-03 03:26:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|