summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/ntp_background_util.h
blob: c04dc61f3d1b99c03acec4d1c6729405fc4b0405 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) 2009 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 CHROME_BROWSER_UI_NTP_BACKGROUND_UTIL_H_
#define CHROME_BROWSER_UI_NTP_BACKGROUND_UTIL_H_

namespace gfx {
class Canvas;
class Rect;
class Size;
}

namespace ui {
class ThemeProvider;
}

class Profile;

class NtpBackgroundUtil {
 public:
  // Paints the NTP background on |canvas| where the theme image fills up
  // |tab_contents_height|.
  // - |area| is the area of the canvas that gets painted and also serves as the
  //   origin of the image (for top-aligned images).
  // - |tab_contents_height| is necessary for correctly painting bottom-aligned
  //   images since then the origin is the bottom of the web page.
  static void PaintBackgroundDetachedMode(Profile* profile,
                                          gfx::Canvas* canvas,
                                          const gfx::Rect& area,
                                          int tab_contents_height);

  // Paints the NTP background on |canvas| where the theme image fills up
  // the entire browser client area from top of tab to bottom of browser client
  // area.
  // - |area_in_canvas| is the area of and relative to the canvas that gets
  //   painted.
  // - |browser_client_area_size| is the size of browser client area where the
  //    entire image will be displayed
  // - |area_in_browser_client_area| is |area_in_canvas| relative to browser
  //   client area of |browser_client_area_size|.
  static void PaintBackgroundForBrowserClientArea(
      Profile* profile,
      gfx::Canvas* canvas,
      const gfx::Rect& area_in_canvas,
      const gfx::Size& browser_client_area_size,
      const gfx::Rect& area_in_browser_client);

  // Returns the x or y coordinate in |view_dimension| where a center-aligned
  // image of |image_dimension| should be placed:
  // - if dimension is width, x-pos is returned.
  // - if dimension is height, y-pos is returned.
  static int GetPlacementOfCenterAlignedImage(int view_dimension,
                                              int image_dimension);

 private:
  NtpBackgroundUtil() {}
};

#endif  // CHROME_BROWSER_UI_NTP_BACKGROUND_UTIL_H_