mirror of https://github.com/AxioDL/metaforce.git
Add TextField drawing
This commit is contained in:
parent
962639c684
commit
cb205304b6
|
@ -21,11 +21,8 @@ private:
|
||||||
Zeus::CColor m_textColor;
|
Zeus::CColor m_textColor;
|
||||||
std::string m_textStr;
|
std::string m_textStr;
|
||||||
std::unique_ptr<TextView> m_text;
|
std::unique_ptr<TextView> m_text;
|
||||||
|
|
||||||
SolidShaderVert m_verts[28];
|
SolidShaderVert m_verts[28];
|
||||||
|
|
||||||
ViewBlock m_bBlock;
|
|
||||||
boo::IGraphicsBufferD* m_bBlockBuf = nullptr;
|
|
||||||
|
|
||||||
boo::IGraphicsBufferD* m_bVertsBuf = nullptr;
|
boo::IGraphicsBufferD* m_bVertsBuf = nullptr;
|
||||||
boo::IVertexFormat* m_bVtxFmt = nullptr; /* OpenGL only */
|
boo::IVertexFormat* m_bVtxFmt = nullptr; /* OpenGL only */
|
||||||
boo::IShaderDataBinding* m_bShaderBinding = nullptr;
|
boo::IShaderDataBinding* m_bShaderBinding = nullptr;
|
||||||
|
@ -71,8 +68,8 @@ public:
|
||||||
void setMultiplyColor(const Zeus::CColor& color)
|
void setMultiplyColor(const Zeus::CColor& color)
|
||||||
{
|
{
|
||||||
View::setMultiplyColor(color);
|
View::setMultiplyColor(color);
|
||||||
m_bBlock.m_color = color;
|
m_viewVertBlock.m_color = color;
|
||||||
m_bBlockBuf->load(&m_bBlock, sizeof(ViewBlock));
|
m_viewVertBlockBuf->load(&m_viewVertBlock, sizeof(ViewBlock));
|
||||||
m_text->setMultiplyColor(color);
|
m_text->setMultiplyColor(color);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
FileBrowser(ViewResources& res, View& parentView)
|
FileBrowser(ViewResources& res, View& parentView)
|
||||||
: FileBrowser(res, parentView, HECL::GetcwdStr()) {}
|
: FileBrowser(res, parentView, HECL::GetcwdStr()) {}
|
||||||
FileBrowser(ViewResources& res, View& parentView, const HECL::SystemString& initialPath);
|
FileBrowser(ViewResources& res, View& parentView, const HECL::SystemString& initialPath);
|
||||||
|
|
||||||
void updateContentOpacity(float opacity);
|
void updateContentOpacity(float opacity);
|
||||||
|
|
||||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
|
|
|
@ -2,14 +2,51 @@
|
||||||
#define SPECTER_TEXTFIELD_HPP
|
#define SPECTER_TEXTFIELD_HPP
|
||||||
|
|
||||||
#include "View.hpp"
|
#include "View.hpp"
|
||||||
|
#include "TextView.hpp"
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
|
||||||
class TextField : public View
|
class TextField : public View
|
||||||
{
|
{
|
||||||
|
std::string m_textStr;
|
||||||
|
std::unique_ptr<TextView> m_text;
|
||||||
|
|
||||||
|
SolidShaderVert m_verts[28];
|
||||||
|
boo::IGraphicsBufferD* m_bVertsBuf = nullptr;
|
||||||
|
boo::IVertexFormat* m_bVtxFmt = nullptr; /* OpenGL only */
|
||||||
|
boo::IShaderDataBinding* m_bShaderBinding = nullptr;
|
||||||
|
|
||||||
|
int m_nomWidth = 0;
|
||||||
|
int m_nomHeight = 0;
|
||||||
|
|
||||||
|
void setInactive();
|
||||||
|
void setHover();
|
||||||
|
void setDisabled();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextField(ViewResources& res, View& parentView);
|
TextField(ViewResources& res, View& parentView);
|
||||||
|
|
||||||
|
void setText(const std::string& str);
|
||||||
|
|
||||||
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
|
void mouseMove(const boo::SWindowCoord&);
|
||||||
|
void mouseEnter(const boo::SWindowCoord&);
|
||||||
|
void mouseLeave(const boo::SWindowCoord&coord);
|
||||||
|
void resized(const boo::SWindowRect& rootView, const boo::SWindowRect& sub);
|
||||||
|
void draw(boo::IGraphicsCommandQueue* gfxQ);
|
||||||
|
|
||||||
|
int nominalWidth() const {return m_nomWidth;}
|
||||||
|
int nominalHeight() const {return m_nomHeight;}
|
||||||
|
|
||||||
|
void setMultiplyColor(const Zeus::CColor& color)
|
||||||
|
{
|
||||||
|
View::setMultiplyColor(color);
|
||||||
|
m_viewVertBlock.m_color = color;
|
||||||
|
m_viewVertBlockBuf->load(&m_viewVertBlock, sizeof(ViewBlock));
|
||||||
|
m_text->setMultiplyColor(color);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,17 @@ namespace Specter
|
||||||
{
|
{
|
||||||
class ThemeData
|
class ThemeData
|
||||||
{
|
{
|
||||||
|
Zeus::CColor m_uiText = Zeus::CColor::skWhite;
|
||||||
|
Zeus::CColor m_fieldText = Zeus::CColor::skBlack;
|
||||||
|
|
||||||
Zeus::CColor m_vpBg = {0.2,0.2,0.2,1.0};
|
Zeus::CColor m_vpBg = {0.2,0.2,0.2,1.0};
|
||||||
Zeus::CColor m_tbBg = {0.4,0.4,0.4,1.0};
|
Zeus::CColor m_tbBg = {0.4,0.4,0.4,1.0};
|
||||||
Zeus::CColor m_uiText = Zeus::CColor::skWhite;
|
Zeus::CColor m_tooltipBg = {0.0, 0.0, 0.0, 0.65};
|
||||||
|
Zeus::CColor m_splashBg = {0.1, 0.1, 0.1, 0.65};
|
||||||
|
|
||||||
|
Zeus::CColor m_splash1 = {1.0, 1.0, 1.0, 1.0};
|
||||||
|
Zeus::CColor m_splash2 = {0.3, 0.3, 0.3, 1.0};
|
||||||
|
|
||||||
Zeus::CColor m_button1Inactive = {0.2823, 0.2823, 0.2823, 1.0};
|
Zeus::CColor m_button1Inactive = {0.2823, 0.2823, 0.2823, 1.0};
|
||||||
Zeus::CColor m_button2Inactive = {0.1725, 0.1725, 0.1725, 1.0};
|
Zeus::CColor m_button2Inactive = {0.1725, 0.1725, 0.1725, 1.0};
|
||||||
Zeus::CColor m_button1Hover = {0.3523, 0.3523, 0.3523, 1.0};
|
Zeus::CColor m_button1Hover = {0.3523, 0.3523, 0.3523, 1.0};
|
||||||
|
@ -23,14 +31,26 @@ class ThemeData
|
||||||
Zeus::CColor m_button2Press = {0.2823, 0.2823, 0.2823, 1.0};
|
Zeus::CColor m_button2Press = {0.2823, 0.2823, 0.2823, 1.0};
|
||||||
Zeus::CColor m_button1Disabled = {0.2823, 0.2823, 0.2823, 0.5};
|
Zeus::CColor m_button1Disabled = {0.2823, 0.2823, 0.2823, 0.5};
|
||||||
Zeus::CColor m_button2Disabled = {0.1725, 0.1725, 0.1725, 0.5};
|
Zeus::CColor m_button2Disabled = {0.1725, 0.1725, 0.1725, 0.5};
|
||||||
Zeus::CColor m_tooltipBg = {0.0, 0.0, 0.0, 0.65};
|
|
||||||
Zeus::CColor m_splashBg = {0.1, 0.1, 0.1, 0.65};
|
Zeus::CColor m_textfield2Inactive = {0.7823, 0.7823, 0.7823, 1.0};
|
||||||
Zeus::CColor m_splash1 = {1.0, 1.0, 1.0, 1.0};
|
Zeus::CColor m_textfield1Inactive = {0.4725, 0.4725, 0.4725, 1.0};
|
||||||
Zeus::CColor m_splash2 = {0.3, 0.3, 0.3, 1.0};
|
Zeus::CColor m_textfield2Hover = {0.8523, 0.8523, 0.8523, 1.0};
|
||||||
|
Zeus::CColor m_textfield1Hover = {0.5425, 0.5425, 0.5425, 1.0};
|
||||||
|
Zeus::CColor m_textfield2Disabled = {0.7823, 0.7823, 0.7823, 0.5};
|
||||||
|
Zeus::CColor m_textfield1Disabled = {0.4725, 0.4725, 0.4725, 0.5};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual const Zeus::CColor& uiText() const {return m_uiText;}
|
||||||
|
virtual const Zeus::CColor& fieldText() const {return m_fieldText;}
|
||||||
|
|
||||||
virtual const Zeus::CColor& viewportBackground() const {return m_vpBg;}
|
virtual const Zeus::CColor& viewportBackground() const {return m_vpBg;}
|
||||||
virtual const Zeus::CColor& toolbarBackground() const {return m_tbBg;}
|
virtual const Zeus::CColor& toolbarBackground() const {return m_tbBg;}
|
||||||
virtual const Zeus::CColor& uiText() const {return m_uiText;}
|
virtual const Zeus::CColor& tooltipBackground() const {return m_tooltipBg;}
|
||||||
|
virtual const Zeus::CColor& splashBackground() const {return m_splashBg;}
|
||||||
|
|
||||||
|
virtual const Zeus::CColor& splash1() const {return m_splash1;}
|
||||||
|
virtual const Zeus::CColor& splash2() const {return m_splash2;}
|
||||||
|
|
||||||
virtual const Zeus::CColor& button1Inactive() const {return m_button1Inactive;}
|
virtual const Zeus::CColor& button1Inactive() const {return m_button1Inactive;}
|
||||||
virtual const Zeus::CColor& button2Inactive() const {return m_button2Inactive;}
|
virtual const Zeus::CColor& button2Inactive() const {return m_button2Inactive;}
|
||||||
virtual const Zeus::CColor& button1Hover() const {return m_button1Hover;}
|
virtual const Zeus::CColor& button1Hover() const {return m_button1Hover;}
|
||||||
|
@ -39,10 +59,13 @@ public:
|
||||||
virtual const Zeus::CColor& button2Press() const {return m_button2Press;}
|
virtual const Zeus::CColor& button2Press() const {return m_button2Press;}
|
||||||
virtual const Zeus::CColor& button1Disabled() const {return m_button1Disabled;}
|
virtual const Zeus::CColor& button1Disabled() const {return m_button1Disabled;}
|
||||||
virtual const Zeus::CColor& button2Disabled() const {return m_button2Disabled;}
|
virtual const Zeus::CColor& button2Disabled() const {return m_button2Disabled;}
|
||||||
virtual const Zeus::CColor& tooltipBackground() const {return m_tooltipBg;}
|
|
||||||
virtual const Zeus::CColor& splashBackground() const {return m_splashBg;}
|
virtual const Zeus::CColor& textfield1Inactive() const {return m_textfield1Inactive;}
|
||||||
virtual const Zeus::CColor& splash1() const {return m_splash1;}
|
virtual const Zeus::CColor& textfield2Inactive() const {return m_textfield2Inactive;}
|
||||||
virtual const Zeus::CColor& splash2() const {return m_splash2;}
|
virtual const Zeus::CColor& textfield1Hover() const {return m_textfield1Hover;}
|
||||||
|
virtual const Zeus::CColor& textfield2Hover() const {return m_textfield2Hover;}
|
||||||
|
virtual const Zeus::CColor& textfield1Disabled() const {return m_textfield1Disabled;}
|
||||||
|
virtual const Zeus::CColor& textfield2Disabled() const {return m_textfield2Disabled;}
|
||||||
};
|
};
|
||||||
|
|
||||||
class ViewResources
|
class ViewResources
|
||||||
|
|
|
@ -21,7 +21,6 @@ Button::Button(ViewResources& res, View& parentView,
|
||||||
const Zeus::CColor& textColor, Style style)
|
const Zeus::CColor& textColor, Style style)
|
||||||
: Control(res, parentView, controlBinding), m_style(style), m_textColor(textColor), m_textStr(text)
|
: Control(res, parentView, controlBinding), m_style(style), m_textColor(textColor), m_textStr(text)
|
||||||
{
|
{
|
||||||
m_bBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
|
|
||||||
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
|
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
|
||||||
|
|
||||||
if (!res.m_viewRes.m_texVtxFmt)
|
if (!res.m_viewRes.m_texVtxFmt)
|
||||||
|
@ -29,17 +28,17 @@ Button::Button(ViewResources& res, View& parentView,
|
||||||
boo::VertexElementDescriptor vdescs[] =
|
boo::VertexElementDescriptor vdescs[] =
|
||||||
{
|
{
|
||||||
{m_bVertsBuf, nullptr, boo::VertexSemantic::Position4},
|
{m_bVertsBuf, nullptr, boo::VertexSemantic::Position4},
|
||||||
{m_bVertsBuf, nullptr, boo::VertexSemantic::UV4}
|
{m_bVertsBuf, nullptr, boo::VertexSemantic::Color}
|
||||||
};
|
};
|
||||||
m_bVtxFmt = res.m_factory->newVertexFormat(2, vdescs);
|
m_bVtxFmt = res.m_factory->newVertexFormat(2, vdescs);
|
||||||
boo::IGraphicsBuffer* bufs[] = {m_bBlockBuf};
|
boo::IGraphicsBuffer* bufs[] = {m_viewVertBlockBuf};
|
||||||
m_bShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_solidShader,
|
m_bShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_solidShader,
|
||||||
m_bVtxFmt, m_bVertsBuf, nullptr,
|
m_bVtxFmt, m_bVertsBuf, nullptr,
|
||||||
nullptr, 1, bufs, 0, nullptr);
|
nullptr, 1, bufs, 0, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
boo::IGraphicsBuffer* bufs[] = {m_bBlockBuf};
|
boo::IGraphicsBuffer* bufs[] = {m_viewVertBlockBuf};
|
||||||
m_bShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_solidShader,
|
m_bShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_solidShader,
|
||||||
res.m_viewRes.m_texVtxFmt,
|
res.m_viewRes.m_texVtxFmt,
|
||||||
m_bVertsBuf, nullptr,
|
m_bVertsBuf, nullptr,
|
||||||
|
@ -271,8 +270,6 @@ void Button::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
View::resized(root, sub);
|
View::resized(root, sub);
|
||||||
boo::SWindowRect textRect = sub;
|
boo::SWindowRect textRect = sub;
|
||||||
float pf = rootView().viewRes().pixelFactor();
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
m_bBlock.setViewRect(root, sub);
|
|
||||||
m_bBlockBuf->load(&m_bBlock, sizeof(ViewBlock));
|
|
||||||
if (m_style == Style::Block)
|
if (m_style == Style::Block)
|
||||||
{
|
{
|
||||||
textRect.location[0] += 5 * pf;
|
textRect.location[0] += 5 * pf;
|
||||||
|
|
|
@ -50,6 +50,7 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, const HECL::Syste
|
||||||
for (const HECL::SystemString& c : m_comps)
|
for (const HECL::SystemString& c : m_comps)
|
||||||
m_pathButtons.emplace_back(*this, res, idx++, c);
|
m_pathButtons.emplace_back(*this, res, idx++, c);
|
||||||
|
|
||||||
|
m_fileField.m_view.reset(new TextField(res, *this));
|
||||||
updateContentOpacity(0.0);
|
updateContentOpacity(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,6 +59,7 @@ void FileBrowser::updateContentOpacity(float opacity)
|
||||||
Zeus::CColor color = Zeus::CColor::lerp({1,1,1,0}, {1,1,1,1}, opacity);
|
Zeus::CColor color = Zeus::CColor::lerp({1,1,1,0}, {1,1,1,1}, opacity);
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.m_view->setMultiplyColor(color);
|
b.m_button.m_view->setMultiplyColor(color);
|
||||||
|
m_fileField.m_view->setMultiplyColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::pathButtonActivated(size_t idx)
|
void FileBrowser::pathButtonActivated(size_t idx)
|
||||||
|
@ -70,30 +72,35 @@ void FileBrowser::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton bu
|
||||||
return;
|
return;
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseDown(coord, button, mod);
|
b.m_button.mouseDown(coord, button, mod);
|
||||||
|
m_fileField.mouseDown(coord, button, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
void FileBrowser::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
{
|
{
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseUp(coord, button, mod);
|
b.m_button.mouseUp(coord, button, mod);
|
||||||
|
m_fileField.mouseUp(coord, button, mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseMove(const boo::SWindowCoord& coord)
|
void FileBrowser::mouseMove(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseMove(coord);
|
b.m_button.mouseMove(coord);
|
||||||
|
m_fileField.mouseMove(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseEnter(const boo::SWindowCoord& coord)
|
void FileBrowser::mouseEnter(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseEnter(coord);
|
b.m_button.mouseEnter(coord);
|
||||||
|
m_fileField.mouseEnter(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
|
void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
{
|
{
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.mouseLeave(coord);
|
b.m_button.mouseLeave(coord);
|
||||||
|
m_fileField.mouseLeave(coord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
void FileBrowser::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
|
@ -117,6 +124,12 @@ void FileBrowser::resized(const boo::SWindowRect& root, const boo::SWindowRect&
|
||||||
b.m_button.m_view->resized(root, pathRect);
|
b.m_button.m_view->resized(root, pathRect);
|
||||||
pathRect.location[0] += pathRect.size[0];
|
pathRect.location[0] += pathRect.size[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pathRect.location[0] = centerRect.location[0] + 10 * pf;
|
||||||
|
pathRect.location[1] -= 25 * pf;
|
||||||
|
pathRect.size[0] = centerRect.size[0] - 20 * pf;
|
||||||
|
pathRect.size[1] = m_fileField.m_view->nominalHeight();
|
||||||
|
m_fileField.m_view->resized(root, pathRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileBrowser::draw(boo::IGraphicsCommandQueue* gfxQ)
|
void FileBrowser::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
@ -124,6 +137,7 @@ void FileBrowser::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
ModalWindow::draw(gfxQ);
|
ModalWindow::draw(gfxQ);
|
||||||
for (PathButton& b : m_pathButtons)
|
for (PathButton& b : m_pathButtons)
|
||||||
b.m_button.m_view->draw(gfxQ);
|
b.m_button.m_view->draw(gfxQ);
|
||||||
|
m_fileField.m_view->draw(gfxQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "Specter/TextField.hpp"
|
#include "Specter/TextField.hpp"
|
||||||
|
#include "Specter/RootView.hpp"
|
||||||
|
#include "Specter/ViewResources.hpp"
|
||||||
|
|
||||||
namespace Specter
|
namespace Specter
|
||||||
{
|
{
|
||||||
|
@ -6,6 +8,159 @@ namespace Specter
|
||||||
TextField::TextField(ViewResources& res, View& parentView)
|
TextField::TextField(ViewResources& res, View& parentView)
|
||||||
: View(res, parentView)
|
: View(res, parentView)
|
||||||
{
|
{
|
||||||
|
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
|
||||||
|
|
||||||
|
if (!res.m_viewRes.m_texVtxFmt)
|
||||||
|
{
|
||||||
|
boo::VertexElementDescriptor vdescs[] =
|
||||||
|
{
|
||||||
|
{m_bVertsBuf, nullptr, boo::VertexSemantic::Position4},
|
||||||
|
{m_bVertsBuf, nullptr, boo::VertexSemantic::Color}
|
||||||
|
};
|
||||||
|
m_bVtxFmt = res.m_factory->newVertexFormat(2, vdescs);
|
||||||
|
boo::IGraphicsBuffer* bufs[] = {m_viewVertBlockBuf};
|
||||||
|
m_bShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_solidShader,
|
||||||
|
m_bVtxFmt, m_bVertsBuf, nullptr,
|
||||||
|
nullptr, 1, bufs, 0, nullptr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
boo::IGraphicsBuffer* bufs[] = {m_viewVertBlockBuf};
|
||||||
|
m_bShaderBinding = res.m_factory->newShaderDataBinding(res.m_viewRes.m_solidShader,
|
||||||
|
res.m_viewRes.m_texVtxFmt,
|
||||||
|
m_bVertsBuf, nullptr,
|
||||||
|
nullptr, 1, bufs, 0, nullptr);
|
||||||
|
}
|
||||||
|
commitResources(res);
|
||||||
|
|
||||||
|
m_verts[0].m_color = rootView().themeData().textfield1Inactive();
|
||||||
|
m_verts[1].m_color = rootView().themeData().textfield2Inactive();
|
||||||
|
m_verts[2].m_color = rootView().themeData().textfield1Inactive();
|
||||||
|
m_verts[3].m_color = rootView().themeData().textfield2Inactive();
|
||||||
|
m_verts[4].m_color = rootView().themeData().textfield2Inactive();
|
||||||
|
for (int i=5 ; i<28 ; ++i)
|
||||||
|
m_verts[i].m_color = res.themeData().textfield2Inactive();
|
||||||
|
m_bVertsBuf->load(m_verts, sizeof(SolidShaderVert) * 28);
|
||||||
|
|
||||||
|
m_text.reset(new TextView(res, *this, res.m_mainFont, TextView::Alignment::Left, 1024));
|
||||||
|
setText("Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::setText(const std::string& str)
|
||||||
|
{
|
||||||
|
m_textStr = str;
|
||||||
|
m_text->typesetGlyphs(str, rootView().themeData().fieldText());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::setInactive()
|
||||||
|
{
|
||||||
|
m_verts[0].m_color = rootView().themeData().textfield1Inactive();
|
||||||
|
m_verts[1].m_color = rootView().themeData().textfield2Inactive();
|
||||||
|
m_verts[2].m_color = rootView().themeData().textfield1Inactive();
|
||||||
|
m_verts[3].m_color = rootView().themeData().textfield2Inactive();
|
||||||
|
m_verts[4].m_color = rootView().themeData().textfield2Inactive();
|
||||||
|
m_bVertsBuf->load(m_verts, sizeof(SolidShaderVert) * 28);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::setHover()
|
||||||
|
{
|
||||||
|
m_verts[0].m_color = rootView().themeData().textfield1Hover();
|
||||||
|
m_verts[1].m_color = rootView().themeData().textfield2Hover();
|
||||||
|
m_verts[2].m_color = rootView().themeData().textfield1Hover();
|
||||||
|
m_verts[3].m_color = rootView().themeData().textfield2Hover();
|
||||||
|
m_verts[4].m_color = rootView().themeData().textfield2Hover();
|
||||||
|
m_bVertsBuf->load(m_verts, sizeof(SolidShaderVert) * 28);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::setDisabled()
|
||||||
|
{
|
||||||
|
m_verts[0].m_color = rootView().themeData().textfield1Disabled();
|
||||||
|
m_verts[1].m_color = rootView().themeData().textfield2Disabled();
|
||||||
|
m_verts[2].m_color = rootView().themeData().textfield1Disabled();
|
||||||
|
m_verts[3].m_color = rootView().themeData().textfield2Disabled();
|
||||||
|
m_verts[4].m_color = rootView().themeData().textfield2Disabled();
|
||||||
|
m_bVertsBuf->load(m_verts, sizeof(SolidShaderVert) * 28);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::mouseDown(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, boo::EModifierKey mod)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::mouseMove(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::mouseEnter(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::mouseLeave(const boo::SWindowCoord& coord)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
|
{
|
||||||
|
View::resized(root, sub);
|
||||||
|
|
||||||
|
float pf = rootView().viewRes().pixelFactor();
|
||||||
|
int width = sub.size[0];
|
||||||
|
int height = 20 * pf;
|
||||||
|
|
||||||
|
m_verts[0].m_pos.assign(1, height+1, 0);
|
||||||
|
m_verts[1].m_pos.assign(1, 1, 0);
|
||||||
|
m_verts[2].m_pos.assign(width+1, height+1, 0);
|
||||||
|
m_verts[3].m_pos.assign(width+1, 1, 0);
|
||||||
|
m_verts[4].m_pos.assign(width+1, 1, 0);
|
||||||
|
|
||||||
|
m_verts[5].m_pos.assign(1, height+1, 0);
|
||||||
|
m_verts[6].m_pos.assign(1, height+1, 0);
|
||||||
|
m_verts[7].m_pos.assign(0, height+1, 0);
|
||||||
|
m_verts[8].m_pos.assign(1, 1, 0);
|
||||||
|
m_verts[9].m_pos.assign(0, 1, 0);
|
||||||
|
m_verts[10].m_pos.assign(0, 1, 0);
|
||||||
|
|
||||||
|
m_verts[11].m_pos.assign(width+2, height+1, 0);
|
||||||
|
m_verts[12].m_pos.assign(width+2, height+1, 0);
|
||||||
|
m_verts[13].m_pos.assign(width+1, height+1, 0);
|
||||||
|
m_verts[14].m_pos.assign(width+2, 1, 0);
|
||||||
|
m_verts[15].m_pos.assign(width+1, 1, 0);
|
||||||
|
m_verts[16].m_pos.assign(width+1, 1, 0);
|
||||||
|
|
||||||
|
m_verts[17].m_pos.assign(1, height+2, 0);
|
||||||
|
m_verts[18].m_pos.assign(1, height+2, 0);
|
||||||
|
m_verts[19].m_pos.assign(1, height+1, 0);
|
||||||
|
m_verts[20].m_pos.assign(width+1, height+2, 0);
|
||||||
|
m_verts[21].m_pos.assign(width+1, height+1, 0);
|
||||||
|
m_verts[22].m_pos.assign(width+1, height+1, 0);
|
||||||
|
|
||||||
|
m_verts[23].m_pos.assign(1, 1, 0);
|
||||||
|
m_verts[24].m_pos.assign(1, 1, 0);
|
||||||
|
m_verts[25].m_pos.assign(1, 0, 0);
|
||||||
|
m_verts[26].m_pos.assign(width+1, 1, 0);
|
||||||
|
m_verts[27].m_pos.assign(width+1, 0, 0);
|
||||||
|
|
||||||
|
m_bVertsBuf->load(m_verts, sizeof(SolidShaderVert) * 28);
|
||||||
|
|
||||||
|
m_nomWidth = width;
|
||||||
|
m_nomHeight = height;
|
||||||
|
|
||||||
|
boo::SWindowRect textRect = sub;
|
||||||
|
textRect.location[0] += 5 * pf;
|
||||||
|
textRect.location[1] += 8 * pf;
|
||||||
|
m_text->resized(root, textRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextField::draw(boo::IGraphicsCommandQueue* gfxQ)
|
||||||
|
{
|
||||||
|
View::draw(gfxQ);
|
||||||
|
gfxQ->setShaderDataBinding(m_bShaderBinding);
|
||||||
|
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
|
||||||
|
gfxQ->draw(0, 28);
|
||||||
|
m_text->draw(gfxQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue