Chromium Code Reviews| Index: ash/wm/workspace/multi_window_resize_controller.cc |
| diff --git a/ash/wm/workspace/multi_window_resize_controller.cc b/ash/wm/workspace/multi_window_resize_controller.cc |
| index dc02e31d3c97c5cc4ce55658b2ef68ed012480d9..f402a546cefe16303fe9228ded734c179f1e2d09 100644 |
| --- a/ash/wm/workspace/multi_window_resize_controller.cc |
| +++ b/ash/wm/workspace/multi_window_resize_controller.cc |
| @@ -5,13 +5,11 @@ |
| #include "ash/wm/workspace/multi_window_resize_controller.h" |
| #include "ash/public/cpp/shell_window_ids.h" |
| -#include "ash/resources/grit/ash_resources.h" |
| #include "ash/root_window_controller.h" |
| #include "ash/wm/workspace/workspace_window_resizer.h" |
| #include "ash/wm_window.h" |
| #include "ui/base/cursor/cursor.h" |
| #include "ui/base/hit_test.h" |
| -#include "ui/base/resource/resource_bundle.h" |
| #include "ui/display/screen.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/image/image.h" |
| @@ -64,45 +62,80 @@ class MultiWindowResizeController::ResizeView : public views::View { |
| public: |
| explicit ResizeView(MultiWindowResizeController* controller, |
| Direction direction) |
| - : controller_(controller), direction_(direction), image_(NULL) { |
| - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| - int image_id = direction == TOP_BOTTOM ? IDR_AURA_MULTI_WINDOW_RESIZE_H |
| - : IDR_AURA_MULTI_WINDOW_RESIZE_V; |
| - image_ = rb.GetImageNamed(image_id).ToImageSkia(); |
| - } |
| + : controller_(controller), direction_(direction) {} |
| // views::View overrides: |
| gfx::Size GetPreferredSize() const override { |
| - return gfx::Size(image_->width(), image_->height()); |
| + const bool vert = direction_ == LEFT_RIGHT; |
| + return gfx::Size(vert ? kShortSide : kLongSide, |
| + vert ? kLongSide : kShortSide); |
| } |
| void OnPaint(gfx::Canvas* canvas) override { |
| - canvas->DrawImageInt(*image_, 0, 0); |
| + cc::PaintFlags flags; |
| + flags.setColor(SkColorSetA(SK_ColorBLACK, 0x7F)); |
| + flags.setAntiAlias(true); |
| + canvas->DrawRoundRect(gfx::RectF(GetLocalBounds()), 2, flags); |
|
varkha
2017/04/27 03:04:29
s/2/kButtonCornerRadius ?
Evan Stade
2017/04/27 17:36:29
I prefer not to used named constants for values th
|
| + |
| + // Craft the left arrow. |
| + SkRect arrow = SkRect::MakeXYWH(4, 28, 4, 8); |
|
varkha
2017/04/27 03:04:29
How about arrow_rect?
varkha
2017/04/27 03:04:29
I can see that XYWH makes it less ambiguous but I
Evan Stade
2017/04/27 17:36:29
changed to kArrowRect
Evan Stade
2017/04/27 17:36:29
Indeed, the XYHW serve as names. The only differen
|
| + SkPath path; |
| + path.moveTo(arrow.right(), arrow.y()); |
| + path.lineTo(arrow.x(), arrow.centerY()); |
| + path.lineTo(arrow.right(), arrow.bottom()); |
| + path.close(); |
| + |
| + // Do the same for the right arrow. |
| + arrow = arrow.makeOffset(kShortSide - arrow.width() - arrow.x() * 2, 0); |
| + path.moveTo(arrow.x(), arrow.y()); |
| + path.lineTo(arrow.right(), arrow.centerY()); |
| + path.lineTo(arrow.x(), arrow.bottom()); |
| + path.close(); |
| + |
| + // The arrows are drawn for the vertical orientation; flip if need be. |
| + if (direction_ == TOP_BOTTOM) { |
| + SkMatrix transform; |
| + constexpr int kHalfShort = kShortSide / 2; |
| + constexpr int kHalfLong = kLongSide / 2; |
| + transform.setRotate(90, kHalfShort, kHalfLong); |
| + transform.postTranslate(kHalfLong - kHalfShort, kHalfShort - kHalfLong); |
| + path.transform(transform); |
| + } |
| + |
| + flags.setColor(SK_ColorWHITE); |
| + canvas->DrawPath(path, flags); |
| } |
| + |
| bool OnMousePressed(const ui::MouseEvent& event) override { |
| gfx::Point location(event.location()); |
| views::View::ConvertPointToScreen(this, &location); |
| controller_->StartResize(location); |
| return true; |
| } |
| + |
| bool OnMouseDragged(const ui::MouseEvent& event) override { |
| gfx::Point location(event.location()); |
| views::View::ConvertPointToScreen(this, &location); |
| controller_->Resize(location, event.flags()); |
| return true; |
| } |
| + |
| void OnMouseReleased(const ui::MouseEvent& event) override { |
| controller_->CompleteResize(); |
| } |
| + |
| void OnMouseCaptureLost() override { controller_->CancelResize(); } |
| + |
| gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override { |
| int component = (direction_ == LEFT_RIGHT) ? HTRIGHT : HTBOTTOM; |
| return ::wm::CompoundEventFilter::CursorForWindowComponent(component); |
| } |
| private: |
| + static constexpr int kLongSide = 64; |
| + static constexpr int kShortSide = 28; |
| + |
| MultiWindowResizeController* controller_; |
| const Direction direction_; |
| - const gfx::ImageSkia* image_; |
| DISALLOW_COPY_AND_ASSIGN(ResizeView); |
| }; |