Skip to content

Commit

Permalink
CI + user_agent + window frame
Browse files Browse the repository at this point in the history
  • Loading branch information
aspect committed Dec 28, 2023
1 parent 504c848 commit 5a7e044
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 26 deletions.
17 changes: 13 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

- name: Install desktop dependencies
run: |
sudo apt install -y librust-atk-dev
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
- name: Checkout sources
uses: actions/checkout@v3
Expand Down Expand Up @@ -84,7 +84,6 @@ jobs:

swap-storage: true


- name: Install desktop dependencies
run: |
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
Expand Down Expand Up @@ -134,6 +133,11 @@ jobs:
name: Lints
runs-on: ubuntu-latest
steps:

- name: Install desktop dependencies
run: |
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
- name: Checkout sources
uses: actions/checkout@v3

Expand Down Expand Up @@ -201,7 +205,7 @@ jobs:
- name: Install desktop dependencies
run: |
sudo apt install -y librust-atk-dev
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
- name: Install stable toolchain
if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success'
Expand Down Expand Up @@ -262,7 +266,7 @@ jobs:
- name: Install desktop dependencies
run: |
sudo apt install -y librust-atk-dev
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
- name: Install stable toolchain
if: steps.install_llvm.outcome == 'success' && steps.install_llvm.conclusion == 'success'
Expand Down Expand Up @@ -306,6 +310,11 @@ jobs:
name: Build Ubuntu Release
runs-on: ubuntu-latest
steps:

- name: Install desktop dependencies
run: |
sudo apt install -y libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
- name: Checkout sources
uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ In addition, on linux, you need to perform the following installs:

#### Ubuntu/Debian:
```bash
sudo apt-get install libglib2.0-dev libatk1.0-dev libgtk-3-dev
sudo apt-get install libglib2.0-dev libatk1.0-dev libgtk-3-dev librust-atk-dev
```

#### Fedora:
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ egui_plot.workspace = true
egui_extras.workspace = true
chrono.workspace = true
eframe = { workspace = true, default-features = false, features = [
# "accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies.
"accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies.
"default_fonts", # Embed the default egui fonts.
# "wgpu", # Use the glow rendering backend. Alternative: "wgpu".
"glow", # Use the glow rendering backend. Alternative: "wgpu".
Expand Down
6 changes: 5 additions & 1 deletion core/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ impl eframe::App for Core {

impl Core {
fn render_frame(&mut self, ctx: &Context, frame: &mut eframe::Frame) {
window_frame(self.window_frame, ctx, "Kaspa NG", |ui| {

let is_fullscreen = ctx.input(|i| i.viewport().fullscreen.unwrap_or(false));

window_frame(self.window_frame && !is_fullscreen, ctx, "Kaspa NG", |ui| {
if !self.settings.initialized {
cfg_if! {
if #[cfg(not(target_arch = "wasm32"))] {
Expand Down Expand Up @@ -523,6 +526,7 @@ impl Core {
});
}

#[cfg(not(target_arch = "wasm32"))]
fn handle_screenshot(&mut self, ctx: &Context, screenshot: Arc<ColorImage>) {
match rfd::FileDialog::new().save_file() {
Some(mut path) => {
Expand Down
79 changes: 64 additions & 15 deletions core/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title:
fn close_maximize_minimize(ui: &mut egui::Ui) {
use egui_phosphor::light::*;

let button_height = 14.0;
let spacing = 8.0;
let button_height = 16.0;

let close_response = ui
.add(Button::new(
Expand All @@ -129,27 +130,75 @@ fn close_maximize_minimize(ui: &mut egui::Ui) {
if close_response.clicked() {
ui.ctx().send_viewport_cmd(egui::ViewportCommand::Close);
}


cfg_if! {
if #[cfg(target_os = "macos")] {
let support_fullscreen = true;
let support_maximize = true;
} else {
let support_fullscreen = true;
let support_maximize = true;
}
}

let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false));
if is_maximized {
let maximized_response = ui
.add(Button::new(RichText::new("🗗").size(button_height)))
.on_hover_text("Restore window");
if maximized_response.clicked() {
ui.ctx()
.send_viewport_cmd(ViewportCommand::Maximized(false));
if support_fullscreen {

ui.add_space(spacing);

let is_fullscreen = ui.input(|i| i.viewport().fullscreen.unwrap_or(false));
if is_fullscreen {
let fullscreen_response = ui
// .add(Button::new(RichText::new("🗗").size(button_height)))
.add(Button::new(RichText::new(ARROWS_IN.to_string()).size(button_height)))
.on_hover_text("Exit Full Screen");
if fullscreen_response.clicked() {
ui.ctx().send_viewport_cmd(ViewportCommand::Fullscreen(false));
}
} else {
let fullscreen_response = ui
// .add(Button::new(RichText::new("🗗").size(button_height)))
.add(Button::new(RichText::new(ARROWS_OUT.to_string()).size(button_height)))
// .add(Button::new(RichText::new(ARROWS_OUT.to_string()).size(button_height)))
.on_hover_text("Full Screen");
if fullscreen_response.clicked() {
ui.ctx().send_viewport_cmd(ViewportCommand::Fullscreen(true));
}
}
} else {
let maximized_response = ui
.add(Button::new(RichText::new("🗗").size(button_height)))
.on_hover_text("Maximize window");
if maximized_response.clicked() {
ui.ctx().send_viewport_cmd(ViewportCommand::Maximized(true));
}

if support_maximize {

ui.add_space(spacing);

let is_maximized = ui.input(|i| i.viewport().maximized.unwrap_or(false));
if is_maximized {
let maximized_response = ui
// .add(Button::new(RichText::new("🗗").size(button_height)))
.add(Button::new(RichText::new(RECTANGLE.to_string()).size(button_height)))
.on_hover_text("Restore window");
if maximized_response.clicked() {
ui.ctx().send_viewport_cmd(ViewportCommand::Maximized(false));
}
} else {
let maximized_response = ui
// .add(Button::new(RichText::new("🗗").size(button_height)))
.add(Button::new(RichText::new(SQUARE.to_string()).size(button_height)))
// .add(Button::new(RichText::new(ARROWS_OUT.to_string()).size(button_height)))
.on_hover_text("Maximize window");
if maximized_response.clicked() {
ui.ctx().send_viewport_cmd(ViewportCommand::Maximized(true));
}
}
}


ui.add_space(spacing+2.0);

let minimized_response = ui
.add(Button::new(RichText::new("🗕").size(button_height)))
// .add(Button::new(RichText::new(ARROW_SQUARE_DOWN.to_string()).size(button_height)))
// .add(Button::new(RichText::new(ARROW_LINE_DOWN.to_string()).size(button_height)))
.on_hover_text("Minimize the window");
if minimized_response.clicked() {
ui.ctx().send_viewport_cmd(ViewportCommand::Minimized(true));
Expand Down
13 changes: 12 additions & 1 deletion core/src/runtime/services/kaspa/config.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use crate::imports::*;
use kaspa_core::kaspad_env;
use crate::app::{VERSION,GIT_DESCRIBE};
use crate::utils::Arglist;

#[cfg(not(target_arch = "wasm32"))]
pub use kaspad_lib::args::Args;

fn user_agent_comment() -> String {
format!("/{}:{}/kaspa-ng:{}-{}/", kaspad_env::name(),kaspad_env::version(), VERSION, GIT_DESCRIBE)
}

#[derive(Debug, Clone)]
pub struct Config {
network: Network,
Expand Down Expand Up @@ -56,6 +61,10 @@ cfg_if! {
args.rpclisten = Some(config.grpc_network_interface.into());
}

args.user_agent_comments = vec![user_agent_comment()];

// TODO - parse custom args and overlap on top of the defaults

Ok(args)
}
}
Expand Down Expand Up @@ -92,6 +101,8 @@ cfg_if! {

args.push("--rpclisten-borsh=default");

args.push(format!("--uacomment={}", user_agent_comment()));

if config.kaspad_daemon_args_enable {
config.kaspad_daemon_args.trim().split(' ').filter(|arg|!arg.trim().is_empty()).for_each(|arg| {
args.push(arg);
Expand Down
7 changes: 4 additions & 3 deletions core/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ impl<'core> Status<'core> {
let status_area_width = ui.available_width() - 24.;
let status_icon_size = theme_style().status_icon_size;
let module = self.module().clone();
let left_padding = 8.0;

match state {
ConnectionStatus::Disconnected => {
ui.add_space(4.);
ui.add_space(left_padding);

match self.settings().node.node_kind {
KaspadNodeKind::Disable => {
Expand Down Expand Up @@ -195,7 +196,7 @@ impl<'core> Status<'core> {
peers,
tps: _,
} => {
ui.add_space(4.);
ui.add_space(left_padding);
ui.label(
RichText::new(egui_phosphor::light::CPU)
.size(status_icon_size)
Expand Down Expand Up @@ -234,7 +235,7 @@ impl<'core> Status<'core> {
ConnectionStatus::Syncing { sync_status, peers } => {
ui.vertical(|ui| {
ui.horizontal(|ui| {
ui.add_space(4.);
ui.add_space(left_padding);
ui.label(
RichText::new(egui_phosphor::light::CLOUD_ARROW_DOWN)
.size(status_icon_size)
Expand Down

0 comments on commit 5a7e044

Please sign in to comment.