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

Unified Diff: ash/wm/workspace/multi_window_resize_controller.cc

Issue 2836493002: Draw multi window resize controls programmatically (Closed)
Patch Set: slicker way of making right arrow Created 3 years, 8 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 | « ash/resources/default_200_percent/common/multi_window_resize_vertical.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c865d344e60715179cc9fea9416ea758e7f17dd2 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,78 @@ 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);
+
+ // Craft the left arrow.
+ const SkRect kArrowBounds = SkRect::MakeXYWH(4, 28, 4, 8);
+ SkPath path;
+ path.moveTo(kArrowBounds.right(), kArrowBounds.y());
+ path.lineTo(kArrowBounds.x(), kArrowBounds.centerY());
+ path.lineTo(kArrowBounds.right(), kArrowBounds.bottom());
+ path.close();
+
+ // Do the same for the right arrow.
+ SkMatrix flip;
+ flip.setScale(-1, 1, kShortSide / 2, kLongSide / 2);
+ path.addPath(path, flip);
+
+ // The arrows are drawn for the vertical orientation; rotate 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);
};
« no previous file with comments | « ash/resources/default_200_percent/common/multi_window_resize_vertical.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698