| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "views/touchui/touch_selection_controller_impl.h" | 5 #include "views/touchui/touch_selection_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/time.h" |
| 7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 8 #include "base/time.h" | |
| 9 #include "grit/ui_strings.h" | 9 #include "grit/ui_strings.h" |
| 10 #include "third_party/skia/include/effects/SkGradientShader.h" | 10 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/gfx/canvas.h" | 13 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/canvas_skia.h" | 14 #include "ui/gfx/canvas_skia.h" |
| 15 #include "ui/gfx/path.h" | 15 #include "ui/gfx/path.h" |
| 16 #include "ui/gfx/rect.h" | 16 #include "ui/gfx/rect.h" |
| 17 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
| 18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 19 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 20 #include "views/background.h" | 20 #include "views/background.h" |
| 21 #include "views/controls/button/button.h" | 21 #include "views/controls/button/button.h" |
| 22 #include "views/controls/button/custom_button.h" | 22 #include "views/controls/button/custom_button.h" |
| 23 #include "views/controls/button/text_button.h" | 23 #include "views/controls/button/text_button.h" |
| 24 #include "views/controls/label.h" |
| 24 #include "views/controls/menu/menu_config.h" | 25 #include "views/controls/menu/menu_config.h" |
| 25 #include "views/controls/label.h" | |
| 26 #include "views/layout/box_layout.h" | 26 #include "views/layout/box_layout.h" |
| 27 #include "views/widget/widget.h" | 27 #include "views/widget/widget.h" |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Constants defining the visual attributes of selection handles | 31 // Constants defining the visual attributes of selection handles |
| 32 const int kSelectionHandleRadius = 10; | 32 const int kSelectionHandleRadius = 10; |
| 33 const int kSelectionHandleCursorHeight = 10; | 33 const int kSelectionHandleCursorHeight = 10; |
| 34 const int kSelectionHandleAlpha = 0x7F; | 34 const int kSelectionHandleAlpha = 0x7F; |
| 35 const SkColor kSelectionHandleColor = | 35 const SkColor kSelectionHandleColor = |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 SkColor background_color, border_color; | 184 SkColor background_color, border_color; |
| 185 if (state == CustomButton::BS_NORMAL) { | 185 if (state == CustomButton::BS_NORMAL) { |
| 186 background_color = SkColorSetARGB(102, 255, 255, 255); | 186 background_color = SkColorSetARGB(102, 255, 255, 255); |
| 187 border_color = SkColorSetARGB(36, 0, 0, 0); | 187 border_color = SkColorSetARGB(36, 0, 0, 0); |
| 188 } else { | 188 } else { |
| 189 background_color = SkColorSetARGB(13, 0, 0, 0); | 189 background_color = SkColorSetARGB(13, 0, 0, 0); |
| 190 border_color = SkColorSetARGB(72, 0, 0, 0); | 190 border_color = SkColorSetARGB(72, 0, 0, 0); |
| 191 } | 191 } |
| 192 int w = view->width(); | 192 int w = view->width(); |
| 193 int h = view->height(); | 193 int h = view->height(); |
| 194 canvas->FillRectInt(background_color, 1, 1, w - 2, h - 2); | 194 canvas->FillRect(background_color, gfx::Rect(1, 1, w - 2, h - 2)); |
| 195 canvas->FillRectInt(border_color, 2, 0, w - 4, 1); | 195 canvas->FillRect(border_color, gfx::Rect(2, 0, w - 4, 1)); |
| 196 canvas->FillRectInt(border_color, 1, 1, 1, 1); | 196 canvas->FillRect(border_color, gfx::Rect(1, 1, 1, 1)); |
| 197 canvas->FillRectInt(border_color, 0, 2, 1, h - 4); | 197 canvas->FillRect(border_color, gfx::Rect(0, 2, 1, h - 4)); |
| 198 canvas->FillRectInt(border_color, 1, h - 2, 1, 1); | 198 canvas->FillRect(border_color, gfx::Rect(1, h - 2, 1, 1)); |
| 199 canvas->FillRectInt(border_color, 2, h - 1, w - 4, 1); | 199 canvas->FillRect(border_color, gfx::Rect(2, h - 1, w - 4, 1)); |
| 200 canvas->FillRectInt(border_color, w - 2, 1, 1, 1); | 200 canvas->FillRect(border_color, gfx::Rect(w - 2, 1, 1, 1)); |
| 201 canvas->FillRectInt(border_color, w - 1, 2, 1, h - 4); | 201 canvas->FillRect(border_color, gfx::Rect(w - 1, 2, 1, h - 4)); |
| 202 canvas->FillRectInt(border_color, w - 2, h - 2, 1, 1); | 202 canvas->FillRect(border_color, gfx::Rect(w - 2, h - 2, 1, 1)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 private: | 205 private: |
| 206 DISALLOW_COPY_AND_ASSIGN(ContextMenuButtonBackground); | 206 DISALLOW_COPY_AND_ASSIGN(ContextMenuButtonBackground); |
| 207 }; | 207 }; |
| 208 | 208 |
| 209 // A View that displays the touch context menu. | 209 // A View that displays the touch context menu. |
| 210 class TouchSelectionControllerImpl::TouchContextMenuView | 210 class TouchSelectionControllerImpl::TouchContextMenuView |
| 211 : public ButtonListener, | 211 : public ButtonListener, |
| 212 public View { | 212 public View { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { | 499 bool TouchSelectionControllerImpl::IsSelectionHandle2Visible() { |
| 500 return selection_handle_2_->IsVisible(); | 500 return selection_handle_2_->IsVisible(); |
| 501 } | 501 } |
| 502 | 502 |
| 503 TouchSelectionController* TouchSelectionController::create( | 503 TouchSelectionController* TouchSelectionController::create( |
| 504 TouchSelectionClientView* client_view) { | 504 TouchSelectionClientView* client_view) { |
| 505 return new TouchSelectionControllerImpl(client_view); | 505 return new TouchSelectionControllerImpl(client_view); |
| 506 } | 506 } |
| 507 | 507 |
| 508 } // namespace views | 508 } // namespace views |
| OLD | NEW |