Browse Source

Debugger tooltips - content displayed in a Popup

- added SVN keyword "Revision" to source files in Debugger.AddIn/Project/Src/Visualizers folder

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@4599 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Martin Koníček 16 years ago
parent
commit
7ff82f21ef
  1. 88
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs
  2. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj
  3. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs
  4. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/TreeNode.cs
  5. 1
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/GridVisualizerWindow.xaml.cs
  6. 13
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/LazyListView.cs
  7. 26
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/PresentationBindings/ScrollUtils.cs
  8. 4
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  9. 7
      src/Main/Base/Project/Src/Editor/ITooltip.cs
  10. 6
      src/Main/Base/Project/Src/Services/Debugger/DebuggerTooltipControl.xaml
  11. 37
      src/Main/Base/Project/Src/Services/Debugger/DebuggerTooltipControl.xaml.cs
  12. 4
      src/Main/Base/Project/Src/Services/Debugger/ITreeNode.cs

88
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs

@ -12,6 +12,7 @@ using System.IO; @@ -12,6 +12,7 @@ using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
@ -174,6 +175,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -174,6 +175,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
textEditor.TextArea.TextEntered += TextArea_TextEntered;
textEditor.MouseHover += textEditor_MouseHover;
textEditor.MouseHoverStopped += textEditor_MouseHoverStopped;
textEditor.MouseLeave += textEditor_MouseLeave;
textEditor.TextArea.Caret.PositionChanged += caret_PositionChanged;
textEditor.TextArea.DefaultInputHandler.CommandBindings.Add(
new CommandBinding(CustomCommands.CtrlSpaceCompletion, OnCodeCompletion));
@ -295,6 +297,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -295,6 +297,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
ToolTip toolTip;
Popup popup;
void textEditor_MouseHover(object sender, MouseEventArgs e)
{
@ -305,18 +308,76 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -305,18 +308,76 @@ namespace ICSharpCode.AvalonEdit.AddIn
if (pos.HasValue) {
args.LogicalPosition = AvalonEditDocumentAdapter.ToLocation(pos.Value);
}
ToolTipRequestService.RequestToolTip(args);
if (args.ContentToShow != null) {
if (toolTip == null) {
toolTip = new ToolTip();
toolTip.Closed += toolTip_Closed;
var contentToShowITooltip = args.ContentToShow as ITooltip;
if (contentToShowITooltip != null && contentToShowITooltip.ShowAsPopup) {
if (!(args.ContentToShow is UIElement)) {
throw new NotSupportedException("Content to show in Popup must be UIElement: " + args.ContentToShow);
}
if (popup == null) {
popup = createPopup();
}
// close old popup
popup.IsOpen = false;
popup.Child = (UIElement)args.ContentToShow;
setPopupPosition(popup, textEditor, e);
// open popup at new location
popup.IsOpen = true;
e.Handled = true;
}
else {
if (toolTip == null) {
toolTip = new ToolTip();
toolTip.Closed += toolTip_Closed;
}
toolTip.Content = args.ContentToShow;
toolTip.IsOpen = true;
e.Handled = true;
}
}
else {
// close popup if mouse hovered over empty area
if (popup != null) {
popup.IsOpen = false;
e.Handled = true;
}
toolTip.Content = args.ContentToShow;
toolTip.IsOpen = true;
e.Handled = true;
}
}
void setPopupPosition(Popup popup, TextEditor textEditor, MouseEventArgs mouseArgs)
{
var popupPosition = getPopupPosition(textEditor, mouseArgs);
popup.HorizontalOffset = popupPosition.X;
popup.VerticalOffset = popupPosition.Y;
}
Point getPopupPosition(TextEditor textEditor, MouseEventArgs mouseArgs)
{
Point mousePos = mouseArgs.GetPosition(textEditor);
return textEditor.PointToScreen(mousePos + new Vector(-4, 6));
// attempt to align Popup with line bottom
/*TextViewPosition? logicalPos = textEditor.GetPositionFromPoint(mousePos);
if (logicalPos.HasValue) {
return textEditor.TextArea.TextView.GetVisualPosition(logicalPos.Value, VisualYPosition.LineBottom);
}
else {
return popupPos;
}*/
}
Popup createPopup()
{
popup = new Popup();
popup.Closed += popup_Closed;
popup.Placement = PlacementMode.Absolute;
popup.StaysOpen = true;
return popup;
}
void textEditor_MouseHoverStopped(object sender, MouseEventArgs e)
{
if (toolTip != null) {
@ -325,11 +386,26 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -325,11 +386,26 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
void textEditor_MouseLeave(object sender, MouseEventArgs e)
{
if (popup != null) {
// do not close popup if mouse moved from editor to popup
if (!popup.IsMouseOver) {
popup.IsOpen = false;
}
}
}
void toolTip_Closed(object sender, RoutedEventArgs e)
{
toolTip = null;
}
void popup_Closed(object sender, EventArgs e)
{
popup = null;
}
volatile static ReadOnlyCollection<ICodeCompletionBinding> codeCompletionBindings;
public static ReadOnlyCollection<ICodeCompletionBinding> CodeCompletionBindings {

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj

@ -236,7 +236,6 @@ @@ -236,7 +236,6 @@
<DependentUpon>GridVisualizerWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Visualizers\GridVisualizer\LazyListView.cs" />
<Compile Include="Src\Visualizers\GridVisualizer\ObjectValue.cs" />
<Compile Include="Src\Visualizers\GridVisualizer\ShowGridVisualizerCommand.cs" />
<Compile Include="Src\Visualizers\GridVisualizer\ValueProviders\EnumerableValuesProvider.cs" />

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/ExpressionNode.cs

@ -75,10 +75,10 @@ namespace Debugger.AddIn.TreeModel @@ -75,10 +75,10 @@ namespace Debugger.AddIn.TreeModel
}
}
public override bool HasChildren {
public override bool HasChildNodes {
get {
if (!evaluated) EvaluateExpression();
return base.HasChildren;
return base.HasChildNodes;
}
}

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/TreeModel/TreeNode.cs

@ -53,7 +53,7 @@ namespace Debugger.AddIn.TreeModel @@ -53,7 +53,7 @@ namespace Debugger.AddIn.TreeModel
get { return childNodes; }
}
public virtual bool HasChildren {
public virtual bool HasChildNodes {
get { return childNodes != null; }
}

1
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/GridVisualizerWindow.xaml.cs

@ -16,6 +16,7 @@ using System.Windows.Documents; @@ -16,6 +16,7 @@ using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Linq;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Debugging;
using ICSharpCode.SharpDevelop.Services;
using Debugger.AddIn.Visualizers.Utils;

13
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/GridVisualizer/LazyListView.cs

@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Martin Koníček" email="martin.konicek@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Windows.Controls;
namespace Debugger.AddIn.Visualizers.GridVisualizer
{
}

26
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Visualizers/PresentationBindings/ScrollUtils.cs

@ -12,30 +12,4 @@ using System.Windows.Media; @@ -12,30 +12,4 @@ using System.Windows.Media;
namespace Debugger.AddIn.Visualizers
{
/// <summary>
/// Description of ScrollUtils.
/// </summary>
public static class ScrollUtils
{
/// <summary>
/// Searches VisualTree of given object for a ScrollViewer.
/// </summary>
public static ScrollViewer GetScrollViewer(this DependencyObject o)
{
var scrollViewer = o as ScrollViewer;
if (scrollViewer != null) {
return scrollViewer;
}
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(o); i++)
{
var child = VisualTreeHelper.GetChild(o, i);
var result = GetScrollViewer(child);
if (result != null) {
return result;
}
}
return null;
}
}
}

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

@ -106,6 +106,9 @@ @@ -106,6 +106,9 @@
<Compile Include="Src\Editor\ITextBuffer.cs" />
<Compile Include="Src\Editor\ITextEditor.cs" />
<Compile Include="Src\Editor\ITextMarker.cs" />
<Compile Include="Src\Editor\ITooltip.cs">
<DependentUpon>ToolTipService.cs</DependentUpon>
</Compile>
<Compile Include="Src\Editor\RefactoringDocumentAdapter.cs" />
<Compile Include="Src\Editor\Search\ISearchResult.cs" />
<Compile Include="Src\Editor\Search\ISearchResultFactory.cs" />
@ -219,7 +222,6 @@ @@ -219,7 +222,6 @@
<DependentUpon>DebuggerTooltipControl.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Services\Debugger\ITooltip.cs" />
<Compile Include="Src\Services\Debugger\ITreeNode.cs" />
<Compile Include="Src\Services\Debugger\LazyItemsControl.cs" />
<Compile Include="Src\Services\Debugger\VirtualizingIEnumerable.cs" />

7
src/Main/Base/Project/Src/Services/Debugger/ITooltip.cs → src/Main/Base/Project/Src/Editor/ITooltip.cs

@ -6,16 +6,17 @@ @@ -6,16 +6,17 @@
// </file>
using System;
namespace ICSharpCode.SharpDevelop.Debugging
namespace ICSharpCode.SharpDevelop.Editor
{
/// <summary>
/// Content of debugger tooltip, specifying whether it should be displayed in a WPF Popup.
/// Content of text editor tooltip (<see cref="ToolTipRequestEventArgs.ContentToShow"/>),
/// specifying whether it should be displayed in a WPF Popup.
/// </summary>
public interface ITooltip
{
/// <summary>
/// If true, this ITooltip will be displayed in a WPF Popup.
/// Otherwise this will be displayed in a WPF Tooltip.
/// Otherwise it will be displayed in a WPF Tooltip.
/// WPF Popups are (unlike WPF Tooltips) focusable.
/// </summary>
bool ShowAsPopup { get; }

6
src/Main/Base/Project/Src/Services/Debugger/DebuggerTooltipControl.xaml

@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
<RepeatButton Name="btnUp" Style="{StaticResource upButtonStyle}" Content="^" Click="BtnUp_Click"></RepeatButton>
<DataGrid VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Disabled"
GridLinesVisibility="None"
RowHeight="20" MaxHeight="202"
RowHeight="18" MaxHeight="202"
SelectionMode="Single"
SelectionUnit="FullRow"
ItemsSource="{Binding}"
@ -153,7 +153,7 @@ @@ -153,7 +153,7 @@
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Border BorderBrush="#FFDDDDDD" BorderThickness="0 0 1 0">
<TextBlock Margin="0 0 6 0" Text="{Binding Path=Name, Mode=OneWay}" VerticalAlignment="Center"></TextBlock>
<TextBlock Margin="6 0" Text="{Binding Path=Name, Mode=OneWay}" VerticalAlignment="Center"></TextBlock>
</Border>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
@ -169,7 +169,7 @@ @@ -169,7 +169,7 @@
<DataGridTemplateColumn MinWidth="20" Header="Text"> <!-- Text (value) -->
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Margin="0 0 6 0" Text="{Binding Path=Text, Mode=OneWay}" VerticalAlignment="Center"></TextBlock>
<TextBlock Margin="6 0" Text="{Binding Path=Text, Mode=OneWay}" VerticalAlignment="Center"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

37
src/Main/Base/Project/Src/Services/Debugger/DebuggerTooltipControl.xaml.cs

@ -14,6 +14,7 @@ using System.Windows.Data; @@ -14,6 +14,7 @@ using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.SharpDevelop.Debugging
{
@ -40,6 +41,24 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -40,6 +41,24 @@ namespace ICSharpCode.SharpDevelop.Debugging
private LazyItemsControl<ITreeNode> lazyGrid;
/// <summary>
/// Determines whether DebuggerTooltipControl should be displayed in WPF Popup.
/// </summary>
public bool ShowAsPopup {
get {
return true;
}
}
/// <summary>
/// Closes the debugger Popup containing this control. Also closes all child Popups.
/// </summary>
/// <returns></returns>
public bool Close()
{
throw new NotImplementedException();
}
private IEnumerable<ITreeNode> itemsSource;
public IEnumerable<ITreeNode> ItemsSource
{
@ -62,24 +81,6 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -62,24 +81,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
}
}
/// <summary>
/// Determines whether DebuggerTooltipControl should be displayed in WPF Popup.
/// </summary>
public bool ShowAsPopup {
get {
return true;
}
}
/// <summary>
/// Closes the debugger Popup containing this control. Also closes all child Popups.
/// </summary>
/// <returns></returns>
public bool Close()
{
throw new NotImplementedException();
}
private void btnExpander_Click(object sender, RoutedEventArgs e)
{
var clickedButton = (ToggleButton)e.OriginalSource;

4
src/Main/Base/Project/Src/Services/Debugger/ITreeNode.cs

@ -10,7 +10,7 @@ using System.Collections.Generic; @@ -10,7 +10,7 @@ using System.Collections.Generic;
namespace ICSharpCode.SharpDevelop.Debugging
{
/// <summary>
/// Node that can be bound to DebuggerTooltipControl.
/// Node that can be bound to <see cref="DebuggerTooltipControl" />.
/// </summary>
public interface ITreeNode
{
@ -22,6 +22,6 @@ namespace ICSharpCode.SharpDevelop.Debugging @@ -22,6 +22,6 @@ namespace ICSharpCode.SharpDevelop.Debugging
IEnumerable<ITreeNode> ChildNodes { get; }
bool HasChildren { get; }
bool HasChildNodes { get; }
}
}

Loading…
Cancel
Save