Compare commits

..

1 commit

Author SHA1 Message Date
6092de0769 Update Rust crate quick-xml to 0.37.0
Some checks failed
Gavania Merge Build / build (pull_request) Failing after 2m23s
2025-03-01 15:05:45 +00:00
4 changed files with 38 additions and 45 deletions

View file

@ -116,7 +116,7 @@ impl ButtonBuilder {
self
}
pub fn build(self, gui_handler: Arc<GuiHandler<'_>>) -> Result<Arc<Button<'_>>> {
pub fn build(self, gui_handler: Arc<GuiHandler>) -> Result<Arc<Button>> {
let framable = Framable::new(gui_handler.clone(), false)?;
let normal = FillType::new(
@ -150,7 +150,7 @@ impl ButtonBuilder {
let clickable = Clickable::new(framable.clone(), click_executable.clone());
let selectable = Selectable::new(
&gui_handler,
gui_handler,
click_executable.clone(),
select_executable.clone(),
on_select_executable.clone(),
@ -253,10 +253,10 @@ pub enum ButtonSelectMode {
Bigger,
}
pub struct Button<'a> {
pub struct Button {
clickable: Arc<Clickable>,
hoverable: Arc<Hoverable>,
selectable: Arc<Selectable<'a>>,
selectable: Arc<Selectable>,
framable: Arc<Framable>,
iconizable: IconizableWrapper,
textable: TextableWrapper,
@ -280,7 +280,7 @@ pub struct Button<'a> {
visible: AtomicBool,
}
impl<'a> Button<'a> {
impl Button {
pub fn builder() -> ButtonBuilder {
ButtonBuilder {
icon: None,
@ -366,10 +366,7 @@ impl<'a> Button<'a> {
self.textable.set_text_color(text_color)
}
pub fn try_from(
button_info: &ButtonInfo,
gui_handler: &Arc<GuiHandler<'a>>,
) -> Result<Arc<Self>> {
pub fn try_from(button_info: &ButtonInfo, gui_handler: &Arc<GuiHandler>) -> Result<Arc<Self>> {
let mut button_builder = Button::builder()
.set_select_mode(button_info.select_mode)
.set_isolate(button_info.isolate);
@ -426,7 +423,7 @@ impl<'a> Button<'a> {
}
}
impl<'a> GuiElementTraits for Button<'a> {
impl GuiElementTraits for Button {
fn gridable(&self) -> Option<&dyn Gridable> {
Some(self)
}
@ -435,12 +432,12 @@ impl<'a> GuiElementTraits for Button<'a> {
Some(self)
}
fn downcast<'b>(&'b self) -> Option<GuiElement<'b>> {
fn downcast<'a>(&'a self) -> Option<GuiElement<'a>> {
Some(GuiElement::Button(self))
}
}
impl<'a> Visibility for Button<'a> {
impl Visibility for Button {
fn visible(&self) -> bool {
self.visible.load(SeqCst)
}
@ -472,7 +469,7 @@ impl<'a> Visibility for Button<'a> {
}
}
impl<'a> Gridable for Button<'a> {
impl Gridable for Button {
fn set_frame(
&self,
x: i32,
@ -497,7 +494,7 @@ impl<'a> Gridable for Button<'a> {
Ok(())
}
fn selectable(&self) -> Option<&Arc<Selectable<'_>>> {
fn selectable(&self) -> Option<&Arc<Selectable>> {
Some(&self.selectable)
}
@ -525,7 +522,7 @@ impl<'a> Gridable for Button<'a> {
}
}
impl<'a> Drop for Button<'a> {
impl Drop for Button {
fn drop(&mut self) {
if self.visible.load(SeqCst) {
self.disable_base().unwrap();
@ -534,7 +531,7 @@ impl<'a> Drop for Button<'a> {
}
// private
impl<'a> Button<'a> {
impl Button {
// fn create_hovered_changed_callback(button: Arc<Button>) -> Result<()> {
// let button_weak = Arc::downgrade(&button);
@ -557,7 +554,7 @@ impl<'a> Button<'a> {
// .set_hovered_changed_callback(Some(hovered_changed))
// }
fn create_clicked_changed_callback(button: Arc<Button<'a>>) {
fn create_clicked_changed_callback(button: Arc<Button>) {
let button_weak = Arc::downgrade(&button);
let clicked_changed = Box::new(move || {
@ -579,7 +576,7 @@ impl<'a> Button<'a> {
.set_clicked_changed_callback(Some(clicked_changed));
}
fn create_selected_changed_callback(button: Arc<Button<'a>>) {
fn create_selected_changed_callback(button: Arc<Button>) {
let button_weak = Arc::downgrade(&button);
let selected_changed = move |selected| {
@ -700,8 +697,8 @@ impl<'a> Button<'a> {
}
}
impl<'a> Deref for Button<'a> {
type Target = Arc<Selectable<'a>>;
impl Deref for Button {
type Target = Arc<Selectable>;
fn deref(&self) -> &Self::Target {
&self.selectable

View file

@ -12,8 +12,8 @@ use std::sync::{
/// `Selectable` gives the ability to navigate per button or controller to
/// optionally adjacent neighbour Selectables and to execute a closure
/// when the current Selectable is pressed
pub struct Selectable<'a> {
pub struct Selectable {
gui_handler: Arc<GuiHandler>,
selected: AtomicBool,
@ -32,33 +32,33 @@ pub struct Selectable<'a> {
isolate: bool,
// used when clicked
executable: Arc<Executable<&'a mut World>>,
executable: Arc<Executable<()>>,
// used internally by button
selected_changed_executable: Arc<Executable<(&'a mut World, bool)>>,
selected_changed_executable: Arc<Executable<bool>>,
// exposed externally for event
on_select_executable: Arc<Executable<(&'mut World, bool)>>,
on_select_executable: Arc<Executable<bool>>,
// used for custom buttons
custom_callback: RwLock<Option<Box<dyn Fn(&mut World, ControllerButton) -> Result<bool> + Send + Sync>>>,
custom_callback: RwLock<Option<Box<dyn Fn(ControllerButton) -> Result<bool> + Send + Sync>>>,
}
impl<'a> Selectable<'a> {
impl Selectable {
/// Factory method for `Selectable`, returns `Arc<Selectable>`.
///
/// # Arguments
///
/// * `executable` is a `Arc<Executable>` instance
pub fn new(
gui_handler: &'a GuiHandler<'a>,
gui_handler: Arc<GuiHandler>,
executable: Arc<Executable<()>>,
selected_changed_executable: Arc<Executable<bool>>,
on_select_executable: Arc<Executable<bool>>,
isolate: bool,
) -> Arc<Self> {
Arc::new(Selectable {
gui_handler,
selected: AtomicBool::new(false),

View file

@ -182,7 +182,7 @@ impl TextToScreen {
}
}
pub struct GuiHandler<'a> {
pub struct GuiHandler {
device: Arc<Device>,
queue: Arc<Mutex<Queue>>,
@ -241,18 +241,18 @@ pub struct GuiHandler<'a> {
current_writeable: RwLock<Option<Arc<Writeable>>>,
current_hoverable: RwLock<Option<Arc<Hoverable>>>,
current_clickable: RwLock<Option<Arc<Clickable>>>,
current_selectable: RwLock<Option<Arc<Selectable<'a>>>>,
current_selectable: RwLock<Option<Arc<Selectable>>>,
text_sample_count: VkSampleCountFlags,
callback_list: Mutex<Vec<Box<dyn FnOnce() -> Result<()> + Send + Sync>>>,
}
impl<'a> GuiHandler<'a> {
impl GuiHandler {
pub fn new(
gui_handler_create_info: GuiHandlerCreateInfo<'_>,
context: &impl ContextInterface,
) -> Result<Arc<Self>> {
) -> Result<Arc<GuiHandler>> {
let device = context.device();
let queue = context.queue();
@ -724,7 +724,7 @@ impl<'a> GuiHandler<'a> {
Ok(false)
}
pub fn current_selectable(&self) -> Result<Option<Arc<Selectable<'a>>>> {
pub fn current_selectable(&self) -> Result<Option<Arc<Selectable>>> {
match self.current_selectable.read().unwrap().as_ref() {
Some(selectable) => Ok(Some(selectable.clone())),
None => Ok(None),
@ -1064,7 +1064,7 @@ macro_rules! remove_element {
}
// object handling
impl<'a> GuiHandler<'a> {
impl GuiHandler {
// framable
pub(crate) fn add_framable(&self, layer: i32, framable: Arc<Framable>) -> Result<()> {
add_element!(self.layers, layer, framable);
@ -1101,17 +1101,13 @@ impl<'a> GuiHandler<'a> {
}
// selectable
pub(crate) fn add_selectable(&self, layer: i32, selectable: Arc<Selectable<'a>>) -> Result<()> {
pub(crate) fn add_selectable(&self, layer: i32, selectable: Arc<Selectable>) -> Result<()> {
add_element!(self.layers, layer, selectable);
Ok(())
}
pub(crate) fn delete_selectable(
&self,
layer: i32,
selectable: &Arc<Selectable<'a>>,
) -> Result<()> {
pub(crate) fn delete_selectable(&self, layer: i32, selectable: &Arc<Selectable>) -> Result<()> {
let mut current_selectable = self.current_selectable.write().unwrap();
if current_selectable.is_some() {
// unwrap is safe, just tested for `is_some`
@ -1236,7 +1232,7 @@ impl<'a> GuiHandler<'a> {
Ok(())
}
pub(crate) fn set_selectable(&self, selectable: Option<Arc<Selectable<'a>>>) -> Result<()> {
pub(crate) fn set_selectable(&self, selectable: Option<Arc<Selectable>>) -> Result<()> {
let mut current_selectable = self.current_selectable.write().unwrap();
if let Some(selectable) = current_selectable.as_ref() {
@ -1272,7 +1268,7 @@ impl<'a> GuiHandler<'a> {
}
// private - create rendering stuff
impl<'a> GuiHandler<'a> {
impl GuiHandler {
fn create_render_targets(
device: &Arc<Device>,
target_images: &TargetMode<Vec<Arc<Image>>>,
@ -1598,7 +1594,7 @@ impl<'a> GuiHandler<'a> {
}
}
impl<'a> GuiHandler<'a> {
impl GuiHandler {
pub fn process(
&self,
buffer_recorder: &mut CommandBufferRecorder<'_>,

View file

@ -32,7 +32,7 @@ pub struct Keyboard {
}
impl Keyboard {
pub fn new(gui_handler: &Arc<GuiHandler<'a>>) -> Result<Arc<Self>> {
pub fn new(gui_handler: &Arc<GuiHandler>) -> Result<Arc<Self>> {
let text_field_gui: Arc<GuiBuilder> =
GuiBuilder::from_str(gui_handler, include_str!("text_field.xml"))?;