Ejemplo n.º 1
0
        /// <summary>
        /// Finalize re-editable text (if applicable).
        /// </summary>
        public void FinalizeText()
        {
            //If this is true, don't finalize any text - this is used to prevent the code from looping recursively.
            if (!ignoreCloneFinalizations)
            {
                //Only bother finalizing text if editing.
                if (CurrentTextEngine.EditMode == EditingMode.Editing)
                {
                    //Start ignoring any Surface.Clone calls from this point on (so that it doesn't start to loop).
                    ignoreCloneFinalizations = true;



                    Document doc = PintaCore.Workspace.ActiveDocument;

                    //Create a backup of everything before redrawing the text and etc.
                    Cairo.ImageSurface oldTextSurface = doc.CurrentUserLayer.TextLayer.Surface.Clone();
                    Cairo.ImageSurface oldUserSurface = doc.CurrentUserLayer.Surface.Clone();
                    TextEngine         oldTextEngine  = CurrentTextEngine.Clone();



                    //Draw the text onto the UserLayer (without the cursor) rather than the TextLayer.
                    RedrawText(false, false);

                    //Clear the TextLayer.
                    doc.CurrentUserLayer.TextLayer.Clear();

                    //Clear the text and its boundaries.
                    CurrentTextEngine.Clear();
                    CurrentTextBounds = Gdk.Rectangle.Zero;



                    //Create a new TextHistoryItem so that the finalization of the text can be undone. Construct
                    //it on the spot so that it is more memory efficient if the changes are small.
                    TextHistoryItem hist = new TextHistoryItem(Icon, FinalizeName, oldTextSurface, oldUserSurface, oldTextEngine, doc.CurrentUserLayer);

                    //Add the new TextHistoryItem.
                    doc.History.PushNewItem(hist);



                    //Stop ignoring any Surface.Clone calls from this point on.
                    ignoreCloneFinalizations = false;



                    //Now that the text has been finalized, change its state.
                    CurrentTextEngine.textMode = TextMode.Unchanged;
                }
            }
        }
Ejemplo n.º 2
0
        private void StartEditing()
        {
            is_editing = true;

            //Start ignoring any Surface.Clone calls from this point on (so that it doesn't start to loop).
            ignoreCloneFinalizations = true;

            //Store the previous state of the current UserLayer's and TextLayer's ImageSurfaces.
            user_undo_surface = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.Surface.Clone();
            text_undo_surface = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.TextLayer.Surface.Clone();
            undo_engine       = CurrentTextEngine.Clone();

            //Stop ignoring any Surface.Clone calls from this point on.
            ignoreCloneFinalizations = false;
        }
Ejemplo n.º 3
0
 public TextTool()
 {
     cursor_hand = new Gdk.Cursor(PintaCore.Chrome.Canvas.Display, PintaCore.Resources.GetIcon("Tools.Pan.png"), 0, 0);
     engine      = new TextEngine();
 }