feat: new styles

This commit is contained in:
faynot
2026-07-08 23:45:37 +03:00
parent 9c279015dc
commit 75af23930f
18 changed files with 3556 additions and 816 deletions

View File

@@ -1,13 +1,13 @@
use iced::widget::{column, container, row, scrollable, text, Space};
use iced::{Alignment, Length, Theme};
use iced::widget::{column, container};
use iced::{Length, Theme};
use crate::interpreter::{Document, Element, Interpreter, RheiContext};
use crate::renderer::render_element;
use crate::Message;
pub struct GlintApp {
pub doc: Document,
pub vdom_roots: Vec<Element>,
pub doc: Document<'static>,
pub vdom_roots: Vec<Element<'static>>,
pub rhei: RheiContext,
}
@@ -18,6 +18,9 @@ impl GlintApp {
pub fn update(&mut self, message: Message) -> iced::Task<Message> {
match message {
Message::WindowScrolled(y) => {
self.doc.variables.insert("__scroll_y".to_string(), y.to_string());
}
Message::EventTriggered(script) => {
if !script.is_empty() {
self.rhei.execute_action(&script, &mut self.doc.variables);
@@ -40,56 +43,64 @@ impl GlintApp {
self.vdom_roots = Interpreter::evaluate_vdom(
&self.doc.roots,
&self.doc.variables,
&mut self.doc.variables,
&self.doc.components,
&self.rhei,
&self.doc.stylesheet,
&[],
);
iced::Task::none()
}
pub fn view(&self) -> iced::Element<'_, Message, Theme, iced::Renderer> {
let mut content = column![].spacing(15).padding(20);
let mut content = column![]
.width(Length::Fill)
.height(Length::Fill);
let mut global_fixed_layers = Vec::new();
let mut global_abs_layers = Vec::new();
let mut global_sticky_layers = Vec::new();
let _scroll_y = self.doc.variables.get("__scroll_y")
.and_then(|v| v.parse::<f32>().ok())
.unwrap_or(0.0);
for root in &self.vdom_roots {
if let Some(el) = render_element(root) {
content = content.push(el);
}
if let Some(el) = render_element(root, None, None, None, &mut global_fixed_layers, &mut global_abs_layers, &mut global_sticky_layers, &self.doc.stylesheet) {
content = content.push(el);
}
}
let status_bar = container(self.build_status_bar(&self.doc.variables))
.width(Length::Fill)
.padding(10);
let layout = column![
scrollable(content).width(Length::Fill).height(Length::Fill),
content,
iced::widget::rule::horizontal(1),
status_bar,
];
container(layout)
.width(Length::Fill)
.height(Length::Fill)
.into()
}
fn build_status_bar<'a>(
&self,
scope: &std::collections::HashMap<String, String>,
) -> iced::Element<'a, Message, Theme, iced::Renderer> {
let slider_val = scope.get("volume_level")
.and_then(|v| v.parse::<f64>().ok())
.unwrap_or(0.0);
row![
text("🟢 Runtime Active (VDOM + Rhai)").size(14),
Space::new().width(Length::Fill),
text(format!("Шаблонных узлов: {}", self.doc.roots.len())).size(14),
Space::new().width(Length::Fixed(15.0)),
text(format!("Слайдер ($volume_level): {:.1}", slider_val)).size(14),
]
.align_y(Alignment::Center)
.into()
.width(Length::Fill)
.height(Length::Fill);
let main_flow = container(layout)
.width(Length::Fill)
.height(Length::Fill);
let has_abs = !global_abs_layers.is_empty();
let has_sticky = !global_sticky_layers.is_empty();
let has_fixed = !global_fixed_layers.is_empty();
if !has_abs && !has_sticky && !has_fixed {
main_flow.into()
} else {
let mut stack_widget = iced::widget::stack![main_flow];
for layer in global_abs_layers {
stack_widget = stack_widget.push(layer);
}
for layer in global_sticky_layers {
stack_widget = stack_widget.push(layer);
}
for layer in global_fixed_layers {
stack_widget = stack_widget.push(layer);
}
stack_widget.into()
}
}
}