1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
use crate::foundation::{NSInteger, NSUInteger};

/// This enum represents the different stock animations possible
/// for ListView row operations. You can pass it to `insert_rows`
/// and `remove_rows` - reloads don't get animations.
#[derive(Copy, Clone, Debug)]
pub enum RowAnimation {
    /// No animation.
    None,

    /// Fades rows in and out.
    Fade,

    /// Creates a gap - this one is mostly useful during
    /// drag and drop operations.
    Gap,

    /// Animates in or out by sliding upwards.
    SlideUp,

    /// Animates in or out by sliding down.
    SlideDown,

    /// Animates in or out by sliding left.
    SlideLeft,

    /// Animates in or out by sliding right.
    SlideRight
}

impl Into<NSUInteger> for RowAnimation {
    fn into(self) -> NSUInteger {
        match self {
            RowAnimation::None => 0x0,
            RowAnimation::Fade => 0x1,
            RowAnimation::Gap => 0x2,
            RowAnimation::SlideUp => 0x10,
            RowAnimation::SlideDown => 0x20,
            RowAnimation::SlideLeft => 0x30,
            RowAnimation::SlideRight => 0x40
        }
    }
}

/// Specifies a row edge.
///
/// Generally used to indicate where row actions (swipe-to-reveal) should appear.
#[derive(Copy, Clone, Debug)]
pub enum RowEdge {
    /// The leading edge.
    Leading,

    /// The trailing edge.
    Trailing
}

impl Into<RowEdge> for NSInteger {
    fn into(self) -> RowEdge {
        match self {
            0 => RowEdge::Leading,
            1 => RowEdge::Trailing,

            // @TODO: This *should* be unreachable, provided macOS doesn't start
            // letting people swipe from vertical directions to reveal stuff. Have to
            // feel like there's a better way to do this, though...
            _ => {
                unreachable!();
            }
        }
    }
}