Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Karlaš <david.karlas@xamarin.com>2015-04-17 13:14:38 +0300
committerDavid Karlaš <david.karlas@xamarin.com>2015-04-17 13:14:48 +0300
commit0f739988a2728794b0af86ba475ba6316a4ca74e (patch)
tree6abc577eb5ad2be162f0bab66ed89f08bafebc91
parent42fe1bed79bb077b3541c8f2c13bb06a145e611d (diff)
[Ide] Added AddOverlay/RemoveOverlay to TextEditor API and reenabled DisassemblyView overlay
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DisassemblyView.cs146
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs9
-rw-r--r--main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs51
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs3
-rw-r--r--main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs10
5 files changed, 72 insertions, 147 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DisassemblyView.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DisassemblyView.cs
index a99d5b1526..a180c96070 100644
--- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DisassemblyView.cs
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger/DisassemblyView.cs
@@ -89,17 +89,16 @@ namespace MonoDevelop.Debugger
currentDebugLineMarker = TextMarkerFactory.CreateCurrentDebugLineTextMarker (editor);
DebuggingService.StoppedEvent += OnStop;
}
-
- OverlayMessageWindow messageOverlayWindow;
+ HBox messageOverlayContent;
void ShowLoadSourceFile (StackFrame sf)
{
- if (messageOverlayWindow != null) {
- messageOverlayWindow.Destroy ();
- messageOverlayWindow = null;
+ if (messageOverlayContent != null) {
+ editor.RemoveOverlay (messageOverlayContent);
+ messageOverlayContent = null;
}
- messageOverlayWindow = new OverlayMessageWindow ();
+ messageOverlayContent = new HBox ();
var hbox = new HBox ();
hbox.Spacing = 8;
@@ -117,13 +116,10 @@ namespace MonoDevelop.Debugger
openButton.WidthRequest = 60;
hbox.PackEnd (openButton, false, false, 0);
- var container = new HBox ();
const int containerPadding = 8;
- container.PackStart (hbox, true, true, containerPadding);
- messageOverlayWindow.Child = container;
- messageOverlayWindow.ShowOverlay (editor);
+ messageOverlayContent.PackStart (hbox, true, true, containerPadding);
+ editor.AddOverlay (messageOverlayContent,() => openButton.SizeRequest ().Width + w + hbox.Spacing * 5 + containerPadding * 2);
- messageOverlayWindow.SizeFunc = () => openButton.SizeRequest ().Width + w + hbox.Spacing * 5 + containerPadding * 2;
openButton.Clicked += delegate {
var dlg = new OpenFileDialog (GettextCatalog.GetString ("File to Open"), Gtk.FileChooserAction.Open) {
TransientFor = IdeApp.Workbench.RootWindow,
@@ -182,9 +178,9 @@ namespace MonoDevelop.Debugger
editor.RemoveMarker (currentDebugLineMarker);
if (DebuggingService.CurrentFrame == null) {
- if (messageOverlayWindow != null) {
- messageOverlayWindow.Destroy ();
- messageOverlayWindow = null;
+ if (messageOverlayContent != null) {
+ editor.RemoveOverlay (messageOverlayContent);
+ messageOverlayContent = null;
}
sw.Sensitive = false;
return;
@@ -195,9 +191,9 @@ namespace MonoDevelop.Debugger
if (!string.IsNullOrWhiteSpace (sf.SourceLocation.FileName) && sf.SourceLocation.Line != -1 && sf.SourceLocation.FileHash != null) {
ShowLoadSourceFile (sf);
} else {
- if (messageOverlayWindow != null) {
- messageOverlayWindow.Destroy ();
- messageOverlayWindow = null;
+ if (messageOverlayContent != null) {
+ editor.RemoveOverlay (messageOverlayContent);
+ messageOverlayContent = null;
}
}
if (!string.IsNullOrEmpty (sf.SourceLocation.FileName) && File.Exists (sf.SourceLocation.FileName))
@@ -400,9 +396,9 @@ namespace MonoDevelop.Debugger
{
addressLines.Clear ();
currentFile = null;
- if (messageOverlayWindow != null) {
- messageOverlayWindow.Destroy ();
- messageOverlayWindow = null;
+ if (messageOverlayContent != null) {
+ editor.RemoveOverlay (messageOverlayContent);
+ messageOverlayContent = null;
}
sw.Sensitive = false;
autoRefill = false;
@@ -490,114 +486,4 @@ namespace MonoDevelop.Debugger
#endregion
}
-
-// class AsmLineMarker: TextLineMarker
-// {
-// public override ChunkStyle GetStyle (ChunkStyle baseStyle)
-// {
-// ChunkStyle st = new ChunkStyle (baseStyle);
-// st.Foreground = new Cairo.Color (125, 125, 125);
-// return st;
-// }
-// }
-
- //Copy pasted from SourceEditor
- class OverlayMessageWindow : Gtk.EventBox
- {
- const int border = 8;
-
- public Func<int> SizeFunc;
-
- TextEditor textEditor;
-
- public OverlayMessageWindow ()
- {
- AppPaintable = true;
- }
-
- public void ShowOverlay (TextEditor textEditor)
- {
- this.textEditor = textEditor;
- this.ShowAll ();
-
- // TODO :Editor transition
-// textEditor.AddTopLevelWidget (this, 0, 0);
-// textEditor.SizeAllocated += HandleSizeAllocated;
-// var child = (TextEditor.EditorContainerChild)textEditor [this];
-// child.FixedPosition = true;
- }
-
- protected override void OnDestroyed ()
- {
- base.OnDestroyed ();
- // TODO :Editor transition
-/* if (textEditor != null) {
- textEditor.SizeAllocated -= HandleSizeAllocated;
- textEditor = null;
- }*/
- }
-
- protected override void OnSizeRequested (ref Requisition requisition)
- {
- base.OnSizeRequested (ref requisition);
-
- if (wRequest > 0) {
- requisition.Width = wRequest;
- }
- }
-
- protected override void OnSizeAllocated (Gdk.Rectangle allocation)
- {
- base.OnSizeAllocated (allocation);
- Resize (allocation);
- }
-
- int wRequest = -1;
-
- void HandleSizeAllocated (object o, Gtk.SizeAllocatedArgs args)
- {
- // TODO :Editor transition
-// if (SizeFunc != null) {
-// var req = Math.Min (SizeFunc (), textEditor.Allocation.Width - border * 2);
-// if (req != wRequest) {
-// wRequest = req;
-// QueueResize ();
-// }
-// } else {
-// if (Allocation.Width > textEditor.Allocation.Width - border * 2) {
-// if (textEditor.Allocation.Width - border * 2 > 0) {
-// QueueResize ();
-// }
-// }
-// }
- Resize (Allocation);
- }
-
- void Resize (Gdk.Rectangle alloc)
- {
- // TODO :Editor transition
-// textEditor.MoveTopLevelWidget (this, (textEditor.Allocation.Width - alloc.Width) / 2, textEditor.Allocation.Height - alloc.Height - 8);
- }
-
- protected override bool OnExposeEvent (Gdk.EventExpose evnt)
- {
- // TODO :Editor transition
-
-// using (var cr = CairoHelper.Create (evnt.Window)) {
-// cr.LineWidth = 1;
-// cr.Rectangle (0, 0, Allocation.Width, Allocation.Height);
-// cr.SetSourceColor (textEditor.ColorStyle.NotificationText.Background);
-// cr.Fill ();
-// cr.RoundedRectangle (0, 0, Allocation.Width, Allocation.Height, 3);
-// cr.SetSourceColor (textEditor.ColorStyle.NotificationText.Background);
-// cr.FillPreserve ();
-//
-// cr.SetSourceColor (textEditor.ColorStyle.NotificationBorder.Color);
-// cr.Stroke ();
-// }
-
- return base.OnExposeEvent (evnt);
- }
-
- }
}
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
index dba695282b..4eb11371f1 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
@@ -2956,6 +2956,15 @@ namespace MonoDevelop.SourceEditor
}
}
+ public void AddOverlay (Control messageOverlayContent, Func<int> sizeFunc)
+ {
+ widget.AddOverlay (messageOverlayContent.GetNativeWidget<Widget> (), sizeFunc);
+ }
+
+ public void RemoveOverlay (Control messageOverlayContent)
+ {
+ widget.RemoveOverlay (messageOverlayContent.GetNativeWidget<Widget> ());
+ }
#region IEditorActionHost implementation
diff --git a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
index a5856a784e..299f164844 100644
--- a/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
+++ b/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorWidget.cs
@@ -819,13 +819,31 @@ namespace MonoDevelop.SourceEditor
return "Unknown";
}
- OverlayMessageWindow messageOverlayWindow;
+ //TODO: Support multiple Overlays at once to display above each other
+ internal void AddOverlay (Widget messageOverlayContent, Func<int> sizeFunc = null)
+ {
+ var messageOverlayWindow = new OverlayMessageWindow ();
+ messageOverlayWindow.Child = messageOverlayContent;
+ messageOverlayWindow.SizeFunc = sizeFunc;
+ messageOverlayWindow.ShowOverlay (TextEditor);
+ messageOverlayWindows.Add (messageOverlayWindow);
+ }
+
+ internal void RemoveOverlay (Widget messageOverlayContent)
+ {
+ var window = messageOverlayWindows.FirstOrDefault (w => w.Child == messageOverlayContent);
+ if (window == null)
+ return;
+ messageOverlayWindows.Remove (window);
+ window.Destroy ();
+ }
+
+ List<OverlayMessageWindow> messageOverlayWindows = new List<OverlayMessageWindow> ();
+ HBox incorrectEolMessage;
void ShowIncorrectEolMarkers (string fileName, bool multiple)
{
RemoveMessageBar ();
- messageOverlayWindow = new OverlayMessageWindow ();
-
var hbox = new HBox ();
hbox.Spacing = 8;
@@ -857,11 +875,9 @@ namespace MonoDevelop.SourceEditor
var combo = new ComboBox (list.ToArray ());
combo.Active = 0;
hbox.PackEnd (combo, false, false, 0);
- var container = new HBox ();
+ incorrectEolMessage = new HBox ();
const int containerPadding = 8;
- container.PackStart (hbox, true, true, containerPadding);
- messageOverlayWindow.Child = container;
- messageOverlayWindow.ShowOverlay (this.TextEditor);
+ incorrectEolMessage.PackStart (hbox, true, true, containerPadding);
// This is hacky, but it will ensure that our combo appears with with the correct size.
GLib.Timeout.Add (100, delegate {
@@ -869,14 +885,15 @@ namespace MonoDevelop.SourceEditor
return false;
});
- messageOverlayWindow.SizeFunc = () => {
+ AddOverlay (incorrectEolMessage, () => {
return okButton.SizeRequest ().Width +
- combo.SizeRequest ().Width +
- image.SizeRequest ().Width +
- w +
- hbox.Spacing * 4 +
- containerPadding * 2;
- };
+ combo.SizeRequest ().Width +
+ image.SizeRequest ().Width +
+ w +
+ hbox.Spacing * 4 +
+ containerPadding * 2;
+ });
+
image.Clicked += delegate {
UseIncorrectMarkers = true;
view.WorkbenchWindow.ShowNotification = false;
@@ -974,9 +991,9 @@ namespace MonoDevelop.SourceEditor
}
if (!TextEditor.Visible)
TextEditor.Visible = true;
- if (messageOverlayWindow != null) {
- messageOverlayWindow.Destroy ();
- messageOverlayWindow = null;
+ if (incorrectEolMessage != null) {
+ RemoveOverlay (incorrectEolMessage);
+ incorrectEolMessage = null;
}
}
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs
index 1cae07fe08..4b299a40ef 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/InternalExtensionAPI/ITextEditorImpl.cs
@@ -237,5 +237,8 @@ namespace MonoDevelop.Ide.Editor
double ZoomLevel { get; set; }
event EventHandler ZoomLevelChanged;
+
+ void AddOverlay (Control messageOverlayContent, Func<int> sizeFunc);
+ void RemoveOverlay (Control messageOverlayContent);
}
} \ No newline at end of file
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs
index 705b6e58e5..b66ec68a1c 100644
--- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs
+++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Editor/TextEditor.cs
@@ -1243,5 +1243,15 @@ namespace MonoDevelop.Ide.Editor
}
projectionsAdded = true;
}
+
+ public void AddOverlay (Control messageOverlayContent, Func<int> sizeFunc)
+ {
+ textEditorImpl.AddOverlay (messageOverlayContent, sizeFunc);
+ }
+
+ public void RemoveOverlay (Control messageOverlayContent)
+ {
+ textEditorImpl.RemoveOverlay (messageOverlayContent);
+ }
}
} \ No newline at end of file