Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(582)

Side by Side Diff: ui/views/examples/fill_example.cc

Issue 2230913003: Experimental alignment layout manager using a property on the views Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed AlignAttribute and associated types to FillAttribute Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/examples/fill_example.h ('k') | ui/views/fill_attribute.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/examples/fill_example.h"
6
7 #include "base/macros.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "build/build_config.h"
10 #include "ui/views/background.h"
11 #include "ui/views/border.h"
12 #include "ui/views/controls/button/label_button.h"
13 #include "ui/views/controls/label.h"
14 #include "ui/views/layout/align_layout.h"
15 #include "ui/views/view.h"
16 #include "ui/views/widget/widget.h"
17
18 using base::ASCIIToUTF16;
19
20 namespace views {
21 namespace examples {
22
23 FillExample::FillExample() : ExampleBase("Fill") {}
24
25 FillExample::~FillExample() {}
26
27 void FillExample::CreateExampleView(View* container) {
28 container->SetLayoutManager(new AlignLayout());
29 new_fill_view_button_ = new LabelButton(this, ASCIIToUTF16("New View"));
30 new_fill_view_button_->SetFocusForPlatform();
31 new_fill_view_button_->set_request_focus_on_press(true);
32 new_fill_view_button_->SetStyle(Button::STYLE_BUTTON);
33 new_fill_view_button_->attributes().Add(
34 base::WrapUnique(new FillAttribute(views::Fill::Content)));
35 container->AddChildView(new_fill_view_button_);
36 }
37
38 void FillExample::ButtonPressed(Button* sender, const ui::Event& event) {
39 Label* label = new Label(LabelText(current_fill_));
40 label->SetBorder(Border::CreateSolidBorder(1, SK_ColorGRAY));
41 label->attributes().Add(base::WrapUnique(new FillAttribute(current_fill_)));
42 label->SetBounds(0, 0, 20, 20);
43 sender->parent()->AddChildView(label);
44 sender->parent()->Layout();
45 switch (current_fill_) {
46 case views::Fill::Top: {
47 current_fill_ = views::Fill::Bottom;
48 break;
49 }
50 case views::Fill::Bottom: {
51 current_fill_ = views::Fill::Left;
52 break;
53 }
54 case views::Fill::Left: {
55 current_fill_ = views::Fill::Right;
56 break;
57 }
58 case views::Fill::Right: {
59 current_fill_ = views::Fill::Top;
60 break;
61 }
62 default:
63 current_fill_ = views::Fill::Top;
64 }
65 }
66
67 base::string16 FillExample::LabelText(views::Fill fill) {
68 switch (fill) {
69 case views::Fill::Top:
70 return ASCIIToUTF16("Top Align");
71 case views::Fill::Bottom:
72 return ASCIIToUTF16("Bottom Align");
73 case views::Fill::Left:
74 return ASCIIToUTF16("Left Align");
75 case views::Fill::Right:
76 return ASCIIToUTF16("Right Align");
77 default:
78 return ASCIIToUTF16("None Or Content Align");
79 }
80 }
81
82 } // namespace examples
83 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/examples/fill_example.h ('k') | ui/views/fill_attribute.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698