Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 namespace views { | 20 namespace views { |
| 22 | 21 |
| 23 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
| 24 // NativeWidgetViews, public: | 23 // NativeWidgetViews, public: |
| 25 | 24 |
| 26 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) | 25 NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) |
| 27 : delegate_(delegate), | 26 : delegate_(delegate), |
| 28 view_(NULL), | 27 view_(NULL), |
| 29 active_(false), | 28 active_(false), |
| 29 maximized_(false), | |
| 30 minimized_(false), | 30 minimized_(false), |
| 31 always_on_top_(false), | 31 always_on_top_(false), |
| 32 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), | 32 ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), |
| 33 hosting_widget_(NULL), | 33 hosting_widget_(NULL), |
| 34 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 34 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 35 delete_native_view_(true) { | 35 delete_native_view_(true) { |
| 36 } | 36 } |
| 37 | 37 |
| 38 NativeWidgetViews::~NativeWidgetViews() { | 38 NativeWidgetViews::~NativeWidgetViews() { |
| 39 delegate_->OnNativeWidgetDestroying(); | 39 delegate_->OnNativeWidgetDestroying(); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 | 382 |
| 383 void NativeWidgetViews::SetAlwaysOnTop(bool on_top) { | 383 void NativeWidgetViews::SetAlwaysOnTop(bool on_top) { |
| 384 always_on_top_ = on_top; | 384 always_on_top_ = on_top; |
| 385 // This is not complete yet. At least |MoveToTop| will need to be updated to | 385 // This is not complete yet. At least |MoveToTop| will need to be updated to |
| 386 // make sure a 'normal' window does not get on top of a window with | 386 // make sure a 'normal' window does not get on top of a window with |
| 387 // |always_on_top_| set. | 387 // |always_on_top_| set. |
| 388 NOTIMPLEMENTED(); | 388 NOTIMPLEMENTED(); |
| 389 } | 389 } |
| 390 | 390 |
| 391 void NativeWidgetViews::Maximize() { | 391 void NativeWidgetViews::Maximize() { |
| 392 NOTIMPLEMENTED(); | 392 if (maximized_) |
| 393 return; | |
| 394 maximized_ = true; | |
| 395 minimized_ = false; | |
| 396 gfx::Size size = GetParentNativeWidget()->GetWindowScreenBounds().size(); | |
| 397 SetBounds(gfx::Rect(gfx::Point(), size)); | |
| 393 } | 398 } |
| 394 | 399 |
| 395 void NativeWidgetViews::Minimize() { | 400 void NativeWidgetViews::Minimize() { |
| 396 gfx::Rect view_bounds = view_->bounds(); | 401 gfx::Rect view_bounds = view_->bounds(); |
| 397 gfx::Rect parent_bounds = view_->parent()->bounds(); | 402 gfx::Rect parent_bounds = view_->parent()->bounds(); |
| 398 | 403 |
| 399 restored_bounds_ = view_bounds; | 404 restored_bounds_ = view_bounds; |
| 400 restored_transform_ = view_->GetTransform(); | 405 restored_transform_ = view_->GetTransform(); |
| 401 | 406 |
| 402 float aspect_ratio = static_cast<float>(view_bounds.width()) / | 407 float aspect_ratio = static_cast<float>(view_bounds.width()) / |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 413 int target_y = parent_bounds.height() - target_size - 20; | 418 int target_y = parent_bounds.height() - target_size - 20; |
| 414 | 419 |
| 415 view_->SetBounds( | 420 view_->SetBounds( |
| 416 target_x, target_y, view_bounds.width(), view_bounds.height()); | 421 target_x, target_y, view_bounds.width(), view_bounds.height()); |
| 417 | 422 |
| 418 ui::Transform transform; | 423 ui::Transform transform; |
| 419 transform.SetScale((float)target_width / (float)view_bounds.width(), | 424 transform.SetScale((float)target_width / (float)view_bounds.width(), |
| 420 (float)target_height / (float)view_bounds.height()); | 425 (float)target_height / (float)view_bounds.height()); |
| 421 view_->SetTransform(transform); | 426 view_->SetTransform(transform); |
| 422 | 427 |
| 423 minimized_ = true; | 428 minimized_ = true; |
|
sky
2011/09/19 20:32:47
Could we use an enum to avoid having to update two
sadrul
2011/09/22 17:00:24
Good idea. I updated to use ui::WindowShowState in
| |
| 429 maximized_ = false; | |
| 424 } | 430 } |
| 425 | 431 |
| 426 bool NativeWidgetViews::IsMaximized() const { | 432 bool NativeWidgetViews::IsMaximized() const { |
| 427 // NOTIMPLEMENTED(); | 433 return maximized_; |
| 428 return false; | |
| 429 } | 434 } |
| 430 | 435 |
| 431 bool NativeWidgetViews::IsMinimized() const { | 436 bool NativeWidgetViews::IsMinimized() const { |
| 432 return minimized_; | 437 return minimized_; |
| 433 } | 438 } |
| 434 | 439 |
| 435 void NativeWidgetViews::Restore() { | 440 void NativeWidgetViews::Restore() { |
| 436 minimized_ = false; | 441 minimized_ = false; |
| 442 maximized_ = false; | |
| 437 view_->SetBoundsRect(restored_bounds_); | 443 view_->SetBoundsRect(restored_bounds_); |
| 438 view_->SetTransform(restored_transform_); | 444 view_->SetTransform(restored_transform_); |
| 439 } | 445 } |
| 440 | 446 |
| 441 void NativeWidgetViews::SetFullscreen(bool fullscreen) { | 447 void NativeWidgetViews::SetFullscreen(bool fullscreen) { |
| 442 NOTIMPLEMENTED(); | 448 NOTIMPLEMENTED(); |
| 443 } | 449 } |
| 444 | 450 |
| 445 bool NativeWidgetViews::IsFullscreen() const { | 451 bool NativeWidgetViews::IsFullscreen() const { |
| 446 // NOTIMPLEMENTED(); | 452 // NOTIMPLEMENTED(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 | 522 |
| 517 const internal::NativeWidgetPrivate* | 523 const internal::NativeWidgetPrivate* |
| 518 NativeWidgetViews::GetParentNativeWidget() const { | 524 NativeWidgetViews::GetParentNativeWidget() const { |
| 519 const Widget* containing_widget = view_ ? view_->GetWidget() : NULL; | 525 const Widget* containing_widget = view_ ? view_->GetWidget() : NULL; |
| 520 return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>( | 526 return containing_widget ? static_cast<const internal::NativeWidgetPrivate*>( |
| 521 containing_widget->native_widget()) : | 527 containing_widget->native_widget()) : |
| 522 NULL; | 528 NULL; |
| 523 } | 529 } |
| 524 | 530 |
| 525 } // namespace views | 531 } // namespace views |
| OLD | NEW |