wgui: basic i18n support, refactoring: use LayoutState, translation framework (LLM-based generator)

This commit is contained in:
Aleksander
2025-08-02 23:31:23 +02:00
parent 4e46c45bcf
commit eaa81450b5
45 changed files with 916 additions and 223 deletions

View File

@@ -1,11 +1,15 @@
use std::{cell::RefCell, rc::Rc};
use std::{
cell::{RefCell, RefMut},
rc::Rc,
};
use glam::Vec2;
use slotmap::SecondaryMap;
use crate::{
animation::{self, Animation},
layout::{WidgetID, WidgetMap, WidgetNodeMap},
i18n::I18n,
layout::{LayoutState, WidgetID},
transform_stack::{Transform, TransformStack},
widget::{WidgetData, WidgetObj},
};
@@ -87,12 +91,6 @@ impl Event {
}
}
pub struct EventRefs<'a> {
pub widgets: &'a WidgetMap,
pub nodes: &'a WidgetNodeMap,
pub tree: &'a taffy::tree::TaffyTree<WidgetID>,
}
#[derive(Default)]
pub struct EventAlterables {
pub dirty_nodes: Vec<taffy::NodeId>,
@@ -126,10 +124,16 @@ impl EventAlterables {
}
pub struct CallbackDataCommon<'a> {
pub refs: &'a EventRefs<'a>,
pub state: &'a LayoutState,
pub alterables: &'a mut EventAlterables,
}
impl<'a> CallbackDataCommon<'a> {
pub fn i18n(&self) -> RefMut<I18n> {
self.state.globals.i18n()
}
}
pub struct CallbackData<'a> {
pub obj: &'a mut dyn WidgetObj,
pub widget_data: &'a mut WidgetData,