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
1=== modified file 'dash/previews/SocialPreview.cpp'
2--- dash/previews/SocialPreview.cpp 2013-01-16 15:43:38 +0000
3+++ dash/previews/SocialPreview.cpp 2013-06-11 21:35:32 +0000
4@@ -132,6 +132,7 @@
5 if (social_preview_model->description.Get().length() > 0)
6 {
7 content_ = new SocialPreviewContent(social_preview_model->description, NUX_TRACKER_LOCATION);
8+ content_->request_close().connect([this]() { preview_container_->request_close.emit(); });
9 social_content_layout->AddView(content_.GetPointer(), 1);
10 } else {
11 image_ = new CoverArt();
12
13=== modified file 'dash/previews/SocialPreviewContent.cpp'
14--- dash/previews/SocialPreviewContent.cpp 2013-02-17 17:03:52 +0000
15+++ dash/previews/SocialPreviewContent.cpp 2013-06-11 21:35:32 +0000
16@@ -130,14 +130,20 @@
17 {
18 dash::previews::Style const& style = dash::previews::Style::Instance();
19
20+ 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); };
21+
22 text_ = new StaticCairoText("", false, NUX_TRACKER_LOCATION);
23 text_->SetLines(-8);
24 text_->SetFont(style.content_font());
25 text_->SetLineSpacing(5);
26 text_->SetTextEllipsize(StaticCairoText::NUX_ELLIPSIZE_MIDDLE);
27+ text_->mouse_click.connect(on_mouse_down);
28
29 nux::Layout* layout = new nux::Layout();
30 layout->AddView(text_.GetPointer(), 1);
31+
32+ mouse_click.connect(on_mouse_down);
33+
34 SetLayout(layout);
35
36 cr_bubble_.reset(new nux::CairoWrapper(GetGeometry(), sigc::bind(sigc::mem_fun(this, &SocialPreviewContent::RedrawBubble), nux::ButtonVisualState::VISUAL_STATE_PRELIGHT)));
37
38=== modified file 'dash/previews/SocialPreviewContent.h'
39--- dash/previews/SocialPreviewContent.h 2012-12-14 12:14:34 +0000
40+++ dash/previews/SocialPreviewContent.h 2013-06-11 21:35:32 +0000
41@@ -30,6 +30,7 @@
42 #include <NuxCore/ObjectPtr.h>
43 #include "unity-shared/StaticCairoText.h"
44 #include "unity-shared/Introspectable.h"
45+#include "PreviewContainer.h"
46
47 namespace unity
48 {
49@@ -49,6 +50,8 @@
50
51 void SetText(std::string const& text);
52
53+ sigc::signal<void> request_close() const { return preview_container_.request_close; }
54+
55 protected:
56 virtual void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
57 virtual void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
58@@ -77,6 +80,8 @@
59
60 typedef std::unique_ptr<nux::CairoWrapper> NuxCairoPtr;
61 NuxCairoPtr cr_bubble_;
62+
63+ PreviewContainer preview_container_;
64 };
65
66 }