use bevy::platform::collections::HashMap;
use bevy::prelude::*;
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub struct PfElementKind(pub String);
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub struct PfName(pub String);
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub struct PfUid(pub String);
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub struct PfAutomationId(pub String);
#[derive(Component, Debug, Clone, Copy, PartialEq, Eq)]
pub struct PfCollapsedDisplay(pub bevy::ui::Display);
#[derive(Component, Debug, Default)]
pub struct XamlNames(pub HashMap<String, Entity>);
impl XamlNames {
pub fn get(&self, name: &str) -> Option<Entity> {
self.0.get(name).copied()
}
}
#[derive(Component, Debug, Default, Clone)]
pub struct PfAttachedProps(pub HashMap<String, String>);
impl PfAttachedProps {
pub fn get(&self, owner: &str, prop: &str) -> Option<&str> {
self.0.get(&format!("{owner}.{prop}")).map(|s| s.as_str())
}
pub fn parse<T: std::str::FromStr>(&self, owner: &str, prop: &str) -> Option<T> {
self.get(owner, prop).and_then(|s| s.trim().parse().ok())
}
}
#[derive(Component, Debug, Clone)]
pub struct ButtonVisual {
pub normal_bg: Color,
pub hover_bg: Color,
pub pressed_bg: Color,
pub normal_border: Color,
pub hover_border: Color,
pub pressed_border: Color,
}
impl Default for ButtonVisual {
fn default() -> Self {
Self {
normal_bg: Color::srgb_u8(0xE1, 0xE1, 0xE1),
hover_bg: Color::srgb_u8(0xE5, 0xF1, 0xFB),
pressed_bg: Color::srgb_u8(0xCC, 0xE4, 0xF7),
normal_border: Color::srgb_u8(0xAD, 0xAD, 0xAD),
hover_border: Color::srgb_u8(0x00, 0x78, 0xD7),
pressed_border: Color::srgb_u8(0x00, 0x54, 0x99),
}
}
}
pub const ACCENT: Color = Color::srgb(0.0, 0.47, 0.84);
#[derive(Resource, Debug, Clone)]
pub struct PfControlTheme {
pub accent: Color,
pub on_accent: Color,
pub control_face: Color,
pub control_border: Color,
pub track: Color,
pub popup_face: Color,
pub popup_border: Color,
pub selection_fill: Color,
pub hover_fill: Color,
pub item_text: Color,
}
impl Default for PfControlTheme {
fn default() -> Self {
Self {
accent: ACCENT,
on_accent: Color::WHITE,
control_face: Color::WHITE,
control_border: Color::srgb_u8(0x70, 0x70, 0x70),
track: Color::srgb_u8(0xC4, 0xC4, 0xC4),
popup_face: Color::WHITE,
popup_border: Color::srgb_u8(0xAD, 0xAD, 0xAD),
selection_fill: Color::srgb(0.796, 0.909, 0.964), hover_fill: Color::srgb(0.898, 0.953, 1.0), item_text: Color::BLACK,
}
}
}
#[derive(Component, Debug, Clone)]
pub struct PfCheckVisual {
pub box_node: Entity,
pub glyph: Entity,
pub accent_fills_box: bool,
}
#[derive(Component, Debug, Default, Clone)]
pub struct PfToggleButton;
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub struct PfRadioGroup(pub String);
#[derive(Component, Debug, Clone)]
pub struct PfProgress {
pub min: f32,
pub max: f32,
pub value: f32,
pub indeterminate: bool,
}
impl PfProgress {
pub fn fraction(&self) -> f32 {
if self.max > self.min {
((self.value - self.min) / (self.max - self.min)).clamp(0.0, 1.0)
} else {
0.0
}
}
}
#[derive(Component, Debug, Clone)]
pub struct PfFrame {
pub content: Entity,
pub chrome: Option<PfFrameChrome>,
pub back: Vec<String>,
pub forward: Vec<String>,
pub current: Option<String>,
pub current_title: Option<String>,
pub pending_source: Option<String>,
}
#[derive(Debug, Clone, Copy)]
pub struct PfFrameChrome {
pub back_button: Entity,
pub forward_button: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfProgressVisual {
pub fill: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfSliderVisual {
pub thumb: Entity,
}
#[derive(Component, Debug, Default, Clone)]
pub struct PfListBox {
pub selected: Option<Entity>,
}
#[derive(Component, Debug, Default, Clone)]
pub struct PfListBoxItem;
#[derive(Component, Debug, Clone)]
pub struct PfItemsPanel {
pub panel: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfGeneratedItemsHost {
pub owner: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfScrollBar {
pub horizontal: bool,
pub viewport: f32,
pub small_change: f32,
pub track: Entity,
pub thumb: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfRepeatButton {
pub delay: f32,
pub interval: f32,
pub pressed_at: Option<f32>,
pub fired: u32,
}
impl Default for PfRepeatButton {
fn default() -> Self {
Self {
delay: 500.0,
interval: 33.0,
pressed_at: None,
fired: 0,
}
}
}
#[derive(Component, Debug, Clone)]
pub struct PfExpander {
pub content: Entity,
pub arrow: Entity,
}
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub struct PfTag(pub String);
#[derive(Component, Debug, Clone)]
pub struct PfViewbox {
pub stretch: bevy_pf_xaml::value::Stretch,
}
#[derive(Component, Debug, Clone, Copy)]
pub struct PfLogicalParent(pub Entity);
#[derive(Component, Debug, Clone)]
pub struct PfComboBox {
pub popup: Entity,
pub backdrop: Entity,
pub text: Entity,
pub selected: Option<usize>,
pub open: bool,
}
#[derive(Component, Debug, Clone)]
pub struct PfComboItem {
pub combo: Entity,
pub index: usize,
}
#[derive(Component, Debug, Clone)]
pub struct PfTabControl {
pub headers: Vec<Entity>,
pub contents: Vec<Entity>,
pub selected: usize,
}
#[derive(Component, Debug, Clone)]
pub struct PfTabHeader {
pub tab_control: Entity,
pub index: usize,
}
#[derive(Component, Debug, Default, Clone)]
pub struct PfTreeView {
pub selected: Option<Entity>,
}
#[derive(Component, Debug, Clone)]
pub struct PfTreeItem {
pub container: Entity,
pub arrow: Entity,
pub expanded: bool,
pub has_children: bool,
}
#[derive(Component, Debug, Clone)]
pub struct PfTreeHeader {
pub tree: Entity,
pub item: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfMenuPopup {
pub menu_root: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfMenuItem {
pub menu_root: Entity,
pub submenu: Option<Entity>,
}
#[derive(Debug, Clone)]
pub struct PfGridColumn {
pub header: String,
pub path: String,
pub width: bevy_pf_xaml::value::GridLength,
pub template: Option<std::sync::Arc<bevy_pf_xaml::XamlNode>>,
}
#[derive(Component, Debug, Clone)]
pub struct PfDataGrid {
pub columns: Vec<PfGridColumn>,
pub rows_host: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfHyperlink(pub String);
#[derive(Component, Debug, Clone)]
pub struct PfPopupSource {
pub popup: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfGridSplitter {
pub columns: bool,
}
#[derive(Component, Debug, Clone)]
pub struct PfCalendar {
pub year: i32,
pub month: u32,
pub selected: Option<(i32, u32, u32)>,
pub days_host: Entity,
pub title: Entity,
pub owner_picker: Option<Entity>,
}
#[derive(Component, Debug, Clone)]
pub struct PfDatePicker {
pub calendar: Entity,
pub popup: Entity,
pub display: Entity,
pub selected: Option<(i32, u32, u32)>,
}
#[derive(Component, Debug, Clone)]
pub struct PfToggleSwitch {
pub track: Entity,
pub thumb: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfNumericUpDown {
pub value: f64,
pub minimum: f64,
pub maximum: f64,
pub increment: f64,
pub text: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfRatingBar {
pub value: u32,
pub maximum: u32,
pub pips: Vec<Entity>,
}
#[derive(Component, Debug, Clone)]
pub struct PfWatermark {
pub overlay: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfBusyIndicator {
pub overlay: Entity,
pub busy: bool,
}
#[derive(Component, Debug, Clone)]
pub struct PfRangeSlider {
pub lower: f32,
pub upper: f32,
pub minimum: f32,
pub maximum: f32,
pub min_range: f32,
pub thumb_lower: Entity,
pub thumb_upper: Entity,
pub fill: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfTimePicker {
pub hour: Option<u32>,
pub minute: Option<u32>,
pub display: Entity,
pub popup: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfColorPicker {
pub selected: Color,
pub swatch: Entity,
pub hex_input: Entity,
pub popup: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfColorHexInput {
pub owner: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfAutoSuggestBox {
pub input: Entity,
pub popup: Entity,
pub items: Vec<String>,
}
#[derive(Component, Debug, Clone)]
pub struct PfPasswordBox {
pub input: Entity,
pub password: String,
pub mask: char,
}
#[derive(Component, Debug, Clone)]
pub struct PfPasswordInput {
pub owner: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfAutoSuggestInput {
pub owner: Entity,
}
#[derive(Component, Debug, Default)]
pub struct PfTemplateParts(pub HashMap<String, Entity>);
impl PfTemplateParts {
pub fn get(&self, name: &str) -> Option<Entity> {
self.0.get(name).copied()
}
}
#[derive(Component, Debug, Clone, Copy)]
pub struct PfTemplatedParent(pub Entity);
#[derive(Component, Debug, Clone)]
pub struct PfTemplatedControl {
pub template_root: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfCommand {
pub name: String,
pub parameter: Option<crate::binding::PfCommandParameter>,
}
#[derive(Component, Debug, Clone)]
pub struct PfCheckableMenuItem {
pub glyph: Entity,
}
#[derive(Component, Debug, Clone)]
pub struct PfNavigationView {
pub frame: Entity,
pub items: Vec<Entity>,
pub selected: Option<usize>,
}