summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/CoverArt.cpp19
-rw-r--r--unity-shared/CoverArt.h3
2 files changed, 18 insertions, 4 deletions
diff --git a/unity-shared/CoverArt.cpp b/unity-shared/CoverArt.cpp
index 99f003b8f..79463a122 100644
--- a/unity-shared/CoverArt.cpp
+++ b/unity-shared/CoverArt.cpp
@@ -42,7 +42,7 @@ DECLARE_LOGGER(logger, "unity.dash.previews.coverart");
namespace
{
-const int ICON_SIZE = 256;
+const RawPixel ICON_SIZE = 256_em;
const int IMAGE_TIMEOUT = 30;
}
@@ -50,6 +50,7 @@ NUX_IMPLEMENT_OBJECT_TYPE(CoverArt);
CoverArt::CoverArt()
: View(NUX_TRACKER_LOCATION)
+ , scale (1.0)
, overlay_text_(nullptr)
, thumb_handle_(0)
, slot_handle_(0)
@@ -58,6 +59,7 @@ CoverArt::CoverArt()
, rotation_(0.0)
{
SetupViews();
+ scale.changed.connect(sigc::mem_fun(this, &CoverArt::UpdateScale));
}
CoverArt::~CoverArt()
@@ -118,12 +120,12 @@ void CoverArt::SetImage(std::string const& image_hint)
if (icon.IsType(G_TYPE_ICON))
{
StartWaiting();
- slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded));
+ slot_handle_ = IconLoader::GetDefault().LoadFromGIconString(image_hint, ICON_SIZE.CP(scale), ICON_SIZE.CP(scale), sigc::mem_fun(this, &CoverArt::IconLoaded));
}
else
{
StartWaiting();
- slot_handle_ = IconLoader::GetDefault().LoadFromIconName(image_hint, ICON_SIZE, ICON_SIZE, sigc::mem_fun(this, &CoverArt::IconLoaded));
+ slot_handle_ = IconLoader::GetDefault().LoadFromIconName(image_hint, ICON_SIZE.CP(scale), ICON_SIZE.CP(scale), sigc::mem_fun(this, &CoverArt::IconLoaded));
}
}
else
@@ -257,7 +259,8 @@ void CoverArt::IconLoaded(std::string const& texid,
return;
}
- nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, pixbuf_width, pixbuf_height);
+ nux::CairoGraphics cairo_graphics(CAIRO_FORMAT_ARGB32, ((RawPixel)pixbuf_width).CP(scale),
+ ((RawPixel)pixbuf_height).CP(scale));
cairo_t* cr = cairo_graphics.GetInternalContext();
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
@@ -496,6 +499,14 @@ bool CoverArt::OnFrameTimeout()
return false;
}
+void CoverArt::UpdateScale(double scale)
+{
+ if (overlay_text_)
+ overlay_text_->SetScale(scale);
+
+ QueueDraw();
+}
+
}
}
}
diff --git a/unity-shared/CoverArt.h b/unity-shared/CoverArt.h
index add94f755..52929c730 100644
--- a/unity-shared/CoverArt.h
+++ b/unity-shared/CoverArt.h
@@ -58,6 +58,9 @@ public:
void SetFont(std::string const& font);
+ void UpdateScale(double scale);
+ nux::Property<double> scale;
+
protected:
virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);