diff --git a/specter/include/Specter/Button.hpp b/specter/include/Specter/Button.hpp index 5435a588f..ce53675d9 100644 --- a/specter/include/Specter/Button.hpp +++ b/specter/include/Specter/Button.hpp @@ -38,7 +38,7 @@ public: }; Button(ViewResources& res, View& parentView, - std::unique_ptr&& controlBinding, const std::string& text); + std::unique_ptr&& controlBinding, const std::string& text); void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey); void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey); void mouseEnter(const boo::SWindowCoord&); diff --git a/specter/include/Specter/Control.hpp b/specter/include/Specter/Control.hpp index d0fbd9d55..0a28af9d9 100644 --- a/specter/include/Specter/Control.hpp +++ b/specter/include/Specter/Control.hpp @@ -13,6 +13,25 @@ struct IControlBinding virtual const std::string& help() const=0; }; +struct IButtonBinding : IControlBinding +{ + virtual void pressed(const boo::SWindowCoord& coord)=0; +}; + +struct IFloatBinding : IControlBinding +{ + virtual float getDefault() const {return 0.0;} + virtual std::pair getBounds() const {return std::make_pair(FLT_MIN, FLT_MAX);} + virtual void changed(float val)=0; +}; + +struct IIntBinding : IControlBinding +{ + virtual int getDefault() const {return 0;} + virtual std::pair getBounds() const {return std::make_pair(INT_MIN, INT_MAX);} + virtual void changed(int val)=0; +}; + struct CVarControlBinding : IControlBinding { HECL::CVar* m_cvar; diff --git a/specter/include/Specter/RootView.hpp b/specter/include/Specter/RootView.hpp index b5d274056..cb94bb82f 100644 --- a/specter/include/Specter/RootView.hpp +++ b/specter/include/Specter/RootView.hpp @@ -61,7 +61,7 @@ public: boo::IWindow* window() const {return m_window;} IViewManager& viewManager() const {return m_viewMan;} - const ViewResources& viewRes() const {return *m_viewRes;} + ViewResources& viewRes() const {return *m_viewRes;} const ThemeData& themeData() const {return m_viewRes->m_theme;} void setContentView(std::unique_ptr&& view); diff --git a/specter/lib/Button.cpp b/specter/lib/Button.cpp index c72e34c6e..b2976c279 100644 --- a/specter/lib/Button.cpp +++ b/specter/lib/Button.cpp @@ -12,7 +12,7 @@ void Button::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData } Button::Button(ViewResources& res, View& parentView, - std::unique_ptr&& controlBinding, const std::string& text) + std::unique_ptr&& controlBinding, const std::string& text) : Control(res, parentView, std::move(controlBinding)), m_textStr(text) { m_bBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1); @@ -141,7 +141,11 @@ void Button::mouseUp(const boo::SWindowCoord& coord, boo::EMouseButton button, b { Control::mouseUp(coord, button, mod); if (m_pressed && m_hovered) + { Log.report(LogVisor::Info, "button '%s' activated", m_textStr.c_str()); + if (m_controlBinding && dynamic_cast(m_controlBinding.get())) + static_cast(*m_controlBinding).pressed(coord); + } m_pressed = false; if (m_hovered) setHover(); diff --git a/specter/lib/Toolbar.cpp b/specter/lib/Toolbar.cpp index caf2ec056..2a456a857 100644 --- a/specter/lib/Toolbar.cpp +++ b/specter/lib/Toolbar.cpp @@ -144,6 +144,8 @@ void Toolbar::resetResources(ViewResources& res) m_padding = res.pixelFactor() * TOOLBAR_PADDING; setBackground(res.themeData().toolbarBackground()); updateSize(); + for (Child& c : m_children) + c.m_view->resetResources(res); } void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub) diff --git a/specter/lib/ViewResources.cpp b/specter/lib/ViewResources.cpp index 6b81aa76f..153cb795c 100644 --- a/specter/lib/ViewResources.cpp +++ b/specter/lib/ViewResources.cpp @@ -48,7 +48,7 @@ void ViewResources::resetPixelFactor(float pf) m_monoFont = m_fcache->prepMonoFont(m_factory, AllCharFilter, false, 10.f, dpi); m_heading14 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 14.f, dpi); m_heading18 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 18.f, dpi); - m_curveFont = m_fcache->prepCurvesFont(m_factory, AllCharFilter, false, 11.f, dpi); + m_curveFont = m_fcache->prepCurvesFont(m_factory, AllCharFilter, false, 8.f, dpi); m_fontData = m_factory->commit(); m_fcache->closeBuiltinFonts(); }