mirror of https://github.com/AxioDL/metaforce.git
Fixed some DPI-switching borks
This commit is contained in:
parent
d923e9eedd
commit
cb8d7145c2
|
@ -38,7 +38,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
Button(ViewResources& res, View& parentView,
|
Button(ViewResources& res, View& parentView,
|
||||||
std::unique_ptr<IControlBinding>&& controlBinding, const std::string& text);
|
std::unique_ptr<IButtonBinding>&& controlBinding, const std::string& text);
|
||||||
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseDown(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
void mouseUp(const boo::SWindowCoord&, boo::EMouseButton, boo::EModifierKey);
|
||||||
void mouseEnter(const boo::SWindowCoord&);
|
void mouseEnter(const boo::SWindowCoord&);
|
||||||
|
|
|
@ -13,6 +13,25 @@ struct IControlBinding
|
||||||
virtual const std::string& help() const=0;
|
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<float,float> 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<int,int> getBounds() const {return std::make_pair(INT_MIN, INT_MAX);}
|
||||||
|
virtual void changed(int val)=0;
|
||||||
|
};
|
||||||
|
|
||||||
struct CVarControlBinding : IControlBinding
|
struct CVarControlBinding : IControlBinding
|
||||||
{
|
{
|
||||||
HECL::CVar* m_cvar;
|
HECL::CVar* m_cvar;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
boo::IWindow* window() const {return m_window;}
|
boo::IWindow* window() const {return m_window;}
|
||||||
IViewManager& viewManager() const {return m_viewMan;}
|
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;}
|
const ThemeData& themeData() const {return m_viewRes->m_theme;}
|
||||||
|
|
||||||
void setContentView(std::unique_ptr<View>&& view);
|
void setContentView(std::unique_ptr<View>&& view);
|
||||||
|
|
|
@ -12,7 +12,7 @@ void Button::Resources::init(boo::IGraphicsDataFactory* factory, const ThemeData
|
||||||
}
|
}
|
||||||
|
|
||||||
Button::Button(ViewResources& res, View& parentView,
|
Button::Button(ViewResources& res, View& parentView,
|
||||||
std::unique_ptr<IControlBinding>&& controlBinding, const std::string& text)
|
std::unique_ptr<IButtonBinding>&& controlBinding, const std::string& text)
|
||||||
: Control(res, parentView, std::move(controlBinding)), m_textStr(text)
|
: Control(res, parentView, std::move(controlBinding)), m_textStr(text)
|
||||||
{
|
{
|
||||||
m_bBlockBuf = res.m_factory->newDynamicBuffer(boo::BufferUse::Uniform, sizeof(ViewBlock), 1);
|
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);
|
Control::mouseUp(coord, button, mod);
|
||||||
if (m_pressed && m_hovered)
|
if (m_pressed && m_hovered)
|
||||||
|
{
|
||||||
Log.report(LogVisor::Info, "button '%s' activated", m_textStr.c_str());
|
Log.report(LogVisor::Info, "button '%s' activated", m_textStr.c_str());
|
||||||
|
if (m_controlBinding && dynamic_cast<IButtonBinding*>(m_controlBinding.get()))
|
||||||
|
static_cast<IButtonBinding&>(*m_controlBinding).pressed(coord);
|
||||||
|
}
|
||||||
m_pressed = false;
|
m_pressed = false;
|
||||||
if (m_hovered)
|
if (m_hovered)
|
||||||
setHover();
|
setHover();
|
||||||
|
|
|
@ -144,6 +144,8 @@ void Toolbar::resetResources(ViewResources& res)
|
||||||
m_padding = res.pixelFactor() * TOOLBAR_PADDING;
|
m_padding = res.pixelFactor() * TOOLBAR_PADDING;
|
||||||
setBackground(res.themeData().toolbarBackground());
|
setBackground(res.themeData().toolbarBackground());
|
||||||
updateSize();
|
updateSize();
|
||||||
|
for (Child& c : m_children)
|
||||||
|
c.m_view->resetResources(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
void Toolbar::resized(const boo::SWindowRect& root, const boo::SWindowRect& sub)
|
||||||
|
|
|
@ -48,7 +48,7 @@ void ViewResources::resetPixelFactor(float pf)
|
||||||
m_monoFont = m_fcache->prepMonoFont(m_factory, AllCharFilter, false, 10.f, dpi);
|
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_heading14 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 14.f, dpi);
|
||||||
m_heading18 = m_fcache->prepMainFont(m_factory, LatinAndJapaneseCharFilter, false, 18.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_fontData = m_factory->commit();
|
||||||
m_fcache->closeBuiltinFonts();
|
m_fcache->closeBuiltinFonts();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue