From e8449f3fdba054b6b1caffcde622f230d5f7f9f1 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Thu, 17 Dec 2015 17:26:10 -1000 Subject: [PATCH] Rendering tweaks/bug-fixes --- specter/include/Specter/Control.hpp | 6 ++++++ specter/include/Specter/FileBrowser.hpp | 10 ++++++++++ specter/include/Specter/FontCache.hpp | 2 +- specter/include/Specter/ModalWindow.hpp | 2 +- specter/include/Specter/TextField.hpp | 6 +++--- specter/include/Specter/View.hpp | 2 +- specter/include/Specter/ViewResources.hpp | 12 ++++++------ specter/lib/Button.cpp | 2 +- specter/lib/FileBrowser.cpp | 11 +++++------ specter/lib/ModalWindow.cpp | 6 ++---- specter/lib/TextField.cpp | 13 ++++++++----- 11 files changed, 44 insertions(+), 28 deletions(-) diff --git a/specter/include/Specter/Control.hpp b/specter/include/Specter/Control.hpp index 2cac3a102..16be0ee86 100644 --- a/specter/include/Specter/Control.hpp +++ b/specter/include/Specter/Control.hpp @@ -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; diff --git a/specter/include/Specter/FileBrowser.hpp b/specter/include/Specter/FileBrowser.hpp index 940d4073e..0eae3fde6 100644 --- a/specter/include/Specter/FileBrowser.hpp +++ b/specter/include/Specter/FileBrowser.hpp @@ -35,6 +35,16 @@ class FileBrowser : public ModalWindow std::vector m_pathButtons; Specter::ViewChild 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 m_fileScroll; Specter::ViewChild m_fileListing; diff --git a/specter/include/Specter/FontCache.hpp b/specter/include/Specter/FontCache.hpp index 859f6a4ba..8e643e54f 100644 --- a/specter/include/Specter/FontCache.hpp +++ b/specter/include/Specter/FontCache.hpp @@ -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; diff --git a/specter/include/Specter/ModalWindow.hpp b/specter/include/Specter/ModalWindow.hpp index bf47f2d9c..42c0851c6 100644 --- a/specter/include/Specter/ModalWindow.hpp +++ b/specter/include/Specter/ModalWindow.hpp @@ -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 m_cornersOutline[4]; std::unique_ptr m_cornersFilled[4]; diff --git a/specter/include/Specter/TextField.hpp b/specter/include/Specter/TextField.hpp index 8a0fdc8d8..f7cb7c194 100644 --- a/specter/include/Specter/TextField.hpp +++ b/specter/include/Specter/TextField.hpp @@ -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 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); diff --git a/specter/include/Specter/View.hpp b/specter/include/Specter/View.hpp index d4aff70d7..f8b90ef63 100644 --- a/specter/include/Specter/View.hpp +++ b/specter/include/Specter/View.hpp @@ -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); diff --git a/specter/include/Specter/ViewResources.hpp b/specter/include/Specter/ViewResources.hpp index 9543e26d6..ce85eefd7 100644 --- a/specter/include/Specter/ViewResources.hpp +++ b/specter/include/Specter/ViewResources.hpp @@ -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; diff --git a/specter/lib/Button.cpp b/specter/lib/Button.cpp index 9ff54e3a7..af81d9fc0 100644 --- a/specter/lib/Button.cpp +++ b/specter/lib/Button.cpp @@ -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); } diff --git a/specter/lib/FileBrowser.cpp b/specter/lib/FileBrowser.cpp index a82d55886..20f6b4db7 100644 --- a/specter/lib/FileBrowser.cpp +++ b/specter/lib/FileBrowser.cpp @@ -40,7 +40,9 @@ static std::vector 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; diff --git a/specter/lib/ModalWindow.cpp b/specter/lib/ModalWindow.cpp index 32a01e1e5..c7a67c98e 100644 --- a/specter/lib/ModalWindow.cpp +++ b/specter/lib/ModalWindow.cpp @@ -338,10 +338,8 @@ 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); + gfxQ->draw(0, 22); + gfxQ->draw(22, 16); m_cornersFilled[0]->draw(gfxQ); m_cornersFilled[1]->draw(gfxQ); diff --git a/specter/lib/TextField.cpp b/specter/lib/TextField.cpp index 6c1840371..7bb8ae1a5 100644 --- a/specter/lib/TextField.cpp +++ b/specter/lib/TextField.cpp @@ -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); }