Commit 242503c6 authored by sadrul@chromium.org's avatar sadrul@chromium.org

NativeWidgetViews: Implement Maximize.

BUG=none
TEST=manually

Review URL: http://codereview.chromium.org/7925006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102330 0039d316-1c4b-4281-b951-d872f2087c98
parent 6dfff633
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "views/widget/native_widget_views.h" #include "views/widget/native_widget_views.h"
#include "ui/gfx/compositor/compositor.h" #include "ui/gfx/compositor/compositor.h"
#include "views/desktop/desktop_window_view.h"
#include "views/view.h" #include "views/view.h"
#include "views/views_delegate.h" #include "views/views_delegate.h"
#include "views/widget/native_widget_view.h" #include "views/widget/native_widget_view.h"
...@@ -31,7 +30,7 @@ NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) ...@@ -31,7 +30,7 @@ NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate)
: delegate_(delegate), : delegate_(delegate),
view_(NULL), view_(NULL),
active_(false), active_(false),
minimized_(false), window_state_(ui::SHOW_STATE_DEFAULT),
always_on_top_(false), always_on_top_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)),
ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
...@@ -410,15 +409,28 @@ void NativeWidgetViews::SetAlwaysOnTop(bool on_top) { ...@@ -410,15 +409,28 @@ void NativeWidgetViews::SetAlwaysOnTop(bool on_top) {
} }
void NativeWidgetViews::Maximize() { void NativeWidgetViews::Maximize() {
NOTIMPLEMENTED(); if (window_state_ == ui::SHOW_STATE_MAXIMIZED)
return;
if (window_state_ != ui::SHOW_STATE_MINIMIZED) {
// Remember bounds and transform to use when unmaximized.
restored_bounds_ = view_->bounds();
restored_transform_ = view_->GetTransform();
}
window_state_ = ui::SHOW_STATE_MAXIMIZED;
gfx::Size size = GetParentNativeWidget()->GetWindowScreenBounds().size();
SetBounds(gfx::Rect(gfx::Point(), size));
} }
void NativeWidgetViews::Minimize() { void NativeWidgetViews::Minimize() {
gfx::Rect view_bounds = view_->bounds(); gfx::Rect view_bounds = view_->bounds();
gfx::Rect parent_bounds = view_->parent()->bounds(); gfx::Rect parent_bounds = view_->parent()->bounds();
restored_bounds_ = view_bounds; if (window_state_ != ui::SHOW_STATE_MAXIMIZED) {
restored_transform_ = view_->GetTransform(); restored_bounds_ = view_bounds;
restored_transform_ = view_->GetTransform();
}
float aspect_ratio = static_cast<float>(view_bounds.width()) / float aspect_ratio = static_cast<float>(view_bounds.width()) /
static_cast<float>(view_bounds.height()); static_cast<float>(view_bounds.height());
...@@ -441,20 +453,19 @@ void NativeWidgetViews::Minimize() { ...@@ -441,20 +453,19 @@ void NativeWidgetViews::Minimize() {
(float)target_height / (float)view_bounds.height()); (float)target_height / (float)view_bounds.height());
view_->SetTransform(transform); view_->SetTransform(transform);
minimized_ = true; window_state_ = ui::SHOW_STATE_MINIMIZED;
} }
bool NativeWidgetViews::IsMaximized() const { bool NativeWidgetViews::IsMaximized() const {
// NOTIMPLEMENTED(); return window_state_ == ui::SHOW_STATE_MAXIMIZED;
return false;
} }
bool NativeWidgetViews::IsMinimized() const { bool NativeWidgetViews::IsMinimized() const {
return minimized_; return window_state_ == ui::SHOW_STATE_MINIMIZED;
} }
void NativeWidgetViews::Restore() { void NativeWidgetViews::Restore() {
minimized_ = false; window_state_ = ui::SHOW_STATE_NORMAL;
view_->SetBoundsRect(restored_bounds_); view_->SetBoundsRect(restored_bounds_);
view_->SetTransform(restored_transform_); view_->SetTransform(restored_transform_);
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <map> #include <map>
#include "base/message_loop.h" #include "base/message_loop.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/transform.h" #include "ui/gfx/transform.h"
#include "views/widget/native_widget_private.h" #include "views/widget/native_widget_private.h"
#include "views/widget/widget.h" #include "views/widget/widget.h"
...@@ -155,7 +156,7 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { ...@@ -155,7 +156,7 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate {
bool active_; bool active_;
bool minimized_; ui::WindowShowState window_state_;
// Set when SetAlwaysOnTop is called, or keep_on_top is set during creation. // Set when SetAlwaysOnTop is called, or keep_on_top is set during creation.
bool always_on_top_; bool always_on_top_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment