summaryrefslogtreecommitdiffstats
path: root/views/controls/button
diff options
context:
space:
mode:
authorchocobo@google.com <chocobo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 01:33:21 +0000
committerchocobo@google.com <chocobo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-08 01:33:21 +0000
commit7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01 (patch)
tree045a49a9bd5eb156517d391ff44d46a20f947a91 /views/controls/button
parent13555c122fbc9ec2a6c1a4cbace288ec7892be6e (diff)
downloadchromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.zip
chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.tar.gz
chromium_src-7598ab5ec8b6b9fe6bfaaa2ee07450747fd1ee01.tar.bz2
Refactor cros library code into central location and have the UI elements observe changes.
- implemented power menu button showing remaining battery info. - implemented clock menu button showing detailed clock info. - also implemented monitoring of network status change. - don't show highlighted state for these menu buttons BUG=23923 TEST=none Review URL: http://codereview.chromium.org/251099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28366 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/controls/button')
-rw-r--r--views/controls/button/custom_button.cc7
-rw-r--r--views/controls/button/custom_button.h6
-rw-r--r--views/controls/button/text_button.cc6
-rw-r--r--views/controls/button/text_button.h1
4 files changed, 19 insertions, 1 deletions
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index 348e527..67ee098 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.cc
@@ -19,7 +19,7 @@ CustomButton::~CustomButton() {
}
void CustomButton::SetState(ButtonState state) {
- if (state != state_) {
+ if (show_highlighted_ && state != state_) {
if (animate_on_state_change_ || !hover_animation_->IsAnimating()) {
animate_on_state_change_ = true;
if (state_ == BS_NORMAL && state == BS_HOT) {
@@ -48,6 +48,10 @@ void CustomButton::SetAnimationDuration(int duration) {
hover_animation_->SetSlideDuration(duration);
}
+void CustomButton::SetShowHighlighted(bool show_highlighted) {
+ show_highlighted_ = show_highlighted;
+}
+
////////////////////////////////////////////////////////////////////////////////
// CustomButton, View overrides:
@@ -74,6 +78,7 @@ CustomButton::CustomButton(ButtonListener* listener)
: Button(listener),
state_(BS_NORMAL),
animate_on_state_change_(true),
+ show_highlighted_(true),
triggerable_event_flags_(MouseEvent::EF_LEFT_BUTTON_DOWN) {
hover_animation_.reset(new ThrobAnimation(this));
hover_animation_->SetSlideDuration(kHoverFadeDurationMs);
diff --git a/views/controls/button/custom_button.h b/views/controls/button/custom_button.h
index f5b5cbe..032db17 100644
--- a/views/controls/button/custom_button.h
+++ b/views/controls/button/custom_button.h
@@ -41,6 +41,9 @@ class CustomButton : public Button,
// Set how long the hover animation will last for.
void SetAnimationDuration(int duration);
+ // Sets whether or not to show the highlighed (i.e. hot) state. Default true.
+ void SetShowHighlighted(bool show_highlighted);
+
// Overridden from View:
virtual void SetEnabled(bool enabled);
virtual bool IsEnabled() const;
@@ -105,6 +108,9 @@ class CustomButton : public Button,
// throbbing.
bool animate_on_state_change_;
+ // Whether or not to show the highlighted (i.e. hot) state.
+ bool show_highlighted_;
+
// Mouse event flags which can trigger button actions.
int triggerable_event_flags_;
diff --git a/views/controls/button/text_button.cc b/views/controls/button/text_button.cc
index 6bb3bec..a64648f 100644
--- a/views/controls/button/text_button.cc
+++ b/views/controls/button/text_button.cc
@@ -4,6 +4,8 @@
#include "views/controls/button/text_button.h"
+#include <algorithm>
+
#include "app/gfx/canvas.h"
#include "app/l10n_util.h"
#include "app/throb_animation.h"
@@ -184,6 +186,10 @@ void TextButton::SetIcon(const SkBitmap& icon) {
icon_ = icon;
}
+void TextButton::SetFont(const gfx::Font& font) {
+ font_ = font;
+}
+
void TextButton::SetEnabledColor(SkColor color) {
color_enabled_ = color;
UpdateColor();
diff --git a/views/controls/button/text_button.h b/views/controls/button/text_button.h
index bd2fcb69..20848db 100644
--- a/views/controls/button/text_button.h
+++ b/views/controls/button/text_button.h
@@ -94,6 +94,7 @@ class TextButton : public CustomButton {
void ClearMaxTextSize();
void set_max_width(int max_width) { max_width_ = max_width; }
+ void SetFont(const gfx::Font& font);
void SetEnabledColor(SkColor color);
void SetDisabledColor(SkColor color);
void SetHighlightColor(SkColor color);