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

Unified Diff: views/controls/resize_area.cc

Issue 3052011: Make the resize gripper invisible.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 5 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 | « views/controls/resize_area.h ('k') | views/controls/resize_gripper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/resize_area.cc
===================================================================
--- views/controls/resize_area.cc (revision 53545)
+++ views/controls/resize_area.cc (working copy)
@@ -2,44 +2,36 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "views/controls/resize_gripper.h"
+#include "views/controls/resize_area.h"
#include "app/resource_bundle.h"
#include "base/logging.h"
-#include "grit/app_resources.h"
namespace views {
-const char ResizeGripper::kViewClassName[] = "views/ResizeGripper";
+const char ResizeArea::kViewClassName[] = "views/ResizeArea";
#if defined(OS_WIN)
static HCURSOR g_resize_cursor = NULL;
#endif
////////////////////////////////////////////////////////////////////////////////
-// ResizeGripper
+// ResizeArea
-ResizeGripper::ResizeGripper(ResizeGripperDelegate* delegate)
+ResizeArea::ResizeArea(ResizeAreaDelegate* delegate)
: delegate_(delegate),
- initial_position_(0),
- gripper_visible_(false) {
- ResourceBundle &rb = ResourceBundle::GetSharedInstance();
- SkBitmap* gripper_image = rb.GetBitmapNamed(IDR_RESIZE_GRIPPER);
- // Explicitly set the image size so that the preferred size is fixed to that
- // of the image. If we didn't do this the preferred size would change
- // depending upon whether the gripper was visible.
- SetImageSize(gfx::Size(gripper_image->width(), gripper_image->height()));
+ initial_position_(0) {
}
-ResizeGripper::~ResizeGripper() {
+ResizeArea::~ResizeArea() {
}
-std::string ResizeGripper::GetClassName() const {
+std::string ResizeArea::GetClassName() const {
return kViewClassName;
}
-gfx::NativeCursor ResizeGripper::GetCursorForPoint(Event::EventType event_type,
- const gfx::Point& p) {
+gfx::NativeCursor ResizeArea::GetCursorForPoint(Event::EventType event_type,
+ const gfx::Point& p) {
if (!enabled_)
return NULL;
#if defined(OS_WIN)
@@ -51,20 +43,12 @@
#endif
}
-void ResizeGripper::OnMouseEntered(const views::MouseEvent& event) {
- SetGripperVisible(true);
-}
-
-void ResizeGripper::OnMouseExited(const views::MouseEvent& event) {
- SetGripperVisible(false);
-}
-
-bool ResizeGripper::OnMousePressed(const views::MouseEvent& event) {
+bool ResizeArea::OnMousePressed(const views::MouseEvent& event) {
if (!event.IsOnlyLeftMouseButton())
return false;
- // The resize gripper obviously will move once you start dragging so we need
- // to convert coordinates to screen coordinates so that we don't loose our
+ // The resize area obviously will move once you start dragging so we need to
+ // convert coordinates to screen coordinates so that we don't lose our
// bearings.
gfx::Point point(event.x(), 0);
View::ConvertPointToScreen(this, &point);
@@ -73,7 +57,7 @@
return true;
}
-bool ResizeGripper::OnMouseDragged(const views::MouseEvent& event) {
+bool ResizeArea::OnMouseDragged(const views::MouseEvent& event) {
if (!event.IsLeftMouseButton())
return false;
@@ -81,43 +65,23 @@
return true;
}
-void ResizeGripper::OnMouseReleased(const views::MouseEvent& event,
- bool canceled) {
- if (canceled)
- ReportResizeAmount(initial_position_, true);
- else
- ReportResizeAmount(event.x(), true);
- SetGripperVisible(HitTest(event.location()));
+void ResizeArea::OnMouseReleased(const views::MouseEvent& event,
+ bool canceled) {
+ ReportResizeAmount(canceled ? initial_position_ : event.x(), true);
}
-bool ResizeGripper::GetAccessibleRole(AccessibilityTypes::Role* role) {
+bool ResizeArea::GetAccessibleRole(AccessibilityTypes::Role* role) {
DCHECK(role);
*role = AccessibilityTypes::ROLE_SEPARATOR;
return true;
}
-void ResizeGripper::ReportResizeAmount(int resize_amount, bool last_update) {
+void ResizeArea::ReportResizeAmount(int resize_amount, bool last_update) {
gfx::Point point(resize_amount, 0);
View::ConvertPointToScreen(this, &point);
resize_amount = point.x() - initial_position_;
-
- if (base::i18n::IsRTL())
- resize_amount = -1 * resize_amount;
- delegate_->OnResize(resize_amount, last_update);
+ delegate_->OnResize(base::i18n::IsRTL() ? -resize_amount : resize_amount,
+ last_update);
}
-void ResizeGripper::SetGripperVisible(bool visible) {
- if (visible == gripper_visible_)
- return;
-
- gripper_visible_ = visible;
- if (gripper_visible_) {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- SkBitmap* gripper_image = rb.GetBitmapNamed(IDR_RESIZE_GRIPPER);
- SetImage(gripper_image);
- } else {
- SetImage(NULL);
- }
-}
-
} // namespace views
« no previous file with comments | « views/controls/resize_area.h ('k') | views/controls/resize_gripper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698