| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "athena/wm/overview_toolbar.h" | 5 #include "athena/wm/overview_toolbar.h" |
| 6 | 6 |
| 7 #include "athena/resources/grit/athena_resources.h" | 7 #include "athena/resources/grit/athena_resources.h" |
| 8 #include "athena/strings/grit/athena_strings.h" |
| 8 #include "base/bind.h" | 9 #include "base/bind.h" |
| 9 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 12 #include "ui/base/l10n/l10n_util.h" |
| 12 #include "ui/base/resource/resource_bundle.h" | 13 #include "ui/base/resource/resource_bundle.h" |
| 13 #include "ui/compositor/closure_animation_observer.h" | 14 #include "ui/compositor/closure_animation_observer.h" |
| 14 #include "ui/compositor/layer.h" | 15 #include "ui/compositor/layer.h" |
| 15 #include "ui/compositor/layer_delegate.h" | 16 #include "ui/compositor/layer_delegate.h" |
| 16 #include "ui/compositor/scoped_layer_animation_settings.h" | 17 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 18 #include "ui/gfx/canvas.h" | 19 #include "ui/gfx/canvas.h" |
| 19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 const int kActionButtonImageSize = 54; | 24 const int kActionButtonImageSize = 54; |
| 24 const int kActionButtonTextSize = 20; | 25 const int kActionButtonTextSize = 20; |
| 25 const int kActionButtonPaddingFromRight = 32; | 26 const int kActionButtonPaddingFromRight = 32; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace athena { | 29 namespace athena { |
| 29 | 30 |
| 30 class ActionButton : public ui::LayerDelegate { | 31 class ActionButton : public ui::LayerDelegate { |
| 31 public: | 32 public: |
| 32 ActionButton(int resource_id, const std::string& label) | 33 ActionButton(int resource_id, const base::string16& label) |
| 33 : resource_id_(resource_id), label_(base::UTF8ToUTF16(label)) { | 34 : resource_id_(resource_id), label_(label) { |
| 34 layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); | 35 layer_.reset(new ui::Layer(ui::LAYER_TEXTURED)); |
| 35 layer_->set_delegate(this); | 36 layer_->set_delegate(this); |
| 36 layer_->SetFillsBoundsOpaquely(false); | 37 layer_->SetFillsBoundsOpaquely(false); |
| 37 layer_->SetVisible(true); | 38 layer_->SetVisible(true); |
| 38 layer_->SetOpacity(0); | 39 layer_->SetOpacity(0); |
| 39 } | 40 } |
| 40 | 41 |
| 41 virtual ~ActionButton() {} | 42 virtual ~ActionButton() {} |
| 42 | 43 |
| 43 static void DestroyAfterFadeout(scoped_ptr<ActionButton> button) { | 44 static void DestroyAfterFadeout(scoped_ptr<ActionButton> button) { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 int resource_id_; | 93 int resource_id_; |
| 93 base::string16 label_; | 94 base::string16 label_; |
| 94 scoped_ptr<ui::Layer> layer_; | 95 scoped_ptr<ui::Layer> layer_; |
| 95 | 96 |
| 96 DISALLOW_COPY_AND_ASSIGN(ActionButton); | 97 DISALLOW_COPY_AND_ASSIGN(ActionButton); |
| 97 }; | 98 }; |
| 98 | 99 |
| 99 OverviewToolbar::OverviewToolbar(aura::Window* container) | 100 OverviewToolbar::OverviewToolbar(aura::Window* container) |
| 100 : shown_(false), | 101 : shown_(false), |
| 101 disabled_action_bitfields_(0), | 102 disabled_action_bitfields_(0), |
| 102 close_(new ActionButton(IDR_ATHENA_OVERVIEW_TRASH, "Close")), | 103 close_(new ActionButton( |
| 103 split_(new ActionButton(IDR_ATHENA_OVERVIEW_SPLIT, "Split")), | 104 IDR_ATHENA_OVERVIEW_TRASH, |
| 105 l10n_util::GetStringUTF16(IDS_ATHENA_OVERVIEW_CLOSE))), |
| 106 split_(new ActionButton( |
| 107 IDR_ATHENA_OVERVIEW_SPLIT, |
| 108 l10n_util::GetStringUTF16(IDS_ATHENA_OVERVIEW_SPLIT))), |
| 104 current_action_(ACTION_TYPE_NONE), | 109 current_action_(ACTION_TYPE_NONE), |
| 105 container_bounds_(container->bounds()) { | 110 container_bounds_(container->bounds()) { |
| 106 const int kPaddingFromBottom = 200; | 111 const int kPaddingFromBottom = 200; |
| 107 const int kPaddingBetweenButtons = 200; | 112 const int kPaddingBetweenButtons = 200; |
| 108 | 113 |
| 109 int x = container_bounds_.right() - | 114 int x = container_bounds_.right() - |
| 110 (kActionButtonPaddingFromRight + kActionButtonImageSize); | 115 (kActionButtonPaddingFromRight + kActionButtonImageSize); |
| 111 int y = container_bounds_.bottom() - | 116 int y = container_bounds_.bottom() - |
| 112 (kPaddingFromBottom + kActionButtonImageSize); | 117 (kPaddingFromBottom + kActionButtonImageSize); |
| 113 split_->SetPosition(gfx::Point(x, y)); | 118 split_->SetPosition(gfx::Point(x, y)); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 button->layer()->GetAnimator()); | 211 button->layer()->GetAnimator()); |
| 207 split_settings.SetTweenType(gfx::Tween::SMOOTH_IN_OUT); | 212 split_settings.SetTweenType(gfx::Tween::SMOOTH_IN_OUT); |
| 208 button->layer()->SetTransform(ComputeTransformFor(button)); | 213 button->layer()->SetTransform(ComputeTransformFor(button)); |
| 209 bool button_is_enabled = | 214 bool button_is_enabled = |
| 210 (button == close_.get() && IsActionEnabled(ACTION_TYPE_CLOSE)) || | 215 (button == close_.get() && IsActionEnabled(ACTION_TYPE_CLOSE)) || |
| 211 (button == split_.get() && IsActionEnabled(ACTION_TYPE_SPLIT)); | 216 (button == split_.get() && IsActionEnabled(ACTION_TYPE_SPLIT)); |
| 212 button->layer()->SetOpacity((button_is_enabled && shown_) ? 1 : 0); | 217 button->layer()->SetOpacity((button_is_enabled && shown_) ? 1 : 0); |
| 213 } | 218 } |
| 214 | 219 |
| 215 } // namespace athena | 220 } // namespace athena |
| OLD | NEW |