Merge lp:~townsend/unity/fix-close-social-preview into lp:unity

Proposed by Christopher Townsend
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 3368
Proposed branch: lp:~townsend/unity/fix-close-social-preview
Merge into: lp:unity
Diff against target: 66 lines (+12/-0)
3 files modified
dash/previews/SocialPreview.cpp (+1/-0)
dash/previews/SocialPreviewContent.cpp (+6/-0)
dash/previews/SocialPreviewContent.h (+5/-0)
To merge this branch: bzr merge lp:~townsend/unity/fix-close-social-preview
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Brandon Schaefer (community) Approve
Review via email: mp+168817@code.launchpad.net

Commit message

Add support to close social previews by clicking anywhere in the preview bubble.

Description of the change

Closing the social preview by clicking in the preview bubble doesn't work. This was missed when the "click anywhere in a preview" work was originally done for 13.04.

The fixes it by adding the necessary plumbing to the SocialPreviewContent class.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Awesome, confirmed fixed! :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dash/previews/SocialPreview.cpp'
--- dash/previews/SocialPreview.cpp 2013-01-16 15:43:38 +0000
+++ dash/previews/SocialPreview.cpp 2013-06-11 21:35:32 +0000
@@ -132,6 +132,7 @@
132 if (social_preview_model->description.Get().length() > 0)132 if (social_preview_model->description.Get().length() > 0)
133 {133 {
134 content_ = new SocialPreviewContent(social_preview_model->description, NUX_TRACKER_LOCATION);134 content_ = new SocialPreviewContent(social_preview_model->description, NUX_TRACKER_LOCATION);
135 content_->request_close().connect([this]() { preview_container_->request_close.emit(); });
135 social_content_layout->AddView(content_.GetPointer(), 1);136 social_content_layout->AddView(content_.GetPointer(), 1);
136 } else {137 } else {
137 image_ = new CoverArt();138 image_ = new CoverArt();
138139
=== modified file 'dash/previews/SocialPreviewContent.cpp'
--- dash/previews/SocialPreviewContent.cpp 2013-02-17 17:03:52 +0000
+++ dash/previews/SocialPreviewContent.cpp 2013-06-11 21:35:32 +0000
@@ -130,14 +130,20 @@
130{130{
131 dash::previews::Style const& style = dash::previews::Style::Instance();131 dash::previews::Style const& style = dash::previews::Style::Instance();
132132
133 auto on_mouse_down = [&](int x, int y, unsigned long button_flags, unsigned long key_flags) { this->preview_container_.OnMouseDown(x, y, button_flags, key_flags); };
134
133 text_ = new StaticCairoText("", false, NUX_TRACKER_LOCATION);135 text_ = new StaticCairoText("", false, NUX_TRACKER_LOCATION);
134 text_->SetLines(-8);136 text_->SetLines(-8);
135 text_->SetFont(style.content_font());137 text_->SetFont(style.content_font());
136 text_->SetLineSpacing(5);138 text_->SetLineSpacing(5);
137 text_->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_MIDDLE);139 text_->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_MIDDLE);
140 text_->mouse_click.connect(on_mouse_down);
138141
139 nux::Layout* layout = new nux::Layout();142 nux::Layout* layout = new nux::Layout();
140 layout->AddView(text_.GetPointer(), 1);143 layout->AddView(text_.GetPointer(), 1);
144
145 mouse_click.connect(on_mouse_down);
146
141 SetLayout(layout);147 SetLayout(layout);
142148
143 cr_bubble_.reset(new nux::CairoWrapper(GetGeometry(), sigc::bind(sigc::mem_fun(this, &SocialPreviewContent::RedrawBubble), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));149 cr_bubble_.reset(new nux::CairoWrapper(GetGeometry(), sigc::bind(sigc::mem_fun(this, &SocialPreviewContent::RedrawBubble), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
144150
=== modified file 'dash/previews/SocialPreviewContent.h'
--- dash/previews/SocialPreviewContent.h 2012-12-14 12:14:34 +0000
+++ dash/previews/SocialPreviewContent.h 2013-06-11 21:35:32 +0000
@@ -30,6 +30,7 @@
30#include <NuxCore/ObjectPtr.h>30#include <NuxCore/ObjectPtr.h>
31#include "unity-shared/StaticCairoText.h"31#include "unity-shared/StaticCairoText.h"
32#include "unity-shared/Introspectable.h"32#include "unity-shared/Introspectable.h"
33#include "PreviewContainer.h"
3334
34namespace unity35namespace unity
35{36{
@@ -49,6 +50,8 @@
4950
50 void SetText(std::string const& text);51 void SetText(std::string const& text);
5152
53 sigc::signal<void> request_close() const { return preview_container_.request_close; }
54
52protected:55protected:
53 virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);56 virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
54 virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);57 virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
@@ -77,6 +80,8 @@
7780
78 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;81 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
79 NuxCairoPtr cr_bubble_;82 NuxCairoPtr cr_bubble_;
83
84 PreviewContainer preview_container_;
80};85};
8186
82}87}