Started prototyping gui

This commit is contained in:
Sebastian 2017-09-16 00:48:20 +02:00
parent bfccaa419c
commit 48f234756c
3 changed files with 71 additions and 11 deletions

BIN
bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1013 B

View File

@ -7,7 +7,14 @@ extern crate serde_derive;
extern crate gst;
extern crate itertools;
use std::sync::mpsc;
use std::time::{SystemTime, Duration};
use std::f32::consts::PI;
use sdl2::pixels;
use sdl2::event::Event;
use sdl2::image::LoadTexture;
use sdl2::gfx::primitives::DrawRenderer;
mod config;
@ -22,11 +29,11 @@ fn main() {
let record_config = config::read_config("rascam.toml");
let mut recoding_pipeline = pipeline::RecordingPipeline::new(&record_config);
//let mut recoding_pipeline = pipeline::RecordingPipeline::new(&record_config);
/*
let sdl_context = sdl2::init().unwrap();
let video_subsys = sdl_context.video().unwrap();
let window = video_subsys.window("rascam", SCREEN_WIDTH, SCREEN_HEIGHT)
.position_centered()
@ -35,15 +42,28 @@ fn main() {
let mut canvas = window.into_canvas().build().unwrap();
canvas.set_draw_color(pixels::Color::RGB(255, 255, 0));
canvas.clear();
canvas.present();
*/
let texture_creator = canvas.texture_creator();
let texture = texture_creator.load_texture("bg.png").unwrap();
recoding_pipeline.start();
loop {
if !recoding_pipeline.handle_events() {
//recoding_pipeline.start();
let mut events = sdl_context.event_pump().unwrap();
let center1_x = 44;
let center1_y = 20;
let center2_x = 115;
let center2_y = 20;
let radius = 14.0f32;
let mut angle = 0.0f32;
let mut now = SystemTime::now();
'main: loop {
/*if !recoding_pipeline.handle_events() {
break;
}
let result = recoding_pipeline.get_max_samples();
@ -55,8 +75,48 @@ fn main() {
println!("Error occured: {}", msg);
break;
}
}*/
if now.elapsed().unwrap() > Duration::from_millis(100) {
canvas.copy(&texture, None, None).expect("Render failed");
canvas.filled_circle(80, 18, 6, pixels::Color::RGB(255, 0, 0)).unwrap();
for quad in 0..2 {
let offset = PI / 2.0f32 * (quad as f32);
let cur_angle = angle + offset;
let off_x = (cur_angle.cos() * 14.0f32).round() as i16;
let off_y = (cur_angle.sin() * 14.0f32).round() as i16;
canvas.line(center1_x - off_x, center1_y - off_y, center1_x + off_x, center1_y + off_y, pixels::Color::RGB(255, 255, 255)).unwrap();
canvas.line(center2_x - off_x, center2_y - off_y, center2_x + off_x, center2_y + off_y, pixels::Color::RGB(255, 255, 255)).unwrap();
canvas.filled_circle(center1_x, center1_y, 3, pixels::Color::RGB(160, 160, 160)).unwrap();
canvas.filled_circle(center2_x, center2_y, 3, pixels::Color::RGB(160, 160, 160)).unwrap();
}
//canvas.clear();
canvas.present();
angle = angle - PI / 15.0f32;
if angle < -PI / 2.0f32 {
angle = angle - PI / 2.0f32;
}
now = SystemTime::now();
}
for event in events.poll_iter() {
match event {
Event::Quit {..} => break 'main,
_ => {}
}
}
}
recoding_pipeline.stop();
//recoding_pipeline.stop();
}

BIN
ui.xcf

Binary file not shown.