diff --git a/Sources/BuiltInNodes/BI_UINodeLayouts.cpp b/Sources/BuiltInNodes/BI_UINodeLayouts.cpp index 66543d6f..7538568e 100644 --- a/Sources/BuiltInNodes/BI_UINodeLayouts.cpp +++ b/Sources/BuiltInNodes/BI_UINodeLayouts.cpp @@ -19,7 +19,7 @@ void HeaderBasedLayout::AddPanels ( const BasicUINode& uiNode, nodeStatus = NodeUIHeaderPanel::NodeStatus::HasValue; } std::wstring nodeName = uiNode.GetNodeName ().GetLocalized (); - if (uiNode.HasIconId ()) { + if (uiNode.HasIconId () && env.GetDrawingContext ().CanDrawIcon ()) { drawer.AddPanel (NUIE::NodeUIPanelPtr (new NodeUIIconHeaderPanel (nodeName, nodeStatus, uiNode.GetIconId (), env))); } else { drawer.AddPanel (NUIE::NodeUIPanelPtr (new NodeUIHeaderPanel (nodeName, nodeStatus))); diff --git a/Sources/NodeUIEngine/NUIE_DrawingContext.cpp b/Sources/NodeUIEngine/NUIE_DrawingContext.cpp index 90c57c63..311aa236 100644 --- a/Sources/NodeUIEngine/NUIE_DrawingContext.cpp +++ b/Sources/NodeUIEngine/NUIE_DrawingContext.cpp @@ -94,6 +94,11 @@ Size DrawingContextDecorator::MeasureText (const Font& font, const std::wstring& return decorated.MeasureText (font, text); } +bool DrawingContextDecorator::CanDrawIcon () +{ + return decorated.CanDrawIcon (); +} + void DrawingContextDecorator::DrawIcon (const Rect& rect, const IconId& iconId) { decorated.DrawIcon (rect, iconId); @@ -169,6 +174,11 @@ Size NullDrawingContext::MeasureText (const Font&, const std::wstring&) return Size (); } +bool NullDrawingContext::CanDrawIcon () +{ + return false; +} + void NullDrawingContext::DrawIcon (const Rect&, const IconId&) { diff --git a/Sources/NodeUIEngine/NUIE_DrawingContext.hpp b/Sources/NodeUIEngine/NUIE_DrawingContext.hpp index bf39d531..5dc9c588 100644 --- a/Sources/NodeUIEngine/NUIE_DrawingContext.hpp +++ b/Sources/NodeUIEngine/NUIE_DrawingContext.hpp @@ -44,6 +44,7 @@ class DrawingContext virtual void DrawFormattedText (const Rect& rect, const Font& font, const std::wstring& text, HorizontalAnchor hAnchor, VerticalAnchor vAnchor, const Color& textColor) = 0; virtual Size MeasureText (const Font& font, const std::wstring& text) = 0; + virtual bool CanDrawIcon () = 0; virtual void DrawIcon (const Rect& rect, const IconId& iconId) = 0; }; @@ -75,6 +76,7 @@ class DrawingContextDecorator : public DrawingContext virtual void DrawFormattedText (const Rect& rect, const Font& font, const std::wstring& text, HorizontalAnchor hAnchor, VerticalAnchor vAnchor, const Color& textColor) override; virtual Size MeasureText (const Font& font, const std::wstring& text) override; + virtual bool CanDrawIcon () override; virtual void DrawIcon (const Rect& rect, const IconId& iconId) override; protected: @@ -106,6 +108,7 @@ class NullDrawingContext : public DrawingContext virtual void DrawFormattedText (const Rect& rect, const Font& font, const std::wstring& text, HorizontalAnchor hAnchor, VerticalAnchor vAnchor, const Color& textColor) override; virtual Size MeasureText (const Font& font, const std::wstring& text) override; + virtual bool CanDrawIcon () override; virtual void DrawIcon (const Rect& rect, const IconId& iconId) override; }; diff --git a/Sources/NodeUIEngine/NUIE_SvgDrawingContext.cpp b/Sources/NodeUIEngine/NUIE_SvgDrawingContext.cpp index 5d73d78e..87164947 100644 --- a/Sources/NodeUIEngine/NUIE_SvgDrawingContext.cpp +++ b/Sources/NodeUIEngine/NUIE_SvgDrawingContext.cpp @@ -261,9 +261,14 @@ Size SvgDrawingContext::MeasureText (const Font& font, const std::wstring& text) return Size (text.length () * font.GetSize (), font.GetSize () * 1.5); } -void SvgDrawingContext::DrawIcon (const Rect&, const IconId&) +bool SvgDrawingContext::CanDrawIcon () { + return false; +} +void SvgDrawingContext::DrawIcon (const Rect&, const IconId&) +{ + DBGBREAK (); } std::wstring ReplaceAll (const std::wstring& string, const std::wstring& from, const std::wstring& to) diff --git a/Sources/NodeUIEngine/NUIE_SvgDrawingContext.hpp b/Sources/NodeUIEngine/NUIE_SvgDrawingContext.hpp index 912513de..8b0842bd 100644 --- a/Sources/NodeUIEngine/NUIE_SvgDrawingContext.hpp +++ b/Sources/NodeUIEngine/NUIE_SvgDrawingContext.hpp @@ -59,6 +59,7 @@ class SvgDrawingContext : public DrawingContext virtual void FillEllipse (const Rect& rect, const Color& color) override; virtual void DrawFormattedText (const Rect& rect, const Font& font, const std::wstring& text, HorizontalAnchor hAnchor, VerticalAnchor vAnchor, const NUIE::Color& textColor) override; virtual Size MeasureText (const Font& font, const std::wstring& text) override; + virtual bool CanDrawIcon () override; virtual void DrawIcon (const Rect& rect, const IconId& iconId) override; private: diff --git a/Sources/WindowsAppSupport/WAS_BitmapContextGdi.cpp b/Sources/WindowsAppSupport/WAS_BitmapContextGdi.cpp index fd20866d..6041364f 100644 --- a/Sources/WindowsAppSupport/WAS_BitmapContextGdi.cpp +++ b/Sources/WindowsAppSupport/WAS_BitmapContextGdi.cpp @@ -229,6 +229,11 @@ NUIE::Size BitmapContextGdi::MeasureText (const NUIE::Font& font, const std::wst return NUIE::Size (gdiRect.right - gdiRect.left + 5, gdiRect.bottom - gdiRect.top); } +bool BitmapContextGdi::CanDrawIcon () +{ + return false; +} + void BitmapContextGdi::DrawIcon (const NUIE::Rect&, const NUIE::IconId&) { DBGBREAK (); diff --git a/Sources/WindowsAppSupport/WAS_BitmapContextGdi.hpp b/Sources/WindowsAppSupport/WAS_BitmapContextGdi.hpp index decce86c..73a81367 100644 --- a/Sources/WindowsAppSupport/WAS_BitmapContextGdi.hpp +++ b/Sources/WindowsAppSupport/WAS_BitmapContextGdi.hpp @@ -79,6 +79,7 @@ class BitmapContextGdi : public NUIE::NativeDrawingContext virtual void DrawFormattedText (const NUIE::Rect& rect, const NUIE::Font& font, const std::wstring& text, NUIE::HorizontalAnchor hAnchor, NUIE::VerticalAnchor vAnchor, const NUIE::Color& textColor) override; virtual NUIE::Size MeasureText (const NUIE::Font& font, const std::wstring& text) override; + virtual bool CanDrawIcon () override; virtual void DrawIcon (const NUIE::Rect& rect, const NUIE::IconId& iconId) override; private: diff --git a/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.cpp b/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.cpp index 47b72bb0..f0cc052b 100644 --- a/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.cpp +++ b/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.cpp @@ -202,6 +202,11 @@ NUIE::Size BitmapContextGdiplus::MeasureText (const NUIE::Font& font, const std: return NUIE::Size (textRect.Width, textRect.Height); } +bool BitmapContextGdiplus::CanDrawIcon () +{ + return false; +} + void BitmapContextGdiplus::DrawIcon (const NUIE::Rect&, const NUIE::IconId&) { DBGBREAK (); diff --git a/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.hpp b/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.hpp index 5a59317e..853eba49 100644 --- a/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.hpp +++ b/Sources/WindowsAppSupport/WAS_BitmapContextGdiplus.hpp @@ -41,6 +41,7 @@ class BitmapContextGdiplus : public NUIE::NativeDrawingContext virtual void DrawFormattedText (const NUIE::Rect& rect, const NUIE::Font& font, const std::wstring& text, NUIE::HorizontalAnchor hAnchor, NUIE::VerticalAnchor vAnchor, const NUIE::Color& textColor) override; virtual NUIE::Size MeasureText (const NUIE::Font& font, const std::wstring& text) override; + virtual bool CanDrawIcon () override; virtual void DrawIcon (const NUIE::Rect& rect, const NUIE::IconId& iconId) override; private: diff --git a/Sources/WindowsAppSupport/WAS_Direct2DContext.cpp b/Sources/WindowsAppSupport/WAS_Direct2DContext.cpp index 912490a8..91b29ebd 100644 --- a/Sources/WindowsAppSupport/WAS_Direct2DContext.cpp +++ b/Sources/WindowsAppSupport/WAS_Direct2DContext.cpp @@ -296,6 +296,11 @@ NUIE::Size Direct2DContext::MeasureText (const NUIE::Font& font, const std::wstr return NUIE::Size (metrics.width * SafetyTextRatio, metrics.height * SafetyTextRatio); } +bool Direct2DContext::CanDrawIcon () +{ + return true; +} + void Direct2DContext::DrawIcon (const NUIE::Rect& rect, const NUIE::IconId& iconId) { if (imageLoader == nullptr) { diff --git a/Sources/WindowsAppSupport/WAS_Direct2DContext.hpp b/Sources/WindowsAppSupport/WAS_Direct2DContext.hpp index 23527ca8..dc3258f3 100644 --- a/Sources/WindowsAppSupport/WAS_Direct2DContext.hpp +++ b/Sources/WindowsAppSupport/WAS_Direct2DContext.hpp @@ -56,6 +56,7 @@ class Direct2DContext : public NUIE::NativeDrawingContext virtual void DrawFormattedText (const NUIE::Rect& rect, const NUIE::Font& font, const std::wstring& text, NUIE::HorizontalAnchor hAnchor, NUIE::VerticalAnchor vAnchor, const NUIE::Color& textColor) override; virtual NUIE::Size MeasureText (const NUIE::Font& font, const std::wstring& text) override; + virtual bool CanDrawIcon () override; virtual void DrawIcon (const NUIE::Rect& rect, const NUIE::IconId& iconId) override; private: