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

Side by Side Diff: views/widget/native_widget_views.cc

Issue 7925006: NativeWidgetViews: Implement Maximize. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/native_widget_views.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "views/widget/native_widget_views.h" 5 #include "views/widget/native_widget_views.h"
6 6
7 #include "ui/gfx/compositor/compositor.h" 7 #include "ui/gfx/compositor/compositor.h"
8 #include "views/desktop/desktop_window_view.h"
9 #include "views/view.h" 8 #include "views/view.h"
10 #include "views/views_delegate.h" 9 #include "views/views_delegate.h"
11 #include "views/widget/native_widget_view.h" 10 #include "views/widget/native_widget_view.h"
12 #include "views/widget/root_view.h" 11 #include "views/widget/root_view.h"
13 #include "views/widget/window_manager.h" 12 #include "views/widget/window_manager.h"
14 13
15 #if defined(HAVE_IBUS) 14 #if defined(HAVE_IBUS)
16 #include "views/ime/input_method_ibus.h" 15 #include "views/ime/input_method_ibus.h"
17 #else 16 #else
18 #include "views/ime/mock_input_method.h" 17 #include "views/ime/mock_input_method.h"
19 #endif 18 #endif
20 19
21 #if defined(OS_LINUX) 20 #if defined(OS_LINUX)
22 #include "views/window/hit_test.h" 21 #include "views/window/hit_test.h"
23 #endif 22 #endif
24 23
25 namespace views { 24 namespace views {
26 25
27 //////////////////////////////////////////////////////////////////////////////// 26 ////////////////////////////////////////////////////////////////////////////////
28 // NativeWidgetViews, public: 27 // NativeWidgetViews, public:
29 28
30 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) 29 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate)
31 : delegate_(delegate), 30 : delegate_(delegate),
32 view_(NULL), 31 view_(NULL),
33 active_(false), 32 active_(false),
34 minimized_(false), 33 window_state_(ui::SHOW_STATE_DEFAULT),
35 always_on_top_(false), 34 always_on_top_(false),
36 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), 35 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
37 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 36 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
38 delete_native_view_(true) { 37 delete_native_view_(true) {
39 } 38 }
40 39
41 NativeWidgetViews::~NativeWidgetViews() { 40 NativeWidgetViews::~NativeWidgetViews() {
42 delegate_->OnNativeWidgetDestroying(); 41 delegate_->OnNativeWidgetDestroying();
43 42
44 if (view_ && delete_native_view_) { 43 if (view_ && delete_native_view_) {
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 402
404 void NativeWidgetViews::SetAlwaysOnTop(bool on_top) { 403 void NativeWidgetViews::SetAlwaysOnTop(bool on_top) {
405 always_on_top_ = on_top; 404 always_on_top_ = on_top;
406 // This is not complete yet. At least |MoveToTop| will need to be updated to 405 // This is not complete yet. At least |MoveToTop| will need to be updated to
407 // make sure a 'normal' window does not get on top of a window with 406 // make sure a 'normal' window does not get on top of a window with
408 // |always_on_top_| set. 407 // |always_on_top_| set.
409 NOTIMPLEMENTED(); 408 NOTIMPLEMENTED();
410 } 409 }
411 410
412 void NativeWidgetViews::Maximize() { 411 void NativeWidgetViews::Maximize() {
413 NOTIMPLEMENTED(); 412 if (window_state_ == ui::SHOW_STATE_MAXIMIZED)
413 return;
414
415 // Remember bounds and transform to use when unmaximized.
416 restored_bounds_ = view_->bounds();
sky 2011/09/22 17:59:10 Should we only do this if we're not minimized?
sadrul 2011/09/22 18:24:45 Yep. Good catch. Made this change here and also in
417 restored_transform_ = view_->GetTransform();
418
419 window_state_ = ui::SHOW_STATE_MAXIMIZED;
420 gfx::Size size = GetParentNativeWidget()->GetWindowScreenBounds().size();
421 SetBounds(gfx::Rect(gfx::Point(), size));
414 } 422 }
415 423
416 void NativeWidgetViews::Minimize() { 424 void NativeWidgetViews::Minimize() {
417 gfx::Rect view_bounds = view_->bounds(); 425 gfx::Rect view_bounds = view_->bounds();
418 gfx::Rect parent_bounds = view_->parent()->bounds(); 426 gfx::Rect parent_bounds = view_->parent()->bounds();
419 427
420 restored_bounds_ = view_bounds; 428 restored_bounds_ = view_bounds;
421 restored_transform_ = view_->GetTransform(); 429 restored_transform_ = view_->GetTransform();
422 430
423 float aspect_ratio = static_cast<float>(view_bounds.width()) / 431 float aspect_ratio = static_cast<float>(view_bounds.width()) /
(...skipping 10 matching lines...) Expand all
434 int target_y = parent_bounds.height() - target_size - 20; 442 int target_y = parent_bounds.height() - target_size - 20;
435 443
436 view_->SetBounds( 444 view_->SetBounds(
437 target_x, target_y, view_bounds.width(), view_bounds.height()); 445 target_x, target_y, view_bounds.width(), view_bounds.height());
438 446
439 ui::Transform transform; 447 ui::Transform transform;
440 transform.SetScale((float)target_width / (float)view_bounds.width(), 448 transform.SetScale((float)target_width / (float)view_bounds.width(),
441 (float)target_height / (float)view_bounds.height()); 449 (float)target_height / (float)view_bounds.height());
442 view_->SetTransform(transform); 450 view_->SetTransform(transform);
443 451
444 minimized_ = true; 452 window_state_ = ui::SHOW_STATE_MINIMIZED;
445 } 453 }
446 454
447 bool NativeWidgetViews::IsMaximized() const { 455 bool NativeWidgetViews::IsMaximized() const {
448 // NOTIMPLEMENTED(); 456 return window_state_ == ui::SHOW_STATE_MAXIMIZED;
449 return false;
450 } 457 }
451 458
452 bool NativeWidgetViews::IsMinimized() const { 459 bool NativeWidgetViews::IsMinimized() const {
453 return minimized_; 460 return window_state_ == ui::SHOW_STATE_MINIMIZED;
454 } 461 }
455 462
456 void NativeWidgetViews::Restore() { 463 void NativeWidgetViews::Restore() {
457 minimized_ = false; 464 window_state_ = ui::SHOW_STATE_NORMAL;
458 view_->SetBoundsRect(restored_bounds_); 465 view_->SetBoundsRect(restored_bounds_);
459 view_->SetTransform(restored_transform_); 466 view_->SetTransform(restored_transform_);
460 } 467 }
461 468
462 void NativeWidgetViews::SetFullscreen(bool fullscreen) { 469 void NativeWidgetViews::SetFullscreen(bool fullscreen) {
463 NOTIMPLEMENTED(); 470 NOTIMPLEMENTED();
464 } 471 }
465 472
466 bool NativeWidgetViews::IsFullscreen() const { 473 bool NativeWidgetViews::IsFullscreen() const {
467 // NOTIMPLEMENTED(); 474 // NOTIMPLEMENTED();
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 } 588 }
582 default: 589 default:
583 // Everything else falls into standard client event handling. 590 // Everything else falls into standard client event handling.
584 break; 591 break;
585 } 592 }
586 } 593 }
587 return false; 594 return false;
588 } 595 }
589 596
590 } // namespace views 597 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/native_widget_views.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698