Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Disable left/right/maximize for panels.

Ideally we should replace this with a dedicated minimize button and its own tooltip, but given the timeframe, I think this hack will suffice.

BUG=120038
TEST=Ensure that only the minimize function works for Panels


Review URL: http://codereview.chromium.org/9773009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128868 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information...
commit 2a7e7e52b671ebc192b1138db450de52383f7527 1 parent 2ab01b8
stevenjb@chromium.org authored
View
4 ash/ash_strings.grd
@@ -182,6 +182,10 @@ This file contains the strings for ash.
Pull down to minimize, left or right to tile
</message>
+ <message name="IDS_FRAME_MAXIMIZE_BUTTON_NO_SIDE_SNAP_TOOLTIP" desc="Tooltip for the maximize/restore button in window frames in aura when side snap is not allowed">
+ Pull down to minimize
+ </message>
+
<!-- Status tray items -->
<message name="IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME" desc="The accessible name of the status tray.">
Status tray
View
24 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 {
View
12 ash/wm/workspace/frame_maximize_button.h
@@ -35,6 +35,11 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton {
virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
+ // Sets is_left_right_enabled_ and updates tooltip.
+ void SetIsLeftRightEnabled(bool e);
+
+ void set_is_maximize_enabled(bool e) { is_maximize_enabled_ = e; }
+
protected:
// ImageButton overrides:
virtual SkBitmap GetImageToPaint() OVERRIDE;
@@ -61,6 +66,9 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton {
// Updates |snap_type_| based on a mouse drag.
void UpdateSnap(const gfx::Point& location);
+ // Returns true if maximizing is allowed.
+ bool AllowMaximize() const;
+
// Returns the type of snap based on the specified location.
SnapType SnapTypeForLocation(const gfx::Point& location) const;
@@ -84,6 +92,10 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton {
// should show the snap locations.
bool is_snap_enabled_;
+ // Selectively enable/disable button functionality.
+ bool is_left_right_enabled_;
+ bool is_maximize_enabled_;
+
// Did the user drag far enough to trigger snapping?
bool exceeded_drag_threshold_;
View
19 chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.cc
@@ -15,6 +15,8 @@
#include "grit/theme_resources.h"
#include "grit/theme_resources_standard.h"
#include "grit/ui_resources.h"
+#include "ui/aura/window.h"
+#include "ui/aura/client/aura_constants.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/hit_test.h"
#include "ui/base/l10n/l10n_util.h"
@@ -62,7 +64,8 @@ BrowserNonClientFrameViewAura::BrowserNonClientFrameViewAura(
maximize_button_(NULL),
close_button_(NULL),
window_icon_(NULL),
- frame_painter_(new ash::FramePainter) {
+ frame_painter_(new ash::FramePainter),
+ allow_maximize_(true) {
}
BrowserNonClientFrameViewAura::~BrowserNonClientFrameViewAura() {
@@ -70,7 +73,16 @@ BrowserNonClientFrameViewAura::~BrowserNonClientFrameViewAura() {
void BrowserNonClientFrameViewAura::Init() {
// Caption buttons.
- maximize_button_ = new ash::FrameMaximizeButton(this, this);
+ ash::FrameMaximizeButton* maximize_button =
+ new ash::FrameMaximizeButton(this, this);
+ maximize_button_ = maximize_button;
+ // Disable snap left/right and maximize for Panels.
+ if (browser_view()->browser()->is_type_panel() &&
+ browser_view()->browser()->app_type() == Browser::APP_TYPE_CHILD) {
+ allow_maximize_ = false;
+ maximize_button->SetIsLeftRightEnabled(false);
+ maximize_button->set_is_maximize_enabled(false);
+ }
maximize_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_ACCNAME_MAXIMIZE));
AddChildView(maximize_button_);
@@ -239,6 +251,9 @@ void BrowserNonClientFrameViewAura::ButtonPressed(views::Button* sender,
if (sender == maximize_button_) {
// The maximize button may move out from under the cursor.
ResetWindowControls();
+ // Don't maximize if this is a Panel.
+ if (!allow_maximize_)
+ return;
if (frame()->IsMaximized())
frame()->Restore();
else
View
4 chrome/browser/ui/views/frame/browser_non_client_frame_view_aura.h
@@ -91,6 +91,10 @@ class BrowserNonClientFrameViewAura : public BrowserNonClientFrameView,
// Painter for the frame header.
scoped_ptr<ash::FramePainter> frame_painter_;
+ // Set to false for Panels where maximize is undesired. (maximize button is
+ // still used for minimizing).
+ bool allow_maximize_;
+
DISALLOW_COPY_AND_ASSIGN(BrowserNonClientFrameViewAura);
};
Please sign in to comment.
Something went wrong with that request. Please try again.