OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_VIEWS_EXAMPLES_BOX_LAYOUT_EXAMPLE_H_ |
| 6 #define UI_VIEWS_EXAMPLES_BOX_LAYOUT_EXAMPLE_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "ui/views/controls/button/button.h" |
| 10 #include "ui/views/controls/button/label_button.h" |
| 11 #include "ui/views/controls/combobox/combobox_listener.h" |
| 12 #include "ui/views/controls/textfield/textfield_controller.h" |
| 13 #include "ui/views/examples/example_base.h" |
| 14 #include "ui/views/layout/box_layout.h" |
| 15 |
| 16 namespace views { |
| 17 |
| 18 class Checkbox; |
| 19 class Combobox; |
| 20 class Textfield; |
| 21 |
| 22 namespace examples { |
| 23 |
| 24 namespace { |
| 25 |
| 26 class ChildPanel; |
| 27 } |
| 28 |
| 29 class VIEWS_EXAMPLES_EXPORT BoxLayoutExample : public ExampleBase, |
| 30 public ButtonListener, |
| 31 public ComboboxListener, |
| 32 public TextfieldController { |
| 33 public: |
| 34 BoxLayoutExample(); |
| 35 ~BoxLayoutExample() override; |
| 36 |
| 37 // ExampleBase |
| 38 void CreateExampleView(View* container) override; |
| 39 |
| 40 private: |
| 41 friend class ChildPanel; |
| 42 // ButtonListener |
| 43 void ButtonPressed(Button* sender, const ui::Event& event) override; |
| 44 |
| 45 // ComboboxListener |
| 46 void OnPerformAction(Combobox* combobox) override; |
| 47 |
| 48 // TextfieldController |
| 49 void ContentsChanged(Textfield* sender, |
| 50 const base::string16& new_contents) override; |
| 51 |
| 52 // Force the box_layout_panel_ to layout and repaint. |
| 53 void RefreshLayoutPanel(); |
| 54 |
| 55 // Set the border insets on the current BoxLayout instance. |
| 56 void UpdateBorderInsets(); |
| 57 |
| 58 // Create a new BoxLayout and ensure all settings match the current state of |
| 59 // the various control_panel_ controls. |
| 60 void UpdateLayoutManager(); |
| 61 |
| 62 // Create a Combobox with a label with |label_text| to the left. Adjust |
| 63 // |vertical_pos| to |vertical_pos| + combo_box->height() + kSpacing. |
| 64 Combobox* CreateCombobox(const base::string16& label_text, |
| 65 const char** items, |
| 66 int count, |
| 67 int& vertical_pos); |
| 68 |
| 69 // Create just a Textfield at the current position of |horizontal_pos| and |
| 70 // |vertical_pos|. Update |horizontal_pos| to |horizontal_pos| + |
| 71 // text_field->width() + kSpacing. |
| 72 Textfield* CreateRawTextfield(int& horizontal_pos, |
| 73 int vertical_pos, |
| 74 bool add); |
| 75 |
| 76 // Create a Textfield with a label with |label_text| to the left. Adjust |
| 77 // |vertical_pos| to |vertical_pos| + combo_box->height() + kSpacing. |
| 78 Textfield* CreateTextfield(const base::string16& label_text, |
| 79 int& vertical_pos); |
| 80 |
| 81 // Returns the current values contained in the child_panel_size_[] Textfields |
| 82 // as a gfx::Size. If either value is negative or not a valid integer, |
| 83 // default values are returned, 180 x 90 for width and height, respectively. |
| 84 gfx::Size GetChildPanelSize() const; |
| 85 |
| 86 BoxLayout* layout_ = nullptr; |
| 87 View* full_panel_ = nullptr; |
| 88 View* box_layout_panel_ = nullptr; |
| 89 View* control_panel_ = nullptr; |
| 90 LabelButton* add_button_ = nullptr; |
| 91 Combobox* orientation_ = nullptr; |
| 92 Combobox* main_axis_alignment_ = nullptr; |
| 93 Combobox* cross_axis_alignment_ = nullptr; |
| 94 Textfield* between_child_spacing_ = nullptr; |
| 95 Textfield* default_flex_ = nullptr; |
| 96 Textfield* min_cross_axis_size_ = nullptr; |
| 97 Textfield* border_insets_[4] = {nullptr, nullptr, nullptr, nullptr}; |
| 98 Textfield* child_panel_size_[2] = {nullptr, nullptr}; |
| 99 Checkbox* collapse_margins_ = nullptr; |
| 100 int panel_count_ = 0; |
| 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(BoxLayoutExample); |
| 103 }; |
| 104 |
| 105 } // namespace examples |
| 106 } // namespace views |
| 107 #endif // UI_VIEWS_EXAMPLES_BOX_LAYOUT_EXAMPLE_H_ |
OLD | NEW |