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

Unified Diff: ui/views/controls/slider.cc

Issue 9853019: Modify the pure-views slider to reset on ESC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « ui/views/controls/slider.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/slider.cc
diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc
index c42902b2de68d02262f436b11fe7fcb9c697db7c..ceb2f581b5debe441f11106faff4c3ed0ddc3dce 100644
--- a/ui/views/controls/slider.cc
+++ b/ui/views/controls/slider.cc
@@ -17,6 +17,9 @@
#include "ui/gfx/point.h"
#include "ui/gfx/rect.h"
#include "ui/views/widget/widget.h"
+#include "ui/base/accelerators/accelerator.h"
sadrul 2012/03/26 22:24:02 sort
rjkroege 2012/04/03 19:24:21 Done.
+
+#include <stdio.h>
namespace {
const int kSlideValueChangeDurationMS = 150;
@@ -137,10 +140,20 @@ void Slider::OnPaint(gfx::Canvas* canvas) {
}
bool Slider::OnMousePressed(const views::MouseEvent& event) {
+ original_value_ = value_;
+ ui::Accelerator escape_accelerator(ui::VKEY_ESCAPE, false, false, false);
+ AddAccelerator(escape_accelerator);
return OnMouseDragged(event);
}
+void Slider::OnMouseReleased(const views::MouseEvent& event) {
+ esc_was_pressed_ = false;
+ ResetAccelerators();
+}
+
bool Slider::OnMouseDragged(const views::MouseEvent& event) {
+ if (esc_was_pressed_)
+ return true;
gfx::Insets inset = GetInsets();
if (orientation_ == HORIZONTAL) {
int amount = base::i18n::IsRTL() ? width() - inset.left() - event.x() :
@@ -166,4 +179,10 @@ void Slider::GetAccessibleState(ui::AccessibleViewState* state) {
base::StringPrintf("%d%%", (int)(value_ * 100 + 0.5)));
}
+bool Slider::AcceleratorPressed(const ui::Accelerator& accelerator) {
+ SetValueInternal(original_value_, VALUE_CHANGED_BY_USER);
+ esc_was_pressed_ = true;
+ return true;
+}
+
} // namespace views
« no previous file with comments | « ui/views/controls/slider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698