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
=== modified file 'dash/previews/PreviewContainer.cpp'
--- dash/previews/PreviewContainer.cpp 2012-08-31 11:52:52 +0000
+++ dash/previews/PreviewContainer.cpp 2012-09-06 07:07:18 +0000
@@ -149,9 +149,9 @@
149149
150 nux::Geometry swipeOut = geometry;150 nux::Geometry swipeOut = geometry;
151 if (swipe_.direction == Navigation::RIGHT)151 if (swipe_.direction == Navigation::RIGHT)
152 swipeOut.OffsetPosition(-(curve_progress * (geometry.GetWidth() + parent_->nav_left_->GetGeometry().GetWidth())), 0);152 swipeOut.OffsetPosition(-(curve_progress * (parent_->GetGeometry().width - geometry.x)), 0);
153 else if (swipe_.direction == Navigation::LEFT)153 else if (swipe_.direction == Navigation::LEFT)
154 swipeOut.OffsetPosition(curve_progress* (geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth()), 0);154 swipeOut.OffsetPosition(curve_progress* (parent_->GetGeometry().width - geometry.x), 0);
155 current_preview_->SetGeometry(swipeOut);155 current_preview_->SetGeometry(swipeOut);
156 }156 }
157 157
@@ -162,9 +162,9 @@
162162
163 nux::Geometry swipeIn = geometry;163 nux::Geometry swipeIn = geometry;
164 if (swipe_.direction == Navigation::RIGHT)164 if (swipe_.direction == Navigation::RIGHT)
165 swipeIn.OffsetPosition(float(geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth()) - (curve_progress * (geometry.GetWidth() + parent_->nav_right_->GetGeometry().GetWidth())), 0);165 swipeIn.OffsetPosition(float(parent_->GetGeometry().width - geometry.x) - (curve_progress * (parent_->GetGeometry().width - geometry.x)), 0);
166 else if (swipe_.direction == Navigation::LEFT)166 else if (swipe_.direction == Navigation::LEFT)
167 swipeIn.OffsetPosition(-((1.0-curve_progress)*(geometry.GetWidth() + parent_->nav_left_->GetGeometry().GetWidth())), 0);167 swipeIn.OffsetPosition(-((1.0-curve_progress)*(parent_->GetGeometry().width - geometry.x)), 0);
168 swipe_.preview->SetGeometry(swipeIn);168 swipe_.preview->SetGeometry(swipeIn);
169 }169 }
170 }170 }
@@ -355,7 +355,6 @@
355 : View(NUX_FILE_LINE_PARAM)355 : View(NUX_FILE_LINE_PARAM)
356 , content_layout_(nullptr)356 , content_layout_(nullptr)
357 , nav_disabled_(Navigation::NONE)357 , nav_disabled_(Navigation::NONE)
358 , last_calc_height_(0)
359 , navigation_progress_speed_(0.0)358 , navigation_progress_speed_(0.0)
360 , navigation_count_(0)359 , navigation_count_(0)
361{360{
@@ -411,7 +410,7 @@
411410
412 layout_ = new nux::HLayout();411 layout_ = new nux::HLayout();
413 SetLayout(layout_);412 SetLayout(layout_);
414 layout_->AddSpace(0, 0);413 layout_->AddSpace(0, 1);
415414
416 nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);415 nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
417 AddChild(nav_left_);416 AddChild(nav_left_);
@@ -421,8 +420,9 @@
421 layout_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);420 layout_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
422421
423 content_layout_ = new PreviewContent(this);422 content_layout_ = new PreviewContent(this);
423 content_layout_->SetMinMaxSize(style.GetPreviewWidth(), style.GetPreviewHeight());
424 AddChild(content_layout_);424 AddChild(content_layout_);
425 layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);425 layout_->AddLayout(content_layout_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
426426
427 nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);427 nav_right_ = new PreviewNavigator(Orientation::RIGHT, NUX_TRACKER_LOCATION);
428 AddChild(nav_right_);428 AddChild(nav_right_);
@@ -431,7 +431,7 @@
431 nav_right_->activated.connect([&]() { navigate_right.emit(); });431 nav_right_->activated.connect([&]() { navigate_right.emit(); });
432 layout_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);432 layout_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
433433
434 layout_->AddSpace(0, 0);434 layout_->AddSpace(0, 1);
435435
436 content_layout_->start_navigation.connect([&]()436 content_layout_->start_navigation.connect([&]()
437 {437 {
@@ -497,32 +497,6 @@
497 gfx_engine.PopClippingRectangle();497 gfx_engine.PopClippingRectangle();
498}498}
499499
500void PreviewContainer::PreLayoutManagement()
501{
502 previews::Style& style = previews::Style::Instance();
503 nux::Geometry const& geo = GetGeometry();
504
505 int available_preview_width = MAX(1, geo.width - nav_left_->GetGeometry().width - nav_right_->GetGeometry().width);
506 int aspect_altered_height = available_preview_width / style.GetPreviewAspectRatio();
507
508 aspect_altered_height = CLAMP(aspect_altered_height, 1, geo.height);
509 if (last_calc_height_ != aspect_altered_height)
510 {
511 last_calc_height_ = aspect_altered_height;
512
513 content_layout_->SetMinimumHeight(aspect_altered_height);
514 content_layout_->SetMaximumHeight(aspect_altered_height);
515
516 nav_left_->SetMinimumHeight(aspect_altered_height);
517 nav_left_->SetMaximumHeight(aspect_altered_height);
518
519 nav_right_->SetMinimumHeight(aspect_altered_height);
520 nav_right_->SetMaximumHeight(aspect_altered_height);
521 }
522
523 View::PreLayoutManagement();
524}
525
526bool PreviewContainer::AnimationInProgress()500bool PreviewContainer::AnimationInProgress()
527{501{
528 // short circuit to avoid unneeded calculations502 // short circuit to avoid unneeded calculations
529503
=== modified file 'dash/previews/PreviewContainer.h'
--- dash/previews/PreviewContainer.h 2012-08-17 07:28:10 +0000
+++ dash/previews/PreviewContainer.h 2012-09-06 07:07:18 +0000
@@ -81,7 +81,6 @@
81protected:81protected:
82 void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);82 void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
83 void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);83 void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
84 void PreLayoutManagement();
8584
86 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);85 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
87 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);86 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
@@ -101,7 +100,6 @@
101 PreviewNavigator* nav_right_;100 PreviewNavigator* nav_right_;
102 PreviewContent* content_layout_;101 PreviewContent* content_layout_;
103 Navigation nav_disabled_;102 Navigation nav_disabled_;
104 int last_calc_height_;
105103
106 // Animation104 // Animation
107 struct timespec last_progress_time_;105 struct timespec last_progress_time_;
108106
=== modified file 'unity-shared/PreviewStyle.cpp'
--- unity-shared/PreviewStyle.cpp 2012-08-20 13:04:20 +0000
+++ unity-shared/PreviewStyle.cpp 2012-09-06 07:07:18 +0000
@@ -39,6 +39,9 @@
39{39{
40Style* style_instance = nullptr;40Style* style_instance = nullptr;
4141
42const int preview_width = 770;
43const int preview_height = 380;
44
42nux::logging::Logger logger("unity.dash.previews.style");45nux::logging::Logger logger("unity.dash.previews.style");
4346
44typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;47typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
@@ -159,9 +162,14 @@
159 return 24; 162 return 24;
160}163}
161164
162float Style::GetPreviewAspectRatio() const165int Style::GetPreviewWidth() const
163{166{
164 return static_cast<float>(796)/390;167 return preview_width;
168}
169
170int Style::GetPreviewHeight() const
171{
172 return preview_height;
165}173}
166174
167int Style::GetDetailsTopMargin() const175int Style::GetDetailsTopMargin() const
@@ -186,7 +194,7 @@
186194
187int Style::GetPanelSplitWidth() const195int Style::GetPanelSplitWidth() const
188{196{
189 return 16;197 return 10;
190}198}
191199
192int Style::GetAppIconAreaWidth() const200int Style::GetAppIconAreaWidth() const
193201
=== modified file 'unity-shared/PreviewStyle.h'
--- unity-shared/PreviewStyle.h 2012-08-20 13:04:20 +0000
+++ unity-shared/PreviewStyle.h 2012-09-06 07:07:18 +0000
@@ -60,7 +60,8 @@
60 int GetNavigatorWidth() const;60 int GetNavigatorWidth() const;
61 int GetNavigatorIconSize() const;61 int GetNavigatorIconSize() const;
62 62
63 float GetPreviewAspectRatio() const;63 int GetPreviewWidth() const;
64 int GetPreviewHeight() const;
6465
65 int GetDetailsTopMargin() const;66 int GetDetailsTopMargin() const;
66 int GetDetailsBottomMargin() const;67 int GetDetailsBottomMargin() const;