Rendering tweaks/bug-fixes

This commit is contained in:
Jack Andersen 2015-12-17 17:26:10 -10:00
parent cb205304b6
commit e8449f3fdb
11 changed files with 44 additions and 28 deletions

View File

@ -34,6 +34,12 @@ struct IIntBinding : IControlBinding
virtual void changed(int val)=0;
};
struct IStringBinding : IControlBinding
{
virtual std::string getDefault() const {return "";}
virtual void changed(const std::string& val)=0;
};
struct CVarControlBinding : IControlBinding
{
HECL::CVar* m_cvar;

View File

@ -35,6 +35,16 @@ class FileBrowser : public ModalWindow
std::vector<PathButton> m_pathButtons;
Specter::ViewChild<Specter::TextField> m_fileField;
struct FileFieldBind : Specter::IStringBinding
{
FileBrowser& m_browser;
FileFieldBind(FileBrowser& browser) : m_browser(browser) {}
const char* name() const {return "File Name";}
void changed(const std::string& val)
{
}
} m_fileFieldBind;
Specter::ViewChild<Specter::ScrollView> m_fileScroll;
Specter::ViewChild<Specter::Table> m_fileListing;

View File

@ -59,7 +59,7 @@ class FontAtlas
friend class FontCache;
FT_Face m_face;
boo::ITextureSA* m_tex = nullptr;
boo::IGraphicsDataToken m_token;
boo::GraphicsDataToken m_token;
uint32_t m_dpi;
FT_Fixed m_ftXscale;
FT_UShort m_ftXPpem;

View File

@ -48,7 +48,7 @@ class ModalWindow : public View
boo::IVertexFormat* m_vertsVtxFmt; /* OpenGL only */
boo::IShaderDataBinding* m_vertsShaderBinding;
boo::IGraphicsDataToken m_windowGfxData;
boo::GraphicsDataToken m_windowGfxData;
std::unique_ptr<TextView> m_cornersOutline[4];
std::unique_ptr<TextView> m_cornersFilled[4];

View File

@ -1,13 +1,13 @@
#ifndef SPECTER_TEXTFIELD_HPP
#define SPECTER_TEXTFIELD_HPP
#include "View.hpp"
#include "Control.hpp"
#include "TextView.hpp"
namespace Specter
{
class TextField : public View
class TextField : public Control
{
std::string m_textStr;
std::unique_ptr<TextView> m_text;
@ -25,7 +25,7 @@ class TextField : public View
void setDisabled();
public:
TextField(ViewResources& res, View& parentView);
TextField(ViewResources& res, View& parentView, IStringBinding* strBind);
void setText(const std::string& str);

View File

@ -39,7 +39,7 @@ private:
boo::IVertexFormat* m_bgVtxFmt = nullptr; /* OpenGL only */
boo::IShaderDataBinding* m_bgShaderBinding;
SolidShaderVert m_bgRect[4];
boo::IGraphicsDataToken m_gfxData;
boo::GraphicsDataToken m_gfxData;
friend class RootView;
void buildResources(ViewResources& res);

View File

@ -15,8 +15,8 @@ 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_tbBg = {0.4,0.4,0.4,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_tooltipBg = {0.0, 0.0, 0.0, 0.65};
Zeus::CColor m_splashBg = {0.1, 0.1, 0.1, 0.65};
@ -33,11 +33,11 @@ class ThemeData
Zeus::CColor m_button2Disabled = {0.1725, 0.1725, 0.1725, 0.5};
Zeus::CColor m_textfield2Inactive = {0.7823, 0.7823, 0.7823, 1.0};
Zeus::CColor m_textfield1Inactive = {0.4725, 0.4725, 0.4725, 1.0};
Zeus::CColor m_textfield1Inactive = {0.5725, 0.5725, 0.5725, 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_textfield1Hover = {0.6425, 0.6425, 0.6425, 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};
Zeus::CColor m_textfield1Disabled = {0.5725, 0.5725, 0.5725, 0.5};
public:
virtual const Zeus::CColor& uiText() const {return m_uiText;}
@ -88,7 +88,7 @@ public:
SplitView::Resources m_splitRes;
Toolbar::Resources m_toolbarRes;
Button::Resources m_buttonRes;
boo::IGraphicsDataToken m_resData;
boo::GraphicsDataToken m_resData;
Specter::FontTag m_mainFont;
Specter::FontTag m_monoFont;

View File

@ -273,7 +273,7 @@ void Button::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
if (m_style == Style::Block)
{
textRect.location[0] += 5 * pf;
textRect.location[1] += 8 * pf;
textRect.location[1] += 7 * pf;
}
m_text->resized(root, textRect);
}

View File

@ -40,7 +40,9 @@ static std::vector<HECL::SystemString> PathComponents(const HECL::SystemString&
}
FileBrowser::FileBrowser(ViewResources& res, View& parentView, const HECL::SystemString& initialPath)
: ModalWindow(res, parentView), m_comps(PathComponents(initialPath))
: ModalWindow(res, parentView),
m_comps(PathComponents(initialPath)),
m_fileFieldBind(*this)
{
commitResources(res);
setBackground({0,0,0,0.5});
@ -50,7 +52,7 @@ FileBrowser::FileBrowser(ViewResources& res, View& parentView, const HECL::Syste
for (const HECL::SystemString& c : m_comps)
m_pathButtons.emplace_back(*this, res, idx++, c);
m_fileField.m_view.reset(new TextField(res, *this));
m_fileField.m_view.reset(new TextField(res, *this, &m_fileFieldBind));
updateContentOpacity(0.0);
}
@ -91,9 +93,6 @@ void FileBrowser::mouseMove(const boo::SWindowCoord& coord)
void FileBrowser::mouseEnter(const boo::SWindowCoord& coord)
{
for (PathButton& b : m_pathButtons)
b.m_button.mouseEnter(coord);
m_fileField.mouseEnter(coord);
}
void FileBrowser::mouseLeave(const boo::SWindowCoord& coord)
@ -122,7 +121,7 @@ void FileBrowser::resized(const boo::SWindowRect& root, const boo::SWindowRect&
pathRect.size[0] = b.m_button.m_view->nominalWidth();
pathRect.size[1] = b.m_button.m_view->nominalHeight();
b.m_button.m_view->resized(root, pathRect);
pathRect.location[0] += pathRect.size[0];
pathRect.location[0] += pathRect.size[0] + 2;
}
pathRect.location[0] = centerRect.location[0] + 10 * pf;

View File

@ -338,9 +338,7 @@ void ModalWindow::draw(boo::IGraphicsCommandQueue* gfxQ)
{
gfxQ->setShaderDataBinding(m_vertsShaderBinding);
gfxQ->setDrawPrimitive(boo::Primitive::TriStrips);
if (m_frame > WIRE_START)
gfxQ->draw(0, 22);
if (m_frame > SOLID_START)
gfxQ->draw(22, 16);
m_cornersFilled[0]->draw(gfxQ);

View File

@ -5,8 +5,8 @@
namespace Specter
{
TextField::TextField(ViewResources& res, View& parentView)
: View(res, parentView)
TextField::TextField(ViewResources& res, View& parentView, IStringBinding* strBind)
: Control(res, parentView, strBind)
{
m_bVertsBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Vertex, sizeof(SolidShaderVert), 28);
@ -96,19 +96,22 @@ void TextField::mouseMove(const boo::SWindowCoord& coord)
void TextField::mouseEnter(const boo::SWindowCoord& coord)
{
setHover();
}
void TextField::mouseLeave(const boo::SWindowCoord& coord)
{
setInactive();
}
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;
boo::SWindowRect newRect = sub;
newRect.size[1] = height;
View::resized(root, newRect);
m_verts[0].m_pos.assign(1, height+1, 0);
m_verts[1].m_pos.assign(1, 1, 0);
@ -150,7 +153,7 @@ void TextField::resized(const boo::SWindowRect& root, const boo::SWindowRect& su
boo::SWindowRect textRect = sub;
textRect.location[0] += 5 * pf;
textRect.location[1] += 8 * pf;
textRect.location[1] += 7 * pf;
m_text->resized(root, textRect);
}