make buttons not overlap! also some adjustments
This commit is contained in:
parent
937d1d68b0
commit
f9e9a26060
4 changed files with 28 additions and 28 deletions
|
@ -22,4 +22,4 @@ strum_macros = "0.27.1"
|
|||
strip = true # Automatically strip symbols from the binary.
|
||||
lto = true # Link-time optimization.
|
||||
opt-level = 3 # Optimize for speed.
|
||||
codegen-units = 1 # Maximum size reduction optimizations.
|
||||
codegen-units = 1 # Maximum size reduction optimizations.
|
Binary file not shown.
BIN
resources/QuodlibetSans-Regular.ttf
Normal file
BIN
resources/QuodlibetSans-Regular.ttf
Normal file
Binary file not shown.
54
src/main.rs
54
src/main.rs
|
@ -4,7 +4,7 @@ mod utils;
|
|||
use file_format::FileFormat;
|
||||
use ::image::{DynamicImage, ImageReader};
|
||||
use iced::{
|
||||
alignment::Vertical::{Bottom, Top}, border, font, gradient, mouse, wgpu::naga::back, widget::{button, center, column, container, image, mouse_area, row, stack, text, Column, Space}, window::{self, icon, Settings}, Alignment::Center, Color, Element, Font, Length, Point, Renderer, Size, Subscription, Task, Theme
|
||||
alignment::Vertical::{Bottom, Top}, border, font::{self, Family, Stretch, Weight}, gradient, mouse::{self, Interaction}, wgpu::naga::back, widget::{button, center, column, container, image, mouse_area, opaque, row, stack, text, Column, Space}, window::{self, icon, Settings}, Alignment::Center, Color, Element, Font, Length, Point, Renderer, Size, Subscription, Task, Theme
|
||||
};
|
||||
use iced_video_player::{Video, VideoPlayer};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -20,7 +20,10 @@ use std::{
|
|||
struct Assets;
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
let segoe_assets = Assets::get("segoe-mdl2-assets.ttf").unwrap();
|
||||
let main_font = Assets::get("QuodlibetSans-Regular.ttf").unwrap();
|
||||
let icon_file = Assets::get("icon.png").unwrap();
|
||||
|
||||
let icon_image = ImageReader::new(Cursor::new(icon_file.data))
|
||||
.with_guessed_format()
|
||||
.unwrap()
|
||||
|
@ -39,7 +42,7 @@ pub fn main() -> iced::Result {
|
|||
min_size: None,
|
||||
visible: true,
|
||||
resizable: false,
|
||||
transparent: false,
|
||||
transparent: true,
|
||||
level: window::Level::Normal,
|
||||
exit_on_close_request: true,
|
||||
..Settings::default()
|
||||
|
@ -48,6 +51,8 @@ pub fn main() -> iced::Result {
|
|||
iced::application(Launcher::boot, Launcher::update, Launcher::view)
|
||||
.title(Launcher::title)
|
||||
.window(settings)
|
||||
.font(segoe_assets.data)
|
||||
.font(main_font.data)
|
||||
.window_size((1280.0, 760.0))
|
||||
.run()
|
||||
}
|
||||
|
@ -121,7 +126,7 @@ enum SaveError {
|
|||
#[derive(Debug, Clone)]
|
||||
enum Message {
|
||||
Loaded(Result<SavedState, LoadError>),
|
||||
DragStarted,
|
||||
DragStarted(),
|
||||
GameSelected(PossibleGames),
|
||||
Close,
|
||||
Minimize
|
||||
|
@ -215,15 +220,13 @@ impl Launcher {
|
|||
Launcher::Loading => match message {
|
||||
Message::Loaded(Ok(save_state)) => {
|
||||
*self = Launcher::Loaded(save_state.into());
|
||||
let segoe_assets = Assets::get("segoe-mdl2-assets.tff").unwrap();
|
||||
let montserrat = Assets::get("Montserrat-SemiBold.ttf").unwrap();
|
||||
Task::batch([font::load(montserrat.data).and_then(|_| Task::none()), font::load(segoe_assets.data).and_then(|_| {Task::none()})])
|
||||
Task::none()
|
||||
},
|
||||
_ => Task::none(),
|
||||
},
|
||||
Launcher::Loaded(_) => {
|
||||
match message {
|
||||
Message::DragStarted => {
|
||||
Message::DragStarted() => {
|
||||
window::get_latest().and_then(move |id: window::Id| {
|
||||
window::drag(id)
|
||||
})
|
||||
|
@ -245,11 +248,14 @@ impl Launcher {
|
|||
}
|
||||
|
||||
fn view(&self) -> Element<Message> {
|
||||
println!("rerender triggered");
|
||||
let mut font = Font::with_name("Quodlibet Sans");
|
||||
font.weight = Weight::Normal;
|
||||
font.stretch = Stretch::Normal;
|
||||
println!("Rerender triggered!");
|
||||
match self {
|
||||
Launcher::Loading => center(text("Loading...").size(50)).into(),
|
||||
Launcher::Loaded(state) => {
|
||||
let game_selector = mouse_area(container(
|
||||
let game_selector = opaque(mouse_area(container(
|
||||
row![
|
||||
get_game_icon(state, &PossibleGames::WutheringWaves),
|
||||
get_game_icon(state, &PossibleGames::ZenlessZoneZero),
|
||||
|
@ -263,26 +269,25 @@ impl Launcher {
|
|||
.align_x(Center)
|
||||
.width(Length::Fill)
|
||||
.style(move |_| style_container(0.0, true)))
|
||||
.on_press(Message::DragStarted);
|
||||
.on_press(Message::DragStarted()));
|
||||
|
||||
let topbar = container(
|
||||
row![
|
||||
text("Reversed Rooms").size(25).font(Font::with_name("Montserrat-SemiBold")),
|
||||
text("Reversed Rooms").size(25).font(font),
|
||||
Space::new(Length::Fill, Length::Fixed(0.0)),
|
||||
row![
|
||||
mouse_area(text("\u{E949}").font(Font::with_name("Segoe MDL2 Assets")).size(25))
|
||||
.on_release(Message::Minimize),
|
||||
mouse_area(text("\u{E106}").font(Font::with_name("Segoe MDL2 Assets")).size(25)).on_release(Message::Close)
|
||||
opaque(mouse_area(text("\u{E949}").font(Font::with_name("Segoe MDL2 Assets")).size(25)).on_release(Message::Minimize).interaction(Interaction::Pointer)),
|
||||
opaque(mouse_area(text("\u{E106}").font(Font::with_name("Segoe MDL2 Assets")).size(25)).on_release(Message::Close).interaction(Interaction::Pointer))
|
||||
].spacing(20)
|
||||
])
|
||||
.width(Length::Fill)
|
||||
.style(move |_| style_container(0.0, false))
|
||||
.padding(20);
|
||||
|
||||
|
||||
let bottom_bar = container(row![
|
||||
text("insert game announcements").size(25).font(Font::with_name("Montserrat SemiBold")).align_y(Bottom),
|
||||
text("The quick brown fox jumped over the lazy dog.").size(25).font(font).align_y(Bottom),
|
||||
Space::new(Length::Fill, Length::Fixed(0.0)),
|
||||
container(mouse_area(button(text("Launch").size(25))
|
||||
opaque(mouse_area(button(text("Launch").size(25))
|
||||
.padding(10)
|
||||
.style(move |_, _| {
|
||||
button::Style {
|
||||
|
@ -291,21 +296,16 @@ impl Launcher {
|
|||
border: border::rounded(5),
|
||||
..button::Style::default()
|
||||
}
|
||||
})).interaction(iced::mouse::Interaction::Pointer))
|
||||
})).interaction(Interaction::Pointer))
|
||||
])
|
||||
.align_y(Bottom)
|
||||
.width(Length::Fill)
|
||||
.style(move |_theme| style_container(180.0, true))
|
||||
.padding(20);
|
||||
|
||||
let user_area = stack![
|
||||
game_selector,
|
||||
column![topbar, Space::new(Length::Fill, Length::Fill), bottom_bar]
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
]
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill);
|
||||
let user_area = column![topbar, Space::new(Length::Fill, Length::Fill), bottom_bar]
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill);
|
||||
|
||||
let background = state.background.as_ref().unwrap();
|
||||
let bg_element: Element<Message> = match background {
|
||||
|
@ -313,7 +313,7 @@ impl Launcher {
|
|||
LauncherBackground::Image(handle) => image(handle.clone()).into(),
|
||||
};
|
||||
|
||||
stack![bg_element, user_area].into()
|
||||
stack![bg_element, game_selector, user_area].into()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue