settings gui PoC
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
animation::{Animation, AnimationEasing},
|
||||
components::{self, tooltip::ComponentTooltip, Component, ComponentBase, ComponentTrait, InitData},
|
||||
components::{self, Component, ComponentBase, ComponentTrait, InitData, tooltip::ComponentTooltip},
|
||||
drawing::{self, Boundary, Color},
|
||||
event::{CallbackDataCommon, EventListenerCollection, EventListenerID, EventListenerKind},
|
||||
i18n::Translation,
|
||||
@@ -10,15 +10,15 @@ use crate::{
|
||||
util::centered_matrix,
|
||||
},
|
||||
widget::{
|
||||
ConstructEssentials, EventResult, WidgetData,
|
||||
label::{WidgetLabel, WidgetLabelParams},
|
||||
rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
util::WLength,
|
||||
ConstructEssentials, EventResult, WidgetData,
|
||||
},
|
||||
};
|
||||
use glam::{Mat4, Vec3};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use taffy::{AlignItems, JustifyContent};
|
||||
use taffy::{AlignItems, JustifyContent, prelude::length};
|
||||
|
||||
pub struct Params {
|
||||
pub text: Option<Translation>, // if unset, label will not be populated
|
||||
@@ -281,6 +281,7 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul
|
||||
style.justify_content = Some(JustifyContent::Center);
|
||||
style.overflow.x = taffy::Overflow::Hidden;
|
||||
style.overflow.y = taffy::Overflow::Hidden;
|
||||
style.gap = length(4.0);
|
||||
|
||||
// update colors to default ones if they are not specified
|
||||
let color = if let Some(color) = params.color {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use taffy::{
|
||||
prelude::{length, percent},
|
||||
AlignItems, JustifyContent,
|
||||
prelude::{length, percent},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -13,10 +13,10 @@ use crate::{
|
||||
layout::{self, LayoutState, WidgetID, WidgetPair},
|
||||
renderer_vk::text::{FontWeight, TextStyle},
|
||||
widget::{
|
||||
ConstructEssentials, EventResult,
|
||||
label::{WidgetLabel, WidgetLabelParams},
|
||||
rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
util::WLength,
|
||||
ConstructEssentials, EventResult,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -223,6 +223,7 @@ fn register_event_mouse_release(
|
||||
)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Result<(WidgetPair, Rc<ComponentCheckbox>)> {
|
||||
let mut style = params.style;
|
||||
|
||||
@@ -230,12 +231,21 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul
|
||||
style.flex_wrap = taffy::FlexWrap::NoWrap;
|
||||
style.align_items = Some(AlignItems::Center);
|
||||
style.justify_content = Some(JustifyContent::Center);
|
||||
|
||||
// make checkbox interaction box larger by setting padding and negative margin
|
||||
style.padding = taffy::Rect {
|
||||
left: length(4.0),
|
||||
right: length(8.0),
|
||||
top: length(4.0),
|
||||
bottom: length(4.0),
|
||||
};
|
||||
|
||||
style.margin = taffy::Rect {
|
||||
left: length(-4.0),
|
||||
right: length(-8.0),
|
||||
top: length(-4.0),
|
||||
bottom: length(-4.0),
|
||||
};
|
||||
//style.align_self = Some(taffy::AlignSelf::Start); // do not stretch self to the parent
|
||||
style.gap = length(4.0);
|
||||
|
||||
|
||||
@@ -15,11 +15,11 @@ use crate::{
|
||||
util,
|
||||
},
|
||||
widget::{
|
||||
ConstructEssentials, EventResult,
|
||||
div::WidgetDiv,
|
||||
label::{WidgetLabel, WidgetLabelParams},
|
||||
rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
util::WLength,
|
||||
ConstructEssentials, EventResult,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -149,7 +149,7 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
const BODY_COLOR: drawing::Color = drawing::Color::new(0.6, 0.65, 0.7, 1.0);
|
||||
const BODY_COLOR: drawing::Color = drawing::Color::new(0.6, 0.65, 0.7, 0.2);
|
||||
const BODY_BORDER_COLOR: drawing::Color = drawing::Color::new(0.4, 0.45, 0.5, 1.0);
|
||||
const HANDLE_BORDER_COLOR: drawing::Color = drawing::Color::new(0.85, 0.85, 0.85, 1.0);
|
||||
const HANDLE_BORDER_COLOR_HOVERED: drawing::Color = drawing::Color::new(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
Reference in New Issue
Block a user