Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 92096cc720 |
@@ -9,6 +9,5 @@ crate_type = "bin"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dirs = "^3.0.1"
|
dirs = "^3.0.1"
|
||||||
iced = "^0.1.1"
|
druid = "^0.6.0"
|
||||||
rodio = "^0.11.0"
|
rodio = "^0.11.0"
|
||||||
env_logger = "^0.8.1"
|
|
||||||
|
|||||||
@@ -22,6 +22,5 @@ released under the MIT license.
|
|||||||
* vinyl crackle
|
* vinyl crackle
|
||||||
* white noise?
|
* white noise?
|
||||||
* fan
|
* fan
|
||||||
* birdsong
|
|
||||||
* set a window icon
|
* set a window icon
|
||||||
* create a nice icon?
|
* create a nice icon?
|
||||||
|
|||||||
122
src/main.rs
122
src/main.rs
@@ -1,6 +1,8 @@
|
|||||||
#![windows_subsystem = "windows"]
|
#![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 rodio::{Sink, Source};
|
||||||
use std::env::args;
|
use std::env::args;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
@@ -10,71 +12,6 @@ use std::process::Command;
|
|||||||
|
|
||||||
const SPACING: i32 = 16;
|
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) {
|
// fn error_popup(message: &str) {
|
||||||
// let popup = gtk::Window::new(gtk::WindowType::Toplevel);
|
// let popup = gtk::Window::new(gtk::WindowType::Toplevel);
|
||||||
// popup.set_title("error");
|
// popup.set_title("error");
|
||||||
@@ -97,7 +34,19 @@ pub fn main() -> iced::Result {
|
|||||||
// popup.destroy();
|
// 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: >k::Application) {
|
// fn build_ui(application: >k::Application) {
|
||||||
// let window = gtk::ApplicationWindow::new(application);
|
// let window = gtk::ApplicationWindow::new(application);
|
||||||
//
|
//
|
||||||
@@ -196,3 +145,42 @@ pub fn main() -> iced::Result {
|
|||||||
//
|
//
|
||||||
// window.show_all();
|
// 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(())
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user