Skip to content

Commit

Permalink
Revises main tab for Slint (#1106)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon authored Nov 16, 2024
1 parent 264e5d7 commit 23748a0
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 123 deletions.
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ms-vscode.hexeditor",
"redhat.vscode-yaml",
"rust-lang.rust-analyzer",
"Slint.slint",
"tamasfe.even-better-toml",
"vadimcn.vscode-lldb"
]
Expand Down
22 changes: 3 additions & 19 deletions gui/slint/main.slint
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { Game } from "structs.slint";
import { Tabs } from "main/tabs.slint";
import { Menu } from "main/menu.slint";
import { Actions } from "main/actions.slint";

export component MainWindow inherits Window {
preferred-width: 1920px;
preferred-height: 1080px;
icon: @image-url("../resources/obliteration-icon.png");
title: "Obliteration";
min-width: 1000px;
min-height: 500px;

in property <[Game]> games: [];
in property <[string]> profiles: [];
in property <[string]> devices: [];

Expand All @@ -25,23 +22,10 @@ export component MainWindow inherits Window {
pure callback quit();

VerticalLayout {
Menu {
background: root.background;
popup_width: root.width / 2;
popup_height: root.height / 2;
popup_x: root.width / 4;
popup_y: root.height / 4;

quit => { quit(); }
open_new_issue_link => { open_new_issue_link(); }
install_pkg => { install_pkg(); }
open_system_folder => { open_system_folder(); }
}
Tabs {
devices: devices;
games: games;
select_game(index) => { }
}

Actions {
profiles: profiles;
start_game => {
Expand Down
12 changes: 4 additions & 8 deletions gui/slint/main/actions.slint
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
import { ComboBox, Button } from "std-widgets.slint";
import { Button, ComboBox, HorizontalBox } from "std-widgets.slint";

export component Actions {
in property <[string]> profiles: [];

pure callback start_game();

HorizontalLayout {

alignment: stretch;
spacing: 5px;

HorizontalBox {
ComboBox {
model: profiles;
horizontal-stretch: 1;
}

Button {
text: "Start";
horizontal-stretch: 0;
icon: @image-url("../../resources/play.svg");
clicked => { start_game(); }
}

Button {
text: "Save";
horizontal-stretch: 0;
icon: @image-url("../../resources/content-save.svg");
}
}
Expand Down
1 change: 1 addition & 0 deletions gui/slint/main/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 33 additions & 26 deletions gui/slint/main/tabs.slint
Original file line number Diff line number Diff line change
@@ -1,43 +1,50 @@

import { TabWidget } from "std-widgets.slint";
import { TabWidget, Button, HorizontalBox } from "std-widgets.slint";
import { DisplayTab } from "tabs/display.slint";
import { CpuTab } from "tabs/cpu.slint";
import { GamesTab } from "tabs/games.slint";
import { Game } from "../structs.slint";
import { Menu } from "menu.slint";

export component Tabs {
in property <[string]> devices: [];
in property <[Game]> games: [];

pure callback select_game(int);
property <int> tab: 1;

TabWidget {
Tab {
title: "Display";
//icon: @image-url("resources/darkmode/card-text-outline.svg");
VerticalLayout {
alignment: start;
VerticalLayout {
HorizontalBox {
Button {
icon: @image-url("menu.svg");
primary: root.tab == 0;
clicked => { root.tab = 0 }
}

DisplayTab { devices: devices; }
Button {
text: "Display";
icon: @image-url("../../resources/monitor.svg");
horizontal-stretch: 1;
primary: root.tab == 1;
clicked => { root.tab = 1 }
}
}
Tab {
title: "CPU";
//icon: @image-url("resources/darkmode/card-text-outline.svg");
VerticalLayout {
alignment: start;

CpuTab {}
Button {
text: "CPU";
icon: @image-url("../../resources/cpu-64-bit.svg");
horizontal-stretch: 1;
primary: root.tab == 2;
clicked => { root.tab = 2 }
}
}
Tab {
title: "Games";
//icon: @image-url("resources/darkmode/view-comfy.png");
VerticalLayout {
alignment: start;

GamesTab { games: games; }
}
if root.tab == 0: Menu {
vertical-stretch: 1;
}

if root.tab == 1: DisplayTab {
devices: devices;
vertical-stretch: 1;
}

if root.tab == 2: CpuTab {
vertical-stretch: 1;
}
}
}
57 changes: 0 additions & 57 deletions gui/slint/main/tabs/games.slint

This file was deleted.

6 changes: 0 additions & 6 deletions gui/slint/structs.slint

This file was deleted.

7 changes: 0 additions & 7 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ fn run() -> Result<(), ApplicationError> {

struct App {
main_window: ui::MainWindow,

games: ModelRc<ui::Game>,
profiles: ModelRc<SharedString>,
}

Expand All @@ -83,10 +81,6 @@ impl App {

main_window.set_devices(ModelRc::new(VecModel::from(devices)));

let games = ModelRc::new(VecModel::from(Vec::new()));

main_window.set_games(games.clone());

let profiles = ModelRc::new(
VecModel::from(vec![profile::Profile::default()])
.map(|p| SharedString::from(String::from(p.name().to_string_lossy()))),
Expand All @@ -102,7 +96,6 @@ impl App {

Ok(Self {
main_window,
games,
profiles,
})
}
Expand Down

0 comments on commit 23748a0

Please sign in to comment.