| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/setting_level_bubble_view.h" | 5 #include "chrome/browser/chromeos/setting_level_bubble_view.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 } // namespace | 26 } // namespace |
| 27 | 27 |
| 28 namespace chromeos { | 28 namespace chromeos { |
| 29 | 29 |
| 30 SettingLevelBubbleView::SettingLevelBubbleView() | 30 SettingLevelBubbleView::SettingLevelBubbleView() |
| 31 : progress_bar_(NULL), | 31 : progress_bar_(NULL), |
| 32 icon_(NULL) { | 32 icon_(NULL) { |
| 33 } | 33 } |
| 34 | 34 |
| 35 void SettingLevelBubbleView::Init(SkBitmap* icon, | 35 void SettingLevelBubbleView::Init(SkBitmap* icon, double level, bool enabled) { |
| 36 int level_percent, | |
| 37 bool enabled) { | |
| 38 DCHECK(icon); | 36 DCHECK(icon); |
| 39 DCHECK(level_percent >= 0 && level_percent <= 100); | |
| 40 icon_ = icon; | 37 icon_ = icon; |
| 41 progress_bar_ = new views::ProgressBar(); | 38 progress_bar_ = new views::ProgressBar(); |
| 42 AddChildView(progress_bar_); | 39 AddChildView(progress_bar_); |
| 40 progress_bar_->SetDisplayRange(0.0, 100.0); |
| 43 progress_bar_->EnableCanvasFlippingForRTLUI(true); | 41 progress_bar_->EnableCanvasFlippingForRTLUI(true); |
| 44 EnableCanvasFlippingForRTLUI(true); | 42 EnableCanvasFlippingForRTLUI(true); |
| 45 SetLevel(level_percent); | 43 SetLevel(level); |
| 46 SetEnabled(enabled); | 44 SetEnabled(enabled); |
| 47 } | 45 } |
| 48 | 46 |
| 49 void SettingLevelBubbleView::SetIcon(SkBitmap* icon) { | 47 void SettingLevelBubbleView::SetIcon(SkBitmap* icon) { |
| 50 DCHECK(icon); | 48 DCHECK(icon); |
| 51 icon_ = icon; | 49 icon_ = icon; |
| 52 SchedulePaint(); | 50 SchedulePaint(); |
| 53 } | 51 } |
| 54 | 52 |
| 55 void SettingLevelBubbleView::SetLevel(int level_percent) { | 53 void SettingLevelBubbleView::SetLevel(double level) { |
| 56 DCHECK(level_percent >= 0 && level_percent <= 100); | 54 progress_bar_->SetValue(level); |
| 57 progress_bar_->SetProgress(level_percent); | |
| 58 } | 55 } |
| 59 | 56 |
| 60 void SettingLevelBubbleView::SetEnabled(bool enabled) { | 57 void SettingLevelBubbleView::SetEnabled(bool enabled) { |
| 61 progress_bar_->SetEnabled(enabled); | 58 progress_bar_->SetEnabled(enabled); |
| 62 } | 59 } |
| 63 | 60 |
| 64 void SettingLevelBubbleView::OnPaint(gfx::Canvas* canvas) { | 61 void SettingLevelBubbleView::OnPaint(gfx::Canvas* canvas) { |
| 65 views::View::OnPaint(canvas); | 62 views::View::OnPaint(canvas); |
| 66 canvas->DrawBitmapInt(*icon_, kPadding, (height() - icon_->height()) / 2); | 63 canvas->DrawBitmapInt(*icon_, kPadding, (height() - icon_->height()) / 2); |
| 67 } | 64 } |
| 68 | 65 |
| 69 void SettingLevelBubbleView::Layout() { | 66 void SettingLevelBubbleView::Layout() { |
| 70 progress_bar_->SetBounds(width() - kPadding - kProgressBarWidth, | 67 progress_bar_->SetBounds(width() - kPadding - kProgressBarWidth, |
| 71 (height() - kProgressBarHeight) / 2, | 68 (height() - kProgressBarHeight) / 2, |
| 72 kProgressBarWidth, kProgressBarHeight); | 69 kProgressBarWidth, kProgressBarHeight); |
| 73 } | 70 } |
| 74 | 71 |
| 75 gfx::Size SettingLevelBubbleView::GetPreferredSize() { | 72 gfx::Size SettingLevelBubbleView::GetPreferredSize() { |
| 76 return gfx::Size(kWidth, kHeight); | 73 return gfx::Size(kWidth, kHeight); |
| 77 } | 74 } |
| 78 | 75 |
| 79 } // namespace chromeos | 76 } // namespace chromeos |
| OLD | NEW |