diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 21:49:12 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-02 21:49:12 +0000 |
commit | f00fa4d766ac76419a051345a496caecfbeddc78 (patch) | |
tree | b742fc1bdaa6dfd815e3b8ad719789572bb23398 /chrome/views | |
parent | 50d7d7283db42b531a9df9c6f5a34b8526d4d5b0 (diff) | |
download | chromium_src-f00fa4d766ac76419a051345a496caecfbeddc78.zip chromium_src-f00fa4d766ac76419a051345a496caecfbeddc78.tar.gz chromium_src-f00fa4d766ac76419a051345a496caecfbeddc78.tar.bz2 |
Fix bookmark and menu drag images by making a halo around them. This makes
the ClearType composited on the correct color to fix the semitransparent pixels
into 1-bit transparency pixels.
Remove some unnecessary header file dependencies on ChromeCanvas I noticed
when compiling this patch.
BUG=8258
Review URL: http://codereview.chromium.org/27321
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10732 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/border.cc | 1 | ||||
-rw-r--r-- | chrome/views/border.h | 12 | ||||
-rw-r--r-- | chrome/views/chrome_menu.cc | 18 | ||||
-rw-r--r-- | chrome/views/default_non_client_view.cc | 1 | ||||
-rw-r--r-- | chrome/views/default_non_client_view.h | 6 | ||||
-rw-r--r-- | chrome/views/label_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/views/root_view_win.cc | 1 | ||||
-rw-r--r-- | chrome/views/text_button.cc | 42 | ||||
-rw-r--r-- | chrome/views/window.cc | 1 |
9 files changed, 55 insertions, 28 deletions
diff --git a/chrome/views/border.cc b/chrome/views/border.cc index 680c071..b454c47 100644 --- a/chrome/views/border.cc +++ b/chrome/views/border.cc @@ -5,6 +5,7 @@ #include "chrome/views/border.h" #include "base/logging.h" +#include "chrome/common/gfx/chrome_canvas.h" namespace views { diff --git a/chrome/views/border.h b/chrome/views/border.h index 2493717..ae6831c 100644 --- a/chrome/views/border.h +++ b/chrome/views/border.h @@ -2,14 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_VIEWS_BORDER_H__ -#define CHROME_VIEWS_BORDER_H__ +#ifndef CHROME_VIEWS_BORDER_H_ +#define CHROME_VIEWS_BORDER_H_ -#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/insets.h" #include "chrome/views/view.h" #include "SkColor.h" +class ChromeCanvas; + namespace views { class View; @@ -50,10 +51,9 @@ class Border { virtual void GetInsets(gfx::Insets* insets) const = 0; private: - DISALLOW_EVIL_CONSTRUCTORS(Border); + DISALLOW_COPY_AND_ASSIGN(Border); }; } // namespace views -#endif // CHROME_VIEWS_BORDER_H__ - +#endif // CHROME_VIEWS_BORDER_H_ diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index f226987..96b24dc 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -1479,10 +1479,20 @@ void MenuItemView::Paint(ChromeCanvas* canvas, bool for_drag) { ChromeFont& font = GetRootMenuItem()->font_; gfx::Rect text_bounds(label_start, top_margin, width, font.height()); text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); - canvas->DrawStringInt(GetTitle(), font, fg_color, - text_bounds.x(), text_bounds.y(), text_bounds.width(), - text_bounds.height(), - GetRootMenuItem()->GetDrawStringFlags()); + if (for_drag) { + // With different themes, it's difficult to tell what the correct foreground + // and background colors are for the text to draw the correct halo. Instead, + // just draw black on white, which will look good in most cases. + canvas->DrawStringWithHalo(GetTitle(), font, 0x00000000, 0xFFFFFFFF, + text_bounds.x(), text_bounds.y(), + text_bounds.width(), text_bounds.height(), + GetRootMenuItem()->GetDrawStringFlags()); + } else { + canvas->DrawStringInt(GetTitle(), font, fg_color, + text_bounds.x(), text_bounds.y(), text_bounds.width(), + text_bounds.height(), + GetRootMenuItem()->GetDrawStringFlags()); + } if (icon_.width() > 0) { gfx::Rect icon_bounds(kItemLeftMargin, diff --git a/chrome/views/default_non_client_view.cc b/chrome/views/default_non_client_view.cc index cde277d..e3998a5 100644 --- a/chrome/views/default_non_client_view.cc +++ b/chrome/views/default_non_client_view.cc @@ -6,6 +6,7 @@ #include "base/win_util.h" #include "chrome/common/gfx/path.h" +#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" diff --git a/chrome/views/default_non_client_view.h b/chrome/views/default_non_client_view.h index a0a87e9..2c46fca 100644 --- a/chrome/views/default_non_client_view.h +++ b/chrome/views/default_non_client_view.h @@ -5,6 +5,7 @@ #ifndef CHROME_VIEWS_DEFAULT_NON_CLIENT_VIEW_H_ #define CHROME_VIEWS_DEFAULT_NON_CLIENT_VIEW_H_ +#include "base/basictypes.h" #include "chrome/views/button.h" #include "chrome/views/custom_frame_window.h" #include "chrome/views/non_client_view.h" @@ -16,6 +17,7 @@ class Path; class Point; } class ChromeCanvas; +class ChromeFont; namespace views { @@ -118,9 +120,9 @@ class DefaultNonClientView : public NonClientView, static WindowResources* inactive_resources_; static ChromeFont title_font_; - DISALLOW_EVIL_CONSTRUCTORS(DefaultNonClientView); + DISALLOW_COPY_AND_ASSIGN(DefaultNonClientView); }; } // namespace views -#endif // #ifndef CHROME_VIEWS_DEFAULT_NON_CLIENT_VIEW_H_ +#endif // CHROME_VIEWS_DEFAULT_NON_CLIENT_VIEW_H_ diff --git a/chrome/views/label_unittest.cc b/chrome/views/label_unittest.cc index 96b4d63..55154a3 100644 --- a/chrome/views/label_unittest.cc +++ b/chrome/views/label_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/string_util.h" +#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" #include "chrome/views/border.h" #include "chrome/views/label.h" diff --git a/chrome/views/root_view_win.cc b/chrome/views/root_view_win.cc index 9b38e64f..8ea6444 100644 --- a/chrome/views/root_view_win.cc +++ b/chrome/views/root_view_win.cc @@ -6,6 +6,7 @@ #include "base/base_drag_source.h" #include "base/logging.h" +#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/drag_drop_types.h" #include "chrome/views/root_view_drop_target.h" diff --git a/chrome/views/text_button.cc b/chrome/views/text_button.cc index f185745..ba4e3b2 100644 --- a/chrome/views/text_button.cc +++ b/chrome/views/text_button.cc @@ -5,6 +5,7 @@ #include "chrome/views/text_button.h" #include "chrome/common/gfx/chrome_canvas.h" +#include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/throb_animation.h" #include "chrome/common/win_util.h" @@ -260,22 +261,31 @@ void TextButton::Paint(ChromeCanvas* canvas, bool for_drag) { gfx::Rect text_bounds(text_x, text_y, text_width, text_size_.height()); text_bounds.set_x(MirroredLeftPointForRect(text_bounds)); - // Draw bevel highlight - canvas->DrawStringInt(text_, - font_, - kHighlightColor, - text_bounds.x() + 1, - text_bounds.y() + 1, - text_bounds.width(), - text_bounds.height()); - - canvas->DrawStringInt(text_, - font_, - color_, - text_bounds.x(), - text_bounds.y(), - text_bounds.width(), - text_bounds.height()); + if (for_drag) { + canvas->DrawStringWithHalo(text_, font_, color_, kHighlightColor, + text_bounds.x(), + text_bounds.y(), + text_bounds.width(), + text_bounds.height(), + l10n_util::DefaultCanvasTextAlignment()); + } else { + // Draw bevel highlight + canvas->DrawStringInt(text_, + font_, + kHighlightColor, + text_bounds.x() + 1, + text_bounds.y() + 1, + text_bounds.width(), + text_bounds.height()); + + canvas->DrawStringInt(text_, + font_, + color_, + text_bounds.x(), + text_bounds.y(), + text_bounds.width(), + text_bounds.height()); + } } if (icon_.width() > 0) { diff --git a/chrome/views/window.cc b/chrome/views/window.cc index 21a2f72..d4cb905 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -6,6 +6,7 @@ #include "base/win_util.h" #include "chrome/app/chrome_dll_resource.h" +#include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/gfx/icon_util.h" #include "chrome/common/gfx/path.h" |