[style] rounded buttons and tweak some spacing and sizes
This commit is contained in:
parent
c35494e4ec
commit
5bf8051be5
5 changed files with 24 additions and 8 deletions
|
@ -245,7 +245,7 @@ fn automatic_area_position(ctx: &Context) -> Pos2 {
|
||||||
|
|
||||||
let left = 16.0;
|
let left = 16.0;
|
||||||
let top = 32.0; // allow existence of menu bar. TODO: get from ui.available()
|
let top = 32.0; // allow existence of menu bar. TODO: get from ui.available()
|
||||||
let spacing = 32.0;
|
let spacing = 16.0;
|
||||||
|
|
||||||
if existing.is_empty() {
|
if existing.is_empty() {
|
||||||
return pos2(left, top);
|
return pos2(left, top);
|
||||||
|
|
|
@ -42,7 +42,7 @@ impl Default for Resize {
|
||||||
resizable: true,
|
resizable: true,
|
||||||
min_size: Vec2::splat(16.0),
|
min_size: Vec2::splat(16.0),
|
||||||
max_size: Vec2::infinity(),
|
max_size: Vec2::infinity(),
|
||||||
default_size: vec2(200.0, 400.0), // TODO: default height for a resizable area (e.g. a window)
|
default_size: vec2(280.0, 400.0), // TODO: perferred size for a resizable area (e.g. a window)
|
||||||
outline: true,
|
outline: true,
|
||||||
handle_offset: Default::default(),
|
handle_offset: Default::default(),
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,24 @@ impl Resize {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Preferred / suggested width. Actual width will depend on contents.
|
||||||
|
///
|
||||||
|
/// Examples:
|
||||||
|
/// * if the contents is text, this will decide where we break long lines.
|
||||||
|
/// * if the contents is a canvas, this decides the width of it,
|
||||||
|
/// * if the contents is some buttons, this is ignored and we will auto-size.
|
||||||
pub fn default_width(mut self, width: f32) -> Self {
|
pub fn default_width(mut self, width: f32) -> Self {
|
||||||
self.default_size.x = width;
|
self.default_size.x = width;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Preferred / suggested height. Actual height will depend on contents.
|
||||||
|
///
|
||||||
|
/// Examples:
|
||||||
|
/// * if the contents is a `ScrollArea` then this decides the maximum size.
|
||||||
|
/// * if the contents is a canvas, this decides the height of it,
|
||||||
|
/// * if the contents is text and buttons, then the `default_height` is ignored
|
||||||
|
/// and the height is picked automatically..
|
||||||
pub fn default_height(mut self, height: f32) -> Self {
|
pub fn default_height(mut self, height: f32) -> Self {
|
||||||
self.default_size.y = height;
|
self.default_size.y = height;
|
||||||
self
|
self
|
||||||
|
|
|
@ -76,7 +76,7 @@ impl ScrollArea {
|
||||||
// outer: size of scroll area including scroll bar(s)
|
// outer: size of scroll area including scroll bar(s)
|
||||||
// inner: excluding scroll bar(s). The area we clip the contents to.
|
// inner: excluding scroll bar(s). The area we clip the contents to.
|
||||||
|
|
||||||
let max_scroll_bar_width = 16.0;
|
let max_scroll_bar_width = ui.style().item_spacing.x + 16.0;
|
||||||
|
|
||||||
let current_scroll_bar_width = if state.show_scroll || !auto_hide_scroll {
|
let current_scroll_bar_width = if state.show_scroll || !auto_hide_scroll {
|
||||||
max_scroll_bar_width // TODO: animate?
|
max_scroll_bar_width // TODO: animate?
|
||||||
|
@ -161,7 +161,8 @@ impl Prepared {
|
||||||
|
|
||||||
let show_scroll_this_frame = content_is_too_small || always_show_scroll;
|
let show_scroll_this_frame = content_is_too_small || always_show_scroll;
|
||||||
if show_scroll_this_frame || state.show_scroll {
|
if show_scroll_this_frame || state.show_scroll {
|
||||||
let left = inner_rect.right() + 2.0;
|
let margin = ui.style().item_spacing.x; // margin between contents and scroll bar
|
||||||
|
let left = inner_rect.right() + margin;
|
||||||
let right = outer_rect.right();
|
let right = outer_rect.right();
|
||||||
let corner_radius = (right - left) / 2.0;
|
let corner_radius = (right - left) / 2.0;
|
||||||
let top = inner_rect.top();
|
let top = inner_rect.top();
|
||||||
|
|
|
@ -287,7 +287,9 @@ impl Path {
|
||||||
/// quadrant 3 right top
|
/// quadrant 3 right top
|
||||||
/// 4 * TAU / 4 = right
|
/// 4 * TAU / 4 = right
|
||||||
pub fn add_circle_quadrant(&mut self, center: Pos2, radius: f32, quadrant: f32) {
|
pub fn add_circle_quadrant(&mut self, center: Pos2, radius: f32, quadrant: f32) {
|
||||||
let n = (radius * 0.5).round() as i32; // TODO: tweak a bit more
|
// TODO: optimize with precalculated vertices for some radii ranges
|
||||||
|
|
||||||
|
let n = (radius * 0.75).round() as i32; // TODO: tweak a bit more
|
||||||
let n = clamp(n, 2..=32);
|
let n = clamp(n, 2..=32);
|
||||||
self.reserve(n as usize + 1);
|
self.reserve(n as usize + 1);
|
||||||
const RIGHT_ANGLE: f32 = TAU / 4.0;
|
const RIGHT_ANGLE: f32 = TAU / 4.0;
|
||||||
|
|
|
@ -105,7 +105,7 @@ impl Default for Interact {
|
||||||
stroke_color: WHITE,
|
stroke_color: WHITE,
|
||||||
stroke_width: 2.0,
|
stroke_width: 2.0,
|
||||||
rect_outline: Some(LineStyle::new(2.0, WHITE)),
|
rect_outline: Some(LineStyle::new(2.0, WHITE)),
|
||||||
corner_radius: 5.0,
|
corner_radius: 0.0,
|
||||||
},
|
},
|
||||||
hovered: WidgetStyle {
|
hovered: WidgetStyle {
|
||||||
bg_fill: None,
|
bg_fill: None,
|
||||||
|
@ -113,7 +113,7 @@ impl Default for Interact {
|
||||||
stroke_color: gray(240, 255),
|
stroke_color: gray(240, 255),
|
||||||
stroke_width: 1.5,
|
stroke_width: 1.5,
|
||||||
rect_outline: Some(LineStyle::new(1.0, WHITE)),
|
rect_outline: Some(LineStyle::new(1.0, WHITE)),
|
||||||
corner_radius: 5.0,
|
corner_radius: 2.0,
|
||||||
},
|
},
|
||||||
inactive: WidgetStyle {
|
inactive: WidgetStyle {
|
||||||
bg_fill: None,
|
bg_fill: None,
|
||||||
|
@ -121,7 +121,7 @@ impl Default for Interact {
|
||||||
stroke_color: gray(210, 255), // Mustn't look grayed out!
|
stroke_color: gray(210, 255), // Mustn't look grayed out!
|
||||||
stroke_width: 1.0,
|
stroke_width: 1.0,
|
||||||
rect_outline: Some(LineStyle::new(1.0, white(128))),
|
rect_outline: Some(LineStyle::new(1.0, white(128))),
|
||||||
corner_radius: 0.0,
|
corner_radius: 4.0,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue