Merge lp:~nick-dedekind/unity/lp1045243.preview-fixed-size into lp:unity

Proposed by Nick Dedekind
Status: Merged
Approved by: Brandon Schaefer
Approved revision: no longer in the source branch.
Merged at revision: 2667
Proposed branch: lp:~nick-dedekind/unity/lp1045243.preview-fixed-size
Merge into: lp:unity
Diff against target: 172 lines (+22/-41)
4 files modified
dash/previews/PreviewContainer.cpp (+8/-34)
dash/previews/PreviewContainer.h (+0/-2)
unity-shared/PreviewStyle.cpp (+12/-4)
unity-shared/PreviewStyle.h (+2/-1)
To merge this branch: bzr merge lp:~nick-dedekind/unity/lp1045243.preview-fixed-size
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
jenkins continuous-integration Pending
Review via email: mp+122655@code.launchpad.net

Commit message

Fixed the size of the previews to 770x380 pixels. (LP#1045243)

Description of the change

Fixed the size of the previews to 770x380 pixels. Resizing dash will not alter size. (LP#1045243)

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

Hmm instead of returning hardcoded values could you make variables at the top of the class?

ie:
const int preview_width = 770;
etc...

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Also this happens:
http://i.imgur.com/h29v5.jpg

When you:
Start the dash and set it to fullscreen
Right click an icon to open preview
Now take the dash out of fullscreen and open a preview.

review: Needs Fixing
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

The resize issue in that image is fixed by a related bug.
https://bugs.launchpad.net/unity/+bug/1038944

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

While I do find it a bit redundant having a style class for values, then defining them somewhere other than the accessors, I have complied with the width/height values. :)

Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Yeah, I figure if someone needs to use that value more then once in this class it's now in a varaible :)

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/previews/PreviewContainer.cpp'
2--- dash/previews/PreviewContainer.cpp 2012-08-31 11:52:52 +0000
3+++ dash/previews/PreviewContainer.cpp 2012-09-06 07:07:18 +0000
4@@ -149,9 +149,9 @@
5
6 nux::Geometry swipeOut = geometry;
7 if (swipe_.direction == Navigation::RIGHT)
8- swipeOut.OffsetPosition(-(curve_progress * (geometry.GetWidth() + parent_->nav_left_->GetGeometry().GetWidth())), 0);
9+ swipeOut.OffsetPosition(-(curve_progress * (parent_->GetGeometry().width - geometry.x)), 0);
10 else if (swipe_.direction == Navigation::LEFT)
11- swipeOut.OffsetPosition(curve_progress* (geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth()), 0);
12+ swipeOut.OffsetPosition(curve_progress* (parent_->GetGeometry().width - geometry.x), 0);
13 current_preview_->SetGeometry(swipeOut);
14 }
15
16@@ -162,9 +162,9 @@
17
18 nux::Geometry swipeIn = geometry;
19 if (swipe_.direction == Navigation::RIGHT)
20- swipeIn.OffsetPosition(float(geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth()) - (curve_progress * (geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth())), 0);
21+ swipeIn.OffsetPosition(float(parent_->GetGeometry().width - geometry.x) - (curve_progress * (parent_->GetGeometry().width - geometry.x)), 0);
22 else if (swipe_.direction == Navigation::LEFT)
23- swipeIn.OffsetPosition(-((1.0-curve_progress)*(geometry.GetWidth() + parent_->nav_left_->GetGeometry().GetWidth())), 0);
24+ swipeIn.OffsetPosition(-((1.0-curve_progress)*(parent_->GetGeometry().width - geometry.x)), 0);
25 swipe_.preview->SetGeometry(swipeIn);
26 }
27 }
28@@ -355,7 +355,6 @@
29 : View(NUX_FILE_LINE_PARAM)
30 , content_layout_(nullptr)
31 , nav_disabled_(Navigation::NONE)
32- , last_calc_height_(0)
33 , navigation_progress_speed_(0.0)
34 , navigation_count_(0)
35 {
36@@ -411,7 +410,7 @@
37
38 layout_ = new nux::HLayout();
39 SetLayout(layout_);
40- layout_->AddSpace(0, 0);
41+ layout_->AddSpace(0, 1);
42
43 nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
44 AddChild(nav_left_);
45@@ -421,8 +420,9 @@
46 layout_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
47
48 content_layout_ = new PreviewContent(this);
49+ content_layout_->SetMinMaxSize(style.GetPreviewWidth(), style.GetPreviewHeight());
50 AddChild(content_layout_);
51- layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
52+ layout_->AddLayout(content_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
53
54 nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);
55 AddChild(nav_right_);
56@@ -431,7 +431,7 @@
57 nav_right_->activated.connect([&]() { navigate_right.emit(); });
58 layout_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
59
60- layout_->AddSpace(0, 0);
61+ layout_->AddSpace(0, 1);
62
63 content_layout_->start_navigation.connect([&]()
64 {
65@@ -497,32 +497,6 @@
66 gfx_engine.PopClippingRectangle();
67 }
68
69-void PreviewContainer::PreLayoutManagement()
70-{
71- previews::Style& style = previews::Style::Instance();
72- nux::Geometry const& geo = GetGeometry();
73-
74- int available_preview_width = MAX(1, geo.width - nav_left_->GetGeometry().width - nav_right_->GetGeometry().width);
75- int aspect_altered_height = available_preview_width / style.GetPreviewAspectRatio();
76-
77- aspect_altered_height = CLAMP(aspect_altered_height, 1, geo.height);
78- if (last_calc_height_ != aspect_altered_height)
79- {
80- last_calc_height_ = aspect_altered_height;
81-
82- content_layout_->SetMinimumHeight(aspect_altered_height);
83- content_layout_->SetMaximumHeight(aspect_altered_height);
84-
85- nav_left_->SetMinimumHeight(aspect_altered_height);
86- nav_left_->SetMaximumHeight(aspect_altered_height);
87-
88- nav_right_->SetMinimumHeight(aspect_altered_height);
89- nav_right_->SetMaximumHeight(aspect_altered_height);
90- }
91-
92- View::PreLayoutManagement();
93-}
94-
95 bool PreviewContainer::AnimationInProgress()
96 {
97 // short circuit to avoid unneeded calculations
98
99=== modified file 'dash/previews/PreviewContainer.h'
100--- dash/previews/PreviewContainer.h 2012-08-17 07:28:10 +0000
101+++ dash/previews/PreviewContainer.h 2012-09-06 07:07:18 +0000
102@@ -81,7 +81,6 @@
103 protected:
104 void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
105 void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
106- void PreLayoutManagement();
107
108 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
109 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
110@@ -101,7 +100,6 @@
111 PreviewNavigator* nav_right_;
112 PreviewContent* content_layout_;
113 Navigation nav_disabled_;
114- int last_calc_height_;
115
116 // Animation
117 struct timespec last_progress_time_;
118
119=== modified file 'unity-shared/PreviewStyle.cpp'
120--- unity-shared/PreviewStyle.cpp 2012-08-20 13:04:20 +0000
121+++ unity-shared/PreviewStyle.cpp 2012-09-06 07:07:18 +0000
122@@ -39,6 +39,9 @@
123 {
124 Style* style_instance = nullptr;
125
126+const int preview_width = 770;
127+const int preview_height = 380;
128+
129 nux::logging::Logger logger("unity.dash.previews.style");
130
131 typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
132@@ -159,9 +162,14 @@
133 return 24;
134 }
135
136-float Style::GetPreviewAspectRatio() const
137-{
138- return static_cast<float>(796)/390;
139+int Style::GetPreviewWidth() const
140+{
141+ return preview_width;
142+}
143+
144+int Style::GetPreviewHeight() const
145+{
146+ return preview_height;
147 }
148
149 int Style::GetDetailsTopMargin() const
150@@ -186,7 +194,7 @@
151
152 int Style::GetPanelSplitWidth() const
153 {
154- return 16;
155+ return 10;
156 }
157
158 int Style::GetAppIconAreaWidth() const
159
160=== modified file 'unity-shared/PreviewStyle.h'
161--- unity-shared/PreviewStyle.h 2012-08-20 13:04:20 +0000
162+++ unity-shared/PreviewStyle.h 2012-09-06 07:07:18 +0000
163@@ -60,7 +60,8 @@
164 int GetNavigatorWidth() const;
165 int GetNavigatorIconSize() const;
166
167- float GetPreviewAspectRatio() const;
168+ int GetPreviewWidth() const;
169+ int GetPreviewHeight() const;
170
171 int GetDetailsTopMargin() const;
172 int GetDetailsBottomMargin() const;