summaryrefslogtreecommitdiff
path: root/dash/previews
diff options
authorNick Dedekind <nicholas.dedekind@gmail.com>2012-08-10 16:05:10 +0100
committerNick Dedekind <nicholas.dedekind@gmail.com>2012-08-10 16:05:10 +0100
commit4af96d27e4489a8c61dbf26db116cca66b3a8f0d (patch)
treef31efd36068ffc0fb18259f01d60da53c9f0e35f /dash/previews
parentbb5fe89b31703e61a1d150c1a68881a27279d019 (diff)
Maximum aspect ratio sourced height for previews.
(bzr r2419.4.63)
Diffstat (limited to 'dash/previews')
-rw-r--r--dash/previews/PreviewContainer.cpp34
-rw-r--r--dash/previews/PreviewContainer.h2
2 files changed, 34 insertions, 2 deletions
diff --git a/dash/previews/PreviewContainer.cpp b/dash/previews/PreviewContainer.cpp
index 6703bfb11..a2bcdd29d 100644
--- a/dash/previews/PreviewContainer.cpp
+++ b/dash/previews/PreviewContainer.cpp
@@ -322,6 +322,7 @@ PreviewContainer::PreviewContainer(NUX_FILE_LINE_DECL)
: View(NUX_FILE_LINE_PARAM)
, content_layout_(nullptr)
, nav_disabled_(Navigation::NONE)
+ , last_calc_height_(0)
, navigation_progress_speed_(0.0)
, navigation_count_(0)
{
@@ -370,12 +371,13 @@ void PreviewContainer::SetupViews()
layout_ = new nux::HLayout();
SetLayout(layout_);
+ layout_->AddSpace(0, 0);
nav_left_ = new PreviewNavigator(Orientation::LEFT, NUX_TRACKER_LOCATION);
nav_left_->SetMinimumWidth(style.GetNavigatorWidth());
nav_left_->SetMaximumWidth(style.GetNavigatorWidth());
nav_left_->activated.connect([&]() { navigate_left.emit(); });
- layout_->AddView(nav_left_, 0);
+ layout_->AddView(nav_left_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
content_layout_ = new PreviewContent(this);
layout_->AddLayout(content_layout_, 1, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
@@ -384,7 +386,9 @@ void PreviewContainer::SetupViews()
nav_right_->SetMinimumWidth(style.GetNavigatorWidth());
nav_right_->SetMaximumWidth(style.GetNavigatorWidth());
nav_right_->activated.connect([&]() { navigate_right.emit(); });
- layout_->AddView(nav_right_, 0);
+ layout_->AddView(nav_right_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
+
+ layout_->AddSpace(0, 0);
content_layout_->start_navigation.connect([&]()
{
@@ -445,6 +449,32 @@ void PreviewContainer::DrawContent(nux::GraphicsEngine& gfx_engine, bool force_d
gfx_engine.PopClippingRectangle();
}
+void PreviewContainer::PreLayoutManagement()
+{
+ previews::Style& style = previews::Style::Instance();
+ nux::Geometry const& geo = GetGeometry();
+
+ int available_preview_width = MAX(1, geo.width - nav_left_->GetGeometry().width - nav_right_->GetGeometry().width);
+ int aspect_altered_height = available_preview_width / style.GetPreviewAspectRatio();
+
+ aspect_altered_height = CLAMP(aspect_altered_height, 1, geo.height);
+ if (last_calc_height_ != aspect_altered_height)
+ {
+ last_calc_height_ = aspect_altered_height;
+
+ content_layout_->SetMinimumHeight(aspect_altered_height);
+ content_layout_->SetMaximumHeight(aspect_altered_height);
+
+ nav_left_->SetMinimumHeight(aspect_altered_height);
+ nav_left_->SetMaximumHeight(aspect_altered_height);
+
+ nav_right_->SetMinimumHeight(aspect_altered_height);
+ nav_right_->SetMaximumHeight(aspect_altered_height);
+ }
+
+ View::PreLayoutManagement();
+}
+
bool PreviewContainer::AnimationInProgress()
{
// short circuit to avoid unneeded calculations
diff --git a/dash/previews/PreviewContainer.h b/dash/previews/PreviewContainer.h
index 13a93b4d0..4a975d158 100644
--- a/dash/previews/PreviewContainer.h
+++ b/dash/previews/PreviewContainer.h
@@ -79,6 +79,7 @@ public:
protected:
void Draw(nux::GraphicsEngine& gfx_engine, bool force_draw);
void DrawContent(nux::GraphicsEngine& gfx_engine, bool force_draw);
+ void PreLayoutManagement();
nux::Area* KeyNavIteration(nux::KeyNavDirection direction);
@@ -100,6 +101,7 @@ private:
PreviewNavigator* nav_right_;
PreviewContent* content_layout_;
Navigation nav_disabled_;
+ int last_calc_height_;
// Animation
struct timespec last_progress_time_;