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

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

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 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/header_view.h ('k') | ash/common/gpu_support.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/frame/header_view.cc
diff --git a/ash/common/frame/header_view.cc b/ash/common/frame/header_view.cc
deleted file mode 100644
index fbd326ad7227eddcda8211e292c0b060bcbc8aff..0000000000000000000000000000000000000000
--- a/ash/common/frame/header_view.cc
+++ /dev/null
@@ -1,201 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/common/frame/header_view.h"
-
-#include "ash/common/frame/caption_buttons/frame_caption_button_container_view.h"
-#include "ash/common/frame/default_header_painter.h"
-#include "ash/common/session/session_state_delegate.h"
-#include "ash/common/wm_shell.h"
-#include "ash/common/wm_window.h"
-#include "ui/gfx/canvas.h"
-#include "ui/views/controls/image_view.h"
-#include "ui/views/widget/widget.h"
-
-namespace ash {
-
-HeaderView::HeaderView(views::Widget* target_widget)
- : target_widget_(target_widget),
- header_painter_(new DefaultHeaderPainter),
- avatar_icon_(nullptr),
- caption_button_container_(nullptr),
- fullscreen_visible_fraction_(0) {
- caption_button_container_ =
- new FrameCaptionButtonContainerView(target_widget_);
- caption_button_container_->UpdateSizeButtonVisibility();
- AddChildView(caption_button_container_);
-
- header_painter_->Init(target_widget_, this, caption_button_container_);
- UpdateAvatarIcon();
-
- WmShell::Get()->AddShellObserver(this);
-}
-
-HeaderView::~HeaderView() {
- WmShell::Get()->RemoveShellObserver(this);
-}
-
-void HeaderView::SchedulePaintForTitle() {
- header_painter_->SchedulePaintForTitle();
-}
-
-void HeaderView::ResetWindowControls() {
- caption_button_container_->ResetWindowControls();
-}
-
-int HeaderView::GetPreferredOnScreenHeight() {
- if (is_immersive_delegate_ && target_widget_->IsFullscreen()) {
- return static_cast<int>(GetPreferredHeight() *
- fullscreen_visible_fraction_);
- }
- return GetPreferredHeight();
-}
-
-int HeaderView::GetPreferredHeight() {
- // Calculating the preferred height requires at least one Layout().
- if (!did_layout_)
- Layout();
- return header_painter_->GetHeaderHeightForPainting();
-}
-
-int HeaderView::GetMinimumWidth() const {
- return header_painter_->GetMinimumHeaderWidth();
-}
-
-void HeaderView::UpdateAvatarIcon() {
- SessionStateDelegate* delegate = WmShell::Get()->GetSessionStateDelegate();
- WmWindow* window = WmWindow::Get(target_widget_->GetNativeWindow());
- bool show = delegate->ShouldShowAvatar(window);
- if (!show) {
- if (!avatar_icon_)
- return;
- delete avatar_icon_;
- avatar_icon_ = nullptr;
- } 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 HeaderView::SizeConstraintsChanged() {
- caption_button_container_->ResetWindowControls();
- caption_button_container_->UpdateSizeButtonVisibility();
- Layout();
-}
-
-void HeaderView::SetFrameColors(SkColor active_frame_color,
- SkColor inactive_frame_color) {
- header_painter_->SetFrameColors(active_frame_color, inactive_frame_color);
-}
-
-SkColor HeaderView::GetActiveFrameColor() const {
- return header_painter_->GetActiveFrameColor();
-}
-
-SkColor HeaderView::GetInactiveFrameColor() const {
- return header_painter_->GetInactiveFrameColor();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// HeaderView, views::View overrides:
-
-void HeaderView::Layout() {
- did_layout_ = true;
- header_painter_->LayoutHeader();
-}
-
-void HeaderView::OnPaint(gfx::Canvas* canvas) {
- bool paint_as_active =
- target_widget_->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 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();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// HeaderView, ShellObserver overrides:
-
-void HeaderView::OnOverviewModeStarting() {
- caption_button_container_->SetVisible(false);
-}
-
-void HeaderView::OnOverviewModeEnded() {
- caption_button_container_->SetVisible(true);
-}
-
-void HeaderView::OnMaximizeModeStarted() {
- caption_button_container_->UpdateSizeButtonVisibility();
- parent()->Layout();
-}
-
-void HeaderView::OnMaximizeModeEnded() {
- caption_button_container_->UpdateSizeButtonVisibility();
- parent()->Layout();
-}
-
-views::View* HeaderView::avatar_icon() const {
- return avatar_icon_;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// HeaderView,
-// ImmersiveFullscreenControllerDelegate overrides:
-
-void HeaderView::OnImmersiveRevealStarted() {
- fullscreen_visible_fraction_ = 0;
- SetPaintToLayer();
- parent()->Layout();
-}
-
-void HeaderView::OnImmersiveRevealEnded() {
- fullscreen_visible_fraction_ = 0;
- DestroyLayer();
- parent()->Layout();
-}
-
-void HeaderView::OnImmersiveFullscreenExited() {
- fullscreen_visible_fraction_ = 0;
- DestroyLayer();
- parent()->Layout();
-}
-
-void HeaderView::SetVisibleFraction(double visible_fraction) {
- if (fullscreen_visible_fraction_ != visible_fraction) {
- fullscreen_visible_fraction_ = visible_fraction;
- parent()->Layout();
- }
-}
-
-std::vector<gfx::Rect> 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;
-}
-
-} // namespace ash
« no previous file with comments | « ash/common/frame/header_view.h ('k') | ash/common/gpu_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698