From 5f1d0213e0dadecc8f93d44e36ea3a11a1aa9baa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Tue, 13 Mar 2018 17:16:24 +0100 Subject: [PATCH] limit to html safe color plus several ones, crowIDE wip --- Crow.csproj | 2 +- CrowIDE/CrowIDE.csproj | 8 +- CrowIDE/src/CrowIDE.cs | 10 +- CrowIDE/src/DesignInterface.cs | 15 - CrowIDE/src/Editors/CodeBuffer/CodeBuffer.cs | 6 +- CrowIDE/src/Editors/CodeBuffer/TextBuffer.cs | 20 +- .../Editors/CodeBuffer/TextBufferEventArgs.cs | 20 + CrowIDE/src/Editors/CodeBuffer/TextEditor.cs | 10 +- CrowIDE/src/Editors/ImlVisualEditor.cs | 141 ++- CrowIDE/src/Editors/Parsers/BufferParser.cs | 2 +- CrowIDE/src/Editors/Parsers2/Tokenizer.cs | 67 + .../Editors/{CodeBuffer => }/SourceEditor.cs | 18 +- CrowIDE/src/MemberView/MembersView.cs | 26 +- CrowIDE/src/MemberView/PropertyContainer.cs | 15 +- CrowIDE/src/Project.cs | 6 + CrowIDE/src/ProjectTree/ImlProjectItem.cs | 21 + CrowIDE/src/ProjectTree/ProjectFile.cs | 21 +- CrowIDE/src/ProjectTree/StyleProjectItem.cs | 50 + CrowIDE/src/Solution.cs | 54 + CrowIDE/ui/CategoryExp.template | 21 + CrowIDE/ui/ContextMenu.template | 2 +- CrowIDE/ui/CrowIDE.crow | 3 +- CrowIDE/ui/DockWindows/GTreeExpITemp.crow | 2 +- CrowIDE/ui/DockWindows/WinSchemaItem.template | 2 +- CrowIDE/ui/DockWindows/winGTExplorer.crow | 2 +- CrowIDE/ui/DockWindows/winStyleView.crow | 16 + CrowIDE/ui/DockWindows/winToolbox.crow | 2 +- CrowIDE/ui/IDE.style | 26 +- CrowIDE/ui/ItemTemplates/Enum.template | 3 +- CrowIDE/ui/ItemTemplates/Fill.template | 2 +- CrowIDE/ui/LQIsExplorer.crow | 6 +- CrowIDE/ui/MembersItem.template | 24 +- CrowIDE/ui/MenuItem.template | 2 +- CrowIDE/ui/Options.crow | 6 +- CrowIDE/ui/ProjectTree.template | 42 +- CrowIDE/ui/TreeExpandable.template | 7 +- CrowIDE/ui/editors/IMLEdit.itemp | 54 +- CrowIDE/ui/editors/TextEditor.crow | 2 +- CrowIDE/ui/test.crow | 4 +- Default.style | 26 +- Templates/ColorPicker.template | 2 +- Templates/ContextMenu.template | 4 +- Templates/FileDialog.template | 2 +- Templates/HScrollBar.template | 6 +- Templates/MenuItem.template | 2 +- Templates/ScrollBar.template | 6 +- Templates/TabItem.template | 2 +- Templates/Tooltip.template | 4 +- Tests/BasicTests.cs | 16 +- Tests/Interfaces/Container/0.crow | 4 +- Tests/Interfaces/Container/2.crow | 4 +- Tests/Interfaces/Container/3.crow | 4 +- Tests/Interfaces/Divers/0.crow | 20 +- Tests/Interfaces/Divers/colorPicker.crow | 4 +- Tests/Interfaces/Divers/testPropLess.crow | 2 +- Tests/Interfaces/Divers/testShape.crow | 6 +- Tests/Interfaces/Divers/welcome.crow | 6 +- Tests/Interfaces/DragAndDrop/0.crow | 12 +- Tests/Interfaces/Experimental/testDock.crow | 6 +- Tests/Interfaces/Experimental/testDock2.crow | 2 +- Tests/Interfaces/Experimental/testStack.crow | 4 +- Tests/Interfaces/GraphicObject/0.crow | 2 +- Tests/Interfaces/GraphicObject/1.crow | 2 +- Tests/Interfaces/Group/0.crow | 8 +- Tests/Interfaces/Group/1.crow | 20 +- Tests/Interfaces/Group/2.crow | 20 +- Tests/Interfaces/Group/3.crow | 20 +- Tests/Interfaces/Group/4.crow | 4 +- Tests/Interfaces/Splitter/1.crow | 2 +- Tests/Interfaces/Stack/0.crow | 8 +- Tests/Interfaces/Stack/0h.crow | 8 +- Tests/Interfaces/Stack/1.crow | 8 +- Tests/Interfaces/Stack/1h.crow | 8 +- Tests/Interfaces/Stack/2.crow | 8 +- Tests/Interfaces/Stack/2h.crow | 8 +- Tests/Interfaces/Stack/3.crow | 44 +- Tests/Interfaces/Stack/3h.crow | 44 +- Tests/Interfaces/Stack/4.crow | 44 +- Tests/Interfaces/TabItem.template | 2 +- Tests/Interfaces/TemplatedContainer/0.crow | 2 +- .../TemplatedContainer/testTabView.crow | 10 +- .../TemplatedContainer/testTabView2.crow | 16 +- .../TemplatedControl/testCombobox.crow | 2 +- Tests/Interfaces/Wrapper/1.1.crow | 20 +- Tests/Interfaces/Wrapper/1.crow | 20 +- Tests/Interfaces/Wrapper/2.1.crow | 20 +- Tests/Interfaces/Wrapper/2.2.crow | 56 +- Tests/Interfaces/Wrapper/2.crow | 20 +- Tests/Tests.csproj | 4 +- Tests/Tutorials/T4_Gauge.cs | 2 +- Tests/test.style | 16 +- Tests/ui/showcase.crow | 4 +- Tests/ui/test.crow | 4 +- src/Colors.cs | 1105 ++++------------- src/GraphicObjects/Border.cs | 2 +- src/GraphicObjects/ColorPicker.cs | 11 +- src/GraphicObjects/Expandable.cs | 2 +- src/GraphicObjects/GraphicObject.cs | 2 +- src/GraphicObjects/Label.cs | 2 +- src/GraphicObjects/SaturationValueSelector.cs | 2 +- src/GraphicObjects/Window.cs | 4 +- src/Instantiator.cs | 10 +- src/Interface.cs | 4 +- src/ObservableList.cs | 1 + src/Size.cs | 8 + src/StyleReader.cs | 26 +- 106 files changed, 1095 insertions(+), 1424 deletions(-) create mode 100644 CrowIDE/src/Editors/CodeBuffer/TextBufferEventArgs.cs create mode 100644 CrowIDE/src/Editors/Parsers2/Tokenizer.cs rename CrowIDE/src/Editors/{CodeBuffer => }/SourceEditor.cs (98%) create mode 100644 CrowIDE/src/ProjectTree/StyleProjectItem.cs create mode 100755 CrowIDE/ui/CategoryExp.template create mode 100644 CrowIDE/ui/DockWindows/winStyleView.crow diff --git a/Crow.csproj b/Crow.csproj index f14b185a..db3da7bb 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -36,7 +36,7 @@ true - __linux__ + DESIGN_MODE $(SolutionDir)build\Release diff --git a/CrowIDE/CrowIDE.csproj b/CrowIDE/CrowIDE.csproj index 6f423c09..a92b4d9b 100644 --- a/CrowIDE/CrowIDE.csproj +++ b/CrowIDE/CrowIDE.csproj @@ -111,7 +111,6 @@ - @@ -122,6 +121,10 @@ + + + + @@ -135,6 +138,7 @@ + @@ -290,6 +294,8 @@ Crow.Coding.ui.TextEditor.crow + + diff --git a/CrowIDE/src/CrowIDE.cs b/CrowIDE/src/CrowIDE.cs index 12664f1b..783db5d1 100644 --- a/CrowIDE/src/CrowIDE.cs +++ b/CrowIDE/src/CrowIDE.cs @@ -42,7 +42,7 @@ namespace Crow.Coding CMDUndo, CMDRedo, CMDCut, CMDCopy, CMDPaste, CMDHelp, CMDAbout, CMDOptions, CMDViewGTExp, CMDViewProps, CMDViewProj, CMDViewProjProps, CMDViewErrors, CMDViewSolution, CMDViewEditor, CMDViewProperties, - CMDViewToolbox, CMDViewSchema, + CMDViewToolbox, CMDViewSchema, CMDViewStyling, CMDCompile; void initCommands () { @@ -57,7 +57,7 @@ namespace Crow.Coding CMDCopy = new Command(new Action(() => Quit (null, null))) { Caption = "Copy", Icon = new SvgPicture("#Crow.Coding.icons.copy-file.svg"), CanExecute = false}; CMDPaste = new Command(new Action(() => Quit (null, null))) { Caption = "Paste", Icon = new SvgPicture("#Crow.Coding.icons.paste-on-document.svg"), CanExecute = false}; CMDHelp = new Command(new Action(() => System.Diagnostics.Debug.WriteLine("help"))) { Caption = "Help", Icon = new SvgPicture("#Crow.Coding.icons.question.svg")}; - CMDOptions = new Command(new Action(() => openOptionsDialog())) { Caption = "Editor Options", Icon = new SvgPicture("#Crow.Coding.icons.tools.svg")}; + CMDOptions = new Command(new Action(() => loadWindow("#Crow.Coding.ui.Options.crow"))) { Caption = "Editor Options", Icon = new SvgPicture("#Crow.Coding.icons.tools.svg")}; cmdCloseSolution = new Command(new Action(() => closeSolution())) { Caption = "Close Solution", Icon = new SvgPicture("#Crow.Coding.ui.icons.paste-on-document.svg"), CanExecute = false}; @@ -74,6 +74,8 @@ namespace Crow.Coding { Caption = "Toolbox", CanExecute = false}; CMDViewSchema = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winSchema.crow"))) { Caption = "IML Shematic View", CanExecute = true}; + CMDViewStyling = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winStyleView.crow"))) + { Caption = "Styling Explorer", CanExecute = true}; CMDViewGTExp = new Command(new Action(() => loadDockWindow ("#Crow.Coding.ui.DockWindows.winGTExplorer.crow"))) { Caption = "Graphic Tree Explorer", CanExecute = false}; @@ -103,12 +105,13 @@ namespace Crow.Coding static void Main () { CrowIDE win = new CrowIDE (); + MainWin = win; win.Run (30); } public CrowIDE () : base(1024, 800,"UIEditor") - { + { } Instantiator instFileDlg; @@ -117,6 +120,7 @@ namespace Crow.Coding Docker mainDock; public static Interface MainIFace; + public static CrowIDE MainWin; protected override void OnLoad (EventArgs e) { diff --git a/CrowIDE/src/DesignInterface.cs b/CrowIDE/src/DesignInterface.cs index 4178e398..04666b11 100644 --- a/CrowIDE/src/DesignInterface.cs +++ b/CrowIDE/src/DesignInterface.cs @@ -66,21 +66,6 @@ namespace Crow.Coding return CreateITorFromIMLFragment (pi.Source).CreateInstance(); return null; } - public override Crow.IML.Instantiator GetInstantiator (string path) - { - System.Diagnostics.Debugger.Break (); - return null; - } - public override ItemTemplate GetItemTemplate (string path) - { - ProjectFile pi; - - if (ProjFile.Project.solution.GetProjectFileFromPath (path, out pi)) - return new ItemTemplate (this, pi.AbsolutePath); - - System.Diagnostics.Debugger.Break (); - return null; - } public override System.IO.Stream GetStreamFromPath (string path) { ProjectFile pi; diff --git a/CrowIDE/src/Editors/CodeBuffer/CodeBuffer.cs b/CrowIDE/src/Editors/CodeBuffer/CodeBuffer.cs index 13c422a6..7d5efec9 100644 --- a/CrowIDE/src/Editors/CodeBuffer/CodeBuffer.cs +++ b/CrowIDE/src/Editors/CodeBuffer/CodeBuffer.cs @@ -63,7 +63,7 @@ namespace Crow.Coding public CodeLine this[int i] { - get { return lines[i]; } + get { return i < LineCount ? lines[i] : null; } set { if (lines [i] == value) return; @@ -392,7 +392,9 @@ namespace Crow.Coding editMutex.EnterReadLock (); - if (value >= lines.Count) + if (LineCount == 0) + _currentLine = 0; + else if (value >= lines.Count) _currentLine = lines.Count-1; else if (value < 0) _currentLine = 0; diff --git a/CrowIDE/src/Editors/CodeBuffer/TextBuffer.cs b/CrowIDE/src/Editors/CodeBuffer/TextBuffer.cs index a98aa08c..e8c87182 100644 --- a/CrowIDE/src/Editors/CodeBuffer/TextBuffer.cs +++ b/CrowIDE/src/Editors/CodeBuffer/TextBuffer.cs @@ -26,7 +26,7 @@ using System.Diagnostics; using System.Threading; using System.Text; -namespace Crow.Coding +namespace Crow.Text { /// /// Code buffer, lines are arranged in a List, new line chars are removed during string.split on '\n...', @@ -38,9 +38,9 @@ namespace Crow.Coding Regex reghexLineBrk = new Regex(@"\r\n|\r|\n|\\\n");//original text line break regex #region Events - public event EventHandler LineUpadateEvent; - public event EventHandler LineRemoveEvent; - public event EventHandler LineAdditionEvent; + public event EventHandler LineUpadateEvent; + public event EventHandler LineRemoveEvent; + public event EventHandler LineAdditionEvent; public event EventHandler BufferCleared; public event EventHandler SelectionChanged; public event EventHandler PositionChanged; @@ -137,7 +137,7 @@ namespace Crow.Coding buffer.Remove (GetBufferIndexOfLine (i), lineLength [i]); lineLength.RemoveAt (i); editMutex.ExitWriteLock (); - LineRemoveEvent.Raise (this, new CodeBufferEventArgs (i)); + LineRemoveEvent.Raise (this, new TextBufferEventArgs (i)); } /// /// insert string without linebreaks at position i in buff @@ -149,7 +149,7 @@ namespace Crow.Coding buffer.Insert (this [i], str); lineLength.Insert (i, str.Length); editMutex.ExitWriteLock (); - LineAdditionEvent.Raise (this, new CodeBufferEventArgs (i)); + LineAdditionEvent.Raise (this, new TextBufferEventArgs (i)); } public void AddLine(string str){ editMutex.EnterWriteLock (); @@ -159,7 +159,7 @@ namespace Crow.Coding lineLength.Add (0); } editMutex.ExitWriteLock (); - LineAdditionEvent.Raise (this, new CodeBufferEventArgs (lineLength.Count - 1)); + LineAdditionEvent.Raise (this, new TextBufferEventArgs (lineLength.Count - 1)); } public void AddRange (string[] items){ int start = lineLength.Count; @@ -167,7 +167,7 @@ namespace Crow.Coding for (int i = 0; i < items.Length; i++) AddLine (items [i]); editMutex.ExitWriteLock (); - LineAdditionEvent.Raise (this, new CodeBufferEventArgs (start, items.Length)); + LineAdditionEvent.Raise (this, new TextBufferEventArgs (start, items.Length)); } public void Clear () { editMutex.EnterWriteLock (); @@ -183,7 +183,7 @@ namespace Crow.Coding buffer.Insert (ptrL, newContent); lineLength [i] = newContent.Length; editMutex.ExitWriteLock (); - LineUpadateEvent.Raise (this, new CodeBufferEventArgs (i)); + LineUpadateEvent.Raise (this, new TextBufferEventArgs (i)); } public void AppenedLine(int i, string newContent){ editMutex.EnterWriteLock (); @@ -193,7 +193,7 @@ namespace Crow.Coding buffer.Insert(ptr, newContent); lineLength [i] += newContent.Length; editMutex.ExitWriteLock (); - LineUpadateEvent.Raise (this, new CodeBufferEventArgs (i)); + LineUpadateEvent.Raise (this, new TextBufferEventArgs (i)); } /// /// Insert new string at caret position, should be sure no line break is inside. diff --git a/CrowIDE/src/Editors/CodeBuffer/TextBufferEventArgs.cs b/CrowIDE/src/Editors/CodeBuffer/TextBufferEventArgs.cs new file mode 100644 index 00000000..3b67bb1c --- /dev/null +++ b/CrowIDE/src/Editors/CodeBuffer/TextBufferEventArgs.cs @@ -0,0 +1,20 @@ +using System; + +namespace Crow.Text +{ + public class TextBufferEventArgs : EventArgs { + public int LineStart; + public int LineCount; + + public TextBufferEventArgs(int lineNumber) { + LineStart = lineNumber; + LineCount = 1; + } + public TextBufferEventArgs(int lineStart, int lineCount) { + LineStart = lineStart; + LineCount = lineCount; + } + } + +} + diff --git a/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs b/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs index 69233e18..6b7234dc 100644 --- a/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs +++ b/CrowIDE/src/Editors/CodeBuffer/TextEditor.cs @@ -37,12 +37,12 @@ using System.Diagnostics; using System.IO; using System.Threading; -namespace Crow.Coding +namespace Crow.Text { /// /// Scrolling text box optimized for monospace fonts, for coding /// - public class TextEditor : Editor + public class TextEditor : Crow.Coding.Editor { #region CTOR public TextEditor (): base() @@ -152,20 +152,20 @@ namespace Crow.Coding editorMutex.ExitWriteLock (); } - void Buffer_LineAdditionEvent (object sender, CodeBufferEventArgs e) + void Buffer_LineAdditionEvent (object sender, TextBufferEventArgs e) { updateMaxScrollY (); RegisterForGraphicUpdate (); isDirty = true; } - void Buffer_LineRemoveEvent (object sender, CodeBufferEventArgs e) + void Buffer_LineRemoveEvent (object sender, TextBufferEventArgs e) { updateMaxScrollY (); RegisterForGraphicUpdate (); notifyPositionChanged (); isDirty = true; } - void Buffer_LineUpadateEvent (object sender, CodeBufferEventArgs e) + void Buffer_LineUpadateEvent (object sender, TextBufferEventArgs e) { RegisterForGraphicUpdate (); notifyPositionChanged (); diff --git a/CrowIDE/src/Editors/ImlVisualEditor.cs b/CrowIDE/src/Editors/ImlVisualEditor.cs index 7a7a888b..76cb4009 100644 --- a/CrowIDE/src/Editors/ImlVisualEditor.cs +++ b/CrowIDE/src/Editors/ImlVisualEditor.cs @@ -28,6 +28,7 @@ using System.Collections.Generic; using Crow.IML; using System.Text; using System.Xml; +using System.Diagnostics; namespace Crow.Coding { @@ -46,7 +47,8 @@ namespace Crow.Coding Exception imlError = null; bool drawGrid, snapToGrid; - int gridSpacing; + int gridSpacing, zoom = 100; + Measure designWidth, designHeight; bool updateEnabled; [DefaultValue(true)] @@ -81,6 +83,42 @@ namespace Crow.Coding RegisterForRedraw (); } } + [DefaultValue(100)] + public int Zoom { + get { return zoom; } + set { + if (zoom == value) + return; + + zoom = value; + NotifyValueChanged ("Zoom", zoom); + Width = (int)(designWidth * zoom / 100.0); + Height = (int)(designHeight * zoom / 100.0); + } + } + [DefaultValue("512")] + public Measure DesignWidth { + get { return designWidth; } + set { + if (designWidth == value) + return; + designWidth = value; + NotifyValueChanged ("DesignWidth", designWidth); + Width = (int)(designWidth * zoom / 100.0); + } + } + [DefaultValue("512")] + public Measure DesignHeight { + get { return designHeight; } + set { + if (designHeight == value) + return; + designHeight = value; + NotifyValueChanged ("DesignHeight", designHeight); + Height = (int)(designHeight * zoom / 100.0); + } + } + public GraphicObject SelectedItem { get { return selectedItem; } set { @@ -149,6 +187,7 @@ namespace Crow.Coding protected override void updateProjFileFromEditor () { + Debug.WriteLine("\t\tImlEditor updateProjFileFromEditor"); try { projFile.UpdateSource(this, imlProjFile.Instance.GetIML()); } catch (Exception ex) { @@ -158,6 +197,7 @@ namespace Crow.Coding } } protected override void updateEditorFromProjFile () { + Debug.WriteLine("\t\tImlEditor updateEditorFromProjFile"); try { string selItemDesignID = null; if (SelectedItem!=null) @@ -196,7 +236,7 @@ namespace Crow.Coding } SelectedItem = go; } catch (Exception ex) { - Error = ex.InnerException; + Error = ex; if (Monitor.IsEntered(imlVE.UpdateMutex)) Monitor.Exit (imlVE.UpdateMutex); } @@ -223,11 +263,10 @@ namespace Crow.Coding switch (layoutType) { case LayoutingType.Width: case LayoutingType.Height: - imlVE.ProcessResize (this.ClientRectangle.Size); + imlVE.ProcessResize (new Size(designWidth,designHeight)); break; } } - public override void onMouseMove (object sender, MouseMoveEventArgs e) { base.onMouseMove (sender, e); @@ -264,29 +303,38 @@ namespace Crow.Coding protected override void onDraw (Cairo.Context gr) { base.onDraw (gr); - if (!drawGrid) - return; + Rectangle cb = new Rectangle (0, 0, designWidth, designHeight);// ClientRectangle; - Rectangle cb = ClientRectangle; - const double gridLineWidth = 0.1; - double glhw = gridLineWidth / 2.0; - int nbLines = cb.Width / gridSpacing ; - double d = cb.Left + gridSpacing; - for (int i = 0; i < nbLines; i++) { - gr.MoveTo (d-glhw, cb.Y); - gr.LineTo (d-glhw, cb.Bottom); - d += gridSpacing; - } - nbLines = cb.Height / gridSpacing; - d = cb.Top + gridSpacing; - for (int i = 0; i < nbLines; i++) { - gr.MoveTo (cb.X, d - glhw); - gr.LineTo (cb.Right, d -glhw); - d += gridSpacing; + gr.Save (); + + double z = zoom / 100.0; + + gr.Scale (z, z); + + if (drawGrid) { + double gridLineWidth = 0.2 / z; + double glhw = gridLineWidth / 2.0; + int nbLines = cb.Width / gridSpacing; + double d = cb.Left + gridSpacing; + for (int i = 0; i < nbLines; i++) { + gr.MoveTo (d - glhw, cb.Y); + gr.LineTo (d - glhw, cb.Bottom); + d += gridSpacing; + } + nbLines = cb.Height / gridSpacing; + d = cb.Top + gridSpacing; + for (int i = 0; i < nbLines; i++) { + gr.MoveTo (cb.X, d - glhw); + gr.LineTo (cb.Right, d - glhw); + d += gridSpacing; + } + gr.LineWidth = gridLineWidth; + Foreground.SetAsSource (gr, cb); + gr.Stroke (); } - gr.LineWidth = gridLineWidth; - Foreground.SetAsSource (gr, cb); + gr.SetSourceColor (Color.Black); + gr.Rectangle (cb, 1.0 / z); gr.Stroke (); lock (imlVE.RenderMutex) { @@ -310,14 +358,16 @@ namespace Crow.Coding gr.Rectangle (hr, 1.0); } - if (SelectedItem?.Parent == null) - return; - hr = SelectedItem.ScreenCoordinates(SelectedItem.getSlot ()); - hr.Inflate (1); - gr.LineWidth = 2; - gr.SetSourceColor (Color.Yellow); - gr.SetDash (new double[]{ 5.0, 3.0 },0.0); - gr.Rectangle (hr, 1.0); + if (SelectedItem?.Parent != null) { + + hr = SelectedItem.ScreenCoordinates (SelectedItem.getSlot ()); + hr.Inflate (1); + gr.LineWidth = 2; + gr.SetSourceColor (Color.Yellow); + gr.SetDash (new double[]{ 5.0, 3.0 }, 0.0); + gr.Rectangle (hr, 1.0); + } + gr.Restore (); } protected override void onDragEnter (object sender, DragDropEventArgs e) @@ -436,6 +486,7 @@ namespace Crow.Coding } void WidgetMouseMove (GraphicObject go, MouseMoveEventArgs e){} + public bool ProcessMouseMove(int x, int y) { int deltaX = x - imlVE.Mouse.X; @@ -459,22 +510,21 @@ namespace Crow.Coding GraphicObject topc = null; while (tmp is GraphicObject) { topc = tmp; - tmp = tmp.LogicalParent as GraphicObject; + tmp = tmp.focusParent; } int idxhw = imlVE.GraphicTree.IndexOf (topc); if (idxhw != 0) { int i = 0; - while (i < idxhw) { - if (imlVE.GraphicTree [i].LogicalParent == imlVE.GraphicTree [i].Parent) { - if (imlVE.GraphicTree [i].MouseIsIn (e.Position)) { - while (imlVE.HoverWidget != null) { - WidgetMouseLeave (imlVE.HoverWidget, e); - imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject; - } - - WidgetCheckOver (GraphicTree [i], e); - return true; + while (i < idxhw) { + if (GraphicTree [i].MouseIsIn (e.Position)) { + while (HoverWidget != null) { + WidgetMouseLeave (imlVE.HoverWidget, e); + HoverWidget = HoverWidget.focusParent; } + + GraphicTree [i].checkHoverWidget (e); + WidgetMouseMove (imlVE.HoverWidget, e); + return true; } i++; } @@ -483,14 +533,16 @@ namespace Crow.Coding if (imlVE.HoverWidget.MouseIsIn (e.Position)) { WidgetCheckOver (imlVE.HoverWidget, (e)); + WidgetMouseMove (imlVE.HoverWidget, e); return true; } else { WidgetMouseLeave (imlVE.HoverWidget, e); //seek upward from last focused graph obj's - while (imlVE.HoverWidget.LogicalParent as GraphicObject != null) { + while (imlVE.HoverWidget.focusParent != null) { imlVE.HoverWidget = imlVE.HoverWidget.LogicalParent as GraphicObject; if (imlVE.HoverWidget.MouseIsIn (e.Position)) { WidgetCheckOver (imlVE.HoverWidget, e); + WidgetMouseMove (imlVE.HoverWidget, e); return true; } else WidgetMouseLeave (imlVE.HoverWidget, e); @@ -504,6 +556,7 @@ namespace Crow.Coding GraphicObject g = imlVE.GraphicTree [i]; if (g.MouseIsIn (e.Position)) { WidgetCheckOver (g, e); + WidgetMouseMove (imlVE.HoverWidget, e); return true; } } diff --git a/CrowIDE/src/Editors/Parsers/BufferParser.cs b/CrowIDE/src/Editors/Parsers/BufferParser.cs index dfec17a3..c193c7db 100644 --- a/CrowIDE/src/Editors/Parsers/BufferParser.cs +++ b/CrowIDE/src/Editors/Parsers/BufferParser.cs @@ -266,7 +266,7 @@ namespace Crow.Coding /// Length. protected virtual string Peek(int length) { if (eol) - throw new ParserException (currentLine, currentColumn, "Unexpected End of Line"); + return "";//throw new ParserException (currentLine, currentColumn, "Unexpected End of Line"); int lg = Math.Min(length, Math.Max (buffer [currentLine].Length - currentColumn, buffer [currentLine].Length - currentColumn - length)); if (lg == 0) return ""; diff --git a/CrowIDE/src/Editors/Parsers2/Tokenizer.cs b/CrowIDE/src/Editors/Parsers2/Tokenizer.cs new file mode 100644 index 00000000..bcda1ec6 --- /dev/null +++ b/CrowIDE/src/Editors/Parsers2/Tokenizer.cs @@ -0,0 +1,67 @@ +// +// Tokenizer.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2013-2017 Jean-Philippe Bruyère +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Crow.Text; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Crow.Coding2 +{ + public static class TokenType { + public const int Undefine = 0; + public const int WhiteSpace = 0; + } + public class Token { + public int ptr; + public int length; + } + + public class Tokenizer + { + #region Regular Expression for validity checks + public Regex rxValidChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); + public Regex rxNameStartChar = new Regex(@"_|\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}"); + public Regex rxNameChar = new Regex(@"\p{Lu}|\p{Ll}|\p{Lt}|\p{Lm}|\p{Lo}|\p{Nl}|\p{Mn}|\p{Mc}|\p{Nd}|\p{Pc}|\p{Cf}"); + public Regex rxNewLineChar = new Regex(@"\u000D|\u000A|\u0085|\u2028|\u2029"); + public Regex rxWhiteSpaceChar = new Regex(@"\p{Zs}|\u0009|\u000B|\u000C"); + public Regex rxDecimal = new Regex(@"[0-9]+"); + public Regex rxHexadecimal = new Regex(@"[0-9a-fA-F]+"); + #endregion + + public List Tokens; + + public Tokenizer (TextBuffer buffer) + { + } + + + public void Tokenize () { + + } + + } +} + diff --git a/CrowIDE/src/Editors/CodeBuffer/SourceEditor.cs b/CrowIDE/src/Editors/SourceEditor.cs similarity index 98% rename from CrowIDE/src/Editors/CodeBuffer/SourceEditor.cs rename to CrowIDE/src/Editors/SourceEditor.cs index 48d634b3..6ebe2c1f 100644 --- a/CrowIDE/src/Editors/CodeBuffer/SourceEditor.cs +++ b/CrowIDE/src/Editors/SourceEditor.cs @@ -47,16 +47,16 @@ namespace Crow.Coding #region CTOR public SourceEditor (): base() { - formatting.Add ((int)XMLParser.TokenType.AttributeName, new TextFormatting (Color.DarkJungleGreen, Color.Transparent)); + formatting.Add ((int)XMLParser.TokenType.AttributeName, new TextFormatting (Color.DarkSlateGray, Color.Transparent)); formatting.Add ((int)XMLParser.TokenType.ElementName, new TextFormatting (Color.DarkBlue, Color.Transparent)); formatting.Add ((int)XMLParser.TokenType.ElementStart, new TextFormatting (Color.Black, Color.Transparent)); formatting.Add ((int)XMLParser.TokenType.ElementEnd, new TextFormatting (Color.Black, Color.Transparent)); formatting.Add ((int)XMLParser.TokenType.ElementClosing, new TextFormatting (Color.Black, Color.Transparent)); - formatting.Add ((int)XMLParser.TokenType.AttributeValueOpening, new TextFormatting (Color.Carmine, Color.Transparent)); - formatting.Add ((int)XMLParser.TokenType.AttributeValueClosing, new TextFormatting (Color.Carmine, Color.Transparent)); - formatting.Add ((int)XMLParser.TokenType.AttributeValue, new TextFormatting (Color.TractorRed, Color.Transparent, false, true)); - formatting.Add ((int)XMLParser.TokenType.XMLDecl, new TextFormatting (Color.AoEnglish, Color.Transparent)); + formatting.Add ((int)XMLParser.TokenType.AttributeValueOpening, new TextFormatting (Color.Crimson, Color.Transparent)); + formatting.Add ((int)XMLParser.TokenType.AttributeValueClosing, new TextFormatting (Color.Crimson, Color.Transparent)); + formatting.Add ((int)XMLParser.TokenType.AttributeValue, new TextFormatting (Color.FireBrick, Color.Transparent, false, true)); + formatting.Add ((int)XMLParser.TokenType.XMLDecl, new TextFormatting (Color.ForestGreen, Color.Transparent)); formatting.Add ((int)BufferParser.TokenType.BlockComment, new TextFormatting (Color.Gray, Color.Transparent, false, true)); formatting.Add ((int)BufferParser.TokenType.LineComment, new TextFormatting (Color.Gray, Color.Transparent, false, true)); @@ -212,6 +212,8 @@ namespace Crow.Coding #region Editor overrides protected override void updateEditorFromProjFile () { + Debug.WriteLine("\t\tSourceEditor updateEditorFromProjFile"); + buffer.editMutex.EnterWriteLock (); loadSource (); buffer.editMutex.ExitWriteLock (); @@ -224,6 +226,8 @@ namespace Crow.Coding } protected override void updateProjFileFromEditor () { + Debug.WriteLine("\t\tSourceEditor updateProjFileFromEditor"); + buffer.editMutex.EnterWriteLock (); string newsrc = buffer.FullText; buffer.editMutex.ExitWriteLock (); @@ -366,7 +370,7 @@ namespace Crow.Coding if (l == buffer.CurrentLine) return; buffer.CurrentLine = l; - if (buffer [l].IsFolded) + if ((bool)buffer [l]?.IsFolded) buffer.ToogleFolding (l); } catch (Exception ex) { requestedLine = value - 1; @@ -399,7 +403,7 @@ namespace Crow.Coding RegisterForGraphicUpdate (); } } - [DefaultValue("BlueGray")] + [DefaultValue("SteelBlue")] public virtual Color SelectionBackground { get { return selBackground; } set { diff --git a/CrowIDE/src/MemberView/MembersView.cs b/CrowIDE/src/MemberView/MembersView.cs index e23a41ba..d8a9ddcd 100644 --- a/CrowIDE/src/MemberView/MembersView.cs +++ b/CrowIDE/src/MemberView/MembersView.cs @@ -37,7 +37,7 @@ namespace Crow.Coding public MembersView () : base() {} //cache property containers per type - Dictionary propContainersCache = new Dictionary(); + //Dictionary propContainersCache = new Dictionary(); Dictionary> categoryContainersCache = new Dictionary> (); [XmlAttributeAttribute][DefaultValue(null)] @@ -63,7 +63,7 @@ namespace Crow.Coding } Type it = instance.GetType (); - if (!propContainersCache.ContainsKey (it.FullName)) { + if (!categoryContainersCache.ContainsKey (it.FullName)) { MemberInfo[] members = it.GetMembers (BindingFlags.Public | BindingFlags.Instance); List props = new List (); foreach (MemberInfo m in members) { @@ -76,20 +76,24 @@ namespace Crow.Coding props.Add (new PropertyContainer (this, pi)); } } - propContainersCache.Add (it.FullName, props.OrderBy (p => p.Name).ToArray ()); - } - - List categories = new List (); + //propContainersCache.Add (it.FullName, props.OrderBy (p => p.Name).ToArray ()); + List categories = new List (); - foreach (IGrouping ig in propContainersCache[it.FullName].GroupBy(pc=>pc.DesignCategory)) { - categories.Add(new CategoryContainer(ig.Key, ig.ToArray())); + foreach (IGrouping ig in props.OrderBy (p => p.Name).GroupBy(pc=>pc.DesignCategory)) { + categories.Add(new CategoryContainer(ig.Key, ig.ToArray())); + } + categoryContainersCache.Add (it.FullName, categories); } - Data = categories; + + Data = categoryContainersCache[it.FullName]; if (lastInst != instance) { - foreach (PropertyContainer pc in propContainersCache [it.FullName]) { - pc.NotifyValueChanged ("Value", pc.Value); + foreach (CategoryContainer cc in categoryContainersCache [it.FullName]) { + foreach (PropertyContainer pc in cc.Properties) { + pc.NotifyValueChanged ("Value", pc.Value); + pc.NotifyValueChanged ("LabForeground", pc.LabForeground); + } } } } diff --git a/CrowIDE/src/MemberView/PropertyContainer.cs b/CrowIDE/src/MemberView/PropertyContainer.cs index 46cbbd74..19f4ed7f 100644 --- a/CrowIDE/src/MemberView/PropertyContainer.cs +++ b/CrowIDE/src/MemberView/PropertyContainer.cs @@ -73,6 +73,8 @@ namespace Crow.Coding } set { try { + if (value == Value) + return; GraphicObject g = Instance; string valstr = null, oldval = null; @@ -116,12 +118,14 @@ namespace Crow.Coding } }else pi.SetValue(g, value); - + + Debug.WriteLine("\t\tPropContainer set design_dirty to instance"); + mview.ProjectNode.Instance.design_HasChanged = true; NotifyValueChanged ("Value", value); NotifyValueChanged ("LabForeground", LabForeground); } catch (Exception ex) { - System.Diagnostics.Debug.WriteLine ("Error setting property:"+ ex.ToString()); + Debug.WriteLine ("Error setting property:"+ ex.ToString()); } // } @@ -184,8 +188,10 @@ namespace Crow.Coding if (!inst.design_iml_values.ContainsKey (Name)) return; inst.design_iml_values.Remove (Name); - //NotifyValueChanged ("Value", Value); - mview.ProjectNode.Instance.design_HasChanged = true; + + NotifyValueChanged ("LabForeground", LabForeground); + mview.ProjectNode.UpdateSource(this, mview.ProjectNode.Instance.GetIML()); + //mview.ProjectNode.Instance.design_HasChanged = true; //should reinstantiate to get default } public void GotoStyle(){ @@ -199,6 +205,7 @@ namespace Crow.Coding Solution s = mview.ProjectNode.Project.solution; if (!s.OpenedItems.Contains (pf)) s.OpenedItems.AddElement (pf); + Debug.WriteLine (fl); pf.CurrentLine = fl.Line; pf.CurrentColumn = fl.Column; } diff --git a/CrowIDE/src/Project.cs b/CrowIDE/src/Project.cs index 6aeb5be7..2c4eda59 100644 --- a/CrowIDE/src/Project.cs +++ b/CrowIDE/src/Project.cs @@ -170,8 +170,14 @@ namespace Crow.Coding switch (pn.Extension) { case ".crow": case ".template": + case ".goml": + case ".itemp": + case ".imtl": f = new ImlProjectItem (pn); break; + case ".style": + f = new StyleProjectItem (pn); + break; default: f = new ProjectFile (pn); break; diff --git a/CrowIDE/src/ProjectTree/ImlProjectItem.cs b/CrowIDE/src/ProjectTree/ImlProjectItem.cs index 7ce24ad7..0575d177 100644 --- a/CrowIDE/src/ProjectTree/ImlProjectItem.cs +++ b/CrowIDE/src/ProjectTree/ImlProjectItem.cs @@ -41,6 +41,7 @@ namespace Crow.Coding #endregion GraphicObject instance; + Measure designWidth, designHeight; /// /// instance created with an instantiator from the source by a DesignInterface, @@ -55,6 +56,26 @@ namespace Crow.Coding NotifyValueChanged ("Instance", instance); } } + + public Measure DesignWidth { + get { return designWidth; } + set { + if (designWidth == value) + return; + designWidth = value; + NotifyValueChanged ("DesignWidth", designWidth); + } + } + public Measure DesignHeight { + get { return designHeight; } + set { + if (designHeight == value) + return; + designHeight = value; + NotifyValueChanged ("DesignHeight", designHeight); + } + } + public List GraphicTree { get { return new List (new GraphicObject[] {instance}); } diff --git a/CrowIDE/src/ProjectTree/ProjectFile.cs b/CrowIDE/src/ProjectTree/ProjectFile.cs index 2c3dbbe4..2fac2f91 100644 --- a/CrowIDE/src/ProjectTree/ProjectFile.cs +++ b/CrowIDE/src/ProjectTree/ProjectFile.cs @@ -96,12 +96,24 @@ namespace Crow.Coding RegisteredEditors.Add (editor, false); } } - public void UpdateSource (object sender, string newSrc){ + public virtual void UpdateSource (object sender, string newSrc){ System.Diagnostics.Debug.WriteLine ("update source by {0}", sender); Source = newSrc; signalOtherRegisteredEditors (sender); } - void signalOtherRegisteredEditors (object sender) { + public void SignalEditorOfType (){ + lock (RegisteredEditors) { + object[] keys = RegisteredEditors.Keys.ToArray (); + foreach (object ed in keys) { + T editor = (T)ed; + if (editor == null) + continue; + RegisteredEditors [editor] = false; + break; + } + } + } + protected void signalOtherRegisteredEditors (object sender) { lock (RegisteredEditors) { object[] keys = RegisteredEditors.Keys.ToArray (); foreach (object editor in keys) { @@ -192,7 +204,7 @@ namespace Crow.Coding origSource = source; NotifyValueChanged ("IsDirty", false); } - public void Save () { + public virtual void Save () { if (!IsDirty) return; using (StreamWriter sw = new StreamWriter (AbsolutePath)) { @@ -201,7 +213,7 @@ namespace Crow.Coding origSource = source; NotifyValueChanged ("IsDirty", false); } - public void SaveAs () { + public virtual void SaveAs () { if (!IsDirty) return; using (StreamWriter sw = new StreamWriter (AbsolutePath)) { @@ -279,7 +291,6 @@ namespace Crow.Coding { Close (); } - void onClickSaveAndCloseNow (object sender, EventArgs e) { Save (); diff --git a/CrowIDE/src/ProjectTree/StyleProjectItem.cs b/CrowIDE/src/ProjectTree/StyleProjectItem.cs new file mode 100644 index 00000000..1de77cd7 --- /dev/null +++ b/CrowIDE/src/ProjectTree/StyleProjectItem.cs @@ -0,0 +1,50 @@ +// +// ProjectNodes.cs +// +// Author: +// Jean-Philippe Bruyère +// +// Copyright (c) 2013-2017 Jean-Philippe Bruyère +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Collections.Generic; +using System.Linq; +using System.Xml; +using System.IO; +using Crow; +using System.Threading; + +namespace Crow.Coding +{ + public class StyleProjectItem : ProjectFile + { + #region CTOR + public StyleProjectItem (ProjectItem pi) : base (pi){ + } + #endregion + + public override void UpdateSource (object sender, string newSrc) + { + base.UpdateSource (sender, newSrc); + Project.solution.ReloadStyling (); + } + } +} + diff --git a/CrowIDE/src/Solution.cs b/CrowIDE/src/Solution.cs index 1b89dc09..68922865 100644 --- a/CrowIDE/src/Solution.cs +++ b/CrowIDE/src/Solution.cs @@ -28,6 +28,51 @@ namespace Crow.Coding{ public string RelativePath; public string ProjectGuid; } + public class StyleItemContainer { + public object Value; + public string Name; + public StyleItemContainer(string name, object _value){ + Name = name; + Value = _value; + } + } + public class StyleContainer : IValueChange { + #region IValueChange implementation + public event EventHandler ValueChanged; + public virtual void NotifyValueChanged(string MemberName, object _value) + { + ValueChanged.Raise(this, new ValueChangeEventArgs(MemberName, _value)); + } + #endregion + + Style style; + bool isExpanded; + + public string Name; + public List Items; + public bool IsExpanded + { + get { return isExpanded; } + set + { + if (value == isExpanded) + return; + isExpanded = value; + NotifyValueChanged ("IsExpanded", isExpanded); + } + } + public StyleContainer(string name, Style _style){ + Name = name; + style = _style; + + Items = new List (); + foreach (string k in style.Keys) { + Items.Add(new StyleItemContainer(k, style[k])); + } + } + } + + /// /// .sln loaded into class. /// @@ -49,12 +94,21 @@ namespace Crow.Coding{ public Dictionary Styling; public Dictionary DefaultTemplates; + public List