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

Unified Diff: chrome/browser/ui/views/frame/browser_header_painter_ash.h

Issue 189463013: [Refactor] Move code for painting the window header for browser windows out of ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
Index: chrome/browser/ui/views/frame/browser_header_painter_ash.h
diff --git a/chrome/browser/ui/views/frame/browser_header_painter_ash.h b/chrome/browser/ui/views/frame/browser_header_painter_ash.h
index dd9f5f2aa94714d42ea5505505ec44a52fe43016..92fa7e6b397a07eba05df0e0f8197e1c3eb9da75 100644
--- a/chrome/browser/ui/views/frame/browser_header_painter_ash.h
+++ b/chrome/browser/ui/views/frame/browser_header_painter_ash.h
@@ -1,24 +1,23 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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.
-#ifndef ASH_WM_HEADER_PAINTER_H_
-#define ASH_WM_HEADER_PAINTER_H_
+#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_
+#define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_
-#include "ash/ash_export.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h" // OVERRIDE
-#include "base/gtest_prod_util.h"
+#include "ash/wm/header_painter.h"
#include "base/memory/scoped_ptr.h"
#include "ui/gfx/animation/animation_delegate.h"
-#include "ui/gfx/geometry/rect.h"
+
+class BrowserView;
+
+namespace ash {
+class FrameCaptionButtonContainerView;
+}
namespace gfx {
-class Canvas;
-class FontList;
class ImageSkia;
-class Point;
-class Size;
+class Rect;
class SlideAnimation;
}
namespace views {
@@ -26,158 +25,92 @@ class View;
class Widget;
}
-namespace ash {
-class FrameCaptionButtonContainerView;
-
-// Helper class for painting the window header.
-class ASH_EXPORT HeaderPainter : public gfx::AnimationDelegate {
+class BrowserHeaderPainterAsh : public ash::HeaderPainter,
James Cook 2014/03/10 17:32:30 Class comment please
+ public gfx::AnimationDelegate {
public:
- enum Mode {
- MODE_ACTIVE,
- MODE_INACTIVE
- };
-
- // TODO(pkotwicz): Move code related to "browser" windows out of ash.
- enum Style {
- // Header style used for browser windows.
- STYLE_BROWSER,
-
- // Header style used for apps and miscellaneous windows (e.g. task manager).
- STYLE_OTHER
- };
-
- HeaderPainter();
- virtual ~HeaderPainter();
-
- // None of the parameters are owned.
- void Init(Style style,
- views::Widget* frame,
- views::View* header_view,
- views::View* window_icon,
- FrameCaptionButtonContainerView* caption_button_container);
-
- // Returns the bounds of the client view for a window with |header_height|
- // and |window_bounds|. The return value and |window_bounds| are in the
- // views::NonClientView's coordinates.
- static gfx::Rect GetBoundsForClientView(int header_height,
- const gfx::Rect& window_bounds);
-
- // Returns the bounds of the window given |header_height| and |client_bounds|.
- // The return value and |client_bounds| are in the views::NonClientView's
- // coordinates.
- static gfx::Rect GetWindowBoundsForClientBounds(
- int header_height,
- const gfx::Rect& client_bounds);
-
- // Determines the window HT* code at |point|. Returns HTNOWHERE if |point| is
- // not within the top |header_height_| of |header_view_|. |point| is in the
- // coordinates of |header_view_|'s widget. The client view must be hittested
- // before calling this method because a browser's tabs are in the top
- // |header_height_| of |header_view_|.
- int NonClientHitTest(const gfx::Point& point) const;
-
- // Returns the header's minimum width.
- int GetMinimumHeaderWidth() const;
-
- // Returns the inset from the right edge.
- int GetRightInset() const;
-
- // Returns the amount that the theme background should be inset.
- int GetThemeBackgroundXInset() const;
-
- // Paints the header.
- // |theme_frame_overlay_id| is 0 if no overlay image should be used.
- // |mode| indicates whether the window should be painted as active.
- void PaintHeader(gfx::Canvas* canvas,
- Mode mode,
- int theme_frame_id,
- int theme_frame_overlay_id);
-
- // Paints the header/content separator line for non-browser windows.
- void PaintHeaderContentSeparator(gfx::Canvas* canvas, Mode mode);
-
- // Returns size of the header/content separator line for non-browser windows
- // in pixels.
- int HeaderContentSeparatorSize() const;
-
- // Paint the title bar, primarily the title string.
- void PaintTitleBar(gfx::Canvas* canvas, const gfx::FontList& title_font_list);
-
- // Performs layout for the header based on |frame_|'s show state.
- void LayoutHeader();
-
- // Sets the height of the header. The height of the header affects painting,
- // and non client hit tests. It does not affect layout.
- void set_header_height(int header_height) {
- header_height_ = header_height;
- }
-
- // Returns the header height.
- int header_height() const {
- return header_height_;
- }
-
- // Schedule a re-paint of the entire title.
- void SchedulePaintForTitle(const gfx::FontList& title_font_list);
-
- // Called when the browser theme changes.
- void OnThemeChanged();
-
- // Overridden from gfx::AnimationDelegate
- virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
+ BrowserHeaderPainterAsh();
+ virtual ~BrowserHeaderPainterAsh();
+
+ // BrowserHeaderPainterAsh does not take ownership of any of the parameters.
+ void Init(
+ views::Widget* frame,
+ BrowserView* browser_view,
+ views::View* header_view,
+ views::View* window_icon,
+ ash::FrameCaptionButtonContainerView* caption_button_container);
+
+ // ash::HeaderPainter overrides:
+ virtual int GetMinimumHeaderWidth() const OVERRIDE;
+ virtual void PaintHeader(gfx::Canvas* canvas, Mode mode) OVERRIDE;
+ virtual void LayoutHeader() OVERRIDE;
+ virtual int GetHeaderHeightForPainting() const OVERRIDE;
+ virtual void SetHeaderHeightForPainting(int height) OVERRIDE;
+ virtual void SchedulePaintForTitle() OVERRIDE;
private:
- FRIEND_TEST_ALL_PREFIXES(HeaderPainterTest, TitleIconAlignment);
+ // gfx::AnimationDelegate override:
+ virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
- // Paints the border around the header.
- void PaintBorder(gfx::Canvas* canvas, Mode mode);
+ // Paints a border around the header for restored windows.
+ void PaintBorderForRestoredWindow(gfx::Canvas* canvas);
- // Updates the images used for the minimize, restore and close buttons.
- void UpdateCaptionButtonImages();
+ // Paints the title bar, primarily the title string.
+ void PaintTitleBar(gfx::Canvas* canvas);
- // Returns the header bounds in the coordinates of |header_view_|. The header
- // is assumed to be positioned at the top left corner of |header_view_| and to
- // have the same width as |header_view_|.
- gfx::Rect GetHeaderLocalBounds() const;
+ // Sets |frame_image| and |frame_overlay_image| to the frame image and the
+ // frame overlay image respectivately which should be used to paint the
+ // header.
+ void GetFrameImages(Mode mode,
+ gfx::ImageSkia* frame_image,
+ gfx::ImageSkia* frame_overlay_image) const;
- // Returns the offset between window left edge and title string.
- int GetTitleOffsetX() const;
+ // Sets |frame_image| and |frame_overlay_image| to the frame image and the
+ // frame overlay image respectively that should be used to paint the header
+ // for tabbed browser windows.
+ void GetFrameImagesForTabbedBrowser(
+ Mode mode,
+ gfx::ImageSkia* frame_image,
+ gfx::ImageSkia* frame_overlay_image) const;
- // Returns the vertical center of the caption button container in window
- // coordinates.
- int GetCaptionButtonContainerCenterY() const;
+ // Returns the frame image which should be used to paint the header for popup
+ // browser windows and for hosted apps when the toolbar is visible.
+ gfx::ImageSkia GetFrameImageForNonTabbedBrowser(Mode mode) const;
- // Returns the radius of the header's top corners.
- int GetHeaderCornerRadius() const;
+ // Updates the images used for the minimize, restore and close buttons.
+ void UpdateCaptionButtonImages();
- // Get the bounds for the title. The provided |title_font_list| is used to
- // determine the correct dimensions.
- gfx::Rect GetTitleBounds(const gfx::FontList& title_font_list);
+ // Returns bounds of the region in |view_| which is painted with the header
+ // images. The region is assumed to start at the top left corner of
+ // |view_| and to have the same width as |view_|.
+ gfx::Rect GetPaintedBounds() const;
- Style style_;
+ // Returns the bounds for the title.
+ gfx::Rect GetTitleBounds() const;
- // Not owned
views::Widget* frame_;
- views::View* header_view_;
- views::View* window_icon_; // May be NULL.
- FrameCaptionButtonContainerView* caption_button_container_;
- // The height of the header.
- int header_height_;
+ // Whether the header is for a tabbed browser window.
+ bool is_tabbed_;
- // Image ids and opacity last used for painting header.
- int previous_theme_frame_id_;
- int previous_theme_frame_overlay_id_;
+ // Whether the header is for an incognito browser window.
+ bool is_incognito_;
- // Image ids and opacity we are crossfading from.
- int crossfade_theme_frame_id_;
- int crossfade_theme_frame_overlay_id_;
+ // The header view.
+ views::View* view_;
- scoped_ptr<gfx::SlideAnimation> crossfade_animation_;
+ views::View* window_icon_;
+ ash::FrameCaptionButtonContainerView* caption_button_container_;
+ int painted_height_;
- DISALLOW_COPY_AND_ASSIGN(HeaderPainter);
-};
+ // Whether the header is painted for the first time.
+ bool initial_paint_;
+
+ // Whether the header should be painted as active.
+ Mode mode_;
-} // namespace ash
+ scoped_ptr<gfx::SlideAnimation> activation_animation_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserHeaderPainterAsh);
+};
-#endif // ASH_WM_HEADER_PAINTER_H_
+#endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_HEADER_PAINTER_ASH_H_

Powered by Google App Engine
This is Rietveld 408576698