Skip to content

Commit

Permalink
macos: render into the titlebar
Browse files Browse the repository at this point in the history
also remove fps indicator unless in profiling mode

Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Feb 11, 2024
1 parent 31d770c commit c1d6788
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
55 changes: 30 additions & 25 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ fn render_note(ui: &mut egui::Ui, damus: &mut Damus, note_key: NoteKey) -> Resul
ui.with_layout(egui::Layout::left_to_right(egui::Align::TOP), |ui| {
let profile = damus.ndb.get_profile_by_pubkey(&txn, note.pubkey());

padding(5.0, ui, |ui| {
padding(6.0, ui, |ui| {
match profile
.as_ref()
.ok()
Expand Down Expand Up @@ -692,7 +692,7 @@ fn render_notes(ui: &mut egui::Ui, damus: &mut Damus, timeline: usize) {
}

fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) {
padding(10.0, ui, |ui| ui.heading("Timeline"));
padding(4.0, ui, |ui| ui.heading("Notifications"));

/*
let font_id = egui::TextStyle::Body.resolve(ui.style());
Expand All @@ -713,28 +713,28 @@ fn timeline_view(ui: &mut egui::Ui, app: &mut Damus, timeline: usize) {
}

fn top_panel(ctx: &egui::Context) -> egui::TopBottomPanel {
// mobile needs padding, at least on android
if is_mobile(ctx) {
let mut top_margin = Margin::default();
top_margin.top = 20.0;

let frame = Frame {
inner_margin: top_margin,
fill: ctx.style().visuals.panel_fill,
..Default::default()
};

return egui::TopBottomPanel::top("top_panel").frame(frame);
}
let mut top_margin = Margin::default();
top_margin.top = 4.0;
top_margin.left = 8.0;
top_margin.right = 8.0;
//top_margin.bottom = -20.0;

let frame = Frame {
inner_margin: top_margin,
fill: ctx.style().visuals.panel_fill,
..Default::default()
};

egui::TopBottomPanel::top("top_panel").frame(Frame::none())
egui::TopBottomPanel::top("top_panel")
.frame(frame)
.show_separator_line(false)
}

fn render_panel<'a>(ctx: &egui::Context, app: &'a mut Damus, timeline_ind: usize) {

Check failure on line 733 in src/app.rs

View workflow job for this annotation

GitHub Actions / Clippy

unused variable: `timeline_ind`

Check warning on line 733 in src/app.rs

View workflow job for this annotation

GitHub Actions / Test Suite

unused variable: `timeline_ind`
top_panel(ctx).show(ctx, |ui| {
set_app_style(ui);

ui.horizontal_wrapped(|ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
ui.visuals_mut().button_frame = false;
egui::widgets::global_dark_light_mode_switch(ui);

Expand All @@ -755,14 +755,19 @@ fn render_panel<'a>(ctx: &egui::Context, app: &'a mut Damus, timeline_ind: usize
app.n_panels -= 1;
}

ui.label(format!(
"FPS: {:.2}, {:10.1}ms",
app.frame_history.fps(),
app.frame_history.mean_frame_time() * 1e3
));

let timeline = &app.timelines[timeline_ind];
ui.label(format!("{} notes", timeline.notes.len()));
#[cfg(feature = "profiling")]
{
ui.weak(format!(
"FPS: {:.2}, {:10.1}ms",
app.frame_history.fps(),
app.frame_history.mean_frame_time() * 1e3
));

ui.weak(format!(
"{} notes",
&app.timelines[timeline_ind].notes.len()
));
}
});
});
}
Expand Down
10 changes: 8 additions & 2 deletions src/bin/notedeck.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![warn(clippy::all, rust_2018_idioms)]
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
use damus::Damus;
use notedeck::Damus;

// Entry point for wasm
//#[cfg(target_arch = "wasm32")]
Expand All @@ -13,7 +13,13 @@ async fn main() {
// Log to stdout (if you run with `RUST_LOG=debug`).
tracing_subscriber::fmt::init();

let native_options = eframe::NativeOptions::default();
let window_builder = Box::new(|builder: egui::ViewportBuilder| {
builder.with_fullsize_content_view(true)
.with_titlebar_shown(false)
.with_title_shown(false)
});
let mut native_options = eframe::NativeOptions::default();
native_options.window_builder = Some(window_builder);

let _res = eframe::run_native(
"Damus NoteDeck",
Expand Down

0 comments on commit c1d6788

Please sign in to comment.