|
|
@ -33,11 +33,12 @@ use crate::drawables::sprite::Sprite;
|
|
|
|
use crate::drawables::text::Text;
|
|
|
|
use crate::drawables::text::Text;
|
|
|
|
use crate::util::load_raw;
|
|
|
|
use crate::util::load_raw;
|
|
|
|
use crate::util::timer::Timer;
|
|
|
|
use crate::util::timer::Timer;
|
|
|
|
use crate::util::vertex::{TextureVertex3D, VertexTypes};
|
|
|
|
use crate::util::vertex::{TextureVertex3D, VertexType};
|
|
|
|
use crate::vkprocessor::VkProcessor;
|
|
|
|
use crate::vkprocessor::VkProcessor;
|
|
|
|
use std::path::Path;
|
|
|
|
use std::path::Path;
|
|
|
|
use gilrs::{Gilrs, Button, Event as GilEvent, GamepadId, Gamepad};
|
|
|
|
use gilrs::{Gilrs, Button, Event as GilEvent, GamepadId, Gamepad};
|
|
|
|
use crate::util::tr_event::TrEvent;
|
|
|
|
use crate::util::tr_event::TrEvent;
|
|
|
|
|
|
|
|
use crate::button_m::Slider;
|
|
|
|
|
|
|
|
|
|
|
|
pub mod util;
|
|
|
|
pub mod util;
|
|
|
|
pub mod vkprocessor;
|
|
|
|
pub mod vkprocessor;
|
|
|
@ -50,27 +51,49 @@ pub mod button_m {
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
use crate::drawables::sprite::Sprite;
|
|
|
|
use std::collections::HashSet;
|
|
|
|
use std::collections::HashSet;
|
|
|
|
use crate::canvas::canvas_frame::Drawable;
|
|
|
|
use crate::canvas::canvas_frame::Drawable;
|
|
|
|
use crate::util::vertex::VertexTypes;
|
|
|
|
use crate::util::vertex::VertexType;
|
|
|
|
|
|
|
|
|
|
|
|
// Should I force these to be drawables
|
|
|
|
|
|
|
|
// or better, how do I force these to be drawables
|
|
|
|
|
|
|
|
enum GuiElements {
|
|
|
|
|
|
|
|
HANDLE(Rect),
|
|
|
|
|
|
|
|
GUIDE(Sprite)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub struct Slider {
|
|
|
|
pub struct Slider {
|
|
|
|
sprites: HashSet<GuiElements>,
|
|
|
|
handle : Rect,
|
|
|
|
|
|
|
|
guide : Vec<Rect>,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scaler: u32,
|
|
|
|
|
|
|
|
position: (f32, f32),
|
|
|
|
|
|
|
|
size: (f32, f32),
|
|
|
|
|
|
|
|
value: u16,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Drawable for Slider {
|
|
|
|
impl Slider {
|
|
|
|
fn get(&self) -> Vec<VertexTypes> {
|
|
|
|
pub fn new(size: (f32, f32), position : (f32, f32), value: u16) -> Slider {
|
|
|
|
|
|
|
|
|
|
|
|
self.sprites.into()
|
|
|
|
// render the guide first
|
|
|
|
// self.sprites.iter().map(|v| {
|
|
|
|
|
|
|
|
//
|
|
|
|
let left_guide_bar = Rect::new((position.0 as f32, position.1 as f32), (0.1, 0.1), 1);
|
|
|
|
// })
|
|
|
|
let right_guide_bar = Rect::new((position.0 + size.0 as f32, position.1 as f32), (0.1, 0.1), 1);
|
|
|
|
|
|
|
|
let line = Rect::new((position.0 as f32, position.1 - (size.1 / 2.0) as f32), (0.1, 0.1), 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let scale = value as f32 / u16::max_value() as f32;
|
|
|
|
|
|
|
|
let handle = Rect::new((position.0 + (size.0 * scale) as f32, position.1 as f32), (0.3, 0.3), 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Slider {
|
|
|
|
|
|
|
|
handle: handle,
|
|
|
|
|
|
|
|
guide: vec![left_guide_bar, right_guide_bar, line],
|
|
|
|
|
|
|
|
scaler: 255,
|
|
|
|
|
|
|
|
position,
|
|
|
|
|
|
|
|
size,
|
|
|
|
|
|
|
|
value
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Drawable for Slider {
|
|
|
|
|
|
|
|
fn get(&self) -> Vec<VertexType> {
|
|
|
|
|
|
|
|
let mut vertices = vec![self.handle.verts.clone()];
|
|
|
|
|
|
|
|
vertices.extend_from_slice(self.guide.iter()
|
|
|
|
|
|
|
|
.map(|x| x.clone().verts).collect::<Vec<VertexType>>().as_slice()
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
vertices
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -149,6 +172,8 @@ pub fn main() {
|
|
|
|
let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
|
|
|
|
let sfml_sprite = Sprite::new((0.0, -0.5), (0.5, 0.5), 1, sfml_handle.clone());
|
|
|
|
let rect = Rect::new((-0.5, -0.5), (0.5, 0.5), 1);
|
|
|
|
let rect = Rect::new((-0.5, -0.5), (0.5, 0.5), 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// let slider = button_m::Slider::new((0.5, 0.1), (0.1,0.1), 30000);
|
|
|
|
|
|
|
|
|
|
|
|
// how do i register a sprite to get events...
|
|
|
|
// how do i register a sprite to get events...
|
|
|
|
// explicit is much easier
|
|
|
|
// explicit is much easier
|
|
|
|
|
|
|
|
|
|
|
@ -235,6 +260,7 @@ pub fn main() {
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
canvas_frame.draw(&funky_sprite);
|
|
|
|
canvas_frame.draw(&text_sprite);
|
|
|
|
canvas_frame.draw(&text_sprite);
|
|
|
|
canvas_frame.draw(&compu_sprite1);
|
|
|
|
canvas_frame.draw(&compu_sprite1);
|
|
|
|
|
|
|
|
// canvas_frame.draw(&slider);
|
|
|
|
|
|
|
|
|
|
|
|
let mut compu_frame = CompuFrame::new();
|
|
|
|
let mut compu_frame = CompuFrame::new();
|
|
|
|
compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
|
|
|
compu_frame.add_with_image_swap(compute_buffer.clone(), compute_kernel.clone(), &compu_sprite1);
|
|
|
|