mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Floating scroll bars (#3539)
* Move scroll bar spacing settings to a `struct ScrollSpacing` * Add a demo for changing scroll bar appearance * Add setting for ScrollBarVisibility in demo * Add `#[inline]` to a `ScrollArea` builder methods * Refactor how scroll bar show/hide is computed * Add support for floating scroll bars * Tweak color and opacity of the scroll handle * Allow allocating a fixed size even for floating scroll bars * Add three pre-sets of scroll bars: solid, thin, floating * Use floating scroll bars as the default * Fix id-clash with bidir scroll areas * Improve demo * Fix doclink * Remove reset button from demo * Fix doclinks * Fix visual artifact with thin rounded rectangles * Fix doclink * typos
This commit is contained in:
@@ -150,6 +150,34 @@ impl Rect {
|
||||
rect
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn with_min_x(mut self, min_x: f32) -> Self {
|
||||
self.min.x = min_x;
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn with_min_y(mut self, min_y: f32) -> Self {
|
||||
self.min.y = min_y;
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn with_max_x(mut self, max_x: f32) -> Self {
|
||||
self.max.x = max_x;
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn with_max_y(mut self, max_y: f32) -> Self {
|
||||
self.max.y = max_y;
|
||||
self
|
||||
}
|
||||
|
||||
/// Expand by this much in each direction, keeping the center
|
||||
#[must_use]
|
||||
pub fn expand(self, amnt: f32) -> Self {
|
||||
|
||||
@@ -274,6 +274,16 @@ impl Vec2 {
|
||||
self.x.max(self.y)
|
||||
}
|
||||
|
||||
/// Swizzle the axes.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn yx(self) -> Vec2 {
|
||||
Vec2 {
|
||||
x: self.y,
|
||||
y: self.x,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn clamp(self, min: Self, max: Self) -> Self {
|
||||
|
||||
Reference in New Issue
Block a user