wgui: interactable components, rename TextLabel -> WidgetLabel
This commit is contained in:
@@ -19,11 +19,10 @@ use crate::{
|
||||
overlay::{FrameMeta, OverlayBackend, ShouldRender, ui_transform},
|
||||
},
|
||||
graphics::{CommandBuffers, ExtentExt},
|
||||
gui,
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
use super::{asset::GuiAsset, timer::GuiTimer, timestep::Timestep};
|
||||
use super::{timer::GuiTimer, timestep::Timestep};
|
||||
|
||||
const MAX_SIZE: u32 = 2048;
|
||||
const MAX_SIZE_VEC2: Vec2 = vec2(MAX_SIZE as _, MAX_SIZE as _);
|
||||
|
||||
@@ -8,8 +8,8 @@ use wgui::{
|
||||
renderer_vk::util,
|
||||
taffy::{self, prelude::length},
|
||||
widget::{
|
||||
div::Div,
|
||||
rectangle::{Rectangle, RectangleParams},
|
||||
div::WidgetDiv,
|
||||
rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
util::WLength,
|
||||
},
|
||||
};
|
||||
@@ -56,7 +56,7 @@ where
|
||||
|
||||
let (background, _) = panel.layout.add_child(
|
||||
panel.layout.root_widget,
|
||||
Rectangle::create(RectangleParams {
|
||||
WidgetRectangle::create(WidgetRectangleParams {
|
||||
color: wgui::drawing::Color::new(0., 0., 0., 0.6),
|
||||
round: WLength::Units(4.0),
|
||||
..Default::default()
|
||||
@@ -85,7 +85,7 @@ where
|
||||
for row in 0..layout.key_sizes.len() {
|
||||
let (div, _) = panel.layout.add_child(
|
||||
background,
|
||||
Div::create().unwrap(),
|
||||
WidgetDiv::create().unwrap(),
|
||||
taffy::Style {
|
||||
flex_direction: taffy::FlexDirection::Row,
|
||||
..Default::default()
|
||||
@@ -106,7 +106,7 @@ where
|
||||
let Some(key) = layout.get_key_data(keymap.as_ref(), has_altgr, col, row) else {
|
||||
let _ = panel.layout.add_child(
|
||||
div,
|
||||
Div::create()?,
|
||||
WidgetDiv::create()?,
|
||||
taffy::Style {
|
||||
size: taffy_size,
|
||||
min_size: taffy_size,
|
||||
@@ -173,7 +173,7 @@ where
|
||||
.layout
|
||||
.state
|
||||
.widgets
|
||||
.get_as::<Rectangle>(*widget_id)
|
||||
.get_as::<WidgetRectangle>(*widget_id)
|
||||
.unwrap(); // want panic
|
||||
|
||||
Rc::new(KeyState {
|
||||
@@ -291,7 +291,7 @@ fn get_anim_transform(pos: f32, widget_size: Vec2) -> Mat4 {
|
||||
)
|
||||
}
|
||||
|
||||
fn set_anim_color(key_state: &KeyState, rect: &mut Rectangle, pos: f32) {
|
||||
fn set_anim_color(key_state: &KeyState, rect: &mut WidgetRectangle, pos: f32) {
|
||||
let br1 = pos * 0.25;
|
||||
let br2 = pos * 0.15;
|
||||
|
||||
@@ -314,7 +314,7 @@ fn on_enter_anim(
|
||||
10,
|
||||
AnimationEasing::OutBack,
|
||||
Box::new(move |common, data| {
|
||||
let rect = data.obj.get_as_mut::<Rectangle>();
|
||||
let rect = data.obj.get_as_mut::<WidgetRectangle>();
|
||||
set_anim_color(&key_state, rect, data.pos);
|
||||
data.data.transform = get_anim_transform(data.pos, data.widget_size);
|
||||
common.alterables.mark_redraw();
|
||||
@@ -332,7 +332,7 @@ fn on_leave_anim(
|
||||
15,
|
||||
AnimationEasing::OutQuad,
|
||||
Box::new(move |common, data| {
|
||||
let rect = data.obj.get_as_mut::<Rectangle>();
|
||||
let rect = data.obj.get_as_mut::<WidgetRectangle>();
|
||||
set_anim_color(&key_state, rect, 1.0 - data.pos);
|
||||
data.data.transform = get_anim_transform(1.0 - data.pos, data.widget_size);
|
||||
common.alterables.mark_redraw();
|
||||
@@ -348,7 +348,7 @@ fn on_press_anim(
|
||||
if key_state.drawn_state.get() {
|
||||
return;
|
||||
}
|
||||
let rect = data.obj.get_as_mut::<Rectangle>();
|
||||
let rect = data.obj.get_as_mut::<WidgetRectangle>();
|
||||
rect.params.border_color = Color::new(1.0, 1.0, 1.0, 1.0);
|
||||
common.alterables.mark_redraw();
|
||||
key_state.drawn_state.set(true);
|
||||
@@ -362,7 +362,7 @@ fn on_release_anim(
|
||||
if !key_state.drawn_state.get() {
|
||||
return;
|
||||
}
|
||||
let rect = data.obj.get_as_mut::<Rectangle>();
|
||||
let rect = data.obj.get_as_mut::<WidgetRectangle>();
|
||||
rect.params.border_color = key_state.border_color;
|
||||
common.alterables.mark_redraw();
|
||||
key_state.drawn_state.set(false);
|
||||
|
||||
@@ -17,8 +17,8 @@ use wgui::{
|
||||
prelude::{auto, length, percent},
|
||||
},
|
||||
widget::{
|
||||
rectangle::{Rectangle, RectangleParams},
|
||||
text::{TextLabel, TextParams},
|
||||
label::{WidgetLabelParams, WidgetLabel},
|
||||
rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
util::WLength,
|
||||
},
|
||||
};
|
||||
@@ -176,7 +176,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box<dyn
|
||||
.layout
|
||||
.add_child(
|
||||
panel.layout.root_widget,
|
||||
Rectangle::create(RectangleParams {
|
||||
WidgetRectangle::create(WidgetRectangleParams {
|
||||
color: parse_color_hex("#1e2030").unwrap(),
|
||||
border_color: parse_color_hex("#5e7090").unwrap(),
|
||||
border: 1.0,
|
||||
@@ -196,9 +196,9 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box<dyn
|
||||
|
||||
let _ = panel.layout.add_child(
|
||||
rect,
|
||||
TextLabel::create(
|
||||
WidgetLabel::create(
|
||||
&mut i18n,
|
||||
TextParams {
|
||||
WidgetLabelParams {
|
||||
content: Translation::from_raw_text(&title),
|
||||
style: TextStyle {
|
||||
color: parse_color_hex("#ffffff"),
|
||||
@@ -219,9 +219,9 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box<dyn
|
||||
|
||||
let _ = panel.layout.add_child(
|
||||
rect,
|
||||
TextLabel::create(
|
||||
WidgetLabel::create(
|
||||
&mut i18n,
|
||||
TextParams {
|
||||
WidgetLabelParams {
|
||||
content: Translation::from_raw_text(&toast.body),
|
||||
style: TextStyle {
|
||||
weight: Some(FontWeight::Bold),
|
||||
|
||||
@@ -7,7 +7,7 @@ use regex::Regex;
|
||||
use wgui::{
|
||||
event::{self, EventListenerKind},
|
||||
i18n::Translation,
|
||||
widget::text::TextLabel,
|
||||
widget::label::WidgetLabel,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -46,7 +46,7 @@ where
|
||||
.layout
|
||||
.state
|
||||
.widgets
|
||||
.get_as::<TextLabel>(*widget_id)
|
||||
.get_as::<WidgetLabel>(*widget_id)
|
||||
.unwrap();
|
||||
|
||||
let format = match role {
|
||||
@@ -165,6 +165,6 @@ fn clock_on_tick(
|
||||
|tz| format!("{}", Local::now().with_timezone(tz).format(&clock.format)),
|
||||
);
|
||||
|
||||
let label = data.obj.get_as_mut::<TextLabel>();
|
||||
let label = data.obj.get_as_mut::<WidgetLabel>();
|
||||
label.set_text(&mut common.i18n(), Translation::from_raw_text(&date_time));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user