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

Unified Diff: ash/frame/custom_frame_view_ash.cc

Issue 1441683007: exo: Add "back" button to shell surface decorations. Base URL: https://chromium.googlesource.com/chromium/src.git@exosphere-subcompositor
Patch Set: rebase Created 5 years, 1 month 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/frame/custom_frame_view_ash.h ('k') | components/exo.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/frame/custom_frame_view_ash.cc
diff --git a/ash/frame/custom_frame_view_ash.cc b/ash/frame/custom_frame_view_ash.cc
index 90d5c6af3dd921c5e225364a22ecf6446d2d6b4a..dfa1912a4e1c94ad269b8525476db2bccb172cf3 100644
--- a/ash/frame/custom_frame_view_ash.cc
+++ b/ash/frame/custom_frame_view_ash.cc
@@ -8,10 +8,12 @@
#include <vector>
#include "ash/ash_switches.h"
+#include "ash/frame/caption_buttons/frame_caption_button.h"
#include "ash/frame/caption_buttons/frame_caption_button_container_view.h"
#include "ash/frame/default_header_painter.h"
#include "ash/frame/frame_border_hit_test_controller.h"
#include "ash/frame/header_painter.h"
+#include "ash/frame/header_painter_util.h"
#include "ash/session/session_state_delegate.h"
#include "ash/shell.h"
#include "ash/shell_observer.h"
@@ -23,12 +25,14 @@
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
+#include "ui/base/hit_test.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/image_view.h"
+#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
#include "ui/views/view_targeter.h"
#include "ui/views/widget/widget.h"
@@ -114,6 +118,39 @@ class CustomFrameViewAshWindowStateDelegate
DISALLOW_COPY_AND_ASSIGN(CustomFrameViewAshWindowStateDelegate);
};
+class LeftHeaderView : public views::View {
+ public:
+ explicit LeftHeaderView(ash::FrameCaptionButton* caption_button)
+ : caption_button_(caption_button) {
+ SetLayoutManager(
+ new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0));
+ AddChildView(caption_button_);
+ caption_button_->SetState(views::Button::STATE_NORMAL);
+ }
+ ~LeftHeaderView() override {}
+
+ void SetPaintAsActive(bool active) {
+ caption_button_->set_paint_as_active(active);
+ }
+
+ private:
+ ash::FrameCaptionButton* caption_button_;
+
+ DISALLOW_COPY_AND_ASSIGN(LeftHeaderView);
+};
+
+// Combines View::ConvertPointToTarget() and View::HitTest() for a given
+// |point|. Converts |point| from |src| to |dst| and hit tests it against |dst|.
+bool ConvertedHitTest(views::View* src,
+ views::View* dst,
+ const gfx::Point& point) {
+ DCHECK(src);
+ DCHECK(dst);
+ gfx::Point converted_point(point);
+ views::View::ConvertPointToTarget(src, dst, &converted_point);
+ return dst->HitTestPoint(converted_point);
+}
+
} // namespace
namespace ash {
@@ -153,6 +190,8 @@ class CustomFrameViewAsh::HeaderView
void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
+ void SetLeftCaptionButton(FrameCaptionButton* left_caption_button);
+
// views::View:
void Layout() override;
void OnPaint(gfx::Canvas* canvas) override;
@@ -170,6 +209,8 @@ class CustomFrameViewAsh::HeaderView
return avatar_icon_;
}
+ views::View* left_header_view() const { return left_header_view_; }
+
private:
// ImmersiveFullscreenController::Delegate:
void OnImmersiveRevealStarted() override;
@@ -189,6 +230,9 @@ class CustomFrameViewAsh::HeaderView
// View which contains the window caption buttons.
FrameCaptionButtonContainerView* caption_button_container_;
+ // View which contains the left caption button.
+ LeftHeaderView* left_header_view_;
+
// The fraction of the header's height which is visible while in fullscreen.
// This value is meaningless when not in fullscreen.
double fullscreen_visible_fraction_;
@@ -201,6 +245,7 @@ CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
header_painter_(new ash::DefaultHeaderPainter),
avatar_icon_(NULL),
caption_button_container_(NULL),
+ left_header_view_(NULL),
fullscreen_visible_fraction_(0) {
caption_button_container_ = new FrameCaptionButtonContainerView(frame_);
caption_button_container_->UpdateSizeButtonVisibility();
@@ -274,18 +319,35 @@ void CustomFrameViewAsh::HeaderView::SetFrameColors(
header_painter_->SetFrameColors(active_frame_color, inactive_frame_color);
}
+void CustomFrameViewAsh::HeaderView::SetLeftCaptionButton(
+ FrameCaptionButton* left_caption_button) {
+ if (left_header_view_)
+ delete left_header_view_;
+ left_header_view_ = new LeftHeaderView(left_caption_button);
+ AddChildView(left_header_view_);
+ header_painter_->UpdateLeftHeaderView(left_header_view_);
+ Layout();
+}
+
///////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh::HeaderView, views::View overrides:
void CustomFrameViewAsh::HeaderView::Layout() {
header_painter_->LayoutHeader();
+ if (left_header_view_) {
+ header_painter_->UpdateLeftViewXInset(0);
+ } else {
+ header_painter_->UpdateLeftViewXInset(
+ ash::HeaderPainterUtil::GetDefaultLeftViewXInset());
+ }
}
void CustomFrameViewAsh::HeaderView::OnPaint(gfx::Canvas* canvas) {
bool paint_as_active =
frame_->non_client_view()->frame_view()->ShouldPaintAsActive();
caption_button_container_->SetPaintAsActive(paint_as_active);
-
+ if (left_header_view_)
+ left_header_view_->SetPaintAsActive(paint_as_active);
HeaderPainter::Mode header_mode = paint_as_active ?
HeaderPainter::MODE_ACTIVE : HeaderPainter::MODE_INACTIVE;
header_painter_->PaintHeader(canvas, header_mode);
@@ -461,6 +523,11 @@ void CustomFrameViewAsh::SetFrameColors(SkColor active_frame_color,
header_view_->SetFrameColors(active_frame_color, inactive_frame_color);
}
+void CustomFrameViewAsh::SetLeftCaptionButton(
+ FrameCaptionButton* left_caption_button) {
+ header_view_->SetLeftCaptionButton(left_caption_button);
+}
+
////////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh, views::NonClientFrameView overrides:
@@ -478,8 +545,16 @@ gfx::Rect CustomFrameViewAsh::GetWindowBoundsForClientBounds(
}
int CustomFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
- return FrameBorderHitTestController::NonClientHitTest(this,
- header_view_->caption_button_container(), point);
+ int hit_test = FrameBorderHitTestController::NonClientHitTest(
+ this, header_view_->caption_button_container(), point);
+
+ // See if the point is actually within the left header view.
+ if (hit_test == HTCAPTION && header_view_->left_header_view() &&
+ ConvertedHitTest(this, header_view_->left_header_view(), point)) {
+ return HTCLIENT;
+ }
+
+ return hit_test;
}
void CustomFrameViewAsh::GetWindowMask(const gfx::Size& size,
« no previous file with comments | « ash/frame/custom_frame_view_ash.h ('k') | components/exo.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698