Skip to content

Commit

Permalink
tweak styling code
Browse files Browse the repository at this point in the history
  • Loading branch information
B0ney committed Nov 9, 2023
1 parent 45f264d commit f3939ef
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 98 deletions.
Binary file modified assets/font/icons.ttf
Binary file not shown.
6 changes: 3 additions & 3 deletions data/src/theme/themes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Themes {
border: color!(0x474747),
},
normal: NormalColors {
primary: color!(0x5E4266),
primary: color!(0xBA84FC),
secondary: color!(0x386e50),
surface: color!(0x828282),
error: color!(0xff5555),
Expand Down Expand Up @@ -68,9 +68,9 @@ impl Themes {
},
Self::LMMS => Palette {
base: BaseColors {
background: color!(0x26_2B_30),
background: color!(0x262B30),
foreground: color!(0x3B424A), //3B424A
dark: color!(0x11_13_14),
dark: color!(0x111314),
border: color!(0x4C5864),
},
normal: NormalColors {
Expand Down
22 changes: 14 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,13 @@ impl Application for XMODITS {
let bottom_left_buttons = row![
button(text_icon("Save Settings", icon::save()))
.on_press(Message::SaveConfig)
.width(Length::FillPortion(2)),
.width(Length::FillPortion(2))
.padding(8),
button(text_icon("START", icon::download()))
.on_press_maybe(not_ripping.then_some(Message::StartRipping))
.style(theme::Button::Start)
.width(Length::FillPortion(2))
.padding(8)
]
.spacing(8);

Expand Down Expand Up @@ -491,21 +493,25 @@ impl Application for XMODITS {
let destination = sample_ripping::view_destination_bar(&self.ripping_cfg).map(Message::RippingCfg);

let top_right_buttons = row![
text(format!("Entries: {}", self.entries.len())),
text(format!("Selected: {}", self.entries.total_selected())),
text(format!(
"Entries: {}, Selected: {}",
self.entries.len(),
self.entries.total_selected()
)),
Space::with_width(Length::Fill),
button("Invert").on_press(Message::InvertSelection),
checkbox("Select All", self.entries.all_selected, Message::SelectAll)
.style(theme::CheckBox::Inverted)
]
.spacing(15)
.spacing(8)
.align_items(Alignment::Center);

let bottom_right_buttons = row![
action("Add File", not_ripping.then_some(Message::FileDialog)),
action("Add Folder", not_ripping.then_some(Message::FolderDialog)),
action("Add File", not_ripping.then_some(Message::FileDialog)).padding(8),
action("Add Folder", not_ripping.then_some(Message::FolderDialog)).padding(8),
Space::with_width(Length::Fill),
action("Delete Selected", not_ripping.then_some(Message::DeleteSelected)),
action("Clear", not_ripping.then_some(Message::Clear)),
action("Delete Selected", not_ripping.then_some(Message::DeleteSelected)).padding(8),
action("Clear", not_ripping.then_some(Message::Clear)).padding(8),
]
.spacing(5);

Expand Down
8 changes: 8 additions & 0 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ pub fn play<'a>() -> Text<'a> {
icon('\u{f4f4}')
}

pub fn stop<'a>() -> Text<'a> {
icon('\u{f4f5}')
}

pub fn pause<'a>() -> Text<'a> {
icon('\u{f4c3}')
}
Expand Down Expand Up @@ -52,6 +56,10 @@ pub fn save<'a>() -> Text<'a> {
icon('\u{e802}')
}

pub fn calendar<'a>() -> Text<'a> {
icon('\u{e803}')
}

fn icon(unicode: char) -> Text<'static> {
text(unicode.to_string())
.font(font::ICONS)
Expand Down
47 changes: 30 additions & 17 deletions src/screen/config/custom_filters/file_date.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
use std::fmt::Display;

use crate::theme::TextInputStyle;
use crate::widget::helpers::control;
use crate::widget::Element;
use crate::{icon, theme};
use crate::{theme::TextInputStyle, widget::helpers::text_icon};
use data::config::filters::{size::Modifier, Size};
use iced::widget::{button, checkbox, column, horizontal_rule, pick_list, row, slider, text, text_input};
use iced::widget::tooltip::Position;
use iced::widget::{
button, checkbox, column, horizontal_rule, pick_list, row, slider, text, text_input, tooltip,
};

#[derive(Debug, Clone, Copy)]
pub enum Message {
Expand All @@ -18,25 +22,34 @@ pub fn view<'a>() -> Element<'a, Message> {
// TODO: buttons must bring up date and time picker, should be an overlay
control(
"File Date",
column![
row![
pick_list(["Created", "Modified"].as_slice(), Some("Created"), |_| {
Message::DatePicker
}),
horizontal_rule(1),
row![
row!["From:", button("2005-12-12").on_press(Message::DatePicker)]
.align_items(iced::Alignment::Center)
.spacing(4),
row!["To:", button("2009-12-12").on_press(Message::DatePicker)]
.align_items(iced::Alignment::Center)
.spacing(4)
]
.align_items(iced::Alignment::Center)

.spacing(4),

tooltip(
button("2005-12-12")
.on_press(Message::DatePicker)
.padding(8)
.style(theme::Button::Dark),
"12 December 2005 @ 19:00",
Position::Bottom,
)
.padding(6)
.style(theme::Container::Frame),
"-",
tooltip(
button("2009-12-12")
.on_press(Message::DatePicker)
.padding(8)
.style(theme::Button::Dark),
"12 December 2009 @ 13:00",
Position::Bottom,
)
.padding(6)
.style(theme::Container::Frame),
]
.spacing(4),
.align_items(iced::Alignment::Center)
.spacing(8),
)
.into()
}
4 changes: 2 additions & 2 deletions src/screen/config/custom_filters/file_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ pub fn view(filter: &Size) -> Element<Message> {
]
.spacing(8)
.align_items(iced::Alignment::Center),
horizontal_rule(1),
text("Hint: 1000 bytes = 1 KB, 1000 KB = 1 MB"),
// horizontal_rule(1),
// text("Hint: 1000 bytes = 1 KB, 1000 KB = 1 MB"),
]
.spacing(8);
control("File Size", settings).into()
Expand Down
58 changes: 14 additions & 44 deletions src/screen/main_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ use self::entry::Entry;
use crate::app::{Message, State};
use crate::ripper::extraction::error::Reason;
use crate::ripper::subscription::CompleteState;
use crate::widget::helpers::{
centered_column_x, centered_container, centered_text, fill_container,
};
use crate::widget::helpers::{centered_column_x, centered_container, centered_text, fill_container};
use crate::widget::{Collection, Element};
use crate::{icon, theme};

use iced::widget::{
button, checkbox, column, container, progress_bar, row, scrollable, text, Space,
};
use iced::widget::{button, checkbox, column, container, progress_bar, row, scrollable, text, Space};
use iced::{Alignment, Length};

pub fn view_samples<'a>() -> Element<'a, Message> {
Expand Down Expand Up @@ -56,9 +52,10 @@ fn view_entry((index, entry): (usize, &Entry)) -> Element<Message> {
.push_maybe(
entry
.is_dir()
.then(|| row![Space::with_width(Length::Fill), icon::folder()]),
.then(|| row![Space::with_width(Length::Fill), icon::folder().size(14)]),
)
.spacing(1)
.spacing(4)
.padding(1)
.align_items(Alignment::Center);

row![
Expand All @@ -72,11 +69,7 @@ fn view_entry((index, entry): (usize, &Entry)) -> Element<Message> {
.into()
}

pub fn view_ripping<'a>(
message: &Option<String>,
progress: f32,
total_errors: u64,
) -> Element<'a, Message> {
pub fn view_ripping<'a>(message: &Option<String>, progress: f32, total_errors: u64) -> Element<'a, Message> {
let cancel_ripping_button = button("Cancel")
.on_press(Message::Cancel)
.style(theme::Button::Cancel)
Expand All @@ -92,23 +85,16 @@ pub fn view_ripping<'a>(
.spacing(8)
.align_items(Alignment::Center);

centered_container(view)
.style(theme::Container::Black)
.into()
centered_container(view).style(theme::Container::Black).into()
}

/// XMODITS has finished extracting the samples
pub fn view_finished<'a>(
complete_state: &'a CompleteState,
time: &'a Time,
) -> Element<'a, Message> {
pub fn view_finished<'a>(complete_state: &'a CompleteState, time: &'a Time) -> Element<'a, Message> {
let continue_button = button("Continue")
.on_press(Message::SetState(State::Idle))
.padding(5);

let save_errors_button = button("Save Errors")
.on_press(Message::SaveErrors)
.padding(5);
let save_errors_button = button("Save Errors").on_press(Message::SaveErrors).padding(5);

match complete_state {
CompleteState::NoErrors => centered_container(
Expand Down Expand Up @@ -197,17 +183,13 @@ pub fn view_finished<'a>(
centered_text(format!("{} errors written", total)),
text(format!("{}", time)),
// space,
row![continue_button]
.padding(4)
.align_items(Alignment::Center)
row![continue_button].padding(4).align_items(Alignment::Center)
]
.align_items(Alignment::Center)
.padding(4)
.spacing(6);

centered_container(view)
.style(theme::Container::Black)
.into()
centered_container(view).style(theme::Container::Black).into()
}

CompleteState::TooMuchErrorsNoLog {
Expand All @@ -216,20 +198,10 @@ pub fn view_finished<'a>(
discarded,
manually_saved,
} => {
let error_message = match errors.len() {
0 => match manually_saved {
false => text("Manually Saving errors..."),
true => text("Errors saved manually :D"),
},
n => text(format!("{} stored errors", n)),
};

let error_message = text(format!("{} stored errors", errors.len()));
let discarded_errors = match discarded {
0 => text("No errors were discarded."),
n => text(format!(
"I had to discard {} error(s) to save memory. >_<",
n
)), // .style(style::text::Text::Error),
n => text(format!("I had to discard {} error(s) to save memory. >_<", n)), // .style(style::text::Text::Error),
};

let buttons = match manually_saved {
Expand All @@ -254,9 +226,7 @@ pub fn view_finished<'a>(
.padding(4)
.spacing(6);

centered_container(view)
.style(theme::Container::Black)
.into()
centered_container(view).style(theme::Container::Black).into()
}
}
}
Loading

0 comments on commit f3939ef

Please sign in to comment.