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

Unified Diff: ash/common/frame/custom_frame_view_ash.cc

Issue 2248383003: Moves HeaderView into it's own .h/.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: feedback Created 4 years, 4 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/common/frame/custom_frame_view_ash.h ('k') | ash/common/frame/header_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/frame/custom_frame_view_ash.cc
diff --git a/ash/common/frame/custom_frame_view_ash.cc b/ash/common/frame/custom_frame_view_ash.cc
index 0f2f4ce3b35ea92f640bf249bd757e9fb23d6f52..f186b0f2883bbd18a9a3b47ff0c48e43f3cc0b5d 100644
--- a/ash/common/frame/custom_frame_view_ash.cc
+++ b/ash/common/frame/custom_frame_view_ash.cc
@@ -9,12 +9,8 @@
#include "ash/common/ash_switches.h"
#include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h"
-#include "ash/common/frame/default_header_painter.h"
#include "ash/common/frame/frame_border_hit_test.h"
-#include "ash/common/frame/header_painter.h"
-#include "ash/common/material_design/material_design_controller.h"
-#include "ash/common/session/session_state_delegate.h"
-#include "ash/common/shell_observer.h"
+#include "ash/common/frame/header_view.h"
#include "ash/common/wm/immersive/wm_immersive_fullscreen_controller.h"
#include "ash/common/wm/immersive/wm_immersive_fullscreen_controller_delegate.h"
#include "ash/common/wm/window_state.h"
@@ -25,12 +21,9 @@
#include "ash/common/wm_window.h"
#include "ash/common/wm_window_observer.h"
#include "ash/common/wm_window_property.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/view.h"
#include "ui/views/view_targeter.h"
#include "ui/views/widget/widget.h"
@@ -117,257 +110,6 @@ class CustomFrameViewAshWindowStateDelegate : public wm::WindowStateDelegate,
} // namespace
///////////////////////////////////////////////////////////////////////////////
-// CustomFrameViewAsh::HeaderView
-
-// View which paints the header. It slides off and on screen in immersive
-// fullscreen.
-class CustomFrameViewAsh::HeaderView
- : public views::View,
- public WmImmersiveFullscreenControllerDelegate,
- public ShellObserver {
- public:
- // |frame| is the widget that the caption buttons act on.
- explicit HeaderView(views::Widget* frame);
- ~HeaderView() override;
-
- // Schedules a repaint for the entire title.
- void SchedulePaintForTitle();
-
- // Tells the window controls to reset themselves to the normal state.
- void ResetWindowControls();
-
- // Returns the amount of the view's pixels which should be on screen.
- int GetPreferredOnScreenHeight() const;
-
- // Returns the view's preferred height.
- int GetPreferredHeight() const;
-
- // Returns the view's minimum width.
- int GetMinimumWidth() const;
-
- void UpdateAvatarIcon();
-
- void SizeConstraintsChanged();
-
- void SetFrameColors(SkColor active_frame_color, SkColor inactive_frame_color);
-
- // views::View:
- void Layout() override;
- void OnPaint(gfx::Canvas* canvas) override;
- void ChildPreferredSizeChanged(views::View* child) override;
-
- // ShellObserver:
- void OnOverviewModeStarting() override;
- void OnOverviewModeEnded() override;
- void OnMaximizeModeStarted() override;
- void OnMaximizeModeEnded() override;
-
- FrameCaptionButtonContainerView* caption_button_container() {
- return caption_button_container_;
- }
-
- views::View* avatar_icon() const { return avatar_icon_; }
-
- private:
- // WmImmersiveFullscreenControllerDelegate:
- void OnImmersiveRevealStarted() override;
- void OnImmersiveRevealEnded() override;
- void OnImmersiveFullscreenExited() override;
- void SetVisibleFraction(double visible_fraction) override;
- std::vector<gfx::Rect> GetVisibleBoundsInScreen() const override;
-
- // The widget that the caption buttons act on.
- views::Widget* frame_;
-
- // Helper for painting the header.
- std::unique_ptr<DefaultHeaderPainter> header_painter_;
-
- views::ImageView* avatar_icon_;
-
- // View which contains the window caption buttons.
- FrameCaptionButtonContainerView* caption_button_container_;
-
- // 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_;
-
- DISALLOW_COPY_AND_ASSIGN(HeaderView);
-};
-
-CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
- : frame_(frame),
- header_painter_(new DefaultHeaderPainter),
- avatar_icon_(NULL),
- caption_button_container_(NULL),
- fullscreen_visible_fraction_(0) {
- caption_button_container_ = new FrameCaptionButtonContainerView(frame_);
- caption_button_container_->UpdateSizeButtonVisibility();
- AddChildView(caption_button_container_);
-
- header_painter_->Init(frame_, this, caption_button_container_);
- UpdateAvatarIcon();
-
- WmShell::Get()->AddShellObserver(this);
-}
-
-CustomFrameViewAsh::HeaderView::~HeaderView() {
- WmShell::Get()->RemoveShellObserver(this);
-}
-
-void CustomFrameViewAsh::HeaderView::SchedulePaintForTitle() {
- header_painter_->SchedulePaintForTitle();
-}
-
-void CustomFrameViewAsh::HeaderView::ResetWindowControls() {
- caption_button_container_->ResetWindowControls();
-}
-
-int CustomFrameViewAsh::HeaderView::GetPreferredOnScreenHeight() const {
- if (frame_->IsFullscreen()) {
- return static_cast<int>(GetPreferredHeight() *
- fullscreen_visible_fraction_);
- }
- return GetPreferredHeight();
-}
-
-int CustomFrameViewAsh::HeaderView::GetPreferredHeight() const {
- return header_painter_->GetHeaderHeightForPainting();
-}
-
-int CustomFrameViewAsh::HeaderView::GetMinimumWidth() const {
- return header_painter_->GetMinimumHeaderWidth();
-}
-
-void CustomFrameViewAsh::HeaderView::UpdateAvatarIcon() {
- SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
- WmWindow* window = WmLookup::Get()->GetWindowForWidget(frame_);
- bool show = delegate->ShouldShowAvatar(window);
- if (!show) {
- if (!avatar_icon_)
- return;
- delete avatar_icon_;
- avatar_icon_ = NULL;
- } else {
- gfx::ImageSkia image = delegate->GetAvatarImageForWindow(window);
- DCHECK_EQ(image.width(), image.height());
- if (!avatar_icon_) {
- avatar_icon_ = new views::ImageView();
- AddChildView(avatar_icon_);
- }
- avatar_icon_->SetImage(image);
- }
- header_painter_->UpdateLeftHeaderView(avatar_icon_);
- Layout();
-}
-
-void CustomFrameViewAsh::HeaderView::SizeConstraintsChanged() {
- caption_button_container_->ResetWindowControls();
- caption_button_container_->UpdateSizeButtonVisibility();
- Layout();
-}
-
-void CustomFrameViewAsh::HeaderView::SetFrameColors(
- SkColor active_frame_color,
- SkColor inactive_frame_color) {
- header_painter_->SetFrameColors(active_frame_color, inactive_frame_color);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CustomFrameViewAsh::HeaderView, views::View overrides:
-
-void CustomFrameViewAsh::HeaderView::Layout() {
- header_painter_->LayoutHeader();
-}
-
-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);
-
- HeaderPainter::Mode header_mode = paint_as_active
- ? HeaderPainter::MODE_ACTIVE
- : HeaderPainter::MODE_INACTIVE;
- header_painter_->PaintHeader(canvas, header_mode);
-}
-
-void CustomFrameViewAsh::HeaderView::ChildPreferredSizeChanged(
- views::View* child) {
- // FrameCaptionButtonContainerView animates the visibility changes in
- // UpdateSizeButtonVisibility(false). Due to this a new size is not available
- // until the completion of the animation. Layout in response to the preferred
- // size changes.
- if (child != caption_button_container_)
- return;
- parent()->Layout();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CustomFrameViewAsh::HeaderView, ShellObserver overrides:
-
-void CustomFrameViewAsh::HeaderView::OnOverviewModeStarting() {
- if (MaterialDesignController::IsOverviewMaterial())
- caption_button_container_->SetVisible(false);
-}
-
-void CustomFrameViewAsh::HeaderView::OnOverviewModeEnded() {
- if (MaterialDesignController::IsOverviewMaterial())
- caption_button_container_->SetVisible(true);
-}
-
-void CustomFrameViewAsh::HeaderView::OnMaximizeModeStarted() {
- caption_button_container_->UpdateSizeButtonVisibility();
- parent()->Layout();
-}
-
-void CustomFrameViewAsh::HeaderView::OnMaximizeModeEnded() {
- caption_button_container_->UpdateSizeButtonVisibility();
- parent()->Layout();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// CustomFrameViewAsh::HeaderView,
-// WmImmersiveFullscreenControllerDelegate overrides:
-
-void CustomFrameViewAsh::HeaderView::OnImmersiveRevealStarted() {
- fullscreen_visible_fraction_ = 0;
- SetPaintToLayer(true);
- layer()->SetFillsBoundsOpaquely(false);
- parent()->Layout();
-}
-
-void CustomFrameViewAsh::HeaderView::OnImmersiveRevealEnded() {
- fullscreen_visible_fraction_ = 0;
- SetPaintToLayer(false);
- parent()->Layout();
-}
-
-void CustomFrameViewAsh::HeaderView::OnImmersiveFullscreenExited() {
- fullscreen_visible_fraction_ = 0;
- SetPaintToLayer(false);
- parent()->Layout();
-}
-
-void CustomFrameViewAsh::HeaderView::SetVisibleFraction(
- double visible_fraction) {
- if (fullscreen_visible_fraction_ != visible_fraction) {
- fullscreen_visible_fraction_ = visible_fraction;
- parent()->Layout();
- }
-}
-
-std::vector<gfx::Rect>
-CustomFrameViewAsh::HeaderView::GetVisibleBoundsInScreen() const {
- // TODO(pkotwicz): Implement views::View::ConvertRectToScreen().
- gfx::Rect visible_bounds(GetVisibleBounds());
- gfx::Point visible_origin_in_screen(visible_bounds.origin());
- views::View::ConvertPointToScreen(this, &visible_origin_in_screen);
- std::vector<gfx::Rect> bounds_in_screen;
- bounds_in_screen.push_back(
- gfx::Rect(visible_origin_in_screen, visible_bounds.size()));
- return bounds_in_screen;
-}
-
-///////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAsh::OverlayView
// View which takes up the entire widget and contains the HeaderView. HeaderView
« no previous file with comments | « ash/common/frame/custom_frame_view_ash.h ('k') | ash/common/frame/header_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698