diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 22:35:13 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-25 22:35:13 +0000 |
commit | 8d8c773c297d22dbf01e2bbb69b7335f52208845 (patch) | |
tree | d45e8affaa57b2dd2516e14c03c3a5f9238247f0 /views/aura_desktop | |
parent | 93543752960447decfc8f0ca38ef9f44f7209cfd (diff) | |
download | chromium_src-8d8c773c297d22dbf01e2bbb69b7335f52208845.zip chromium_src-8d8c773c297d22dbf01e2bbb69b7335f52208845.tar.gz chromium_src-8d8c773c297d22dbf01e2bbb69b7335f52208845.tar.bz2 |
Re-land: Create a new views_aura_desktop.
Get views::Widget rendering working against an aura::Window NativeWidget.
http://crbug.com/93944
TEST=none
Original review URL: http://codereview.chromium.org/7741027
Review URL: http://codereview.chromium.org/7747032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98331 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/aura_desktop')
-rw-r--r-- | views/aura_desktop/aura_desktop_main.cc | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/views/aura_desktop/aura_desktop_main.cc b/views/aura_desktop/aura_desktop_main.cc new file mode 100644 index 0000000..ce6f3a7 --- /dev/null +++ b/views/aura_desktop/aura_desktop_main.cc @@ -0,0 +1,106 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "aura/desktop.h" +#include "aura/desktop_host.h" +#include "aura/window.h" +#include "aura/window_delegate.h" +#include "base/at_exit.h" +#include "base/command_line.h" +#include "base/i18n/icu_util.h" +#include "base/memory/scoped_ptr.h" +#include "base/message_loop.h" +#include "third_party/skia/include/core/SkXfermode.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/base/ui_base_paths.h" +#include "ui/gfx/canvas.h" +#include "ui/gfx/canvas_skia.h" +#include "ui/gfx/rect.h" +#include "views/widget/widget.h" + +namespace { + +// Trivial WindowDelegate implementation that draws a colored background. +class DemoWindowDelegate : public aura::WindowDelegate { + public: + explicit DemoWindowDelegate(SkColor color) : color_(color) {} + + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { + canvas->AsCanvasSkia()->drawColor(color_, SkXfermode::kSrc_Mode); + } + + private: + SkColor color_; + + DISALLOW_COPY_AND_ASSIGN(DemoWindowDelegate); +}; + +class TestView : public views::View { + public: + TestView() {} + virtual ~TestView() {} + + private: + // Overridden from views::View: + virtual void OnPaint(gfx::Canvas* canvas) { + canvas->FillRectInt(SK_ColorYELLOW, 0, 0, width(), height()); + } + + DISALLOW_COPY_AND_ASSIGN(TestView); +}; + +} // namespace + +int main(int argc, char** argv) { + CommandLine::Init(argc, argv); + + // The exit manager is in charge of calling the dtors of singleton objects. + base::AtExitManager exit_manager; + + ui::RegisterPathProvider(); + icu_util::Initialize(); + ResourceBundle::InitSharedInstance("en-US"); + +#if defined(USE_X11) + base::MessagePumpX::DisableGtkMessagePump(); +#endif + + aura::Desktop::GetInstance(); + + // Create a hierarchy of test windows. + DemoWindowDelegate window_delegate1(SK_ColorBLUE); + aura::Window window1(&window_delegate1); + window1.set_id(1); + window1.Init(); + window1.SetBounds(gfx::Rect(100, 100, 400, 400), 0); + window1.SetVisibility(aura::Window::VISIBILITY_SHOWN); + window1.SetParent(NULL); + + DemoWindowDelegate window_delegate2(SK_ColorRED); + aura::Window window2(&window_delegate2); + window2.set_id(2); + window2.Init(); + window2.SetBounds(gfx::Rect(200, 200, 350, 350), 0); + window2.SetVisibility(aura::Window::VISIBILITY_SHOWN); + window2.SetParent(NULL); + + DemoWindowDelegate window_delegate3(SK_ColorGREEN); + aura::Window window3(&window_delegate3); + window3.set_id(3); + window3.Init(); + window3.SetBounds(gfx::Rect(10, 10, 50, 50), 0); + window3.SetVisibility(aura::Window::VISIBILITY_SHOWN); + window3.SetParent(&window2); + + views::Widget widget; + views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); + params.bounds = gfx::Rect(75, 75, 80, 80); + params.parent = &window2; + widget.Init(params); + widget.SetContentsView(new TestView); + + aura::Desktop::GetInstance()->Run(); + return 0; +} + |