Use BTreeMap for splits and regions in pane_grid

This preserves ordering between calls to update and draw logic.
This commit is contained in:
Héctor Ramón Jiménez 2021-01-07 21:07:44 +01:00
parent 31522e30aa
commit e7344d03b4
4 changed files with 12 additions and 12 deletions

View file

@ -3,7 +3,7 @@ use crate::{
Rectangle, Size,
};
use std::collections::HashMap;
use std::collections::BTreeMap;
/// A layout node of a [`PaneGrid`].
///
@ -59,8 +59,8 @@ impl Node {
&self,
spacing: f32,
size: Size,
) -> HashMap<Pane, Rectangle> {
let mut regions = HashMap::new();
) -> BTreeMap<Pane, Rectangle> {
let mut regions = BTreeMap::new();
self.compute_regions(
spacing,
@ -83,8 +83,8 @@ impl Node {
&self,
spacing: f32,
size: Size,
) -> HashMap<Split, (Axis, Rectangle, f32)> {
let mut splits = HashMap::new();
) -> BTreeMap<Split, (Axis, Rectangle, f32)> {
let mut splits = BTreeMap::new();
self.compute_splits(
spacing,
@ -191,7 +191,7 @@ impl Node {
&self,
spacing: f32,
current: &Rectangle,
regions: &mut HashMap<Pane, Rectangle>,
regions: &mut BTreeMap<Pane, Rectangle>,
) {
match self {
Node::Split {
@ -212,7 +212,7 @@ impl Node {
&self,
spacing: f32,
current: &Rectangle,
splits: &mut HashMap<Split, (Axis, Rectangle, f32)>,
splits: &mut BTreeMap<Split, (Axis, Rectangle, f32)>,
) {
match self {
Node::Split {