Commit 630fdace authored by jianli@chromium.org's avatar jianli@chromium.org

Make panels turn on or off shadow effect.

This is needed for stacking panels. The foreground panel windows will turn off the shadow while the background stack window will provider the shadow.

BUG=223155,177770
TEST=none due to no functionality change yet

Review URL: https://codereview.chromium.org/13853010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194615 0039d316-1c4b-4281-b951-d872f2087c98
parent 6f743a27
...@@ -64,6 +64,7 @@ class PanelCocoa : public NativePanel { ...@@ -64,6 +64,7 @@ class PanelCocoa : public NativePanel {
virtual void MinimizePanelBySystem() OVERRIDE; virtual void MinimizePanelBySystem() OVERRIDE;
virtual bool IsPanelMinimizedBySystem() const OVERRIDE; virtual bool IsPanelMinimizedBySystem() const OVERRIDE;
virtual void ShowShadow(bool show) OVERRIDE;
virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE; virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE;
Panel* panel() const; Panel* panel() const;
......
...@@ -272,6 +272,10 @@ bool PanelCocoa::IsPanelMinimizedBySystem() const { ...@@ -272,6 +272,10 @@ bool PanelCocoa::IsPanelMinimizedBySystem() const {
return false; return false;
} }
void PanelCocoa::ShowShadow(bool show) {
[controller_ showShadow:show];
}
void PanelCocoa::PanelExpansionStateChanging( void PanelCocoa::PanelExpansionStateChanging(
Panel::ExpansionState old_state, Panel::ExpansionState new_state) { Panel::ExpansionState old_state, Panel::ExpansionState new_state) {
[controller_ updateWindowLevel:(new_state != Panel::EXPANDED)]; [controller_ updateWindowLevel:(new_state != Panel::EXPANDED)];
......
...@@ -137,6 +137,9 @@ class PanelCocoa; ...@@ -137,6 +137,9 @@ class PanelCocoa;
// Turns on user-resizable corners/sides indications and enables live resize. // Turns on user-resizable corners/sides indications and enables live resize.
- (void)enableResizeByMouse:(BOOL)enable; - (void)enableResizeByMouse:(BOOL)enable;
// Turns on/off shadow effect around the window shape.
- (void)showShadow:(BOOL)show;
- (NSRect)frameRectForContentRect:(NSRect)contentRect; - (NSRect)frameRectForContentRect:(NSRect)contentRect;
- (NSRect)contentRectForFrameRect:(NSRect)frameRect; - (NSRect)contentRectForFrameRect:(NSRect)frameRect;
......
...@@ -923,6 +923,12 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) { ...@@ -923,6 +923,12 @@ NSCursor* LoadWebKitCursor(WebKit::WebCursorInfo::Type type) {
[[self window] invalidateCursorRectsForView:overlayView_]; [[self window] invalidateCursorRectsForView:overlayView_];
} }
- (void)showShadow:(BOOL)show {
if (![self isWindowLoaded])
return;
[[self window] setHasShadow:show];
}
// We have custom implementation of these because our titlebar height is custom // We have custom implementation of these because our titlebar height is custom
// and does not match the standard one. // and does not match the standard one.
- (NSRect)frameRectForContentRect:(NSRect)contentRect { - (NSRect)frameRectForContentRect:(NSRect)contentRect {
......
...@@ -326,6 +326,10 @@ bool PanelGtk::IsPanelMinimizedBySystem() const { ...@@ -326,6 +326,10 @@ bool PanelGtk::IsPanelMinimizedBySystem() const {
return false; return false;
} }
void PanelGtk::ShowShadow(bool show) {
NOTIMPLEMENTED();
}
void PanelGtk::UpdateWindowShape() { void PanelGtk::UpdateWindowShape() {
int width = configure_size_.width(); int width = configure_size_.width();
int height = configure_size_.height(); int height = configure_size_.height();
......
...@@ -83,6 +83,7 @@ class PanelGtk : public NativePanel, ...@@ -83,6 +83,7 @@ class PanelGtk : public NativePanel,
virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) OVERRIDE; virtual void SetWindowCornerStyle(panel::CornerStyle corner_style) OVERRIDE;
virtual void MinimizePanelBySystem() OVERRIDE; virtual void MinimizePanelBySystem() OVERRIDE;
virtual bool IsPanelMinimizedBySystem() const OVERRIDE; virtual bool IsPanelMinimizedBySystem() const OVERRIDE;
virtual void ShowShadow(bool show) OVERRIDE;
virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE; virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE;
......
...@@ -228,6 +228,7 @@ void DetachedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) { ...@@ -228,6 +228,7 @@ void DetachedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
Panel::USE_SYSTEM_ATTENTION)); Panel::USE_SYSTEM_ATTENTION));
panel->SetAlwaysOnTop(false); panel->SetAlwaysOnTop(false);
panel->ShowShadow(true);
panel->EnableResizeByMouse(true); panel->EnableResizeByMouse(true);
panel->UpdateMinimizeRestoreButtonVisibility(); panel->UpdateMinimizeRestoreButtonVisibility();
panel->SetWindowCornerStyle(panel::ALL_ROUNDED); panel->SetWindowCornerStyle(panel::ALL_ROUNDED);
......
...@@ -761,6 +761,7 @@ void DockedPanelCollection::CloseAll() { ...@@ -761,6 +761,7 @@ void DockedPanelCollection::CloseAll() {
void DockedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) { void DockedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
panel->set_attention_mode(Panel::USE_PANEL_ATTENTION); panel->set_attention_mode(Panel::USE_PANEL_ATTENTION);
panel->SetAlwaysOnTop(true); panel->SetAlwaysOnTop(true);
panel->ShowShadow(true);
panel->EnableResizeByMouse(true); panel->EnableResizeByMouse(true);
panel->UpdateMinimizeRestoreButtonVisibility(); panel->UpdateMinimizeRestoreButtonVisibility();
panel->SetWindowCornerStyle(panel::TOP_ROUNDED); panel->SetWindowCornerStyle(panel::TOP_ROUNDED);
......
...@@ -88,6 +88,9 @@ class NativePanel { ...@@ -88,6 +88,9 @@ class NativePanel {
// iconic. // iconic.
virtual bool IsPanelMinimizedBySystem() const = 0; virtual bool IsPanelMinimizedBySystem() const = 0;
// Turns on/off the shadow effect around the window shape.
virtual void ShowShadow(bool show) = 0;
// Create testing interface for native panel. (Keep this last to separate // Create testing interface for native panel. (Keep this last to separate
// it from regular API.) // it from regular API.)
virtual NativePanelTesting* CreateNativePanelTesting() = 0; virtual NativePanelTesting* CreateNativePanelTesting() = 0;
......
...@@ -306,6 +306,10 @@ bool Panel::IsMinimizedBySystem() const { ...@@ -306,6 +306,10 @@ bool Panel::IsMinimizedBySystem() const {
return native_panel_->IsPanelMinimizedBySystem(); return native_panel_->IsPanelMinimizedBySystem();
} }
void Panel::ShowShadow(bool show) {
native_panel_->ShowShadow(show);
}
void Panel::Restore() { void Panel::Restore() {
if (collection_) if (collection_)
collection_->RestorePanel(this); collection_->RestorePanel(this);
......
...@@ -305,6 +305,9 @@ class Panel : public BaseWindow, ...@@ -305,6 +305,9 @@ class Panel : public BaseWindow,
bool IsMinimizedBySystem() const; bool IsMinimizedBySystem() const;
// Turns on/off the shadow effect around the window shape.
void ShowShadow(bool show);
protected: protected:
// Panel can only be created using PanelManager::CreatePanel() or subclass. // Panel can only be created using PanelManager::CreatePanel() or subclass.
// |app_name| is the default title for Panels when the page content does not // |app_name| is the default title for Panels when the page content does not
......
...@@ -522,6 +522,9 @@ void StackedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) { ...@@ -522,6 +522,9 @@ void StackedPanelCollection::UpdatePanelOnCollectionChange(Panel* panel) {
static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION | static_cast<Panel::AttentionMode>(Panel::USE_PANEL_ATTENTION |
Panel::USE_SYSTEM_ATTENTION)); Panel::USE_SYSTEM_ATTENTION));
panel->SetAlwaysOnTop(false); panel->SetAlwaysOnTop(false);
// TODO(jianli): Change from true to false when the background window is used
// to provide the shadow.
panel->ShowShadow(true);
panel->EnableResizeByMouse(true); panel->EnableResizeByMouse(true);
panel->UpdateMinimizeRestoreButtonVisibility(); panel->UpdateMinimizeRestoreButtonVisibility();
UpdatePanelCornerStyle(panel); UpdatePanelCornerStyle(panel);
......
...@@ -644,6 +644,19 @@ bool PanelView::IsPanelMinimizedBySystem() const { ...@@ -644,6 +644,19 @@ bool PanelView::IsPanelMinimizedBySystem() const {
return window_->IsMinimized(); return window_->IsMinimized();
} }
void PanelView::ShowShadow(bool show) {
#if defined(OS_WIN)
// The overlapped window has the shadow while the popup window does not have
// the shadow.
int overlap_style = WS_OVERLAPPED | WS_THICKFRAME | WS_SYSMENU;
int popup_style = WS_POPUP;
UpdateWindowAttribute(GWL_STYLE,
show ? overlap_style : popup_style,
show ? popup_style : overlap_style,
true);
#endif
}
void PanelView::AttachWebContents(content::WebContents* contents) { void PanelView::AttachWebContents(content::WebContents* contents) {
web_view_->SetWebContents(contents); web_view_->SetWebContents(contents);
} }
......
...@@ -80,6 +80,7 @@ class PanelView : public NativePanel, ...@@ -80,6 +80,7 @@ class PanelView : public NativePanel,
virtual int TitleOnlyHeight() const OVERRIDE; virtual int TitleOnlyHeight() const OVERRIDE;
virtual void MinimizePanelBySystem() OVERRIDE; virtual void MinimizePanelBySystem() OVERRIDE;
virtual bool IsPanelMinimizedBySystem() const OVERRIDE; virtual bool IsPanelMinimizedBySystem() const OVERRIDE;
virtual void ShowShadow(bool show) OVERRIDE;
virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE; virtual NativePanelTesting* CreateNativePanelTesting() OVERRIDE;
// Overridden from views::View: // Overridden from views::View:
......
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