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

Unified Diff: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc

Issue 7273073: Animated Rotation (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address reviewer comments Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
diff --git a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
index 47708be1a4b962b62c204fe258912cd86df2defc..f5fd86c596c3dbc353920e41453e806f908bb268 100644
--- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
+++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
@@ -4,8 +4,46 @@
#include "chrome/browser/ui/touch/frame/touch_browser_frame_view.h"
+#include "chrome/browser/ui/touch/animation/screen_rotation_setter.h"
#include "chrome/browser/ui/touch/keyboard/keyboard_manager.h"
#include "views/controls/button/image_button.h"
+#include "views/desktop/desktop_window_view.h"
+#include "ui/gfx/transform.h"
+
+namespace {
+
+ui::Transform SideToTransform(sensors::ScreenOrientation::Side side,
+ const ui::Transform& old_transform,
+ const gfx::Size& size) {
+ gfx::Point origin;
+ gfx::Point bottom_right(size.width(), size.height());
+ old_transform.TransformPoint(origin);
+ old_transform.TransformPoint(bottom_right);
+ int original_width = abs(origin.x() - bottom_right.x());
+ int original_height = abs(origin.y() - bottom_right.y());
+ ui::Transform to_return;
+ switch (side) {
+ case sensors::ScreenOrientation::TOP: break;
+ case sensors::ScreenOrientation::RIGHT:
+ to_return.ConcatRotate(90);
+ to_return.ConcatTranslate(original_width, 0);
+ break;
+ case sensors::ScreenOrientation::LEFT:
+ to_return.ConcatRotate(-90);
+ to_return.ConcatTranslate(0, original_height);
+ break;
+ case sensors::ScreenOrientation::BOTTOM:
+ to_return.ConcatRotate(180);
+ to_return.ConcatTranslate(original_width, original_height);
+ break;
+ default:
+ to_return = old_transform;
+ break;
+ }
+ return to_return;
+}
+
+} // namespace
// static
const char TouchBrowserFrameView::kViewClassName[] =
@@ -19,9 +57,11 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
: OpaqueBrowserFrameView(frame, browser_view) {
// Make sure the singleton KeyboardManager object is initialized.
KeyboardManager::GetInstance();
+ sensors::Provider::GetInstance()->AddListener(this);
}
TouchBrowserFrameView::~TouchBrowserFrameView() {
+ sensors::Provider::GetInstance()->RemoveListener(this);
}
std::string TouchBrowserFrameView::GetClassName() const {
@@ -47,3 +87,30 @@ bool TouchBrowserFrameView::HitTest(const gfx::Point& point) const {
return false;
}
+
+void TouchBrowserFrameView::OnScreenOrientationChanged(
+ const sensors::ScreenOrientation& change) {
+ // In views desktop mode, then the desktop_window_view will not be NULL and
+ // is the view to be rotated.
+ views::View* to_rotate =
+ views::desktop::DesktopWindowView::desktop_window_view;
+
+ if (!to_rotate) {
+ // Otherwise, rotate the widget's view.
+ views::Widget* widget = GetWidget();
+ to_rotate = widget->GetRootView();
+ }
+
+ if (!initialized_screen_rotation_) {
+ to_rotate->SetPaintToLayer(true);
+ to_rotate->SetLayerPropertySetter(
+ ScreenRotationSetterFactory::Create(to_rotate));
+ initialized_screen_rotation_ = true;
+ }
+
+ ui::Transform xform = SideToTransform(change.upward,
+ to_rotate->GetTransform(),
+ to_rotate->size());
+ to_rotate->SetTransform(xform);
+}
+
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698