1 Commits
iced ... druid

Author SHA1 Message Date
92096cc720 broken wip example 2020-09-30 12:47:07 +01:00
3 changed files with 56 additions and 70 deletions

View File

@@ -9,6 +9,5 @@ crate_type = "bin"
[dependencies]
dirs = "^3.0.1"
iced = "^0.1.1"
druid = "^0.6.0"
rodio = "^0.11.0"
env_logger = "^0.8.1"

View File

@@ -22,6 +22,5 @@ released under the MIT license.
* vinyl crackle
* white noise?
* fan
* birdsong
* set a window icon
* create a nice icon?

View File

@@ -1,6 +1,8 @@
#![windows_subsystem = "windows"]
use iced::{Settings, Application, Element, executor, Length, Container, Column, Scrollable, Slider};
// use gio::prelude::*;
// use gtk::prelude::*;
// use gtk::Orientation;
use rodio::{Sink, Source};
use std::env::args;
use std::fs::File;
@@ -10,71 +12,6 @@ use std::process::Command;
const SPACING: i32 = 16;
struct Sound {
name: String,
path: String, // bytes instead?
sink: Sink,
volume: f32,
}
/// todo: maybe add a play/pause state or global volume? saved presets?
struct State {
sounds: Vec<Sound>
}
enum Lull {
Loading,
Loaded(State),
}
impl Application for Lull {
type Executor = executor::Default;
type Message = Message;
type Flags = ();
fn new(_flags: Self::Flags) -> (Self, Command) {
(
Lull {sounds: Vec::new()},
Command::none(),
)
}
fn title(&self) -> String {
String::from("lull")
}
fn update(&mut self, message: Self::Message) -> Command {
match self {
self::Loading => {},
self::Loaded => {},
}
Command::none()
}
fn view(&mut self) -> Element<'_, Self::Message> {
unimplemented!()
}
}
fn get_data_dir() -> PathBuf {
let mut data_dir = dirs::data_dir().expect("Couldn't find user data directory");
data_dir.push("ruin/lull");
if !data_dir.exists() {
std::fs::create_dir_all(&data_dir).expect("Couldn't create lull data directory");
}
data_dir
}
pub fn main() -> iced::Result {
env_logger::init();
Lull::run(Settings::default())
}
// fn error_popup(message: &str) {
// let popup = gtk::Window::new(gtk::WindowType::Toplevel);
// popup.set_title("error");
@@ -97,7 +34,19 @@ pub fn main() -> iced::Result {
// popup.destroy();
// });
// }
//
// fn get_data_dir() -> PathBuf {
// let mut data_dir = dirs::data_dir().expect("Couldn't find user data directory");
//
// data_dir.push("ruin/lull");
//
// if !data_dir.exists() {
// std::fs::create_dir_all(&data_dir).expect("Couldn't create lull data directory");
// }
//
// data_dir
// }
//
// fn build_ui(application: &gtk::Application) {
// let window = gtk::ApplicationWindow::new(application);
//
@@ -196,3 +145,42 @@ pub fn main() -> iced::Result {
//
// window.show_all();
// }
//
// fn main() {
// let application = gtk::Application::new(
// Some("dev.tinybird.max.lull"),
// Default::default()
// ).expect("Initialization failed...");
//
// application.connect_activate(|app| {
// build_ui(app);
// });
//
// application.run(&args().collect::<Vec<_>>());
// }
use druid::{AppLauncher, WindowDesc, Widget, PlatformError};
use druid::widget::{Label, Padding, Flex, Align, FlexParams, CrossAxisAlignment, Slider};
fn build_ui() -> impl Widget<()> {
Padding::new(
10.0,
Flex::column()
.with_flex_child(
Flex::row()
.with_flex_child(Align::centered(Label::new("sound 1")), FlexParams::new(1.0, CrossAxisAlignment::End))
.with_child(Align::centered(Label::new("slider"))),
1.0
)
.with_child(
Flex::row()
.with_flex_child(Label::new("top right"), 1.0)
.with_flex_child(Align::centered(Label::new("bottom right")), 1.0)
)
)
}
fn main() -> Result<(), PlatformError> {
AppLauncher::with_window(WindowDesc::new(build_ui)).launch(())?;
Ok(())
}