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

Side by Side Diff: chrome/browser/ntp_background_util.cc

Issue 255086: GTK: Draw bottom-aligned ntp themes on floating bookmark bar.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: +comment Created 11 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ntp_background_util.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ntp_background_util.h"
6
7 #include "app/gfx/canvas.h"
8 #include "base/gfx/rect.h"
9 #include "base/logging.h"
10 #include "chrome/browser/browser_theme_provider.h"
11 #include "grit/theme_resources.h"
12 #include "skia/ext/skia_utils.h"
13 #include "third_party/skia/include/core/SkBitmap.h"
14
15 namespace {
16
17 void PaintThemeBackground(
18 gfx::Canvas* canvas, SkBitmap* ntp_background, int tiling, int alignment,
19 const gfx::Rect& area, int tab_contents_height) {
20 int x_pos = 0;
21 int y_pos = 0;
22 int width = area.width() + ntp_background->width();
23 int height = area.height() + ntp_background->height();
24
25 if (alignment & BrowserThemeProvider::ALIGN_BOTTOM)
26 y_pos += area.height() + tab_contents_height - ntp_background->height();
27
28 if (alignment & BrowserThemeProvider::ALIGN_RIGHT) {
29 x_pos += area.width() - ntp_background->width();
30 } else if (alignment & BrowserThemeProvider::ALIGN_LEFT) {
31 // no op
32 } else { // ALIGN_CENTER
33 x_pos += area.width() / 2 - ntp_background->width() / 2;
34 }
35
36 if (tiling != BrowserThemeProvider::REPEAT &&
37 tiling != BrowserThemeProvider::REPEAT_X) {
38 width = ntp_background->width();
39 } else if (x_pos > 0) {
40 x_pos = x_pos % ntp_background->width() - ntp_background->width();
41 }
42
43 if (tiling != BrowserThemeProvider::REPEAT &&
44 tiling != BrowserThemeProvider::REPEAT_Y) {
45 height = ntp_background->height();
46 } else if (y_pos > 0) {
47 y_pos = y_pos % ntp_background->height() - ntp_background->height();
48 }
49
50 x_pos += area.x();
51 y_pos += area.y();
52
53 canvas->TileImageInt(*ntp_background, x_pos, y_pos, width, height);
54 }
55
56 } // namespace
57
58 // static
59 void NtpBackgroundUtil::PaintBackgroundDetachedMode(
60 ThemeProvider* tp, gfx::Canvas* canvas, const gfx::Rect& area,
61 int tab_contents_height) {
62 // Draw the background to match the new tab page.
63 canvas->FillRectInt(tp->GetColor(BrowserThemeProvider::COLOR_NTP_BACKGROUND),
64 area.x(), area.y(), area.width(), area.height());
65
66 if (tp->HasCustomImage(IDR_THEME_NTP_BACKGROUND)) {
67 int tiling = BrowserThemeProvider::NO_REPEAT;
68 tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_TILING,
69 &tiling);
70 int alignment;
71 if (tp->GetDisplayProperty(BrowserThemeProvider::NTP_BACKGROUND_ALIGNMENT,
72 &alignment)) {
73 SkBitmap* ntp_background = tp->GetBitmapNamed(IDR_THEME_NTP_BACKGROUND);
74
75 PaintThemeBackground(
76 canvas, ntp_background, tiling, alignment, area, tab_contents_height);
77 }
78 }
79 }
OLDNEW
« no previous file with comments | « chrome/browser/ntp_background_util.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698