summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorEleni Maria Stea <elenimaria.stea@canonical.com>2014-10-06 18:02:42 +0300
committerEleni Maria Stea <elenimaria.stea@canonical.com>2014-10-06 18:02:42 +0300
commitf36d7199859d3f26fa12639a2b66694f34fac81e (patch)
tree563b83f8b1d66a9ea3e7b63851bb3812788c515a /unity-shared
parentc23ec7167a657bf41a15d5f5449ff2a9c11b5ac2 (diff)
added new layout functions for the expose mode
(bzr r3875.3.1)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/LayoutSystem.cpp38
-rw-r--r--unity-shared/LayoutSystem.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/unity-shared/LayoutSystem.cpp b/unity-shared/LayoutSystem.cpp
index f2ea8b87a..40a2a4485 100644
--- a/unity-shared/LayoutSystem.cpp
+++ b/unity-shared/LayoutSystem.cpp
@@ -35,6 +35,44 @@ void LayoutSystem::LayoutWindows(LayoutWindow::Vector const& windows, nux::Geome
LayoutGridWindows(windows, max_bounds, final_bounds);
}
+void LayoutSystem::LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds)
+{
+ if (windows.empty())
+ return;
+
+ std::stable_sort(windows.begin(), windows.end(),
+ [](const LayoutWindow::Ptr& a, const LayoutWindow::Ptr& b)
+ {
+ int acentery = a->geo.y + a->geo.height / 2;
+ int bcentery = b->geo.y + b->geo.height / 2;
+ return acentery < bcentery;
+ });
+
+ LayoutGridWindows(windows, max_bounds, final_bounds);
+
+ std::vector<LayoutWindow::Vector> rows = GetRows(windows, max_bounds);
+ LayoutWindow::Vector ordered_windows;
+
+ for (auto row : rows)
+ {
+ std::stable_sort(row.begin(), row.end(),
+ [](const LayoutWindow::Ptr& a, const LayoutWindow::Ptr& b)
+ {
+ int acenterx = a->geo.x + a->geo.width / 2;
+ int bcenterx = b->geo.x + b->geo.width / 2;
+ return acenterx < bcenterx;
+ });
+
+ for (auto win : row)
+ {
+ ordered_windows.push_back(win);
+ }
+ }
+
+ LayoutGridWindows(ordered_windows, max_bounds, final_bounds);
+ windows = ordered_windows;
+}
+
nux::Size LayoutSystem::GridSizeForWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const
{
unsigned count = windows.size();
diff --git a/unity-shared/LayoutSystem.h b/unity-shared/LayoutSystem.h
index 6241f727c..9c1f7e04f 100644
--- a/unity-shared/LayoutSystem.h
+++ b/unity-shared/LayoutSystem.h
@@ -64,6 +64,7 @@ public:
LayoutSystem();
void LayoutWindows(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
+ void LayoutWindowsNearest(LayoutWindow::Vector& windows, nux::Geometry const& max_bounds, nux::Geometry& final_bounds);
std::vector<int> GetRowSizes(LayoutWindow::Vector const& windows, nux::Geometry const& max_bounds) const;
protected: