forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wires up necessary pieces to use views with view_manager
The browser side obviously has to change rather extensively, but the rest work on both linux and windows. BUG=365012 TEST=none R=ben@chromium.org Review URL: https://codereview.chromium.org/321043002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276070 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
sky@chromium.org
committed
Jun 10, 2014
1 parent
6e0990e
commit 33bc2bc
Showing
19 changed files
with
612 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2014 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 "mojo/aura/aura_init.h" | ||
|
||
#include "mojo/aura/context_factory_mojo.h" | ||
#include "mojo/aura/screen_mojo.h" | ||
#include "ui/aura/env.h" | ||
|
||
namespace mojo { | ||
|
||
AuraInit::AuraInit() { | ||
aura::Env::CreateInstance(true); | ||
|
||
context_factory_.reset(new ContextFactoryMojo); | ||
aura::Env::GetInstance()->set_context_factory(context_factory_.get()); | ||
|
||
screen_.reset(ScreenMojo::Create()); | ||
gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, screen_.get()); | ||
} | ||
|
||
AuraInit::~AuraInit() { | ||
} | ||
|
||
} // namespace mojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2014 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. | ||
|
||
#ifndef MOJO_AURA_AURA_INIT_MOJO_H_ | ||
#define MOJO_AURA_AURA_INIT_MOJO_H_ | ||
|
||
#include "base/memory/scoped_ptr.h" | ||
|
||
namespace ui { | ||
class ContextFactory; | ||
} | ||
|
||
namespace mojo { | ||
|
||
class ScreenMojo; | ||
|
||
// Sets up necessary state for aura when run with the viewmanager. | ||
class AuraInit { | ||
public: | ||
AuraInit(); | ||
~AuraInit(); | ||
|
||
private: | ||
scoped_ptr<ui::ContextFactory> context_factory_; | ||
scoped_ptr<ScreenMojo> screen_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(AuraInit); | ||
}; | ||
|
||
} // namespace mojo | ||
|
||
#endif // MOJO_AURA_AURA_INIT_MOJO_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
include_rules = [ | ||
"+cc", | ||
"+skia/ext", | ||
"+ui/aura", | ||
"+ui/base/hit_test.h", | ||
"+ui/compositor", | ||
"+ui/events", | ||
"+ui/gfx", | ||
"+ui/views", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright 2014 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 "base/basictypes.h" | ||
#include "mojo/public/cpp/application/application.h" | ||
#include "mojo/services/public/cpp/view_manager/view.h" | ||
#include "mojo/services/public/cpp/view_manager/view_manager.h" | ||
#include "mojo/services/public/cpp/view_manager/view_manager_delegate.h" | ||
#include "mojo/services/public/cpp/view_manager/view_observer.h" | ||
#include "mojo/services/public/cpp/view_manager/view_tree_node.h" | ||
#include "mojo/views/native_widget_view_manager.h" | ||
#include "mojo/views/views_init.h" | ||
#include "ui/views/controls/textfield/textfield.h" | ||
#include "ui/views/layout/fill_layout.h" | ||
#include "ui/views/widget/widget.h" | ||
#include "ui/views/widget/widget_delegate.h" | ||
|
||
namespace mojo { | ||
namespace examples { | ||
|
||
// This is the basics of creating a views widget with a textfield. | ||
// TODO: cleanup! | ||
class Browser : public Application, public view_manager::ViewManagerDelegate { | ||
public: | ||
Browser() : view_manager_(NULL), view_(NULL) {} | ||
|
||
virtual ~Browser() { | ||
} | ||
|
||
private: | ||
// Overridden from Application: | ||
virtual void Initialize() MOJO_OVERRIDE { | ||
views_init_.reset(new ViewsInit); | ||
|
||
view_manager::ViewManager::Create(this, this); | ||
} | ||
|
||
void CreateWidget() { | ||
views::Textfield* textfield = new views::Textfield; | ||
|
||
views::WidgetDelegateView* widget_delegate = new views::WidgetDelegateView; | ||
widget_delegate->GetContentsView()->AddChildView(textfield); | ||
widget_delegate->GetContentsView()->SetLayoutManager(new views::FillLayout); | ||
|
||
views::Widget* widget = new views::Widget; | ||
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); | ||
params.native_widget = new NativeWidgetViewManager(widget, view_); | ||
params.delegate = widget_delegate; | ||
params.bounds = gfx::Rect(200, 200); | ||
widget->Init(params); | ||
widget->Show(); | ||
textfield->RequestFocus(); | ||
} | ||
|
||
// view_manager::ViewManagerDelegate: | ||
virtual void OnRootAdded(view_manager::ViewManager* view_manager, | ||
view_manager::ViewTreeNode* root) OVERRIDE { | ||
// TODO: deal with OnRootAdded() being invoked multiple times. | ||
view_manager_ = view_manager; | ||
view_ = view_manager::View::Create(view_manager_); | ||
view_manager_->GetRoots().front()->SetActiveView(view_); | ||
|
||
CreateWidget(); | ||
} | ||
virtual void OnRootRemoved(view_manager::ViewManager* view_manager, | ||
view_manager::ViewTreeNode* root) OVERRIDE { | ||
} | ||
|
||
scoped_ptr<ViewsInit> views_init_; | ||
|
||
view_manager::ViewManager* view_manager_; | ||
view_manager::View* view_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(Browser); | ||
}; | ||
|
||
} // namespace examples | ||
|
||
// static | ||
Application* Application::Create() { | ||
return new examples::Browser; | ||
} | ||
|
||
} // namespace mojo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.