OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "aura/desktop.h" | |
6 #include "aura/desktop_host.h" | |
7 #include "aura/window.h" | |
8 #include "aura/window_delegate.h" | |
9 #include "base/at_exit.h" | |
10 #include "base/command_line.h" | |
11 #include "base/i18n/icu_util.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/message_loop.h" | |
14 #include "third_party/skia/include/core/SkXfermode.h" | |
15 #include "ui/base/resource/resource_bundle.h" | |
16 #include "ui/base/ui_base_paths.h" | |
17 #include "ui/gfx/canvas.h" | |
18 #include "ui/gfx/canvas_skia.h" | |
19 #include "ui/gfx/rect.h" | |
20 #include "views/widget/widget.h" | |
21 | |
22 namespace { | |
23 | |
24 // Trivial WindowDelegate implementation that draws a colored background. | |
25 class DemoWindowDelegate : public aura::WindowDelegate { | |
26 public: | |
27 explicit DemoWindowDelegate(SkColor color) : color_(color) {} | |
28 | |
29 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | |
30 canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode); | |
31 } | |
32 | |
33 private: | |
34 SkColor color_; | |
35 | |
36 DISALLOW_COPY_AND_ASSIGN(DemoWindowDelegate); | |
37 }; | |
38 | |
39 class TestView : public views::View { | |
40 public: | |
41 TestView() {} | |
42 virtual ~TestView() {} | |
43 | |
44 private: | |
45 // Overridden from views::View: | |
46 virtual void OnPaint(gfx::Canvas* canvas) { | |
47 canvas->FillRectInt(SK_ColorYELLOW, 0, 0, width(), height()); | |
48 } | |
49 | |
50 DISALLOW_COPY_AND_ASSIGN(TestView); | |
51 }; | |
52 | |
53 } // namespace | |
54 | |
55 int main(int argc, char** argv) { | |
56 CommandLine::Init(argc, argv); | |
57 | |
58 // The exit manager is in charge of calling the dtors of singleton objects. | |
59 base::AtExitManager exit_manager; | |
60 | |
61 ui::RegisterPathProvider(); | |
62 icu_util::Initialize(); | |
63 ResourceBundle::InitSharedInstance("en-US"); | |
64 | |
65 #if defined(USE_X11) | |
66 base::MessagePumpX::DisableGtkMessagePump(); | |
67 #endif | |
68 | |
69 aura::Desktop::GetInstance(); | |
70 | |
71 // Create a hierarchy of test windows. | |
72 DemoWindowDelegate window_delegate1(SK_ColorBLUE); | |
73 aura::Window window1(&window_delegate1); | |
74 window1.set_id(1); | |
75 window1.Init(); | |
76 window1.SetBounds(gfx::Rect(100, 100, 400, 400), 0); | |
77 window1.SetVisibility(aura::Window::VISIBILITY_SHOWN); | |
78 window1.SetParent(NULL); | |
79 | |
80 DemoWindowDelegate window_delegate2(SK_ColorRED); | |
81 aura::Window window2(&window_delegate2); | |
82 window2.set_id(2); | |
83 window2.Init(); | |
84 window2.SetBounds(gfx::Rect(200, 200, 350, 350), 0); | |
85 window2.SetVisibility(aura::Window::VISIBILITY_SHOWN); | |
86 window2.SetParent(NULL); | |
87 | |
88 DemoWindowDelegate window_delegate3(SK_ColorGREEN); | |
89 aura::Window window3(&window_delegate3); | |
90 window3.set_id(3); | |
91 window3.Init(); | |
92 window3.SetBounds(gfx::Rect(10, 10, 50, 50), 0); | |
93 window3.SetVisibility(aura::Window::VISIBILITY_SHOWN); | |
94 window3.SetParent(&window2); | |
95 | |
96 views::Widget widget; | |
97 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | |
98 params.bounds = gfx::Rect(75, 75, 80, 80); | |
99 params.parent = &window2; | |
100 widget.Init(params); | |
101 widget.SetContentsView(new TestView); | |
102 | |
103 aura::Desktop::GetInstance()->Run(); | |
104 return 0; | |
105 } | |
106 | |
OLD | NEW |