OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/network/tray_network.h" | 5 #include "ash/system/network/tray_network.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 virtual ~NonActivatableSettingsBubble() {} | 79 virtual ~NonActivatableSettingsBubble() {} |
80 | 80 |
81 virtual bool CanActivate() const OVERRIDE { | 81 virtual bool CanActivate() const OVERRIDE { |
82 return false; | 82 return false; |
83 } | 83 } |
84 | 84 |
85 private: | 85 private: |
86 DISALLOW_COPY_AND_ASSIGN(NonActivatableSettingsBubble); | 86 DISALLOW_COPY_AND_ASSIGN(NonActivatableSettingsBubble); |
87 }; | 87 }; |
88 | 88 |
89 // A ToggleImageButton with fixed size, paddings and hover effects. These | |
90 // buttons are used in the header. | |
91 class HeaderButton : public views::ToggleImageButton { | |
92 public: | |
93 HeaderButton(views::ButtonListener* listener, | |
94 int enabled_resource_id, | |
95 int disabled_resource_id) | |
96 : views::ToggleImageButton(listener) { | |
97 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | |
98 SetImage(views::CustomButton::BS_NORMAL, | |
99 bundle.GetImageNamed(enabled_resource_id).ToSkBitmap()); | |
100 SetToggledImage(views::CustomButton::BS_NORMAL, | |
101 bundle.GetImageNamed(disabled_resource_id).ToSkBitmap()); | |
102 SetImageAlignment(views::ImageButton::ALIGN_CENTER, | |
103 views::ImageButton::ALIGN_MIDDLE); | |
104 set_background(views::Background::CreateSolidBackground( | |
105 ash::kHeaderBackgroundColor)); | |
106 } | |
107 | |
108 virtual ~HeaderButton() {} | |
109 | |
110 private: | |
111 // Overridden from views::View. | |
112 virtual gfx::Size GetPreferredSize() OVERRIDE { | |
113 return gfx::Size(ash::kTrayPopupItemHeight, ash::kTrayPopupItemHeight); | |
114 } | |
115 | |
116 virtual void OnPaintBorder(gfx::Canvas* canvas) OVERRIDE { | |
117 // Left border. | |
118 canvas->FillRect(gfx::Rect(0, 0, 1, height()), ash::kBorderDarkColor); | |
119 } | |
120 | |
121 // Overridden from views::CustomButton. | |
122 virtual void StateChanged() OVERRIDE { | |
123 set_background(views::Background::CreateSolidBackground( | |
124 IsHotTracked() ? ash::kHeaderHoverBackgroundColor : | |
125 ash::kHeaderBackgroundColor)); | |
126 } | |
127 | |
128 DISALLOW_COPY_AND_ASSIGN(HeaderButton); | |
129 }; | |
130 | |
131 } // namespace | 89 } // namespace |
132 | 90 |
133 namespace ash { | 91 namespace ash { |
134 namespace internal { | 92 namespace internal { |
135 | 93 |
136 namespace tray { | 94 namespace tray { |
137 | 95 |
138 enum ColorTheme { | 96 enum ColorTheme { |
139 LIGHT, | 97 LIGHT, |
140 DARK, | 98 DARK, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 AddChildView(header_); | 226 AddChildView(header_); |
269 } | 227 } |
270 | 228 |
271 void AppendHeaderButtons() { | 229 void AppendHeaderButtons() { |
272 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 230 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
273 | 231 |
274 header_buttons_ = new views::View; | 232 header_buttons_ = new views::View; |
275 header_buttons_->SetLayoutManager(new | 233 header_buttons_->SetLayoutManager(new |
276 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 234 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
277 | 235 |
278 button_wifi_ = new HeaderButton(this, | 236 button_wifi_ = new TrayPopupHeaderButton(this, |
279 IDR_AURA_UBER_TRAY_WIFI_ENABLED, | 237 IDR_AURA_UBER_TRAY_WIFI_ENABLED, |
280 IDR_AURA_UBER_TRAY_WIFI_DISABLED); | 238 IDR_AURA_UBER_TRAY_WIFI_DISABLED); |
281 button_wifi_->SetToggled(!delegate->GetWifiEnabled()); | 239 button_wifi_->SetToggled(!delegate->GetWifiEnabled()); |
282 header_buttons_->AddChildView(button_wifi_); | 240 header_buttons_->AddChildView(button_wifi_); |
283 | 241 |
284 if (delegate->GetCellularAvailable()) { | 242 if (delegate->GetCellularAvailable()) { |
285 button_cellular_ = new HeaderButton(this, | 243 button_cellular_ = new TrayPopupHeaderButton(this, |
286 IDR_AURA_UBER_TRAY_CELLULAR_ENABLED, | 244 IDR_AURA_UBER_TRAY_CELLULAR_ENABLED, |
287 IDR_AURA_UBER_TRAY_CELLULAR_DISABLED); | 245 IDR_AURA_UBER_TRAY_CELLULAR_DISABLED); |
288 button_cellular_->SetToggled(!delegate->GetCellularEnabled()); | 246 button_cellular_->SetToggled(!delegate->GetCellularEnabled()); |
289 header_buttons_->AddChildView(button_cellular_); | 247 header_buttons_->AddChildView(button_cellular_); |
290 } | 248 } |
291 | 249 |
292 info_icon_ = new HeaderButton(this, | 250 info_icon_ = new TrayPopupHeaderButton(this, |
293 IDR_AURA_UBER_TRAY_NETWORK_INFO, | 251 IDR_AURA_UBER_TRAY_NETWORK_INFO, |
294 IDR_AURA_UBER_TRAY_NETWORK_INFO); | 252 IDR_AURA_UBER_TRAY_NETWORK_INFO); |
295 header_buttons_->AddChildView(info_icon_); | 253 header_buttons_->AddChildView(info_icon_); |
296 | 254 |
297 header_->AddChildView(header_buttons_); | 255 header_->AddChildView(header_buttons_); |
298 } | 256 } |
299 | 257 |
300 void AppendNetworkEntries() { | 258 void AppendNetworkEntries() { |
301 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 259 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
302 std::vector<NetworkIconInfo> list; | 260 std::vector<NetworkIconInfo> list; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 if (tray_.get()) | 524 if (tray_.get()) |
567 tray_->Update(info); | 525 tray_->Update(info); |
568 if (default_.get()) | 526 if (default_.get()) |
569 default_->Update(); | 527 default_->Update(); |
570 if (detailed_.get()) | 528 if (detailed_.get()) |
571 detailed_->Update(); | 529 detailed_->Update(); |
572 } | 530 } |
573 | 531 |
574 } // namespace internal | 532 } // namespace internal |
575 } // namespace ash | 533 } // namespace ash |
OLD | NEW |