diff options
| author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-07-17 16:28:47 +0100 |
|---|---|---|
| committer | Nick Dedekind <nicholas.dedekind@gmail.com> | 2012-07-17 16:28:47 +0100 |
| commit | d81520d95b182dcada788d6ee736a0f40964d0cd (patch) | |
| tree | ff7e7e277118cb428e7e6c1060b095ad9a27a713 /unity-shared | |
| parent | d9170c4708b5702936a95d200685f98f6666ec40 (diff) | |
Added music preview.
(bzr r2419.4.21)
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | unity-shared/CoverArt.cpp (renamed from unity-shared/ApplicationScreenshot.cpp) | 25 | ||||
| -rw-r--r-- | unity-shared/CoverArt.h (renamed from unity-shared/ApplicationScreenshot.h) | 15 | ||||
| -rw-r--r-- | unity-shared/PreviewStyle.cpp | 121 | ||||
| -rw-r--r-- | unity-shared/PreviewStyle.h | 34 |
5 files changed, 165 insertions, 32 deletions
diff --git a/unity-shared/CMakeLists.txt b/unity-shared/CMakeLists.txt index 272bd3d25..cd4df5f15 100644 --- a/unity-shared/CMakeLists.txt +++ b/unity-shared/CMakeLists.txt @@ -31,8 +31,8 @@ include_directories (. .. ../services ../UnityCore ${UNITY_SRC} ${CMAKE_BINARY_D set (UNITY_SHARED_SOURCES AbstractSeparator.cpp Animator.cpp - ApplicationScreenshot.cpp BGHash.cpp + CoverArt.cpp BackgroundEffectHelper.cpp DashStyle.cpp FontSettings.cpp diff --git a/unity-shared/ApplicationScreenshot.cpp b/unity-shared/CoverArt.cpp index 67ed0bac3..0a9ac6419 100644 --- a/unity-shared/ApplicationScreenshot.cpp +++ b/unity-shared/CoverArt.cpp @@ -17,10 +17,11 @@ * <http://www.gnu.org/licenses/> * * Authored by: Andrea Cimitan <andrea.cimitan@canonical.com> + * Nick Dedekind <nick.dedekind@canonical.com> * */ -#include "ApplicationScreenshot.h" +#include "CoverArt.h" #include "unity-shared/IntrospectableWrappers.h" #include <NuxCore/Logger.h> #include <Nux/VLayout.h> @@ -34,25 +35,25 @@ namespace previews namespace { -nux::logging::Logger logger("unity.dash.previews.applicationscreenshot"); +nux::logging::Logger logger("unity.dash.previews.coverart"); } -NUX_IMPLEMENT_OBJECT_TYPE(ApplicationScreenshot); +NUX_IMPLEMENT_OBJECT_TYPE(CoverArt); -ApplicationScreenshot::ApplicationScreenshot() +CoverArt::CoverArt() : View(NUX_TRACKER_LOCATION) , overlay_text_(nullptr) { SetupViews(); } -ApplicationScreenshot::~ApplicationScreenshot() +CoverArt::~CoverArt() { if (overlay_text_) overlay_text_->UnReference(); } -void ApplicationScreenshot::SetImage(std::string const& image_hint) +void CoverArt::SetImage(std::string const& image_hint) { if (overlay_text_ && GetLayout()) GetLayout()->RemoveChildObject(overlay_text_); @@ -66,7 +67,7 @@ void ApplicationScreenshot::SetImage(std::string const& image_hint) QueueDraw(); } -void ApplicationScreenshot::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw) +void CoverArt::Draw(nux::GraphicsEngine& gfx_engine, bool force_draw) { nux::Geometry const& base = GetGeometry(); @@ -140,7 +141,7 @@ void ApplicationScreenshot::Draw(nux::GraphicsEngine& gfx_engine, bool force_dra gfx_engine.PopClippingRectangle(); } -void ApplicationScreenshot::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw) +void CoverArt::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw) { nux::Geometry const& base = GetGeometry(); gfx_engine.PushClippingRectangle(base); @@ -151,12 +152,12 @@ void ApplicationScreenshot::DrawContent(nux::GraphicsEngine& gfx_engine, bool fo gfx_engine.PopClippingRectangle(); } -std::string ApplicationScreenshot::GetName() const +std::string CoverArt::GetName() const { - return "ApplicationScreenshot"; + return "CoverArt"; } -void ApplicationScreenshot::SetupViews() +void CoverArt::SetupViews() { nux::VLayout* layout = new nux::VLayout(); layout->AddSpace(0, 1); @@ -171,7 +172,7 @@ void ApplicationScreenshot::SetupViews() overlay_text_->SetText("No Image Available"); } -void ApplicationScreenshot::SetFont(std::string const& font) +void CoverArt::SetFont(std::string const& font) { overlay_text_->SetFont(font); } diff --git a/unity-shared/ApplicationScreenshot.h b/unity-shared/CoverArt.h index 122a30c99..dad9969ae 100644 --- a/unity-shared/ApplicationScreenshot.h +++ b/unity-shared/CoverArt.h @@ -17,11 +17,12 @@ * <http://www.gnu.org/licenses/> * * Authored by: Andrea Cimitan <andrea.cimitan@canonical.com> + * Nick Dedekind <nick.dedekind@canonical.com> * */ -#ifndef APPLICATIONSCREENSHOT_H -#define APPLICATIONSCREENSHOT_H +#ifndef COVERART_H +#define COVERART_H #include <Nux/Nux.h> #include <Nux/View.h> @@ -36,14 +37,14 @@ namespace dash namespace previews { -class ApplicationScreenshot : public nux::View +class CoverArt : public nux::View { public: - typedef nux::ObjectPtr<ApplicationScreenshot> Ptr; - NUX_DECLARE_OBJECT_TYPE(ApplicationScreenshot, nux::View); + typedef nux::ObjectPtr<CoverArt> Ptr; + NUX_DECLARE_OBJECT_TYPE(CoverArt, nux::View); - ApplicationScreenshot(); - virtual ~ApplicationScreenshot(); + CoverArt(); + virtual ~CoverArt(); void SetImage(std::string const& image_hint); diff --git a/unity-shared/PreviewStyle.cpp b/unity-shared/PreviewStyle.cpp index d9c28394a..934fe8752 100644 --- a/unity-shared/PreviewStyle.cpp +++ b/unity-shared/PreviewStyle.cpp @@ -19,9 +19,14 @@ * Authored by: Nick Dedekind <nick.dedekind@canonical.com> * */ + #include "PreviewStyle.h" #include <NuxCore/Logger.h> +#include <NuxGraphics/GLTextureResourceManager.h> +#include <UnityCore/GLibWrapper.h> +#include "config.h" + namespace unity { namespace dash @@ -34,9 +39,48 @@ Style* style_instance = nullptr; nux::logging::Logger logger("unity.dash.previews.style"); +typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr; + +class LazyLoadTexture +{ +public: + LazyLoadTexture(std::string const& filename, int size = -1); + nux::BaseTexture* texture(); +private: + void LoadTexture(); +private: + std::string filename_; + int size_; + BaseTexturePtr texture_; +}; + } // namespace + +class Style::Impl +{ +public: + Impl(Style* owner) + : owner_(owner) + , preview_nav_left_texture_("/prev.svg") + , preview_nav_right_texture_("/next.svg") + , preview_play_texture_("/play.svg") + , preview_pause_texture_("/pause.svg") + { + } + ~Impl() {} + + Style* owner_; + + LazyLoadTexture preview_nav_left_texture_; + LazyLoadTexture preview_nav_right_texture_; + LazyLoadTexture preview_play_texture_; + LazyLoadTexture preview_pause_texture_; +}; + + Style::Style() +: pimpl(new Impl(this)) { if (style_instance) { @@ -64,23 +108,23 @@ Style& Style::Instance() return *style_instance; } -int Style::NavigatorMinimumWidth() const +int Style::GetNavigatorWidth() const { return 42; } -int Style::NavigatorMaximumWidth() const +int Style::GetImageWidth() const { - return 42; + return 400; } -std::string Style::app_name_font() const +std::string Style::title_font() const { - return "Ubuntu 20"; + return "Ubuntu 22"; } -std::string Style::version_size_font() const +std::string Style::subtitle_size_font() const { - return "Ubuntu 12"; + return "Ubuntu 12.5"; } std::string Style::app_license_font() const { @@ -112,6 +156,69 @@ std::string Style::no_preview_image_font() const return "Ubuntu Light 16"; } +std::string Style::track_font() const +{ + return "Ubuntu Light 10"; +} + + + +nux::BaseTexture* Style::GetNavLeftIcon() +{ + return pimpl->preview_nav_left_texture_.texture(); } + +nux::BaseTexture* Style::GetNavRightIcon() +{ + return pimpl->preview_nav_right_texture_.texture(); } + +nux::BaseTexture* Style::GetPlayIcon() +{ + return pimpl->preview_play_texture_.texture(); } + +nux::BaseTexture* Style::GetPauseIcon() +{ + return pimpl->preview_pause_texture_.texture(); +} + + + +namespace +{ +LazyLoadTexture::LazyLoadTexture(std::string const& filename, int size) + : filename_(filename) + , size_(size) +{ +} + +nux::BaseTexture* LazyLoadTexture::texture() +{ + if (!texture_) + LoadTexture(); + return texture_.GetPointer(); +} + +void LazyLoadTexture::LoadTexture() +{ + std::string full_path = PKGDATADIR + filename_; + glib::Object<GdkPixbuf> pixbuf; + glib::Error error; + + pixbuf = ::gdk_pixbuf_new_from_file_at_size(full_path.c_str(), size_, size_, &error); + if (error) + { + LOG_WARN(logger) << "Unable to texture " << full_path << ": " << error; + } + else + { + texture_.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true)); + } +} + +} // namesspace + +} // namespace previews +} // namespace dash +} // namespace unity diff --git a/unity-shared/PreviewStyle.h b/unity-shared/PreviewStyle.h index 75132f709..0570ece7f 100644 --- a/unity-shared/PreviewStyle.h +++ b/unity-shared/PreviewStyle.h @@ -23,7 +23,16 @@ #ifndef PREVIEWSTYLE_H #define PREVIEWSTYLE_H - #include <string> +#include <Nux/Nux.h> +#include <Nux/View.h> + +#include <string> +#include <memory> + +namespace nux +{ + class BaseTexture; +} namespace unity { @@ -47,13 +56,15 @@ public: static Style& Instance(); - int NavigatorMinimumWidth() const; - int NavigatorMaximumWidth() const; + int GetNavigatorWidth() const; + int GetImageWidth() const; + + + std::string title_font() const; + std::string subtitle_size_font() const; //////////////////////////////// // Application Preview - std::string app_name_font() const; - std::string version_size_font() const; std::string app_license_font() const; std::string app_last_update_font() const; std::string app_copywrite_font() const; @@ -62,8 +73,21 @@ public: std::string user_rating_font() const; std::string no_preview_image_font() const; //////////////////////////////// + + //////////////////////////////// + // Music Preview + std::string track_font() const; + //////////////////////////////// + + + nux::BaseTexture* GetNavLeftIcon(); + nux::BaseTexture* GetNavRightIcon(); + nux::BaseTexture* GetPlayIcon(); + nux::BaseTexture* GetPauseIcon(); protected: + class Impl; + std::unique_ptr<Impl> pimpl; }; |
