diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 00:28:00 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-03 00:28:00 +0000 |
commit | 32670b07a6c42634f446e3d471f42a9fb40090f2 (patch) | |
tree | 77b15435f3a436d54fcaa5cb4c0d4371a007fad6 /chrome/views/non_client_view.h | |
parent | a0e5688cc11f7f5e835b5c1a75c17ce4a28a1527 (diff) | |
download | chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.zip chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.tar.gz chromium_src-32670b07a6c42634f446e3d471f42a9fb40090f2.tar.bz2 |
Support DWM switching.
This completes the collapsing of window types and browser frames around a single class: views::Window. CustomFrameWindow is removed with this change.
The Browser window is represented by a single views::Window subclass: BrowserFrame, which replaces both AeroGlassFrame and OpaqueFrame.
NonClientView is now a container of two sibling classes - the Window's ClientView (in the Browser's case, BrowserView), and a NonClientFrameView subclass, which provides the rendering for the non-client portions of the window. These Views are siblings rather than the ClientView a child of the NonClientFrameView because when the DWM is toggled, the ClientView would have to be re-parented. Many Views make the assumption they are only inserted into a View hierarchy once, and so this is problematic. By having the views be siblings, this is avoided.
With this in mind, all of the former NonClientViews now become NonClientFrameView subclasses:
DefaultNonClientView -> CustomFrameView
(non-existent, NonClientView) -> NativeFrameView
AeroGlassNonClientView -> GlassBrowserFrameView
OpaqueNonClientView -> OpaqueBrowserFrameView
The latter two derive from NonClientFrameView via BrowserNonClientFrameView, which adds some extras.
I also had to modify the TabRenderer class to know how to drop its cache of tab background images when the theme changes since it uses different ones for Glass and non-Glass.
This change also fixes a few non-client flicker issues relating to window non-client activation by using more ScopedRedrawLocks. (Touches info_bubble.cc, window.cc)
Bugs fixed:
http://crbug.com/153
http://crbug.com/747
http://crbug.com/2371
http://crbug.com/3264
http://crbug.com/8234
Plumbing for http://crbug.com/8247
Design docs:
http://dev.chromium.org/developers/design-documents/views-windowing
http://dev.chromium.org/developers/design-documents/browser-window
Review URL: http://codereview.chromium.org/27317
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/non_client_view.h')
-rw-r--r-- | chrome/views/non_client_view.h | 186 |
1 files changed, 136 insertions, 50 deletions
diff --git a/chrome/views/non_client_view.h b/chrome/views/non_client_view.h index 1887c2e..f801d6f 100644 --- a/chrome/views/non_client_view.h +++ b/chrome/views/non_client_view.h @@ -5,6 +5,7 @@ #ifndef CHROME_VIEWS_NON_CLIENT_VIEW_H_ #define CHROME_VIEWS_NON_CLIENT_VIEW_H_ +#include "base/task.h" #include "chrome/views/view.h" #include "chrome/views/client_view.h" @@ -14,21 +15,15 @@ class Path; namespace views { -/////////////////////////////////////////////////////////////////////////////// -// NonClientView -// -// An object implementing the NonClientView interface is a View that provides -// the "non-client" areas of a window. This is the area that typically -// encompasses the window frame - title bar, sizing borders and window -// controls. This interface provides methods that allow a specific -// presentation to define non-client areas for windows hit testing, the shape -// of the window, and other window-related information. +//////////////////////////////////////////////////////////////////////////////// +// NonClientFrameView // -class NonClientView : public View { +// An object that subclasses NonClientFrameView is a View that renders and +// responds to events within the frame portions of the non-client area of a +// window. This view does _not_ contain the ClientView, but rather is a sibling +// of it. +class NonClientFrameView : public views::View { public: - NonClientView(); - virtual ~NonClientView(); - // Various edges of the frame border have a 1 px shadow along their edges; in // a few cases we shift elements based on this amount for visual appeal. static const int kFrameShadowThickness; @@ -36,6 +31,99 @@ class NonClientView : public View { // frame border. static const int kClientEdgeThickness; + void DisableInactiveRendering(bool disable) { + paint_as_active_ = disable; + if (!paint_as_active_) + SchedulePaint(); + } + + // Returns the bounds (in this View's parent's coordinates) that the client + // view should be laid out within. + virtual gfx::Rect GetBoundsForClientView() const = 0; + + // Returns true if this FrameView should always use the custom frame, + // regardless of the system settings. An example is the Constrained Window, + // which is a child window and must always provide its own frame. + virtual bool AlwaysUseCustomFrame() const { return false; } + + virtual gfx::Rect GetWindowBoundsForClientBounds( + const gfx::Rect& client_bounds) const = 0; + virtual gfx::Point GetSystemMenuPoint() const = 0; + virtual int NonClientHitTest(const gfx::Point& point) = 0; + virtual void GetWindowMask(const gfx::Size& size, + gfx::Path* window_mask) = 0; + virtual void EnableClose(bool enable) = 0; + virtual void ResetWindowControls() = 0; + + protected: + NonClientFrameView() : paint_as_active_(false) {} + + + // Helper for non-client view implementations to determine which area of the + // window border the specified |point| falls within. The other parameters are + // the size of the sizing edges, and whether or not the window can be + // resized. + int GetHTComponentForFrame(const gfx::Point& point, + int top_resize_border_height, + int resize_border_thickness, + int top_resize_corner_height, + int resize_corner_width, + bool can_resize); + + // Accessor for paint_as_active_. + bool paint_as_active() const { return paint_as_active_; } + + private: + // True when the non-client view should always be rendered as if the window + // were active, regardless of whether or not the top level window actually + // is active. + bool paint_as_active_; +}; + +//////////////////////////////////////////////////////////////////////////////// +// NonClientView +// +// The NonClientView is the logical root of all Views contained within a +// Window, except for the RootView which is its parent and of which it is the +// sole child. The NonClientView has two children, the NonClientFrameView which +// is responsible for painting and responding to events from the non-client +// portions of the window, and the ClientView, which is responsible for the +// same for the client area of the window: +// +// +- views::Window ------------------------------------+ +// | +- views::RootView ------------------------------+ | +// | | +- views::NonClientView ---------------------+ | | +// | | | +- views::NonClientFrameView subclass ---+ | | | +// | | | | | | | | +// | | | | << all painting and event receiving >> | | | | +// | | | | << of the non-client areas of a >> | | | | +// | | | | << views::Window. >> | | | | +// | | | | | | | | +// | | | +----------------------------------------+ | | | +// | | | +- views::ClientView or subclass --------+ | | | +// | | | | | | | | +// | | | | << all painting and event receiving >> | | | | +// | | | | << of the client areas of a >> | | | | +// | | | | << views::Window. >> | | | | +// | | | | | | | | +// | | | +----------------------------------------+ | | | +// | | +--------------------------------------------+ | | +// | +------------------------------------------------+ | +// +----------------------------------------------------+ +// +// The NonClientFrameView and ClientView are siblings because due to theme +// changes the NonClientFrameView may be replaced with different +// implementations (e.g. during the switch from DWM/Aero-Glass to Vista Basic/ +// Classic rendering). +// +class NonClientView : public View { + public: + explicit NonClientView(Window* frame); + virtual ~NonClientView(); + + // Replaces the current NonClientFrameView (if any) with the specified one. + void SetFrameView(NonClientFrameView* frame_view); + // Returns true if the ClientView determines that the containing window can be // closed, false otherwise. bool CanClose() const; @@ -43,48 +131,52 @@ class NonClientView : public View { // Called by the containing Window when it is closed. void WindowClosing(); + // Called by the window when it receives a theme changed notification. Changes + // the content of the NonClientView to match what is required for the current + // system theme. + void SystemThemeChanged(); + + // Changes the frame from native to custom depending on the value of + // |use_native_frame|. + void SetUseNativeFrame(bool use_native_frame); + // Returns true if the native window frame should be used, false if the // NonClientView provides its own frame implementation. bool UseNativeFrame() const; - // Calculates the bounds of the client area of the window assuming the - // window is sized to |width| and |height|. - virtual gfx::Rect CalculateClientAreaBounds(int width, int height) const; + // Prevents the window from being rendered as deactivated when |disable| is + // true, until called with |disable| false. Used when a sub-window is to be + // shown that shouldn't visually de-activate the window. + // Subclasses can override this to perform additional actions when this value + // changes. + void DisableInactiveRendering(bool disable); - // Calculates the size of window required to display a client area of the - // specified width and height. - virtual gfx::Size CalculateWindowSizeForClientSize(int width, - int height) const; + // Returns the bounds of the window required to display the content area at + // the specified bounds. + gfx::Rect GetWindowBoundsForClientBounds(const gfx::Rect client_bounds) const; // Returns the point, in screen coordinates, where the system menu should // be shown so it shows up anchored to the system menu icon. - virtual gfx::Point GetSystemMenuPoint() const; + gfx::Point GetSystemMenuPoint() const; // Determines the windows HT* code when the mouse cursor is at the // specified point, in window coordinates. - virtual int NonClientHitTest(const gfx::Point& point); + int NonClientHitTest(const gfx::Point& point); // Returns a mask to be used to clip the top level window for the given // size. This is used to create the non-rectangular window shape. - virtual void GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask); + void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); // Toggles the enable state for the Close button (and the Close menu item in // the system menu). - virtual void EnableClose(bool enable); + void EnableClose(bool enable); // Tells the window controls as rendered by the NonClientView to reset // themselves to a normal state. This happens in situations where the // containing window does not receive a normal sequences of messages that // would lead to the controls returning to this normal state naturally, e.g. // when the window is maximized, minimized or restored. - virtual void ResetWindowControls(); - - // Prevents the non-client view from rendering as inactive when called with - // |disable| true, until called with false. - void set_paint_as_active(bool paint_as_active) { - paint_as_active_ = paint_as_active; - } + void ResetWindowControls(); // Get/Set client_view property. ClientView* client_view() const { return client_view_; } @@ -100,30 +192,24 @@ class NonClientView : public View { // NonClientView, View overrides: virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); - // Helper for non-client view implementations to determine which area of the - // window border the specified |point| falls within. The other parameters are - // the size of the sizing edges, and whether or not the window can be - // resized. - int GetHTComponentForFrame(const gfx::Point& point, - int top_resize_border_height, - int resize_border_thickness, - int top_resize_corner_height, - int resize_corner_width, - bool can_resize); - - // Accessor for paint_as_active_. - bool paint_as_active() const { return paint_as_active_; } - private: + // The frame that hosts this NonClientView. + Window* frame_; + // A ClientView object or subclass, responsible for sizing the contents view // of the window, hit testing and perhaps other tasks depending on the // implementation. ClientView* client_view_; - // True when the non-client view should always be rendered as if the window - // were active, regardless of whether or not the top level window actually - // is active. - bool paint_as_active_; + // The NonClientFrameView that renders the non-client portions of the window. + // This object is not owned by the view hierarchy because it can be replaced + // dynamically as the system settings change. + scoped_ptr<NonClientFrameView> frame_view_; + + // Whether or not we should use the native frame. + bool use_native_frame_; + + DISALLOW_COPY_AND_ASSIGN(NonClientView); }; } // namespace views |