| 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 "ui/views/examples/bubble_example.h" | 5 #include "ui/views/examples/bubble_example.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "ui/views/bubble/bubble_delegate.h" | 8 #include "ui/views/bubble/bubble_delegate.h" |
| 9 #include "ui/views/controls/button/text_button.h" | 9 #include "ui/views/controls/button/label_button.h" |
| 10 #include "ui/views/controls/label.h" | 10 #include "ui/views/controls/label.h" |
| 11 #include "ui/views/layout/box_layout.h" | 11 #include "ui/views/layout/box_layout.h" |
| 12 #include "ui/views/layout/fill_layout.h" | 12 #include "ui/views/layout/fill_layout.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 namespace examples { | 16 namespace examples { |
| 17 | 17 |
| 18 struct BubbleConfig { | 18 struct BubbleConfig { |
| 19 string16 label; | 19 string16 label; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 string16 label_; | 54 string16 label_; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 BubbleExample::BubbleExample() : ExampleBase("Bubble") {} | 57 BubbleExample::BubbleExample() : ExampleBase("Bubble") {} |
| 58 | 58 |
| 59 BubbleExample::~BubbleExample() {} | 59 BubbleExample::~BubbleExample() {} |
| 60 | 60 |
| 61 void BubbleExample::CreateExampleView(View* container) { | 61 void BubbleExample::CreateExampleView(View* container) { |
| 62 container->SetLayoutManager( | 62 container->SetLayoutManager(new BoxLayout(BoxLayout::kHorizontal, 0, 0, 1)); |
| 63 new BoxLayout(BoxLayout::kHorizontal, 0, 0, 1)); | 63 round_ = new LabelButton(this, kRoundConfig.label); |
| 64 round_ = new TextButton(this, kRoundConfig.label); | 64 arrow_ = new LabelButton(this, kArrowConfig.label); |
| 65 arrow_ = new TextButton(this, kArrowConfig.label); | 65 fade_in_ = new LabelButton(this, kFadeInConfig.label); |
| 66 fade_in_ = new TextButton(this, kFadeInConfig.label); | 66 fade_out_ = new LabelButton(this, kFadeOutConfig.label); |
| 67 fade_out_ = new TextButton(this, kFadeOutConfig.label); | |
| 68 container->AddChildView(round_); | 67 container->AddChildView(round_); |
| 69 container->AddChildView(arrow_); | 68 container->AddChildView(arrow_); |
| 70 container->AddChildView(fade_in_); | 69 container->AddChildView(fade_in_); |
| 71 container->AddChildView(fade_out_); | 70 container->AddChildView(fade_out_); |
| 72 } | 71 } |
| 73 | 72 |
| 74 void BubbleExample::ButtonPressed(Button* sender, const ui::Event& event) { | 73 void BubbleExample::ButtonPressed(Button* sender, const ui::Event& event) { |
| 75 BubbleConfig config; | 74 BubbleConfig config; |
| 76 if (sender == round_) | 75 if (sender == round_) |
| 77 config = kRoundConfig; | 76 config = kRoundConfig; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 93 bubble_delegate->GetWidget()->Show(); | 92 bubble_delegate->GetWidget()->Show(); |
| 94 | 93 |
| 95 if (config.fade_out) { | 94 if (config.fade_out) { |
| 96 bubble_delegate->set_close_on_esc(false); | 95 bubble_delegate->set_close_on_esc(false); |
| 97 bubble_delegate->StartFade(false); | 96 bubble_delegate->StartFade(false); |
| 98 } | 97 } |
| 99 } | 98 } |
| 100 | 99 |
| 101 } // namespace examples | 100 } // namespace examples |
| 102 } // namespace views | 101 } // namespace views |
| OLD | NEW |