diff options
author | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 17:06:47 +0000 |
---|---|---|
committer | mgiuca@chromium.org <mgiuca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-28 17:06:47 +0000 |
commit | cd6a73dcd63893d805b86f62354d4bb5b0cbbbf8 (patch) | |
tree | 81f7ce9a1cf75a8924c6cc69e2ef895c9e655fe2 /apps/ui | |
parent | 2e85d47cd990ab6ec0dbf7df044e337e3fd872d1 (diff) | |
download | chromium_src-cd6a73dcd63893d805b86f62354d4bb5b0cbbbf8.zip chromium_src-cd6a73dcd63893d805b86f62354d4bb5b0cbbbf8.tar.gz chromium_src-cd6a73dcd63893d805b86f62354d4bb5b0cbbbf8.tar.bz2 |
Linux: App windows with frame: chrome and no color are now native.
This is bringing Aura in line with the existing GTK behaviour. Windows
with a coloured frame still have the Windows 8 look.
App windows on Linux now always use AppWindowFrameView instead of the
blue CustomFrameView.
BUG=322256
Review URL: https://codereview.chromium.org/210363004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps/ui')
-rw-r--r-- | apps/ui/views/app_window_frame_view.cc | 51 | ||||
-rw-r--r-- | apps/ui/views/app_window_frame_view.h | 16 |
2 files changed, 41 insertions, 26 deletions
diff --git a/apps/ui/views/app_window_frame_view.cc b/apps/ui/views/app_window_frame_view.cc index e1c399f..5f7842c 100644 --- a/apps/ui/views/app_window_frame_view.cc +++ b/apps/ui/views/app_window_frame_view.cc @@ -4,12 +4,12 @@ #include "apps/ui/views/app_window_frame_view.h" -#include "apps/ui/native_app_window.h" #include "base/strings/utf_string_conversions.h" #include "extensions/common/draggable_region.h" #include "grit/theme_resources.h" #include "grit/ui_strings.h" // Accessibility names #include "third_party/skia/include/core/SkPaint.h" +#include "third_party/skia/include/core/SkRegion.h" #include "ui/base/hit_test.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -37,9 +37,9 @@ namespace apps { const char AppWindowFrameView::kViewClassName[] = "browser/ui/views/extensions/AppWindowFrameView"; -AppWindowFrameView::AppWindowFrameView(NativeAppWindow* window) - : window_(window), - widget_(NULL), +AppWindowFrameView::AppWindowFrameView() + : widget_(NULL), + draggable_region_(NULL), close_button_(NULL), maximize_button_(NULL), restore_button_(NULL), @@ -51,18 +51,22 @@ AppWindowFrameView::AppWindowFrameView(NativeAppWindow* window) AppWindowFrameView::~AppWindowFrameView() {} void AppWindowFrameView::Init(views::Widget* widget, + bool draw_frame, const SkColor& frame_color, + const SkRegion* draggable_region, int resize_inside_bounds_size, int resize_outside_bounds_size, int resize_outside_scale_for_touch, int resize_area_corner_size) { widget_ = widget; + draw_frame_ = draw_frame; frame_color_ = frame_color; + draggable_region_ = draggable_region; resize_inside_bounds_size_ = resize_inside_bounds_size; resize_outside_bounds_size_ = resize_outside_bounds_size; resize_area_corner_size_ = resize_area_corner_size; - if (!window_->IsFrameless()) { + if (draw_frame) { ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); close_button_ = new views::ImageButton(this); close_button_->SetImage( @@ -125,7 +129,7 @@ void AppWindowFrameView::Init(views::Widget* widget, // views::NonClientFrameView implementation. gfx::Rect AppWindowFrameView::GetBoundsForClientView() const { - if (window_->IsFrameless() || widget_->IsFullscreen()) + if (!draw_frame_ || widget_->IsFullscreen()) return bounds(); return gfx::Rect( 0, kCaptionHeight, width(), std::max(0, height() - kCaptionHeight)); @@ -133,8 +137,16 @@ gfx::Rect AppWindowFrameView::GetBoundsForClientView() const { gfx::Rect AppWindowFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { - if (window_->IsFrameless()) { - gfx::Rect window_bounds = client_bounds; + gfx::Rect window_bounds = client_bounds; +#if defined(OS_LINUX) && !defined(OS_CHROMEOS) + // Get the difference between the widget's client area bounds and window + // bounds, and grow |window_bounds| by that amount. + gfx::Insets native_frame_insets = + widget_->GetClientAreaBoundsInScreen().InsetsFrom( + widget_->GetWindowBoundsInScreen()); + window_bounds.Inset(native_frame_insets); +#endif + if (!draw_frame_) { // Enforce minimum size (1, 1) in case that client_bounds is passed with // empty size. This could occur when the frameless window is being // initialized. @@ -147,10 +159,10 @@ gfx::Rect AppWindowFrameView::GetWindowBoundsForClientBounds( int closeButtonOffsetX = (kCaptionHeight - close_button_->height()) / 2; int header_width = close_button_->width() + closeButtonOffsetX * 2; - return gfx::Rect(client_bounds.x(), - client_bounds.y() - kCaptionHeight, - std::max(header_width, client_bounds.width()), - client_bounds.height() + kCaptionHeight); + return gfx::Rect(window_bounds.x(), + window_bounds.y() - kCaptionHeight, + std::max(header_width, window_bounds.width()), + window_bounds.height() + kCaptionHeight); } int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) { @@ -189,11 +201,8 @@ int AppWindowFrameView::NonClientHitTest(const gfx::Point& point) { // Check for possible draggable region in the client area for the frameless // window. - if (window_->IsFrameless()) { - SkRegion* draggable_region = window_->GetDraggableRegion(); - if (draggable_region && draggable_region->contains(point.x(), point.y())) - return HTCAPTION; - } + if (draggable_region_ && draggable_region_->contains(point.x(), point.y())) + return HTCAPTION; int client_component = widget_->client_view()->NonClientHitTest(point); if (client_component != HTNOWHERE) @@ -235,7 +244,7 @@ gfx::Size AppWindowFrameView::GetPreferredSize() { } void AppWindowFrameView::Layout() { - if (window_->IsFrameless()) + if (!draw_frame_) return; gfx::Size close_size = close_button_->GetPreferredSize(); const int kButtonOffsetY = 0; @@ -282,7 +291,7 @@ void AppWindowFrameView::Layout() { } void AppWindowFrameView::OnPaint(gfx::Canvas* canvas) { - if (window_->IsFrameless()) + if (!draw_frame_) return; ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); @@ -314,7 +323,7 @@ const char* AppWindowFrameView::GetClassName() const { return kViewClassName; } gfx::Size AppWindowFrameView::GetMinimumSize() { gfx::Size min_size = widget_->client_view()->GetMinimumSize(); - if (window_->IsFrameless()) + if (!draw_frame_) return min_size; // Ensure we can display the top of the caption area. @@ -346,7 +355,7 @@ gfx::Size AppWindowFrameView::GetMaximumSize() { void AppWindowFrameView::ButtonPressed(views::Button* sender, const ui::Event& event) { - DCHECK(!window_->IsFrameless()); + DCHECK(draw_frame_); if (sender == close_button_) widget_->Close(); else if (sender == maximize_button_) diff --git a/apps/ui/views/app_window_frame_view.h b/apps/ui/views/app_window_frame_view.h index 69e84e9..64379f8 100644 --- a/apps/ui/views/app_window_frame_view.h +++ b/apps/ui/views/app_window_frame_view.h @@ -7,12 +7,15 @@ #include <string> +#include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/path.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" #include "ui/views/controls/button/button.h" #include "ui/views/window/non_client_view.h" +class SkRegion; + namespace gfx { class Canvas; class Point; @@ -29,22 +32,24 @@ class Widget; namespace apps { -class NativeAppWindow; - // A frameless or non-Ash, non-panel NonClientFrameView for app windows. class AppWindowFrameView : public views::NonClientFrameView, public views::ButtonListener { public: static const char kViewClassName[]; - explicit AppWindowFrameView(NativeAppWindow* window); + explicit AppWindowFrameView(); virtual ~AppWindowFrameView(); // Initializes this for |widget|. Sets the number of pixels for which a click // is interpreted as a resize for the inner and outer border of the window - // and the lower-right corner resize handle. + // and the lower-right corner resize handle. If |draw_frame|, the view draws + // its own window title area and controls, using |frame_color| (otherwise + // |frame_color| is ignored). |draggable_region| may be NULL. void Init(views::Widget* widget, + bool draw_frame, const SkColor& frame_color, + const SkRegion* draggable_region, int resize_inside_bounds_size, int resize_outside_bounds_size, int resize_outside_scale_for_touch, @@ -74,9 +79,10 @@ class AppWindowFrameView : public views::NonClientFrameView, virtual void ButtonPressed(views::Button* sender, const ui::Event& event) OVERRIDE; - NativeAppWindow* window_; views::Widget* widget_; + bool draw_frame_; SkColor frame_color_; + const SkRegion* draggable_region_; views::ImageButton* close_button_; views::ImageButton* maximize_button_; views::ImageButton* restore_button_; |