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

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: Formatting and comment fix. Created 9 years, 5 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/common/url_constants.h » ('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 b1ae5b4e448f79eb5900b069d3b4ab81d56e0130..dcaa9d20a99b05c198628e2a43c49d758641794b 100644
--- a/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
+++ b/chrome/browser/ui/touch/frame/touch_browser_frame_view.cc
@@ -23,6 +23,8 @@
#include "ui/base/animation/slide_animation.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/transform.h"
+#include "views/animation/screen_rotation.h"
+#include "views/desktop/desktop_window_view.h"
#include "views/controls/button/image_button.h"
#include "views/controls/textfield/textfield.h"
#include "views/focus/focus_manager.h"
@@ -46,6 +48,15 @@ bool TabContentsHasFocus(const TabContents* contents) {
return view->Contains(view->GetFocusManager()->GetFocusedView());
}
+int SideToDegrees(sensors::ScreenOrientation::Side side) {
+ switch (side) {
+ case sensors::ScreenOrientation::RIGHT: return 90;
+ case sensors::ScreenOrientation::LEFT: return -90;
+ case sensors::ScreenOrientation::BOTTOM: return 180;
+ default: return 0;
+ }
+}
+
} // namespace
// static
@@ -61,7 +72,8 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
keyboard_showing_(false),
keyboard_height_(kDefaultKeyboardHeight),
focus_listener_added_(false),
- keyboard_(NULL) {
+ keyboard_(NULL),
+ up_(sensors::ScreenOrientation::TOP) {
registrar_.Add(this,
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
NotificationService::AllSources());
@@ -92,10 +104,13 @@ TouchBrowserFrameView::TouchBrowserFrameView(BrowserFrame* frame,
chromeos::input_method::InputMethodManager::GetInstance();
manager->AddVirtualKeyboardObserver(this);
#endif
+
+ sensors::Provider::GetInstance()->AddListener(this);
}
TouchBrowserFrameView::~TouchBrowserFrameView() {
browser_view()->browser()->tabstrip_model()->RemoveObserver(this);
+ sensors::Provider::GetInstance()->RemoveListener(this);
}
std::string TouchBrowserFrameView::GetClassName() const {
@@ -361,6 +376,25 @@ void TouchBrowserFrameView::AnimationEnded(const ui::Animation* animation) {
SchedulePaint();
}
+void TouchBrowserFrameView::OnScreenOrientationChanged(
+ const sensors::ScreenOrientation& change) {
+
+ views::View* to_rotate =
+ views::desktop::DesktopWindowView::desktop_window_view;
+
+ if (!to_rotate) {
+ views::Widget* widget = GetWidget();
+ to_rotate = widget->GetRootView();
+ }
+
+ views::ScreenRotation::Perform(
+ to_rotate,
+ SideToDegrees(up_),
+ SideToDegrees(change.upward));
cwolfe 2011/07/21 17:47:01 ScreenOrientation::FRONT and ::BACK should probabl
+
+ up_ = change.upward;
+}
+
#if defined(OS_CHROMEOS)
void TouchBrowserFrameView::VirtualKeyboardChanged(
chromeos::input_method::InputMethodManager* manager,
« no previous file with comments | « chrome/browser/ui/touch/frame/touch_browser_frame_view.h ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698