Merge remote-tracking branch 'origin/main' into next-dash-interface
[skip ci]
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
use crate::{
|
||||
assets::AssetPath,
|
||||
components::{Component, button, tooltip},
|
||||
components::{button, tooltip, Component},
|
||||
drawing::Color,
|
||||
i18n::Translation,
|
||||
layout::WidgetID,
|
||||
parser::{
|
||||
AttribPair, ParserContext, ParserFile, parse_check_f32, parse_check_i32, parse_children, print_invalid_attrib,
|
||||
process_component,
|
||||
parse_check_f32, parse_check_i32, parse_children, parse_f32, print_invalid_attrib, process_component,
|
||||
style::{parse_color_opt, parse_round, parse_style, parse_text_style},
|
||||
AttribPair, ParserContext, ParserFile,
|
||||
},
|
||||
widget::util::WLength,
|
||||
};
|
||||
@@ -28,6 +28,7 @@ pub fn parse_component_button<'a>(
|
||||
let mut tooltip: Option<String> = None;
|
||||
let mut tooltip_side: Option<tooltip::TooltipSide> = None;
|
||||
let mut sticky: bool = false;
|
||||
let mut long_press_time = 0.0;
|
||||
let mut sprite_src: Option<AssetPath> = None;
|
||||
|
||||
let mut translation: Option<Translation> = None;
|
||||
@@ -45,7 +46,7 @@ pub fn parse_component_button<'a>(
|
||||
translation = Some(Translation::from_translation_key(value));
|
||||
}
|
||||
"round" => {
|
||||
parse_round(value, &mut round);
|
||||
parse_round(value, &mut round, ctx.doc_params.globals.get().defaults.rounding_mult);
|
||||
}
|
||||
"color" => {
|
||||
parse_color_opt(value, &mut color);
|
||||
@@ -92,6 +93,9 @@ pub fn parse_component_button<'a>(
|
||||
let mut sticky_i32 = 0;
|
||||
sticky = parse_check_i32(value, &mut sticky_i32) && sticky_i32 == 1;
|
||||
}
|
||||
"long_press_time" => {
|
||||
long_press_time = parse_f32(value).unwrap_or(long_press_time);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
@@ -113,6 +117,7 @@ pub fn parse_component_button<'a>(
|
||||
text: Translation::from_translation_key(&t),
|
||||
}),
|
||||
sticky,
|
||||
long_press_time,
|
||||
sprite_src,
|
||||
},
|
||||
)?;
|
||||
|
||||
@@ -8,7 +8,7 @@ mod widget_rectangle;
|
||||
mod widget_sprite;
|
||||
|
||||
use crate::{
|
||||
assets::{AssetPath, AssetPathOwned, normalize_path},
|
||||
assets::{normalize_path, AssetPath, AssetPathOwned},
|
||||
components::{Component, ComponentWeak},
|
||||
drawing::{self},
|
||||
globals::WguiGlobals,
|
||||
@@ -400,6 +400,7 @@ impl ParserContext<'_> {
|
||||
insert_color_vars!(self, "accent", def.accent_color, def.translucent_alpha);
|
||||
insert_color_vars!(self, "danger", def.danger_color, def.translucent_alpha);
|
||||
insert_color_vars!(self, "faded", def.faded_color, def.translucent_alpha);
|
||||
insert_color_vars!(self, "bg", def.bg_color, def.translucent_alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,14 @@ use taffy::{
|
||||
use crate::{
|
||||
drawing,
|
||||
parser::{
|
||||
AttribPair, is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val,
|
||||
print_invalid_attrib, print_invalid_value,
|
||||
is_percent, parse_color_hex, parse_f32, parse_percent, parse_size_unit, parse_val, print_invalid_attrib,
|
||||
print_invalid_value, AttribPair,
|
||||
},
|
||||
renderer_vk::text::{FontWeight, HorizontalAlign, TextStyle},
|
||||
widget::util::WLength,
|
||||
};
|
||||
|
||||
pub fn parse_round(value: &str, round: &mut WLength) {
|
||||
pub fn parse_round(value: &str, round: &mut WLength, multiplier: f32) {
|
||||
if is_percent(value) {
|
||||
if let Some(val) = parse_percent(value) {
|
||||
*round = WLength::Percent(val);
|
||||
@@ -21,7 +21,7 @@ pub fn parse_round(value: &str, round: &mut WLength) {
|
||||
print_invalid_value(value);
|
||||
}
|
||||
} else if let Some(val) = parse_f32(value) {
|
||||
*round = WLength::Units(val);
|
||||
*round = WLength::Units((val * multiplier).max(0.));
|
||||
} else {
|
||||
print_invalid_value(value);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ use crate::{
|
||||
drawing::GradientMode,
|
||||
layout::WidgetID,
|
||||
parser::{
|
||||
AttribPair, ParserContext, ParserFile, parse_children, parse_widget_universal, print_invalid_attrib,
|
||||
parse_children, parse_widget_universal, print_invalid_attrib,
|
||||
style::{parse_color, parse_round, parse_style},
|
||||
AttribPair, ParserContext, ParserFile,
|
||||
},
|
||||
widget::rectangle::{WidgetRectangle, WidgetRectangleParams},
|
||||
};
|
||||
@@ -40,7 +41,11 @@ pub fn parse_widget_rectangle<'a>(
|
||||
}
|
||||
}
|
||||
"round" => {
|
||||
parse_round(value, &mut params.round);
|
||||
parse_round(
|
||||
value,
|
||||
&mut params.round,
|
||||
ctx.doc_params.globals.get().defaults.rounding_mult,
|
||||
);
|
||||
}
|
||||
"border" => {
|
||||
params.border = value.parse().unwrap_or_else(|_| {
|
||||
|
||||
Reference in New Issue
Block a user