mitsuami-appkit 1.1.0

AppKit (macOS) backend for mitsuami
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Scroll views: scrolling as the user does, and their scrollers.

use mitsuami_core::ScrollAxes;
use objc2_app_kit::NSScrollView;
use objc2_foundation::NSPoint;

/// Scrolls like the user would, so the clip view reports the change.
pub(super) fn scroll_to(scroll: &NSScrollView, origin: NSPoint) {
    let clip = scroll.contentView();
    clip.scrollToPoint(crate::classes::clip_origin(&clip, origin));
    scroll.reflectScrolledClipView(&clip);
}

/// Scrollers for the axes that scroll, if the scroll view shows any.
pub(super) fn set_scrollers(scroll: &NSScrollView, axes: ScrollAxes, show: bool) {
    scroll.setHasVerticalScroller(show && axes.vertical());
    scroll.setHasHorizontalScroller(show && axes.horizontal());
}