Procházet zdrojové kódy

tools: scroll to last selected object

Daniele Bartolini před 1 rokem
rodič
revize
a4bf4e967e
2 změnil soubory, kde provedl 7 přidání a 0 odebrání
  1. 1 0
      docs/changelog.rst
  2. 6 0
      tools/level_editor/level_tree_view.vala

+ 1 - 0
docs/changelog.rst

@@ -8,6 +8,7 @@ Changelog
 
 * Added the ability to add/remove components from units in the Inspector panel.
 * Improved compatibility with Hi-DPI screens.
+* The Level Tree will now scroll to the last selected object.
 
 **Runtime**
 

+ 6 - 0
tools/level_editor/level_tree_view.vala

@@ -299,6 +299,8 @@ public class LevelTreeView : Gtk.Box
 		_tree_selection.changed.disconnect(on_tree_selection_changed);
 		_tree_selection.unselect_all();
 
+		Gtk.TreePath? last_selected = null;
+
 		_tree_sort.foreach ((model, path, iter) => {
 				Value type;
 				model.get_value(iter, Column.TYPE, out type);
@@ -311,6 +313,7 @@ public class LevelTreeView : Gtk.Box
 				foreach (Guid? guid in selection) {
 					if ((Guid)id == guid) {
 						_tree_selection.select_iter(iter);
+						last_selected = path;
 						return false;
 					}
 				}
@@ -318,6 +321,9 @@ public class LevelTreeView : Gtk.Box
 				return false;
 			});
 
+		if (last_selected != null)
+			_tree_view.scroll_to_cell(last_selected, null, false, 0.0f, 0.0f);
+
 		_tree_selection.changed.connect(on_tree_selection_changed);
 	}