diff options
author | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 23:42:10 +0000 |
---|---|---|
committer | jamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-21 23:42:10 +0000 |
commit | 7b7284b5bff831a811eaca8fae460143ed0a4dc5 (patch) | |
tree | c96f9a444f983be7c35b8c9f5bd4f430796667c3 /ash | |
parent | 85febf0f25dabcfe35e9aade2d44dfaab7d6e3db (diff) | |
download | chromium_src-7b7284b5bff831a811eaca8fae460143ed0a4dc5.zip chromium_src-7b7284b5bff831a811eaca8fae460143ed0a4dc5.tar.gz chromium_src-7b7284b5bff831a811eaca8fae460143ed0a4dc5.tar.bz2 |
Change immersive mode button to toggle
BUG=none
TEST=manual, button changes toggle state when clicked
Review URL: https://chromiumcodereview.appspot.com/11421017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/frame_painter.cc | 22 | ||||
-rw-r--r-- | ash/wm/frame_painter.h | 14 | ||||
-rw-r--r-- | ash/wm/frame_painter_unittest.cc | 3 |
3 files changed, 33 insertions, 6 deletions
diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc index a4b4c70..2ca029b 100644 --- a/ash/wm/frame_painter.cc +++ b/ash/wm/frame_painter.cc @@ -233,7 +233,7 @@ void FramePainter::UpdateSoloWindowHeader(RootWindow* root_window) { UpdateSoloWindowInRoot(root_window, NULL /* ignorable_window */); } -void FramePainter::AddImmersiveButton(views::ImageButton* button) { +void FramePainter::AddImmersiveButton(views::ToggleImageButton* button) { DCHECK(button); immersive_button_ = button; immersive_button_->SetVisible(frame_->IsMaximized()); @@ -556,11 +556,16 @@ void FramePainter::LayoutHeader(views::NonClientFrameView* view, } if (immersive_button_) { - // TODO(jamescook): Need real art. + // TODO(jamescook): Need real art. crbug.com/160897 SetButtonImages(immersive_button_, IDR_AURA_UBER_TRAY_DISPLAY, IDR_AURA_UBER_TRAY_DISPLAY_HOVER, IDR_AURA_UBER_TRAY_DISPLAY_PRESSED); + // TODO(jamescook): This needs real art too. crbug.com/160897 + SetToggledButtonImages(immersive_button_, + IDR_AURA_UBER_TRAY_DISPLAY_HOVER, + IDR_AURA_UBER_TRAY_DISPLAY_HOVER, + IDR_AURA_UBER_TRAY_DISPLAY_PRESSED); } gfx::Size close_size = close_button_->GetPreferredSize(); @@ -702,6 +707,19 @@ void FramePainter::SetButtonImages(views::ImageButton* button, theme_provider->GetImageSkiaNamed(pushed_image_id)); } +void FramePainter::SetToggledButtonImages(views::ToggleImageButton* button, + int normal_image_id, + int hot_image_id, + int pushed_image_id) { + ui::ThemeProvider* theme_provider = frame_->GetThemeProvider(); + button->SetToggledImage(views::CustomButton::STATE_NORMAL, + theme_provider->GetImageSkiaNamed(normal_image_id)); + button->SetToggledImage(views::CustomButton::STATE_HOVERED, + theme_provider->GetImageSkiaNamed(hot_image_id)); + button->SetToggledImage(views::CustomButton::STATE_PRESSED, + theme_provider->GetImageSkiaNamed(pushed_image_id)); +} + int FramePainter::GetTitleOffsetX() const { return window_icon_ ? window_icon_->bounds().right() + kTitleIconOffsetX : diff --git a/ash/wm/frame_painter.h b/ash/wm/frame_painter.h index d2b6fb7..91b6571 100644 --- a/ash/wm/frame_painter.h +++ b/ash/wm/frame_painter.h @@ -33,6 +33,7 @@ class SlideAnimation; namespace views { class ImageButton; class NonClientFrameView; +class ToggleImageButton; class View; class Widget; } @@ -76,7 +77,7 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, static void UpdateSoloWindowHeader(aura::RootWindow* root_window); // Adds an "immersive mode" button to the layout. Does not take ownership. - void AddImmersiveButton(views::ImageButton* button); + void AddImmersiveButton(views::ToggleImageButton* button); // Helpers for views::NonClientFrameView implementations. gfx::Rect GetBoundsForClientView(int top_height, @@ -148,12 +149,19 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, FRIEND_TEST_ALL_PREFIXES(FramePainterTest, UseSoloWindowHeaderMultiDisplay); FRIEND_TEST_ALL_PREFIXES(FramePainterTest, GetHeaderOpacity); - // Sets the images for a button base on IDs from the |frame_| theme provider. + // Sets the images for a button based on IDs from the |frame_| theme provider. void SetButtonImages(views::ImageButton* button, int normal_image_id, int hot_image_id, int pushed_image_id); + // Sets the toggled-state button images for a button based on IDs from the + // |frame_| theme provider. + void SetToggledButtonImages(views::ToggleImageButton* button, + int normal_image_id, + int hot_image_id, + int pushed_image_id); + // Returns the offset between window left edge and title string. int GetTitleOffsetX() const; @@ -204,7 +212,7 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, views::View* window_icon_; // May be NULL. views::ImageButton* size_button_; views::ImageButton* close_button_; - views::ImageButton* immersive_button_; // May be NULL. + views::ToggleImageButton* immersive_button_; // May be NULL. aura::Window* window_; // Window frame header/caption parts. diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc index 070cde23..6ff1b5d 100644 --- a/ash/wm/frame_painter_unittest.cc +++ b/ash/wm/frame_painter_unittest.cc @@ -24,6 +24,7 @@ using views::Widget; using views::ImageButton; +using views::ToggleImageButton; namespace { @@ -141,7 +142,7 @@ TEST_F(FramePainterTest, ImmersiveButton) { EXPECT_EQ(NULL, painter.immersive_button_); // Add an immersive button. - ImageButton immersive(NULL); + ToggleImageButton immersive(NULL); painter.AddImmersiveButton(&immersive); // Immersive button starts invisible. |