Compare commits
1 commit
16c32f6dbe
...
85afd978ac
Author | SHA1 | Date | |
---|---|---|---|
85afd978ac |
44 changed files with 94 additions and 89 deletions
|
@ -2,7 +2,7 @@
|
|||
name = "ui"
|
||||
version = "0.1.0"
|
||||
authors = ["hodasemi <michaelh.95@t-online.de>"]
|
||||
edition = "2024"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
quick-xml = "0.37.0"
|
||||
|
@ -18,4 +18,3 @@ anyhow = { version = "1.0.86", features = ["backtrace"] }
|
|||
audio = { git = "https://gavania.de/hodasemi/audio.git", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["audio"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::gui_handler::gui::displayable::DisplayableFillType;
|
||||
use crate::guihandler::gui::displayable::DisplayableFillType;
|
||||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use utilities::prelude::*;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::gui_handler::gui::displayable::DisplayableFillType;
|
||||
use crate::guihandler::gui::displayable::DisplayableFillType;
|
||||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use assetpath::AssetPath;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::gui_handler::gui::displayable::DisplayableFillType;
|
||||
use crate::guihandler::gui::displayable::DisplayableFillType;
|
||||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use utilities::prelude::*;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::gui_handler::gui::displayable::DisplayableFillType;
|
||||
use crate::guihandler::gui::displayable::DisplayableFillType;
|
||||
use crate::prelude::*;
|
||||
use anyhow::anyhow;
|
||||
use anyhow::{Context, Result};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
builder::validator::buttoninfo::ButtonInfo,
|
||||
gui_handler::gui::iconizable::IconizablePositioning, prelude::*,
|
||||
builder::validator::buttoninfo::ButtonInfo, guihandler::gui::iconizable::IconizablePositioning,
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
gui_handler::gui::displayable::{DisplayableFillType, DisplayableType},
|
||||
guihandler::gui::displayable::{DisplayableFillType, DisplayableType},
|
||||
prelude::*,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
builder::validator::iconinfo::IconInfo, gui_handler::gui::iconizable::IconizablePositioning,
|
||||
builder::validator::iconinfo::IconInfo, guihandler::gui::iconizable::IconizablePositioning,
|
||||
prelude::*,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
builder::validator::labelinfo::LabelInfo, gui_handler::gui::iconizable::IconizablePositioning,
|
||||
builder::validator::labelinfo::LabelInfo, guihandler::gui::iconizable::IconizablePositioning,
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{gui_handler::gui::iconizable::IconBuilderType, prelude::*};
|
||||
use crate::{guihandler::gui::iconizable::IconBuilderType, prelude::*};
|
||||
use anyhow::Result;
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
|
@ -13,7 +13,7 @@ pub mod multi_line_label;
|
|||
pub mod multi_line_textfield;
|
||||
pub mod progress_bar;
|
||||
pub mod textfield;
|
||||
pub mod ui_element;
|
||||
pub mod uielement;
|
||||
|
||||
pub mod traits;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{
|
||||
builder::validator::multi_line_text_field_info::MultiLineTextFieldInfo,
|
||||
gui_handler::gui::{displayable::DisplayableFillType, writeable::ModifyText},
|
||||
guihandler::gui::{displayable::DisplayableFillType, writeable::ModifyText},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@ pub use super::{
|
|||
progress_bar::{GrowDirection, ProgressBar, ProgressBarBuilder},
|
||||
textfield::TextField,
|
||||
traits::*,
|
||||
ui_element::*,
|
||||
uielement::*,
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
gui_handler::gui::iconizable::{IconBuilderType, IconizablePositioning},
|
||||
guihandler::gui::iconizable::{IconBuilderType, IconizablePositioning},
|
||||
prelude::*,
|
||||
};
|
||||
use anyhow::Result;
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
//! `Audible` is a property to play a sound
|
||||
|
||||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use assetpath::AssetPath;
|
||||
|
||||
// #[cfg(feature = "audio")]
|
||||
// use audio::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
/// `Audible` gives the ability to play a sound
|
||||
pub struct Audible {
|
||||
// gui_handler: Arc<GuiHandler>,
|
||||
// sound: Arc<Sound>,
|
||||
}
|
||||
|
||||
impl Audible {
|
||||
pub fn new(gui_handler: Arc<GuiHandler>, mut path: AssetPath) -> Result<Arc<Self>> {
|
||||
if !path.has_prefix() {
|
||||
path.set_prefix(&gui_handler.resource_base_path().full_path());
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// let sound = gui_handler.context().sound_handler().load_sound(
|
||||
// path,
|
||||
// "gui",
|
||||
// SoundInterpretation::Generic,
|
||||
// )?;
|
||||
|
||||
Ok(Arc::new(Audible {
|
||||
// gui_handler,
|
||||
// sound
|
||||
}))
|
||||
}
|
||||
|
||||
pub fn play(&self) -> Result<()> {
|
||||
// self.sound.play(Some(false))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Audible {
|
||||
fn drop(&mut self) {
|
||||
// self.gui_handler
|
||||
// .context()
|
||||
// .sound_handler()
|
||||
// .remove_sound(&self.sound)
|
||||
// .unwrap();
|
||||
}
|
||||
}
|
49
src/guihandler/gui/audible.rs
Normal file
49
src/guihandler/gui/audible.rs
Normal file
|
@ -0,0 +1,49 @@
|
|||
//! `Audible` is a property to play a sound
|
||||
|
||||
use crate::prelude::*;
|
||||
use anyhow::Result;
|
||||
use assetpath::AssetPath;
|
||||
|
||||
#[cfg(feature = "audio")]
|
||||
use audio::*;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
/// `Audible` gives the ability to play a sound
|
||||
pub struct Audible {
|
||||
gui_handler: Arc<GuiHandler>,
|
||||
|
||||
sound: Arc<Sound>,
|
||||
}
|
||||
|
||||
impl Audible {
|
||||
pub fn new(gui_handler: Arc<GuiHandler>, mut path: AssetPath) -> Result<Arc<Self>> {
|
||||
if !path.has_prefix() {
|
||||
path.set_prefix(&gui_handler.resource_base_path().full_path());
|
||||
}
|
||||
|
||||
let sound = gui_handler.context().sound_handler().load_sound(
|
||||
path,
|
||||
"gui",
|
||||
SoundInterpretation::Generic,
|
||||
)?;
|
||||
|
||||
Ok(Arc::new(Audible { gui_handler, sound }))
|
||||
}
|
||||
|
||||
pub fn play(&self) -> Result<()> {
|
||||
self.sound.play(Some(false))?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Audible {
|
||||
fn drop(&mut self) {
|
||||
self.gui_handler
|
||||
.context()
|
||||
.sound_handler()
|
||||
.remove_sound(&self.sound)
|
||||
.unwrap();
|
||||
}
|
||||
}
|
|
@ -15,8 +15,8 @@ use super::{
|
|||
use cgmath::{ortho, vec2};
|
||||
|
||||
use std::sync::{
|
||||
Arc, Mutex, RwLock,
|
||||
atomic::{AtomicBool, AtomicU32, Ordering::SeqCst},
|
||||
Arc, Mutex, RwLock,
|
||||
};
|
||||
use std::{collections::HashMap, ptr};
|
||||
use std::{mem, sync::Weak};
|
||||
|
@ -191,6 +191,8 @@ impl TextToScreen {
|
|||
}
|
||||
|
||||
pub struct GuiHandler {
|
||||
_context: Arc<dyn ContextInterface>,
|
||||
|
||||
device: Arc<Device>,
|
||||
queue: Arc<Mutex<Queue>>,
|
||||
|
||||
|
@ -262,7 +264,7 @@ pub struct GuiHandler {
|
|||
impl GuiHandler {
|
||||
pub fn new(
|
||||
gui_handler_create_info: GuiHandlerCreateInfo<'_>,
|
||||
context: &impl ContextInterface,
|
||||
context: &Arc<dyn ContextInterface>,
|
||||
) -> Result<Arc<GuiHandler>> {
|
||||
let device = context.device();
|
||||
let queue = context.queue();
|
||||
|
@ -309,6 +311,8 @@ impl GuiHandler {
|
|||
.build(device.clone())?;
|
||||
|
||||
Ok(Arc::new(GuiHandler {
|
||||
_context: context.clone(),
|
||||
|
||||
device: device.clone(),
|
||||
queue: queue.clone(),
|
||||
|
||||
|
@ -414,6 +418,11 @@ impl GuiHandler {
|
|||
&self.queue
|
||||
}
|
||||
|
||||
#[cfg(feature = "audio")]
|
||||
pub(crate) fn context(&self) -> &Arc<dyn ContextInterface> {
|
||||
&self._context
|
||||
}
|
||||
|
||||
pub fn width(&self) -> u32 {
|
||||
self.width.load(SeqCst)
|
||||
}
|
||||
|
@ -1428,8 +1437,8 @@ impl GuiHandler {
|
|||
.build(device.clone())?;
|
||||
|
||||
// --- pipeline creation ---
|
||||
let vertex_shader_text = include_bytes!("gui_shader/text.vert.spv");
|
||||
let fragment_shader_text = include_bytes!("gui_shader/text.frag.spv");
|
||||
let vertex_shader_text = include_bytes!("guishader/text.vert.spv");
|
||||
let fragment_shader_text = include_bytes!("guishader/text.frag.spv");
|
||||
|
||||
let vertex_shader = ShaderModule::from_slice(device.clone(), vertex_shader_text)?;
|
||||
let fragment_shader = ShaderModule::from_slice(device.clone(), fragment_shader_text)?;
|
||||
|
@ -1473,9 +1482,9 @@ impl GuiHandler {
|
|||
|
||||
// pipeline creation
|
||||
let vertex_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("gui_shader/rect.vert.spv"))?;
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("guishader/rect.vert.spv"))?;
|
||||
let fragment_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("gui_shader/rect.frag.spv"))?;
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("guishader/rect.frag.spv"))?;
|
||||
|
||||
render_targets.execute(|render_target| {
|
||||
Ok(GuiSeparator {
|
||||
|
@ -1513,10 +1522,10 @@ impl GuiHandler {
|
|||
|
||||
// pipeline creation
|
||||
let vertex_shader =
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("gui_shader/rect.vert.spv"))?;
|
||||
ShaderModule::from_slice(device.clone(), include_bytes!("guishader/rect.vert.spv"))?;
|
||||
let fragment_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("gui_shader/input_rect.frag.spv"),
|
||||
include_bytes!("guishader/input_rect.frag.spv"),
|
||||
)?;
|
||||
|
||||
render_targets.execute(|render_target| {
|
||||
|
@ -1556,11 +1565,11 @@ impl GuiHandler {
|
|||
// pipeline creation
|
||||
let vertex_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("gui_shader/single_color.vert.spv"),
|
||||
include_bytes!("guishader/single_color.vert.spv"),
|
||||
)?;
|
||||
let fragment_shader = ShaderModule::from_slice(
|
||||
device.clone(),
|
||||
include_bytes!("gui_shader/single_color.frag.spv"),
|
||||
include_bytes!("guishader/single_color.frag.spv"),
|
||||
)?;
|
||||
|
||||
render_targets.execute(|render_target| {
|
||||
|
@ -1641,20 +1650,20 @@ impl GuiHandler {
|
|||
text_objects,
|
||||
rectangle_objects,
|
||||
single_color_object,
|
||||
index,
|
||||
&&&index,
|
||||
text_pipeline,
|
||||
text_descriptor,
|
||||
)| {
|
||||
self.render(
|
||||
buffer_recorder,
|
||||
&command_buffers[****index],
|
||||
&command_buffers[index],
|
||||
&*render_target.read().unwrap(),
|
||||
single_color_object,
|
||||
rectangle_objects,
|
||||
text_objects,
|
||||
text_pipeline,
|
||||
text_descriptor,
|
||||
****index,
|
||||
index,
|
||||
)
|
||||
},
|
||||
)?;
|
|
@ -1,5 +1,5 @@
|
|||
pub mod gui;
|
||||
pub mod gui_handler;
|
||||
pub mod guihandler;
|
||||
|
||||
mod elements;
|
||||
|
|
@ -16,4 +16,4 @@ pub use super::gui::{
|
|||
#[cfg(feature = "audio")]
|
||||
pub use super::gui::audible::Audible;
|
||||
|
||||
pub use super::gui_handler::{Font, GuiHandler, GuiHandlerCreateInfo};
|
||||
pub use super::guihandler::{Font, GuiHandler, GuiHandlerCreateInfo};
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
pub mod builder;
|
||||
pub mod elements;
|
||||
pub mod gui_handler;
|
||||
pub mod guihandler;
|
||||
pub mod keyboard;
|
||||
pub mod states;
|
||||
pub mod tab_control;
|
||||
|
@ -10,8 +10,8 @@ pub mod tab_control;
|
|||
mod context_interface;
|
||||
mod controller_button;
|
||||
mod element_creator;
|
||||
mod gui_direction;
|
||||
mod mouse_button;
|
||||
mod guidirection;
|
||||
mod mousebutton;
|
||||
pub mod prelude;
|
||||
|
||||
pub type CustomCallback<I, O> = dyn Fn(I) -> anyhow::Result<O> + Send + Sync;
|
||||
|
|
|
@ -3,10 +3,10 @@ pub use super::context_interface::{ContextInterface, TargetMode, Unfold};
|
|||
pub use super::controller_button::ControllerButton;
|
||||
pub use super::element_creator::*;
|
||||
pub use super::elements::prelude::*;
|
||||
pub use super::gui_direction::GuiDirection;
|
||||
pub use super::gui_handler::prelude::*;
|
||||
pub use super::guidirection::GuiDirection;
|
||||
pub use super::guihandler::prelude::*;
|
||||
pub use super::keyboard::Keyboard;
|
||||
pub use super::mouse_button::MouseButton;
|
||||
pub use super::mousebutton::MouseButton;
|
||||
pub use super::states::*;
|
||||
pub use super::tab_control::TabControl;
|
||||
|
||||
|
|
Loading…
Reference in a new issue