| 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/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "ui/views/bubble/bubble_delegate.h" | 9 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 10 #include "ui/views/controls/button/label_button.h" | 10 #include "ui/views/controls/button/label_button.h" |
| 11 #include "ui/views/controls/label.h" | 11 #include "ui/views/controls/label.h" |
| 12 #include "ui/views/layout/box_layout.h" | 12 #include "ui/views/layout/box_layout.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 | 14 |
| 15 using base::ASCIIToUTF16; | 15 using base::ASCIIToUTF16; |
| 16 | 16 |
| 17 namespace views { | 17 namespace views { |
| 18 namespace examples { | 18 namespace examples { |
| 19 | 19 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 42 case BubbleBorder::TOP_CENTER: return ASCIIToUTF16("TOP_CENTER"); | 42 case BubbleBorder::TOP_CENTER: return ASCIIToUTF16("TOP_CENTER"); |
| 43 case BubbleBorder::BOTTOM_CENTER: return ASCIIToUTF16("BOTTOM_CENTER"); | 43 case BubbleBorder::BOTTOM_CENTER: return ASCIIToUTF16("BOTTOM_CENTER"); |
| 44 case BubbleBorder::LEFT_CENTER: return ASCIIToUTF16("LEFT_CENTER"); | 44 case BubbleBorder::LEFT_CENTER: return ASCIIToUTF16("LEFT_CENTER"); |
| 45 case BubbleBorder::RIGHT_CENTER: return ASCIIToUTF16("RIGHT_CENTER"); | 45 case BubbleBorder::RIGHT_CENTER: return ASCIIToUTF16("RIGHT_CENTER"); |
| 46 case BubbleBorder::NONE: return ASCIIToUTF16("NONE"); | 46 case BubbleBorder::NONE: return ASCIIToUTF16("NONE"); |
| 47 case BubbleBorder::FLOAT: return ASCIIToUTF16("FLOAT"); | 47 case BubbleBorder::FLOAT: return ASCIIToUTF16("FLOAT"); |
| 48 } | 48 } |
| 49 return ASCIIToUTF16("INVALID"); | 49 return ASCIIToUTF16("INVALID"); |
| 50 } | 50 } |
| 51 | 51 |
| 52 class ExampleBubble : public BubbleDelegateView { | 52 class ExampleBubble : public BubbleDialogDelegateView { |
| 53 public: | 53 public: |
| 54 ExampleBubble(View* anchor, BubbleBorder::Arrow arrow) | 54 ExampleBubble(View* anchor, BubbleBorder::Arrow arrow) |
| 55 : BubbleDelegateView(anchor, arrow) {} | 55 : BubbleDialogDelegateView(anchor, arrow) {} |
| 56 | 56 |
| 57 protected: | 57 protected: |
| 58 int GetDialogButtons() const override { return ui::DIALOG_BUTTON_NONE; } |
| 59 |
| 58 void Init() override { | 60 void Init() override { |
| 59 SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 50, 50, 0)); | 61 SetLayoutManager(new BoxLayout(BoxLayout::kVertical, 50, 50, 0)); |
| 60 AddChildView(new Label(GetArrowName(arrow()))); | 62 AddChildView(new Label(GetArrowName(arrow()))); |
| 61 } | 63 } |
| 62 | 64 |
| 63 private: | 65 private: |
| 64 DISALLOW_COPY_AND_ASSIGN(ExampleBubble); | 66 DISALLOW_COPY_AND_ASSIGN(ExampleBubble); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 } // namespace | 69 } // namespace |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 else if (sender == big_shadow_) | 112 else if (sender == big_shadow_) |
| 111 bubble->set_shadow(BubbleBorder::BIG_SHADOW); | 113 bubble->set_shadow(BubbleBorder::BIG_SHADOW); |
| 112 else if (sender == small_shadow_) | 114 else if (sender == small_shadow_) |
| 113 bubble->set_shadow(BubbleBorder::SMALL_SHADOW); | 115 bubble->set_shadow(BubbleBorder::SMALL_SHADOW); |
| 114 else if (sender == no_assets_) | 116 else if (sender == no_assets_) |
| 115 bubble->set_shadow(BubbleBorder::NO_ASSETS); | 117 bubble->set_shadow(BubbleBorder::NO_ASSETS); |
| 116 | 118 |
| 117 if (sender == persistent_) | 119 if (sender == persistent_) |
| 118 bubble->set_close_on_deactivate(false); | 120 bubble->set_close_on_deactivate(false); |
| 119 | 121 |
| 120 BubbleDelegateView::CreateBubble(bubble); | 122 BubbleDialogDelegateView::CreateBubble(bubble); |
| 121 if (sender == align_to_edge_) | 123 if (sender == align_to_edge_) |
| 122 bubble->SetAlignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 124 bubble->SetAlignment(BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
| 123 | 125 |
| 124 bubble->GetWidget()->Show(); | 126 bubble->GetWidget()->Show(); |
| 125 } | 127 } |
| 126 | 128 |
| 127 } // namespace examples | 129 } // namespace examples |
| 128 } // namespace views | 130 } // namespace views |
| OLD | NEW |