aboutsummaryrefslogtreecommitdiffstatsci
path: root/src/Interface.cs
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-09 18:46:40 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2018-02-09 18:46:40 +0100
commitd783669223da5bfe8caa1b95c0ff6e1c5046e09e (patch)
tree08e156330c147d73aff48d018d60df6bfa50e259 /src/Interface.cs
parent8678c71d24bd88ceca04dc71b0d1b93a2f51cecf (diff)
Squashed commit devel branch:
commit 7f91f7c2e83f7cfb2922ea83586f156f03f88a59 Author: Jean-Philippe Bruyère <jp_bruyere@hotmail.com> Date: Fri Feb 9 18:13:59 2018 +0100 go back to OpenTK-2, waiting for an official release commit 125f32758a584c4976d3536eab3702fd37a8a7a9 Author: Jean-Philippe Bruyère <jp_bruyere@hotmail.com> Date: Fri Feb 9 17:26:00 2018 +0100 LoadInterface replaced by AddWidget overload, [ide] property view item templates in separate template file commit 7c48cd2f0332d2ec82006edb755fcd37ab1f2b4a Author: Jean-Philippe Bruyère <jp_bruyere@hotmail.com> Date: Fri Feb 9 12:10:13 2018 +0100 Tooltips, CrowIDE improvements, Fetch subdata when test not eq TypeOf, debug listener in basicTest, RemoveWidget in iface modifié : Crow.ControlsLib/Crow.ControlsLib.csproj modifié : Crow.csproj modifié : Crow.sln modifié : CrowIDE/CrowIDE.csproj modifié : CrowIDE/src/CrowIDE.cs modifié : CrowIDE/src/ImlVisualEditor.cs nouveau fichier : CrowIDE/src/Project.cs nouveau fichier : CrowIDE/src/Solution.cs nouveau fichier : CrowIDE/src/VerticalLine.cs nouveau fichier : CrowIDE/ui/ProjectProperties.crow nouveau fichier : CrowIDE/ui/ProjectTree.template nouveau fichier : CrowIDE/ui/TreeExpandable.template modifié : CrowIDE/ui/imlEditor.crow modifié : Default.style nouveau fichier : Icons/assembly.svg nouveau fichier : Templates/Tooltip.template modifié : Tests/BasicTests.cs modifié : Tests/HelloWorld.cs modifié : Tests/Interfaces/Divers/0.crow modifié : Tests/Interfaces/Divers/testShape.crow modifié : Tests/Interfaces/Divers/welcome.crow modifié : Tests/Tests.csproj modifié : src/CompilerServices/CompilerServices.cs modifié : src/GraphicObjects/FileDialog.cs modifié : src/GraphicObjects/GraphicObject.cs modifié : src/GraphicObjects/MessageBox.cs modifié : src/Instantiator.cs modifié : src/Interface.cs modifié : src/ItemTemplate.cs
Diffstat (limited to 'src/Interface.cs')
-rw-r--r--src/Interface.cs84
1 files changed, 76 insertions, 8 deletions
diff --git a/src/Interface.cs b/src/Interface.cs
index ab78e42d..992ff6f6 100644
--- a/src/Interface.cs
+++ b/src/Interface.cs
@@ -88,6 +88,8 @@ namespace Crow
public Interface(){
CurrentInterface = this;
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
+
+ initTooltip ();
}
#endregion
@@ -100,6 +102,8 @@ namespace Crow
public static bool FocusOnHover = false;
/// <summary> Threshold to catch borders for sizing </summary>
public static int BorderThreshold = 5;
+ /// <summary> delay before tooltip appear </summary>
+ public static int ToolTipDelay = 500;
/// <summary>Double click threshold in milisecond</summary>
public static int DoubleClick = 200;//max duration between two mouse_down evt for a dbl clk in milisec.
/// <summary> Time to wait in millisecond before starting repeat loop</summary>
@@ -313,9 +317,12 @@ namespace Crow
return tmp;
}
}
- /// <summary>Create an instance of a GraphicObject and add it to the GraphicTree
- /// of this Interface</summary>
- public GraphicObject LoadInterface (string path)
+ /// <summary>
+ /// Create an instance of a GraphicObject and add it to the GraphicTree of this Interface
+ /// </summary>
+ /// <returns>new instance of graphic object created</returns>
+ /// <param name="path">path of the iml file to load</param>
+ public GraphicObject AddWidget (string path)
{
lock (UpdateMutex) {
GraphicObject tmp = Load (path);
@@ -323,8 +330,11 @@ namespace Crow
return tmp;
}
}
- /// <summary>Create an instance of a GraphicObject linked to this interface but
- /// not added to the GraphicTree</summary>
+ /// <summary>
+ /// Create an instance of a GraphicObject linked to this interface but not added to the GraphicTree
+ /// </summary>
+ /// <returns>new instance of graphic object created</returns>
+ /// <param name="path">path of the iml file to load</param>
public GraphicObject Load (string path)
{
try {
@@ -333,7 +343,11 @@ namespace Crow
throw new Exception ("Error loading <" + path + ">:", ex);
}
}
- /// <summary>Fetch instantiator it from cache or create it</summary>
+ /// <summary>
+ /// Fetch instantiator from cache or create it.
+ /// </summary>
+ /// <returns>new Instantiator</returns>
+ /// <param name="path">path of the iml file to load</param>
public static Instantiator GetInstantiator(string path){
if (!Instantiators.ContainsKey(path))
Instantiators [path] = new Instantiator(path);
@@ -626,7 +640,7 @@ namespace Crow
#region GraphicTree handling
/// <summary>Add widget to the Graphic tree of this interface and register it for layouting</summary>
- public void AddWidget(GraphicObject g, bool isOverlay = false)
+ public void AddWidget(GraphicObject g)
{
g.Parent = this;
int ptr = 0;
@@ -648,7 +662,7 @@ namespace Crow
g.RegisteredLayoutings = LayoutingType.None;
g.RegisterForLayouting (LayoutingType.Sizing | LayoutingType.ArrangeChildren);
}
- /// <summary>Set visible state of widget to false and remove if from the graphic tree</summary>
+ /// <summary>Set visible state of widget to false and delete if from the graphic tree</summary>
public void DeleteWidget(GraphicObject g)
{
lock (UpdateMutex) {
@@ -658,6 +672,15 @@ namespace Crow
g.Dispose ();
}
}
+ /// <summary>Set visible state of widget to false and remove if from the graphic tree</summary>
+ public void RemoveWidget(GraphicObject g)
+ {
+ lock (UpdateMutex) {
+ RegisterClip (g.ScreenCoordinates (g.LastPaintedSlot));
+ GraphicTree.Remove (g);
+ g.Parent = null;
+ }
+ }
/// <summary> Remove all Graphic objects from top container </summary>
public void ClearInterface()
{
@@ -770,6 +793,7 @@ namespace Crow
}
if (HoverWidget != null) {
+ resetTooltip ();
//check topmost graphicobject first
GraphicObject tmp = HoverWidget;
GraphicObject topc = null;
@@ -947,6 +971,50 @@ namespace Crow
}
#endregion
+ #region Tooltip handling
+ Stopwatch tooltipTimer = new Stopwatch();
+ GraphicObject ToolTipContainer = null;
+ volatile bool tooltipVisible = false;
+
+ void initTooltip () {
+ ToolTipContainer = Load ("#Crow.Tooltip.template");
+ Thread t = new Thread (toolTipThreadFunc);
+ t.IsBackground = true;
+ t.Start ();
+ }
+ void toolTipThreadFunc ()
+ {
+ while(true) {
+ if (tooltipTimer.ElapsedMilliseconds > ToolTipDelay) {
+ if (!tooltipVisible) {
+ GraphicObject g = _hoverWidget;
+ while (g != null) {
+ if (!string.IsNullOrEmpty (g.Tooltip)) {
+ AddWidget (ToolTipContainer);
+ ToolTipContainer.DataSource = g;
+ ToolTipContainer.Top = Mouse.Y + 10;
+ ToolTipContainer.Left = Mouse.X + 10;
+ tooltipVisible = true;
+ break;
+ }
+ g = g.LogicalParent as GraphicObject;
+ }
+ }
+ }
+ Thread.Sleep (200);
+ }
+
+ }
+ void resetTooltip () {
+ if (tooltipVisible) {
+ //ToolTipContainer.DataSource = null;
+ RemoveWidget (ToolTipContainer);
+ tooltipVisible = false;
+ }
+ tooltipTimer.Restart ();
+ }
+ #endregion
+
#region Device Repeat Events
volatile bool mouseRepeatOn, keyboardRepeatOn;
volatile int mouseRepeatCount, keyboardRepeatCount;