diff options
author | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-15 13:42:58 +0000 |
---|---|---|
committer | glotov@google.com <glotov@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-15 13:42:58 +0000 |
commit | 5da5b8b3d7fa0b5697c404c5e993eaf93b2af157 (patch) | |
tree | a355cc0fa02b32c6095e3839859b7d8cd53c4fc7 | |
parent | 3bcb6c574262ba68bb25436dc38a50e2b932e207 (diff) | |
download | chromium_src-5da5b8b3d7fa0b5697c404c5e993eaf93b2af157.zip chromium_src-5da5b8b3d7fa0b5697c404c5e993eaf93b2af157.tar.gz chromium_src-5da5b8b3d7fa0b5697c404c5e993eaf93b2af157.tar.bz2 |
Merge 66061 - Adding style notion to the TextButton.
Welcome screen uses different style of buttons.
BUG=chromium-os:8468
TEST=none
Review URL: http://codereview.chromium.org/4402001
TBR=glotov@google.com
Review URL: http://codereview.chromium.org/4995002
git-svn-id: svn://svn.chromium.org/chrome/branches/552/src@66117 0039d316-1c4b-4281-b951-d872f2087c98
29 files changed, 142 insertions, 17 deletions
diff --git a/app/resources/menu_droparrow.png b/app/resources/menu_droparrow.png Binary files differindex 8aef68b..cc0f545 100644 --- a/app/resources/menu_droparrow.png +++ b/app/resources/menu_droparrow.png diff --git a/chrome/app/theme/textbutton_dropdown_b_h.png b/chrome/app/theme/textbutton_dropdown_b_h.png Binary files differnew file mode 100644 index 0000000..e69324c --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_b_h.png diff --git a/chrome/app/theme/textbutton_dropdown_b_p.png b/chrome/app/theme/textbutton_dropdown_b_p.png Binary files differnew file mode 100644 index 0000000..3446f9c --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_b_p.png diff --git a/chrome/app/theme/textbutton_dropdown_bl_h.png b/chrome/app/theme/textbutton_dropdown_bl_h.png Binary files differnew file mode 100644 index 0000000..f1fce0d --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_bl_h.png diff --git a/chrome/app/theme/textbutton_dropdown_bl_p.png b/chrome/app/theme/textbutton_dropdown_bl_p.png Binary files differnew file mode 100644 index 0000000..91506aa7 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_bl_p.png diff --git a/chrome/app/theme/textbutton_dropdown_br_h.png b/chrome/app/theme/textbutton_dropdown_br_h.png Binary files differnew file mode 100644 index 0000000..3a54b0c --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_br_h.png diff --git a/chrome/app/theme/textbutton_dropdown_br_p.png b/chrome/app/theme/textbutton_dropdown_br_p.png Binary files differnew file mode 100644 index 0000000..8fb9fb1 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_br_p.png diff --git a/chrome/app/theme/textbutton_dropdown_c_h.png b/chrome/app/theme/textbutton_dropdown_c_h.png Binary files differnew file mode 100644 index 0000000..e777467 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_c_h.png diff --git a/chrome/app/theme/textbutton_dropdown_c_p.png b/chrome/app/theme/textbutton_dropdown_c_p.png Binary files differnew file mode 100644 index 0000000..84c9ed0 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_c_p.png diff --git a/chrome/app/theme/textbutton_dropdown_l_h.png b/chrome/app/theme/textbutton_dropdown_l_h.png Binary files differnew file mode 100644 index 0000000..9e10ed2f --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_l_h.png diff --git a/chrome/app/theme/textbutton_dropdown_l_p.png b/chrome/app/theme/textbutton_dropdown_l_p.png Binary files differnew file mode 100644 index 0000000..a46ae7b --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_l_p.png diff --git a/chrome/app/theme/textbutton_dropdown_r_h.png b/chrome/app/theme/textbutton_dropdown_r_h.png Binary files differnew file mode 100644 index 0000000..12db0c4 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_r_h.png diff --git a/chrome/app/theme/textbutton_dropdown_r_p.png b/chrome/app/theme/textbutton_dropdown_r_p.png Binary files differnew file mode 100644 index 0000000..fc9a62a --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_r_p.png diff --git a/chrome/app/theme/textbutton_dropdown_t_h.png b/chrome/app/theme/textbutton_dropdown_t_h.png Binary files differnew file mode 100644 index 0000000..8789156 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_t_h.png diff --git a/chrome/app/theme/textbutton_dropdown_t_p.png b/chrome/app/theme/textbutton_dropdown_t_p.png Binary files differnew file mode 100644 index 0000000..2fb5de9 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_t_p.png diff --git a/chrome/app/theme/textbutton_dropdown_tl_h.png b/chrome/app/theme/textbutton_dropdown_tl_h.png Binary files differnew file mode 100644 index 0000000..c30901e --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_tl_h.png diff --git a/chrome/app/theme/textbutton_dropdown_tl_p.png b/chrome/app/theme/textbutton_dropdown_tl_p.png Binary files differnew file mode 100644 index 0000000..c87d3f1 --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_tl_p.png diff --git a/chrome/app/theme/textbutton_dropdown_tr_h.png b/chrome/app/theme/textbutton_dropdown_tr_h.png Binary files differnew file mode 100644 index 0000000..dd4dd3e --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_tr_h.png diff --git a/chrome/app/theme/textbutton_dropdown_tr_p.png b/chrome/app/theme/textbutton_dropdown_tr_p.png Binary files differnew file mode 100644 index 0000000..776b57d --- /dev/null +++ b/chrome/app/theme/textbutton_dropdown_tr_p.png diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 7498617..d8f610f 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -580,6 +580,24 @@ <include name="IDR_SCROLL_THUMB_H" file="chromeos_scroll_thumb_h.png" type="BINDATA" /> <include name="IDR_SCROLL_THUMB_P" file="chromeos_scroll_thumb_p.png" type="BINDATA" /> <include name="IDR_SHUTDOWN_ICON" file="shutdown_icon.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_BOTTOM_H" file="textbutton_dropdown_b_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_BOTTOM_LEFT_H" file="textbutton_dropdown_bl_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_BOTTOM_LEFT_P" file="textbutton_dropdown_bl_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_BOTTOM_P" file="textbutton_dropdown_b_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_BOTTOM_RIGHT_H" file="textbutton_dropdown_br_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_BOTTOM_RIGHT_P" file="textbutton_dropdown_br_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_CENTER_H" file="textbutton_dropdown_c_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_CENTER_P" file="textbutton_dropdown_c_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_LEFT_H" file="textbutton_dropdown_l_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_LEFT_P" file="textbutton_dropdown_l_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_RIGHT_H" file="textbutton_dropdown_r_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_RIGHT_P" file="textbutton_dropdown_r_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_TOP_H" file="textbutton_dropdown_t_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_TOP_LEFT_H" file="textbutton_dropdown_tl_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_TOP_LEFT_P" file="textbutton_dropdown_tl_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_TOP_P" file="textbutton_dropdown_t_p.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_TOP_RIGHT_H" file="textbutton_dropdown_tr_h.png" type="BINDATA" /> + <include name="IDR_DROPDOWN_TOP_RIGHT_P" file="textbutton_dropdown_tr_p.png" type="BINDATA" /> </if> </includes> </release> diff --git a/chrome/browser/chromeos/login/network_selection_view.cc b/chrome/browser/chromeos/login/network_selection_view.cc index 4c8ce93..5280d8b 100644 --- a/chrome/browser/chromeos/login/network_selection_view.cc +++ b/chrome/browser/chromeos/login/network_selection_view.cc @@ -65,7 +65,7 @@ const int kControlPaddingRow = 15; const int kWelcomeTitleFontDelta = 5; // Fixed size for language/keyboard/network controls height. -const int kSelectionBoxHeight = 30; +const int kSelectionBoxHeight = 29; // Menu button is drawn using our custom icons in resources. See // TextButtonBorder::Paint() for details. So this offset compensate @@ -120,14 +120,14 @@ class NetworkControlReportOnActivate : public NetworkDropdownButton { }; // MenuButton with custom processing on focus events. -class NotifyingMenuButton : public views::MenuButton { +class NotifyingMenuButton : public DropDownButton { public: NotifyingMenuButton(views::ButtonListener* listener, const std::wstring& text, views::ViewMenuDelegate* menu_delegate, bool show_menu_marker, NetworkScreenDelegate* delegate) - : MenuButton(listener, text, menu_delegate, show_menu_marker), + : DropDownButton(listener, text, menu_delegate, show_menu_marker), delegate_(delegate) {} // Overridden from View: @@ -305,7 +305,7 @@ void NetworkSelectionView::Init() { select_keyboard_label_ = new views::Label(); select_keyboard_label_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); - keyboards_menubutton_ = new views::MenuButton( + keyboards_menubutton_ = new DropDownButton( NULL /* listener */, L"", delegate_->keyboard_switch_menu(), true /* show_menu_marker */); InitMenuButtonProperties(keyboards_menubutton_); diff --git a/chrome/browser/chromeos/login/network_selection_view.h b/chrome/browser/chromeos/login/network_selection_view.h index dfcc709..54626dd 100644 --- a/chrome/browser/chromeos/login/network_selection_view.h +++ b/chrome/browser/chromeos/login/network_selection_view.h @@ -9,7 +9,7 @@ #include "base/scoped_ptr.h" #include "base/string16.h" #include "chrome/browser/chromeos/login/login_html_dialog.h" -#include "views/controls/button/menu_button.h" +#include "chrome/browser/chromeos/views/dropdown_button.h" #include "views/controls/link.h" #include "views/view.h" #include "views/widget/widget_gtk.h" @@ -105,8 +105,8 @@ class NetworkSelectionView : public views::View, views::View* contents_view_; // Screen controls. - views::MenuButton* languages_menubutton_; - views::MenuButton* keyboards_menubutton_; + DropDownButton* languages_menubutton_; + DropDownButton* keyboards_menubutton_; views::Label* welcome_label_; views::Label* select_language_label_; views::Label* select_keyboard_label_; diff --git a/chrome/browser/chromeos/status/network_dropdown_button.cc b/chrome/browser/chromeos/status/network_dropdown_button.cc index d2be0ec..32ff4e6 100644 --- a/chrome/browser/chromeos/status/network_dropdown_button.cc +++ b/chrome/browser/chromeos/status/network_dropdown_button.cc @@ -25,10 +25,10 @@ const int NetworkDropdownButton::kThrobDuration = 1000; NetworkDropdownButton::NetworkDropdownButton(bool browser_mode, gfx::NativeWindow parent_window) - : MenuButton(NULL, - l10n_util::GetString(IDS_STATUSBAR_NO_NETWORKS_MESSAGE), - this, - true), + : DropDownButton(NULL, + l10n_util::GetString(IDS_STATUSBAR_NO_NETWORKS_MESSAGE), + this, + true), browser_mode_(browser_mode), ALLOW_THIS_IN_INITIALIZER_LIST(animation_connecting_(this)), parent_window_(parent_window) { diff --git a/chrome/browser/chromeos/status/network_dropdown_button.h b/chrome/browser/chromeos/status/network_dropdown_button.h index ec2e337..a187f71 100644 --- a/chrome/browser/chromeos/status/network_dropdown_button.h +++ b/chrome/browser/chromeos/status/network_dropdown_button.h @@ -9,7 +9,7 @@ #include "app/throb_animation.h" #include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/status/network_menu.h" -#include "views/controls/button/menu_button.h" +#include "chrome/browser/chromeos/views/dropdown_button.h" namespace chromeos { @@ -17,7 +17,7 @@ namespace chromeos { // This class will handle getting the networks to show connected network // at top level and populating the menu. // See NetworkMenu for more details. -class NetworkDropdownButton : public views::MenuButton, +class NetworkDropdownButton : public DropDownButton, public NetworkMenu, public NetworkLibrary::NetworkManagerObserver { public: diff --git a/chrome/browser/chromeos/views/dropdown_button.cc b/chrome/browser/chromeos/views/dropdown_button.cc new file mode 100644 index 0000000..58e9d368 --- /dev/null +++ b/chrome/browser/chromeos/views/dropdown_button.cc @@ -0,0 +1,73 @@ +// Copyright (c) 2010 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. + +#include "app/resource_bundle.h" +#include "chrome/browser/chromeos/views/dropdown_button.h" +#include "gfx/canvas_skia.h" +#include "grit/theme_resources.h" + +namespace { +// Asset icon particularities makes us offset focus frame. +const int kFocusFrameTopOffset = 0; +const int kFocusFrameLeftOffset = 0; +const int kFocusFrameRightOffset = 0; +const int kFocusFrameBottomOffset = 1; + +// TextButtonBorder specification that uses different icons to draw the +// button. +class DropDownButtonBorder : public views::TextButtonBorder { + public: + DropDownButtonBorder(); + + private: + DISALLOW_COPY_AND_ASSIGN(DropDownButtonBorder); +}; + +DropDownButtonBorder::DropDownButtonBorder() { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + + hot_set_.top_left = rb.GetBitmapNamed(IDR_DROPDOWN_TOP_LEFT_H); + hot_set_.top = rb.GetBitmapNamed(IDR_DROPDOWN_TOP_H); + hot_set_.top_right = rb.GetBitmapNamed(IDR_DROPDOWN_TOP_RIGHT_H); + hot_set_.left = rb.GetBitmapNamed(IDR_DROPDOWN_LEFT_H); + hot_set_.center = rb.GetBitmapNamed(IDR_DROPDOWN_CENTER_H); + hot_set_.right = rb.GetBitmapNamed(IDR_DROPDOWN_RIGHT_H); + hot_set_.bottom_left = rb.GetBitmapNamed(IDR_DROPDOWN_BOTTOM_LEFT_H); + hot_set_.bottom = rb.GetBitmapNamed(IDR_DROPDOWN_BOTTOM_H); + hot_set_.bottom_right = rb.GetBitmapNamed(IDR_DROPDOWN_BOTTOM_RIGHT_H); + + pushed_set_.top_left = rb.GetBitmapNamed(IDR_DROPDOWN_TOP_LEFT_P); + pushed_set_.top = rb.GetBitmapNamed(IDR_DROPDOWN_TOP_P); + pushed_set_.top_right = rb.GetBitmapNamed(IDR_DROPDOWN_TOP_RIGHT_P); + pushed_set_.left = rb.GetBitmapNamed(IDR_DROPDOWN_LEFT_P); + pushed_set_.center = rb.GetBitmapNamed(IDR_DROPDOWN_CENTER_P); + pushed_set_.right = rb.GetBitmapNamed(IDR_DROPDOWN_RIGHT_P); + pushed_set_.bottom_left = rb.GetBitmapNamed(IDR_DROPDOWN_BOTTOM_LEFT_P); + pushed_set_.bottom = rb.GetBitmapNamed(IDR_DROPDOWN_BOTTOM_P); + pushed_set_.bottom_right = rb.GetBitmapNamed(IDR_DROPDOWN_BOTTOM_RIGHT_P); +} + +} // namespace + +namespace chromeos { + +DropDownButton::DropDownButton(views::ButtonListener* listener, + const std::wstring& text, + views::ViewMenuDelegate* menu_delegate, + bool show_menu_marker) + : MenuButton(listener, text, menu_delegate, show_menu_marker) { + set_border(new DropDownButtonBorder); +} + +DropDownButton::~DropDownButton() { +} + +void DropDownButton::PaintFocusBorder(gfx::Canvas* canvas) { + if (HasFocus() && (IsFocusable() || IsAccessibilityFocusableInRootView())) + canvas->DrawFocusRect(kFocusFrameLeftOffset, kFocusFrameTopOffset, + width() - kFocusFrameRightOffset, + height() - kFocusFrameBottomOffset); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/views/dropdown_button.h b/chrome/browser/chromeos/views/dropdown_button.h new file mode 100644 index 0000000..637b7fa --- /dev/null +++ b/chrome/browser/chromeos/views/dropdown_button.h @@ -0,0 +1,33 @@ +// Copyright (c) 2010 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_CHROMEOS_VIEWS_DROPDOWN_BUTTON_H_ +#define CHROME_BROWSER_CHROMEOS_VIEWS_DROPDOWN_BUTTON_H_ +#pragma once + +#include <string> + +#include "views/controls/button/menu_button.h" + +namespace chromeos { + +// MenuButton specification that uses different icons to draw the button and +// adjust focus frame accordingly to the icons particularities. +class DropDownButton : public views::MenuButton { + public: + DropDownButton(views::ButtonListener* listener, + const std::wstring& text, + views::ViewMenuDelegate* menu_delegate, + bool show_menu_marker); + virtual ~DropDownButton(); + + virtual void PaintFocusBorder(gfx::Canvas* canvas); + + private: + DISALLOW_COPY_AND_ASSIGN(DropDownButton); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_VIEWS_DROPDOWN_BUTTON_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 44545a4..29def4e 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -750,6 +750,8 @@ 'browser/chromeos/view_ids.h', 'browser/chromeos/views/copy_background.cc', 'browser/chromeos/views/copy_background.h', + 'browser/chromeos/views/dropdown_button.cc', + 'browser/chromeos/views/dropdown_button.h', 'browser/chromeos/views/menu_locator.cc', 'browser/chromeos/views/menu_locator.h', 'browser/chromeos/views/native_menu_domui.cc', diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index e7f7f1b..1b94359 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -54,7 +54,7 @@ MenuButton::MenuButton(ButtonListener* listener, menu_delegate_(menu_delegate), show_menu_marker_(show_menu_marker), menu_marker_(ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_MENU_DROPARROW)), + IDR_MENU_DROPARROW)), destroyed_flag_(NULL) { set_alignment(TextButton::ALIGN_LEFT); } diff --git a/views/controls/button/menu_button.h b/views/controls/button/menu_button.h index 72f8fb6..1e78a9c 100644 --- a/views/controls/button/menu_button.h +++ b/views/controls/button/menu_button.h @@ -31,8 +31,7 @@ class MenuButton : public TextButton { // The menu button's class name. static const char kViewClassName[]; - // - // Create a Button + // Create a Button. MenuButton(ButtonListener* listener, const std::wstring& text, ViewMenuDelegate* menu_delegate, @@ -51,7 +50,7 @@ class MenuButton : public TextButton { virtual void Paint(gfx::Canvas* canvas, bool for_drag); // These methods are overriden to implement a simple push button - // behavior + // behavior. virtual bool OnMousePressed(const MouseEvent& e); virtual void OnMouseReleased(const MouseEvent& e, bool canceled); virtual void OnMouseExited(const MouseEvent& event); |