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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_view.cc

Issue 8221027: Make views::Label and views::Link auto-color themselves to be readable over their background colo... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/infobars/infobar_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_view.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #endif 9 #endif
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 set_background(new InfoBarBackground(delegate->GetInfoBarType())); 69 set_background(new InfoBarBackground(delegate->GetInfoBarType()));
70 } 70 }
71 71
72 InfoBarView::~InfoBarView() { 72 InfoBarView::~InfoBarView() {
73 // We should have closed any open menus in PlatformSpecificHide(), then 73 // We should have closed any open menus in PlatformSpecificHide(), then
74 // subclasses' RunMenu() functions should have prevented opening any new ones 74 // subclasses' RunMenu() functions should have prevented opening any new ones
75 // once we became unowned. 75 // once we became unowned.
76 DCHECK(!menu_runner_.get()); 76 DCHECK(!menu_runner_.get());
77 } 77 }
78 78
79 // static 79 views::Label* InfoBarView::CreateLabel(const string16& text) const {
80 views::Label* InfoBarView::CreateLabel(const string16& text) {
81 views::Label* label = new views::Label(text, 80 views::Label* label = new views::Label(text,
82 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); 81 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont));
83 label->SetColor(SK_ColorBLACK); 82 label->SetBackgroundColor(background()->get_color());
83 label->SetEnabledColor(SK_ColorBLACK);
84 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 84 label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
85 return label; 85 return label;
86 } 86 }
87 87
88 // static
89 views::Link* InfoBarView::CreateLink(const string16& text, 88 views::Link* InfoBarView::CreateLink(const string16& text,
90 views::LinkListener* listener, 89 views::LinkListener* listener) const {
91 const SkColor& background_color) {
92 views::Link* link = new views::Link; 90 views::Link* link = new views::Link;
93 link->SetText(text); 91 link->SetText(text);
94 link->SetFont( 92 link->SetFont(
95 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); 93 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont));
96 link->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 94 link->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
97 link->set_listener(listener); 95 link->set_listener(listener);
98 link->MakeReadableOverBackgroundColor(background_color); 96 link->SetBackgroundColor(background()->get_color());
99 return link; 97 return link;
100 } 98 }
101 99
102 // static 100 // static
103 views::MenuButton* InfoBarView::CreateMenuButton( 101 views::MenuButton* InfoBarView::CreateMenuButton(
104 const string16& text, 102 const string16& text,
105 views::ViewMenuDelegate* menu_delegate) { 103 views::ViewMenuDelegate* menu_delegate) {
106 views::MenuButton* menu_button = 104 views::MenuButton* menu_button =
107 new views::MenuButton(NULL, UTF16ToWideHack(text), menu_delegate, true); 105 new views::MenuButton(NULL, UTF16ToWideHack(text), menu_delegate, true);
108 menu_button->set_border(new InfoBarButtonBorder); 106 menu_button->set_border(new InfoBarButtonBorder);
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 375
378 void InfoBarView::FocusWillChange(View* focused_before, View* focused_now) { 376 void InfoBarView::FocusWillChange(View* focused_before, View* focused_now) {
379 // This will trigger some screen readers to read the entire contents of this 377 // This will trigger some screen readers to read the entire contents of this
380 // infobar. 378 // infobar.
381 if (focused_before && focused_now && !Contains(focused_before) && 379 if (focused_before && focused_now && !Contains(focused_before) &&
382 Contains(focused_now) && GetWidget()) { 380 Contains(focused_now) && GetWidget()) {
383 GetWidget()->NotifyAccessibilityEvent( 381 GetWidget()->NotifyAccessibilityEvent(
384 this, ui::AccessibilityTypes::EVENT_ALERT, true); 382 this, ui::AccessibilityTypes::EVENT_ALERT, true);
385 } 383 }
386 } 384 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_view.h ('k') | chrome/browser/ui/views/infobars/link_infobar.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698