Skip to main content

cosmic_applet_avestruz/views/components/
constants.rs

1// SPDX-License-Identifier: MIT
2
3//! Sizes shared between views, and the scroller they share.
4
5use std::sync::LazyLock;
6
7use cosmic::widget;
8
9/// The scrollable holding the list of the view on show: a feed's, a
10/// thread's.
11///
12/// One id for them all, because to the runtime they are one widget. Views
13/// are laid out alike, and a scrollable that turns up where another was
14/// takes over its state, its id (libcosmic's widget tree hands the old id
15/// to the new widget) and how far it was scrolled. A view that wants its
16/// list somewhere says so by scrolling this, every time it comes on show.
17pub static LIST_SCROLL_ID: LazyLock<widget::Id> = LazyLock::new(widget::Id::unique);
18
19/// How wide the popup is, at the least and at the most. Said twice, to the
20/// compositor that places the popup and to the wrapper that sizes it to its
21/// content, which would otherwise pin it to libcosmic's 360.
22pub const POPUP_MIN_WIDTH: f32 = 420.0;
23pub const POPUP_MAX_WIDTH: f32 = 640.0;
24
25/// The room beside a view's list, inside its scroller: at the left, and at
26/// the right, where the scrollbar is drawn over what is scrolled. And how
27/// wide that leaves the list in a popup at its widest: what a picture
28/// that fills its row is as wide as.
29pub const LIST_PADDING_LEFT: u16 = 12;
30pub const LIST_PADDING_RIGHT: u16 = 14;
31pub const LIST_MAX_WIDTH: f32 = POPUP_MAX_WIDTH - (LIST_PADDING_LEFT + LIST_PADDING_RIGHT) as f32;
32
33/// How tall the popup may be while the height of its screen is not known:
34/// what fits any screen. And the least it may ever be told it may be,
35/// however short the screen: the least the compositor is asked for.
36pub const POPUP_MAX_HEIGHT_UNMEASURED: f32 = 600.0;
37pub const POPUP_MIN_HEIGHT: f32 = 300.0;