diff --git a/Pinta.Core/Actions/LayerActions.cs b/Pinta.Core/Actions/LayerActions.cs index f6c9fade92..e69e7e7170 100644 --- a/Pinta.Core/Actions/LayerActions.cs +++ b/Pinta.Core/Actions/LayerActions.cs @@ -393,9 +393,6 @@ private void HandlePintaCoreActionsLayersAddNewLayerActivated (object sender, Ev UserLayer l = doc.Layers.AddNewLayer (string.Empty); - // Make new layer the current layer - doc.Layers.SetCurrentUserLayer (l); - AddLayerHistoryItem hist = new ( Resources.Icons.LayerNew, Translations.GetString ("Add New Layer"), diff --git a/Pinta.Core/Classes/DocumentLayers.cs b/Pinta.Core/Classes/DocumentLayers.cs index 8e51b8ed0f..6961040043 100644 --- a/Pinta.Core/Classes/DocumentLayers.cs +++ b/Pinta.Core/Classes/DocumentLayers.cs @@ -82,7 +82,7 @@ public Layer ToolLayer { /// /// Creates a new layer and adds it to the Layer collection after the - /// currently selected layer. + /// currently selected layer, making it the new selected layer. /// public UserLayer AddNewLayer (string name) { @@ -91,14 +91,12 @@ public UserLayer AddNewLayer (string name) ? CreateLayer () : CreateLayer (name); - user_layers.Insert (CurrentUserLayerIndex + 1, layer); - - if (user_layers.Count == 1) - CurrentUserLayerIndex = 0; + user_layers.Insert (++CurrentUserLayerIndex, layer); layer.PropertyChanged += RaiseLayerPropertyChangedEvent; - LayerAdded?.Invoke (this, new IndexEventArgs (user_layers.Count - 1)); + LayerAdded?.Invoke (this, new IndexEventArgs (CurrentUserLayerIndex)); + SelectedLayerChanged?.Invoke (this, EventArgs.Empty); return layer; } @@ -218,6 +216,7 @@ public UserLayer DuplicateCurrentLayer () layer.PropertyChanged += RaiseLayerPropertyChangedEvent; LayerAdded?.Invoke (this, new IndexEventArgs (CurrentUserLayerIndex)); + SelectedLayerChanged?.Invoke (this, EventArgs.Empty); return layer; } diff --git a/Pinta/Actions/Edit/PasteAction.cs b/Pinta/Actions/Edit/PasteAction.cs index 760537a1e8..92da40ade5 100644 --- a/Pinta/Actions/Edit/PasteAction.cs +++ b/Pinta/Actions/Edit/PasteAction.cs @@ -1,22 +1,22 @@ -// +// // PasteAction.cs -// +// // Author: // Jonathan Pobst // Cameron White -// +// // Copyright (c) 2012 Jonathan Pobst, Cameron White -// +// // 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 @@ -170,7 +170,6 @@ public static async void Paste ( // layer and record it's creation in the history if (toNewLayer) { var l = doc.Layers.AddNewLayer (string.Empty); - doc.Layers.SetCurrentUserLayer (l); paste_action.Push (new AddLayerHistoryItem (Resources.Icons.LayerNew, Translations.GetString ("Add New Layer"), doc.Layers.IndexOf (l))); }