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

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

Issue 9773009: Disable left/right/maximize for panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 9 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
Index: ash/wm/workspace/frame_maximize_button.cc
diff --git a/ash/wm/workspace/frame_maximize_button.cc b/ash/wm/workspace/frame_maximize_button.cc
index 989b288cb3ba2a22a0ee6bbb9fa28ecbbaa717e5..e5a483d088ac85141f89e90553ebf27c7f09d711 100644
--- a/ash/wm/workspace/frame_maximize_button.cc
+++ b/ash/wm/workspace/frame_maximize_button.cc
@@ -96,6 +96,8 @@ FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener,
: ImageButton(listener),
frame_(frame),
is_snap_enabled_(false),
+ is_left_right_enabled_(true),
+ is_maximize_enabled_(true),
exceeded_drag_threshold_(false),
snap_type_(SNAP_NONE) {
// TODO(sky): nuke this. It's temporary while we don't have good images.
@@ -162,6 +164,14 @@ void FrameMaximizeButton::OnMouseCaptureLost() {
ImageButton::OnMouseCaptureLost();
}
+void FrameMaximizeButton::SetIsLeftRightEnabled(bool e) {
+ is_left_right_enabled_ = e;
+ int id = is_left_right_enabled_ ?
+ IDS_FRAME_MAXIMIZE_BUTTON_TOOLTIP :
+ IDS_FRAME_MAXIMIZE_BUTTON_NO_SIDE_SNAP_TOOLTIP;
+ SetTooltipText(l10n_util::GetStringUTF16(id));
+}
+
SkBitmap FrameMaximizeButton::GetImageToPaint() {
if (is_snap_enabled_) {
int id = 0;
@@ -261,19 +271,25 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location) {
phantom_window_->Show(BoundsForType(snap_type_));
}
+bool FrameMaximizeButton::AllowMaximize() const {
+ return !frame_->GetWidget()->IsMaximized() && is_maximize_enabled_;
+}
+
FrameMaximizeButton::SnapType FrameMaximizeButton::SnapTypeForLocation(
const gfx::Point& location) const {
int delta_x = location.x() - press_location_.x();
int delta_y = location.y() - press_location_.y();
if (!views::View::ExceededDragThreshold(delta_x, delta_y))
- return frame_->GetWidget()->IsMaximized() ? SNAP_NONE : SNAP_MAXIMIZE;
+ return AllowMaximize() ? SNAP_MAXIMIZE : SNAP_NONE;
else if (delta_x < 0 && delta_y > delta_x && delta_y < -delta_x)
- return SNAP_LEFT;
+ return is_left_right_enabled_ ? SNAP_LEFT : SNAP_NONE;
else if (delta_x > 0 && delta_y > -delta_x && delta_y < delta_x)
- return SNAP_RIGHT;
+ return is_left_right_enabled_ ? SNAP_RIGHT : SNAP_NONE;
else if (delta_y > 0)
return SNAP_MINIMIZE;
- return frame_->GetWidget()->IsMaximized() ? SNAP_NONE : SNAP_MAXIMIZE;
+ else if (AllowMaximize())
+ return SNAP_MAXIMIZE;
+ return SNAP_NONE;
}
gfx::Rect FrameMaximizeButton::BoundsForType(SnapType type) const {
« no previous file with comments | « ash/wm/workspace/frame_maximize_button.h ('k') | chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698