Browse Source

Implemented hiding of status strip in fullscreen.

Hiding of main menu refactored.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@455 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 20 years ago
parent
commit
1660fd6f02
  1. 2
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  2. 148
      src/Main/Base/Project/Src/Gui/Components/AutoHide/AutoHideContainer.cs
  3. 112
      src/Main/Base/Project/Src/Gui/Components/AutoHide/AutoHideMenuStripContainer.cs
  4. 34
      src/Main/Base/Project/Src/Gui/Components/AutoHide/AutoHideStatusStripContainer.cs
  5. 22
      src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

2
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -691,6 +691,8 @@ @@ -691,6 +691,8 @@
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\FullscreenPanel.cs" />
<Compile Include="Src\Dom\MemberLookupHelper.cs" />
<Compile Include="Src\Gui\Components\AutoHide\AutoHideMenuStripContainer.cs" />
<Compile Include="Src\Gui\Components\AutoHide\AutoHideStatusStripContainer.cs" />
<Compile Include="Src\Gui\Components\AutoHide\AutoHideContainer.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

148
src/Main/Base/Project/Src/Gui/Components/AutoHide/AutoHideContainer.cs

@ -0,0 +1,148 @@ @@ -0,0 +1,148 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui
{
public class AutoHideContainer: Panel
{
protected Control control;
protected bool autoHide = true;
protected bool showOnMouseMove = true;
protected bool showOnMouseDown = true;
protected int activatorHeight = 1;
protected bool mouseIn;
public virtual bool AutoHide {
get {
return autoHide;
}
set {
autoHide = value;
RefreshSize();
}
}
protected virtual void RefreshSize()
{
if (autoHide) {
this.Height = activatorHeight;
this.Controls.Clear();
} else {
this.Height = PreferredHeight;
control.Dock = DockStyle.Fill;
this.Controls.Add(control);
}
}
protected virtual int PreferredHeight {
get {
return control.PreferredSize.Height;
}
}
public bool ShowOnMouseMove {
get {
return showOnMouseMove;
}
set {
showOnMouseMove = value;
}
}
public bool ShowOnMouseDown {
get {
return showOnMouseDown;
}
set {
showOnMouseDown = value;
}
}
public Color ActivatorColor {
get {
return this.ForeColor;
}
set {
this.ForeColor = value;
}
}
public int ActivatorHeight {
get {
return activatorHeight;
}
set {
activatorHeight = value;
}
}
public AutoHideContainer(Control control)
{
if (control == null) {
throw new ArgumentNullException("control");
}
this.control = control;
RefreshSize();
this.MouseMove += OnPanelMouseMove;
this.MouseDown += OnPanelMouseDown;
control.MouseEnter += OnControlMouseEnter;
control.MouseLeave += OnControlMouseLeave;
}
protected virtual void OnPanelMouseMove(object sender, MouseEventArgs e)
{
if (showOnMouseMove && autoHide) {
ShowOverlay();
}
}
protected virtual void OnPanelMouseDown(object sender, MouseEventArgs e)
{
if (showOnMouseDown && autoHide) {
ShowOverlay();
}
}
protected virtual void OnControlMouseEnter(object sender, EventArgs e)
{
mouseIn = true;
}
protected virtual void OnControlMouseLeave(object sender, EventArgs e)
{
mouseIn = false;
HideOverlay();
}
public virtual void ShowOverlay()
{
control.Dock = DockStyle.None;
control.Size = new Size(this.Width, control.PreferredSize.Height);
if (this.Dock != DockStyle.Bottom) {
control.Location = new Point(this.Left, this.Top);
} else {
control.Location = new Point(this.Left, this.Top - control.PreferredSize.Height + 1);
}
Parent.Controls.Add(control);
control.BringToFront();
}
public virtual void HideOverlay()
{
if (Parent.Controls.Contains(control)) {
Parent.Controls.Remove(control);
}
}
}
}

112
src/Main/Base/Project/Src/Gui/Components/AutoHide/AutoHideMenuStripContainer.cs

@ -16,107 +16,34 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -16,107 +16,34 @@ namespace ICSharpCode.SharpDevelop.Gui
/// AutoHideMenuStripContainer can be used instead of MenuStrip to get a menu
/// which is automaticaly hiden and shown. It is especially useful in fullscreen.
/// </summary>
public class AutoHideMenuStripContainer: Panel
public class AutoHideMenuStripContainer: AutoHideContainer
{
MenuStrip menuStrip;
bool autoHide; // Set in the constructor to fire set_AutoHide
bool showOnMouseMove = true;
bool showOnMouseDown = true;
protected bool dropDownOpened;
bool mouseIn;
bool dropDownOpened;
Padding? defaultPadding;
/// <summary>
/// Gets or sets whether to hide the menu. If set to false, it will behave as normal menu.
/// </summary>
public bool AutoHide {
public override bool AutoHide {
get {
return autoHide;
return base.AutoHide;
}
set {
autoHide = value;
if (autoHide) {
this.Height = 1;
this.Controls.Clear();
} else {
this.Height = menuStrip.PreferredSize.Height;
menuStrip.Dock = DockStyle.Fill;
this.Controls.Add(menuStrip);
if (defaultPadding == null) {
defaultPadding = ((MenuStrip)control).Padding;
}
((MenuStrip)control).Padding = value?Padding.Empty:(Padding)defaultPadding;
base.AutoHide = value;
}
}
public bool ShowOnMouseMove {
get {
return showOnMouseMove;
}
set {
showOnMouseMove = value;
}
}
public bool ShowOnMouseDown {
get {
return showOnMouseDown;
}
set {
showOnMouseDown = value;
}
}
public Color ActivatorColor {
get {
return this.ForeColor;
}
set {
this.ForeColor = value;
}
}
public AutoHideMenuStripContainer(MenuStrip menuStrip)
public AutoHideMenuStripContainer(MenuStrip menuStrip):base(menuStrip)
{
if (menuStrip == null) {
throw new ArgumentNullException("menuStrip");
}
this.menuStrip = menuStrip;
this.AutoHide = true;
this.MouseMove += OnPanelMouseMove;
this.MouseDown += OnPanelMouseDown;
menuStrip.MouseEnter += OnMenuMouseEnter;
menuStrip.MouseLeave += OnMenuMouseLeave;
menuStrip.AutoSize = false;
menuStrip.ItemAdded += OnMenuItemAdded;
foreach(ToolStripMenuItem menuItem in menuStrip.Items) {
AddEventHandlersForItem(menuItem);
}
}
void OnPanelMouseMove(object sender, MouseEventArgs e)
{
if (showOnMouseMove && autoHide) {
ShowOverlay();
}
}
void OnPanelMouseDown(object sender, MouseEventArgs e)
{
if (showOnMouseDown && autoHide) {
ShowOverlay();
}
}
void OnMenuMouseEnter(object sender, EventArgs e)
{
mouseIn = true;
}
void OnMenuMouseLeave(object sender, EventArgs e)
{
mouseIn = false;
if (!dropDownOpened) {
HideOverlay();
}
}
void OnMenuItemAdded(object sender, EventArgs e)
{
AddEventHandlersForItem((ToolStripMenuItem)sender);
@ -141,20 +68,11 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -141,20 +68,11 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
public void ShowOverlay()
protected override void OnControlMouseLeave(object sender, EventArgs e)
{
menuStrip.Dock = DockStyle.None;
menuStrip.Location = this.Location;
menuStrip.AutoSize = false;
menuStrip.Size = new Size(this.Width, menuStrip.PreferredSize.Height);
Parent.Controls.Add(menuStrip);
menuStrip.BringToFront();
}
public void HideOverlay()
{
if (Parent.Controls.Contains(menuStrip)) {
Parent.Controls.Remove(menuStrip);
mouseIn = false;
if (!dropDownOpened) {
HideOverlay();
}
}
}

34
src/Main/Base/Project/Src/Gui/Components/AutoHide/AutoHideStatusStripContainer.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
// <file>
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
// <license see="prj:///doc/license.txt">GNU General Public License</license>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// AutoHideStatusStripContainer can be used instead of StatusStrip to get a status strip
/// which is automaticaly hiden and shown. It is especially useful in fullscreen.
/// </summary>
public class AutoHideStatusStripContainer: AutoHideContainer
{
public AutoHideStatusStripContainer(StatusStrip statusStrip): base(statusStrip)
{
statusStrip.AutoSize = false;
statusStrip.MouseMove += StatusStripMouseMove;
}
void StatusStripMouseMove(object sender, MouseEventArgs e)
{
if (e.Y < control.Height - 3) {
HideOverlay();
}
}
}
}

22
src/Main/Base/Project/Src/Gui/Workbench/Layouts/SdiWorkspaceLayout.cs

@ -31,6 +31,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -31,6 +31,7 @@ namespace ICSharpCode.SharpDevelop.Gui
Dictionary<string, PadContentWrapper> contentHash = new Dictionary<string, PadContentWrapper>();
ToolStripContainer toolStripContainer;
AutoHideMenuStripContainer mainMenuContainer;
AutoHideStatusStripContainer statusStripContainer;
public IWorkbenchWindow ActiveWorkbenchwindow {
get {
@ -106,6 +107,9 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -106,6 +107,9 @@ namespace ICSharpCode.SharpDevelop.Gui
this.dockPanel.ActiveAutoHideContent = null;
this.dockPanel.Dock = System.Windows.Forms.DockStyle.Fill;
statusStripContainer = new AutoHideStatusStripContainer((StatusStrip)StatusBarService.Control);
statusStripContainer.Dock = DockStyle.Bottom;
LoadLayoutConfiguration();
ShowPads();
ShowViewContents();
@ -119,8 +123,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -119,8 +123,7 @@ namespace ICSharpCode.SharpDevelop.Gui
// wbForm.Controls.Add(this.dockPanel);
toolStripContainer.ContentPanel.Controls.Add(mainMenuContainer);
StatusBarService.Control.Dock = DockStyle.Bottom;
toolStripContainer.ContentPanel.Controls.Add(StatusBarService.Control);
toolStripContainer.ContentPanel.Controls.Add(statusStripContainer);
wbForm.Controls.Add(toolStripContainer);
@ -146,6 +149,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -146,6 +149,7 @@ namespace ICSharpCode.SharpDevelop.Gui
switch (e.Key) {
case "HideMainMenu":
case "HideToolbars":
case "HideStatusBar":
RedrawAllComponents();
break;
}
@ -481,6 +485,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -481,6 +485,7 @@ namespace ICSharpCode.SharpDevelop.Gui
RedrawMainMenu();
RedrawToolbars();
RedrawStatusBar();
}
void RedrawMainMenu()
@ -511,6 +516,19 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -511,6 +516,19 @@ namespace ICSharpCode.SharpDevelop.Gui
}
}
void RedrawStatusBar()
{
Properties fullscreenProperties = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.FullscreenOptions", new Properties());
bool hideInFullscreen = fullscreenProperties.Get("HideStatusBar", true);
bool showOnMouseMove = fullscreenProperties.Get("ShowStatusBarOnMouseMove", true);
bool statusBarVisible = PropertyService.Get("ICSharpCode.SharpDevelop.Gui.StatusBarVisible", true);
statusStripContainer.AutoHide = wbForm.FullScreen && hideInFullscreen;
statusStripContainer.ShowOnMouseDown = true;
statusStripContainer.ShowOnMouseMove = showOnMouseMove;
statusStripContainer.Visible = statusBarVisible;
}
public void CloseWindowEvent(object sender, EventArgs e)
{
SdiWorkspaceWindow f = (SdiWorkspaceWindow)sender;

Loading…
Cancel
Save