/// <summary> /// A history item for when text is created, edited, and/or finalized. /// </summary> /// <param name="icon">The history item's icon.</param> /// <param name="text">The history item's title.</param> /// <param name="passedTextSurface">The stored TextLayer surface.</param> /// <param name="passedUserSurface">The stored UserLayer surface.</param> /// <param name="passedTextEngine">The text engine being used.</param> /// <param name="passedUserLayer">The UserLayer being modified.</param> public TextHistoryItem(string icon, string text, ImageSurface passedTextSurface, ImageSurface passedUserSurface, TextEngine passedTextEngine, UserLayer passedUserLayer) : base(icon, text) { userLayer = passedUserLayer; text_surface_diff = SurfaceDiff.Create(passedTextSurface, userLayer.TextLayer.Layer.Surface, true); if (text_surface_diff == null) { textSurface = passedTextSurface; } else { (passedTextSurface as IDisposable).Dispose(); } user_surface_diff = SurfaceDiff.Create(passedUserSurface, userLayer.Surface, true); if (user_surface_diff == null) { userSurface = passedUserSurface; } else { (passedUserSurface as IDisposable).Dispose(); } tEngine = passedTextEngine; textBounds = new Gdk.Rectangle(userLayer.textBounds.X, userLayer.textBounds.Y, userLayer.textBounds.Width, userLayer.textBounds.Height); }
/// <summary> /// A history item for when text is created, edited, and/or finalized. /// </summary> /// <param name="icon">The history item's icon.</param> /// <param name="text">The history item's title.</param> /// <param name="passedTextSurface">The stored TextLayer surface.</param> /// <param name="passedUserSurface">The stored UserLayer surface.</param> /// <param name="passedTextEngine">The text engine being used.</param> /// <param name="passedUserLayer">The UserLayer being modified.</param> public TextHistoryItem(string icon, string text, ImageSurface passedTextSurface, ImageSurface passedUserSurface, TextEngine passedTextEngine, UserLayer passedUserLayer) : base(icon, text) { userLayer = passedUserLayer; text_surface_diff = SurfaceDiff.Create(passedTextSurface, userLayer.TextLayer.Layer.Surface, true); if (text_surface_diff == null) { textSurface = passedTextSurface; } else { (passedTextSurface as IDisposable).Dispose(); } user_surface_diff = SurfaceDiff.Create(passedUserSurface, userLayer.Surface, true); if (user_surface_diff == null) { userSurface = passedUserSurface; } else { (passedUserSurface as IDisposable).Dispose(); } tEngine = passedTextEngine; textBounds = new Gdk.Rectangle(userLayer.textBounds.X, userLayer.textBounds.Y, userLayer.textBounds.Width, userLayer.textBounds.Height); }
private void Swap() { // Grab the original surface ImageSurface surf = userLayer.TextLayer.Layer.Surface; if (text_surface_diff != null) { text_surface_diff.ApplyAndSwap(surf); PintaCore.Workspace.Invalidate(text_surface_diff.GetBounds()); } else { // Undo to the "old" surface userLayer.TextLayer.Layer.Surface = textSurface; // Store the original surface for Redo textSurface = surf; } // Grab the original surface surf = userLayer.Surface; if (user_surface_diff != null) { user_surface_diff.ApplyAndSwap(surf); PintaCore.Workspace.Invalidate(user_surface_diff.GetBounds()); } else { // Undo to the "old" surface userLayer.Surface = userSurface; // Store the original surface for Redo userSurface = surf; } //Redraw everything since surfaces were swapped. PintaCore.Workspace.Invalidate(); //Store the old text data temporarily. TextEngine oldTEngine = tEngine; Gdk.Rectangle oldTextBounds = textBounds; //Swap half of the data. tEngine = userLayer.tEngine; textBounds = userLayer.textBounds; //Swap the other half. userLayer.tEngine = oldTEngine; userLayer.textBounds = oldTextBounds; }
public void PerformEnter () { var engine = new TextEngine (new List<string> () { "foo", "bar" }); engine.SetCursorPosition (new TextPosition (1, 1), true); engine.PerformEnter (); Assert.AreEqual (3, engine.LineCount); Assert.AreEqual (LinesToString (new string[] {"foo", "b", "ar" }), engine.ToString()); Assert.AreEqual (new TextPosition (2, 0), engine.CurrentPosition); }
public void DeleteSelection () { var engine = new TextEngine (new List<string> () { "это тест", "это еще один тест" }); engine.SetCursorPosition (new TextPosition (0, 2), true); engine.PerformDown (true); engine.PerformDelete (); Assert.AreEqual (1, engine.LineCount); Assert.AreEqual (LinesToString (new string[] { "это еще один тест" }), engine.ToString ()); Assert.AreEqual (new TextPosition (0, 2), engine.CurrentPosition); }
public void DeleteMultiLineSelection () { var engine = new TextEngine (new List<string> () { "line 1", "line 2", "line 3" }); engine.SetCursorPosition (new TextPosition (0, 2), true); engine.PerformDown (true); engine.PerformDown (true); engine.PerformDelete (); Assert.AreEqual (1, engine.LineCount); Assert.AreEqual (LinesToString (new string[] { "line 3" }), engine.ToString ()); }
public void PerformLeft () { var engine = new TextEngine (new List<string> () { "foo", "bar" }); engine.SetCursorPosition (new TextPosition (1, 0), true); engine.PerformLeft (false, false); Assert.AreEqual (new TextPosition (0, 3), engine.CurrentPosition); engine.SetCursorPosition (new TextPosition (0, 1), true); engine.PerformLeft (false, false); Assert.AreEqual (new TextPosition (0, 0), engine.CurrentPosition); engine.PerformLeft (false, false); Assert.AreEqual (new TextPosition (0, 0), engine.CurrentPosition); }
/// <summary> /// Performs a deep clone of the TextEngine instance and returns the clone. /// </summary> /// <returns>A clone of this TextEngine instance.</returns> public TextEngine Clone() { TextEngine clonedTE = new TextEngine(); clonedTE.layout = layout.Copy(); clonedTE.lines = lines.ToList(); clonedTE.textMode = textMode; clonedTE.linePos = linePos; clonedTE.textPos = textPos; clonedTE.selectionRelativeIndex = selectionRelativeIndex; clonedTE.underline = underline; clonedTE.Origin = new Point(Origin.X, Origin.Y); //The rest of the variables are calculated on the spot. return(clonedTE); }
/// <summary> /// Performs a deep clone of the TextEngine instance and returns the clone. /// </summary> /// <returns>A clone of this TextEngine instance.</returns> public TextEngine Clone() { TextEngine clonedTE = new TextEngine(); clonedTE.lines = lines.ToList(); clonedTE.State = State; clonedTE.currentPos = currentPos; clonedTE.selectionStart = selectionStart; clonedTE.FontFace = FontFace; clonedTE.FontSize = FontSize; clonedTE.Bold = Bold; clonedTE.Italic = Italic; clonedTE.Underline = Underline; clonedTE.Alignment = Alignment; clonedTE.Origin = new Point(Origin.X, Origin.Y); //The rest of the variables are calculated on the spot. return(clonedTE); }
/// <summary> /// Performs a deep clone of the TextEngine instance and returns the clone. /// </summary> /// <returns>A clone of this TextEngine instance.</returns> public TextEngine Clone() { TextEngine clonedTE = new TextEngine(); clonedTE.lines = lines.ToList(); clonedTE.State = State; clonedTE.currentPos = currentPos; clonedTE.selectionStart = selectionStart; clonedTE.FontFace = FontFace; clonedTE.FontSize = FontSize; clonedTE.Bold = Bold; clonedTE.Italic = Italic; clonedTE.Underline = Underline; clonedTE.Alignment = Alignment; clonedTE.Origin = new Point(Origin.X, Origin.Y); //The rest of the variables are calculated on the spot. return clonedTE; }
private void setupUserLayer() { tEngine = new TextEngine(); TextLayer = new ReEditableLayer(this); }
private void setupUserLayer() { tEngine = new TextEngine(); TextLayer = new ReEditableLayer(this); }
/// <summary> /// Performs a deep clone of the TextEngine instance and returns the clone. /// </summary> /// <returns>A clone of this TextEngine instance.</returns> public TextEngine Clone() { TextEngine clonedTE = new TextEngine(); clonedTE.layout = layout.Copy(); clonedTE.lines = lines.ToList(); clonedTE.textMode = textMode; clonedTE.linePos = linePos; clonedTE.textPos = textPos; clonedTE.selectionRelativeIndex = selectionRelativeIndex; clonedTE.underline = underline; clonedTE.Origin = new Point(Origin.X, Origin.Y); //The rest of the variables are calculated on the spot. return clonedTE; }
//Call the base class constructor and setup the TextEngine. public UserLayer(ImageSurface surface, bool hidden, double opacity, string name) : base(surface, hidden, opacity, name) { tEngine = new TextEngine(); }
private void Swap() { // Grab the original surface ImageSurface surf = userLayer.TextLayer.Layer.Surface; if (text_surface_diff != null) { text_surface_diff.ApplyAndSwap(surf); PintaCore.Workspace.Invalidate(text_surface_diff.GetBounds()); } else { // Undo to the "old" surface userLayer.TextLayer.Layer.Surface = textSurface; // Store the original surface for Redo textSurface = surf; } // Grab the original surface surf = userLayer.Surface; if (user_surface_diff != null) { user_surface_diff.ApplyAndSwap(surf); PintaCore.Workspace.Invalidate(user_surface_diff.GetBounds()); } else { // Undo to the "old" surface userLayer.Surface = userSurface; // Store the original surface for Redo userSurface = surf; } //Redraw everything since surfaces were swapped. PintaCore.Workspace.Invalidate(); //Store the old text data temporarily. TextEngine oldTEngine = tEngine; Gdk.Rectangle oldTextBounds = textBounds; //Swap half of the data. tEngine = userLayer.tEngine; textBounds = userLayer.textBounds; //Swap the other half. userLayer.tEngine = oldTEngine; userLayer.textBounds = oldTextBounds; }
//Call the base class constructor and setup the TextEngine. public UserLayer(ImageSurface surface) : base(surface) { tEngine = new TextEngine(); }
//Call the base class constructor and setup the TextEngine. public UserLayer(ImageSurface surface, bool hidden, double opacity, string name) : base(surface, hidden, opacity, name) { tEngine = new TextEngine(); }
//Call the base class constructor and setup the TextEngine. public UserLayer(ImageSurface surface) : base(surface) { tEngine = new TextEngine(); }