Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
		/// <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);
		}
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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 ());
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
		/// <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;
		}
Exemplo n.º 11
0
		private void setupUserLayer()
		{
			tEngine = new TextEngine();

			TextLayer = new ReEditableLayer(this);
		}
Exemplo n.º 12
0
        private void setupUserLayer()
        {
            tEngine = new TextEngine();

            TextLayer = new ReEditableLayer(this);
        }
Exemplo n.º 13
0
        /// <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;
        }
Exemplo n.º 14
0
 //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();
 }
Exemplo n.º 15
0
		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;
		}
Exemplo n.º 16
0
 //Call the base class constructor and setup the TextEngine.
 public UserLayer(ImageSurface surface) : base(surface)
 {
     tEngine = new TextEngine();
 }
Exemplo n.º 17
0
 //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();
 }
Exemplo n.º 18
0
 //Call the base class constructor and setup the TextEngine.
 public UserLayer(ImageSurface surface)
     : base(surface)
 {
     tEngine = new TextEngine();
 }