Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: ash/wm/workspace/snap_sizer.cc

Issue 9956056: ash: Add accelerator for snapping windows left/right. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/workspace/snap_sizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/workspace/snap_sizer.cc
diff --git a/ash/wm/workspace/snap_sizer.cc b/ash/wm/workspace/snap_sizer.cc
index 9b064e7bf1fdf08844999765fa30fb163e9d54d2..963742b49d7e24d7cca64284063b68ff282aa071 100644
--- a/ash/wm/workspace/snap_sizer.cc
+++ b/ash/wm/workspace/snap_sizer.cc
@@ -66,6 +66,15 @@ void SnapSizer::Update(const gfx::Point& location) {
time_last_update_ = base::TimeTicks::Now();
}
+gfx::Rect SnapSizer::GetSnapBounds(const gfx::Rect& bounds) {
+ for (size_t i = 0; i < arraysize(kPercents); ++i) {
+ gfx::Rect target = GetTargetBoundsForPercent(i);
+ if (target != bounds && target.width() > bounds.width())
sky 2012/04/25 19:23:20 Can you use rect == to find the current snap bound
sadrul 2012/04/25 19:37:54 Done.
+ return target;
+ }
+ return target_bounds_;
+}
+
int SnapSizer::CalculateIncrement(int x, int reference_x) const {
if (AlongEdge(x))
return 1;
@@ -94,12 +103,16 @@ void SnapSizer::ChangeBounds(int x, int delta) {
}
gfx::Rect SnapSizer::GetTargetBounds() const {
+ return GetTargetBoundsForPercent(percent_index_);
+}
+
+gfx::Rect SnapSizer::GetTargetBoundsForPercent(int percent_index) const {
gfx::Rect work_area(ScreenAsh::GetUnmaximizedWorkAreaBounds(window_));
int y = WindowResizer::AlignToGridRoundUp(work_area.y(), grid_size_);
// We don't align to the bottom of the grid as the launcher may not
// necessarily align to the grid (happens when auto-hidden).
int max_y = work_area.bottom();
- int width = static_cast<float>(work_area.width()) * kPercents[percent_index_];
+ int width = static_cast<float>(work_area.width()) * kPercents[percent_index];
if (edge_ == LEFT_EDGE) {
int x = WindowResizer::AlignToGridRoundUp(work_area.x(), grid_size_);
int mid_x = WindowResizer::AlignToGridRoundUp(
« no previous file with comments | « ash/wm/workspace/snap_sizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698