android: update to latest winit/egui/android-activity
so we can start fixing this shit Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
641
Cargo.lock
generated
641
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
13
Cargo.toml
@@ -62,10 +62,6 @@ bincode = "1.3.3"
|
|||||||
mime_guess = "2.0.5"
|
mime_guess = "2.0.5"
|
||||||
pretty_assertions = "1.4.1"
|
pretty_assertions = "1.4.1"
|
||||||
|
|
||||||
[patch.crates-io]
|
|
||||||
egui = { git = "https://github.com/damus-io/egui", branch = "update_layouter_0.29.1" }
|
|
||||||
epaint = { git = "https://github.com/damus-io/egui", branch = "update_layouter_0.29.1" }
|
|
||||||
|
|
||||||
[profile.small]
|
[profile.small]
|
||||||
inherits = 'release'
|
inherits = 'release'
|
||||||
opt-level = 'z' # Optimize for size
|
opt-level = 'z' # Optimize for size
|
||||||
@@ -73,3 +69,12 @@ lto = true # Enable link-time optimization
|
|||||||
codegen-units = 1 # Reduce number of codegen units to increase optimizations
|
codegen-units = 1 # Reduce number of codegen units to increase optimizations
|
||||||
panic = 'abort' # Abort on panic
|
panic = 'abort' # Abort on panic
|
||||||
strip = true # Strip symbols from binary*
|
strip = true # Strip symbols from binary*
|
||||||
|
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
egui = { git = "https://github.com/jb55/egui", rev = "03c769a3576920d5e33e01c06167e7c67d296625" }
|
||||||
|
eframe = { git = "https://github.com/jb55/egui", rev = "03c769a3576920d5e33e01c06167e7c67d296625" }
|
||||||
|
egui-winit = { git = "https://github.com/jb55/egui", rev = "03c769a3576920d5e33e01c06167e7c67d296625" }
|
||||||
|
egui_extras = { git = "https://github.com/jb55/egui", rev = "03c769a3576920d5e33e01c06167e7c67d296625" }
|
||||||
|
# on master was git = "https://github.com/damus-io/egui", branch = "update_layouter_0.29.1"
|
||||||
|
epaint = { git = "https://github.com/jb55/egui", rev = "03c769a3576920d5e33e01c06167e7c67d296625" }
|
||||||
|
|||||||
@@ -33,30 +33,13 @@ pub struct Notedeck {
|
|||||||
unrecognized_args: BTreeSet<String>,
|
unrecognized_args: BTreeSet<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn margin_top(narrow: bool) -> f32 {
|
|
||||||
#[cfg(target_os = "android")]
|
|
||||||
{
|
|
||||||
// FIXME - query the system bar height and adjust more precisely
|
|
||||||
let _ = narrow; // suppress compiler warning on android
|
|
||||||
40.0
|
|
||||||
}
|
|
||||||
#[cfg(not(target_os = "android"))]
|
|
||||||
{
|
|
||||||
if narrow {
|
|
||||||
50.0
|
|
||||||
} else {
|
|
||||||
0.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Our chrome, which is basically nothing
|
/// Our chrome, which is basically nothing
|
||||||
fn main_panel(style: &egui::Style, narrow: bool) -> egui::CentralPanel {
|
fn main_panel(style: &egui::Style) -> egui::CentralPanel {
|
||||||
let inner_margin = egui::Margin {
|
let inner_margin = egui::Margin {
|
||||||
top: margin_top(narrow),
|
top: 0,
|
||||||
left: 0.0,
|
left: 0,
|
||||||
right: 0.0,
|
right: 0,
|
||||||
bottom: 0.0,
|
bottom: 0,
|
||||||
};
|
};
|
||||||
egui::CentralPanel::default().frame(egui::Frame {
|
egui::CentralPanel::default().frame(egui::Frame {
|
||||||
inner_margin,
|
inner_margin,
|
||||||
@@ -73,7 +56,7 @@ impl eframe::App for Notedeck {
|
|||||||
// handle account updates
|
// handle account updates
|
||||||
self.accounts.update(&mut self.ndb, &mut self.pool, ctx);
|
self.accounts.update(&mut self.ndb, &mut self.pool, ctx);
|
||||||
|
|
||||||
main_panel(&ctx.style(), crate::ui::is_narrow(ctx)).show(ctx, |ui| {
|
main_panel(&ctx.style()).show(ctx, |ui| {
|
||||||
// render app
|
// render app
|
||||||
if let Some(app) = &self.app {
|
if let Some(app) = &self.app {
|
||||||
let app = app.clone();
|
let app = app.clone();
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ pub struct ColorTheme {
|
|||||||
pub inactive_weak_bg_fill: Color32,
|
pub inactive_weak_bg_fill: Color32,
|
||||||
}
|
}
|
||||||
|
|
||||||
const WIDGET_ROUNDING: Rounding = Rounding::same(8.0);
|
const WIDGET_ROUNDING: Rounding = Rounding::same(8);
|
||||||
|
|
||||||
pub fn create_themed_visuals(theme: ColorTheme, default: Visuals) -> Visuals {
|
pub fn create_themed_visuals(theme: ColorTheme, default: Visuals) -> Visuals {
|
||||||
Visuals {
|
Visuals {
|
||||||
@@ -83,12 +83,12 @@ pub fn create_themed_visuals(theme: ColorTheme, default: Visuals) -> Visuals {
|
|||||||
},
|
},
|
||||||
extreme_bg_color: theme.extreme_bg_color,
|
extreme_bg_color: theme.extreme_bg_color,
|
||||||
error_fg_color: theme.err_fg_color,
|
error_fg_color: theme.err_fg_color,
|
||||||
window_rounding: Rounding::same(8.0),
|
window_rounding: Rounding::same(8),
|
||||||
window_fill: theme.window_fill,
|
window_fill: theme.window_fill,
|
||||||
window_shadow: Shadow {
|
window_shadow: Shadow {
|
||||||
offset: [0.0, 8.0].into(),
|
offset: [0, 8],
|
||||||
blur: 24.0,
|
blur: 24,
|
||||||
spread: 0.0,
|
spread: 0,
|
||||||
color: egui::Color32::from_rgba_unmultiplied(0x6D, 0x6D, 0x6D, 0x14),
|
color: egui::Color32::from_rgba_unmultiplied(0x6D, 0x6D, 0x6D, 0x14),
|
||||||
},
|
},
|
||||||
window_stroke: Stroke {
|
window_stroke: Stroke {
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ public class MainActivity extends GameActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
// Shrink view so it does not get covered by insets.
|
// Shrink view so it does not get covered by insets.
|
||||||
|
|
||||||
/*
|
|
||||||
View content = getWindow().getDecorView().findViewById(android.R.id.content);
|
View content = getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
ViewCompat.setOnApplyWindowInsetsListener(content, (v, windowInsets) -> {
|
ViewCompat.setOnApplyWindowInsetsListener(content, (v, windowInsets) -> {
|
||||||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
@@ -39,7 +38,6 @@ public class MainActivity extends GameActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), true);
|
||||||
*/
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
}
|
}
|
||||||
@@ -48,11 +46,10 @@ public class MainActivity extends GameActivity {
|
|||||||
public boolean onTouchEvent(MotionEvent event) {
|
public boolean onTouchEvent(MotionEvent event) {
|
||||||
// Offset the location so it fits the view with margins caused by insets.
|
// Offset the location so it fits the view with margins caused by insets.
|
||||||
|
|
||||||
/*
|
|
||||||
int[] location = new int[2];
|
int[] location = new int[2];
|
||||||
findViewById(android.R.id.content).getLocationOnScreen(location);
|
findViewById(android.R.id.content).getLocationOnScreen(location);
|
||||||
event.offsetLocation(-location[0], -location[1]);
|
event.offsetLocation(-location[0], -location[1]);
|
||||||
*/
|
|
||||||
return super.onTouchEvent(event);
|
return super.onTouchEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ pub async fn android_main(app: AndroidApp) {
|
|||||||
use tracing_subscriber::{prelude::*, EnvFilter};
|
use tracing_subscriber::{prelude::*, EnvFilter};
|
||||||
|
|
||||||
std::env::set_var("RUST_BACKTRACE", "full");
|
std::env::set_var("RUST_BACKTRACE", "full");
|
||||||
std::env::set_var("RUST_LOG", "egui=trace");
|
std::env::set_var("RUST_LOG", "egui=trace,android_activity=debug");
|
||||||
|
|
||||||
//std::env::set_var(
|
//std::env::set_var(
|
||||||
// "RUST_LOG",
|
// "RUST_LOG",
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ impl<'a> AccountLoginView<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> InnerResponse<Option<AccountLoginResponse>> {
|
pub fn ui(&mut self, ui: &mut egui::Ui) -> InnerResponse<Option<AccountLoginResponse>> {
|
||||||
Frame::none()
|
Frame::new().outer_margin(12.0).show(ui, |ui| self.show(ui))
|
||||||
.outer_margin(12.0)
|
|
||||||
.show(ui, |ui| self.show(ui))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show(&mut self, ui: &mut egui::Ui) -> Option<AccountLoginResponse> {
|
fn show(&mut self, ui: &mut egui::Ui) -> Option<AccountLoginResponse> {
|
||||||
@@ -123,7 +121,7 @@ fn login_textedit(manager: &mut AcquireKeyState) -> TextEdit {
|
|||||||
)
|
)
|
||||||
.vertical_align(Align::Center)
|
.vertical_align(Align::Center)
|
||||||
.min_size(Vec2::new(0.0, 40.0))
|
.min_size(Vec2::new(0.0, 40.0))
|
||||||
.margin(Margin::same(12.0))
|
.margin(Margin::same(12))
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_visible = manager.password_visible();
|
let is_visible = manager.password_visible();
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ impl<'a> AccountsView<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn ui(&mut self, ui: &mut Ui) -> InnerResponse<Option<AccountsViewResponse>> {
|
pub fn ui(&mut self, ui: &mut Ui) -> InnerResponse<Option<AccountsViewResponse>> {
|
||||||
Frame::none().outer_margin(12.0).show(ui, |ui| {
|
Frame::new().outer_margin(12.0).show(ui, |ui| {
|
||||||
if let Some(resp) = Self::top_section_buttons_widget(ui).inner {
|
if let Some(resp) = Self::top_section_buttons_widget(ui).inner {
|
||||||
return Some(resp);
|
return Some(resp);
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ fn show_profile_card(
|
|||||||
let mut op: Option<ProfilePreviewAction> = None;
|
let mut op: Option<ProfilePreviewAction> = None;
|
||||||
|
|
||||||
ui.add_sized(max_size, |ui: &mut egui::Ui| {
|
ui.add_sized(max_size, |ui: &mut egui::Ui| {
|
||||||
let mut frame = Frame::none();
|
let mut frame = Frame::new();
|
||||||
if is_selected || card_resp.hovered() {
|
if is_selected || card_resp.hovered() {
|
||||||
frame = frame.fill(ui.visuals().noninteractive().weak_bg_fill);
|
frame = frame.fill(ui.visuals().noninteractive().weak_bg_fill);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ impl<'a> AddColumnView<'a> {
|
|||||||
.vertical_align(Align::Center)
|
.vertical_align(Align::Center)
|
||||||
.desired_width(f32::INFINITY)
|
.desired_width(f32::INFINITY)
|
||||||
.min_size(Vec2::new(0.0, 40.0))
|
.min_size(Vec2::new(0.0, 40.0))
|
||||||
.margin(Margin::same(12.0))
|
.margin(Margin::same(12))
|
||||||
});
|
});
|
||||||
|
|
||||||
ui.add(text_edit);
|
ui.add(text_edit);
|
||||||
@@ -315,10 +315,10 @@ impl<'a> AddColumnView<'a> {
|
|||||||
{
|
{
|
||||||
egui::Frame::window(ui.style())
|
egui::Frame::window(ui.style())
|
||||||
.outer_margin(Margin {
|
.outer_margin(Margin {
|
||||||
left: 4.0,
|
left: 4,
|
||||||
right: 4.0,
|
right: 4,
|
||||||
top: 12.0,
|
top: 12,
|
||||||
bottom: 32.0,
|
bottom: 32,
|
||||||
})
|
})
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ProfilePreview::new(&profile, self.img_cache).ui(ui);
|
ProfilePreview::new(&profile, self.img_cache).ui(ui);
|
||||||
@@ -754,7 +754,7 @@ pub fn hashtag_ui(
|
|||||||
.vertical_align(Align::Center)
|
.vertical_align(Align::Center)
|
||||||
.desired_width(f32::INFINITY)
|
.desired_width(f32::INFINITY)
|
||||||
.min_size(Vec2::new(0.0, 40.0))
|
.min_size(Vec2::new(0.0, 40.0))
|
||||||
.margin(Margin::same(12.0));
|
.margin(Margin::same(12));
|
||||||
ui.add(text_edit);
|
ui.add(text_edit);
|
||||||
|
|
||||||
ui.add_space(8.0);
|
ui.add_space(8.0);
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ impl<'a> NavTitle<'a> {
|
|||||||
let x_range = ui.available_rect_before_wrap().x_range();
|
let x_range = ui.available_rect_before_wrap().x_range();
|
||||||
let is_dragging = egui::DragAndDrop::payload::<usize>(ui.ctx()).is_some(); // must be outside ui.dnd_drop_zone to capture properly
|
let is_dragging = egui::DragAndDrop::payload::<usize>(ui.ctx()).is_some(); // must be outside ui.dnd_drop_zone to capture properly
|
||||||
let (_, _) = ui.dnd_drop_zone::<usize, ()>(
|
let (_, _) = ui.dnd_drop_zone::<usize, ()>(
|
||||||
egui::Frame::none().inner_margin(Margin::same(8.0)),
|
egui::Frame::new().inner_margin(Margin::same(8)),
|
||||||
|ui| {
|
|ui| {
|
||||||
let distances: Vec<(egui::Response, f32)> =
|
let distances: Vec<(egui::Response, f32)> =
|
||||||
self.collect_column_distances(ui, id);
|
self.collect_column_distances(ui, id);
|
||||||
@@ -291,10 +291,10 @@ impl<'a> NavTitle<'a> {
|
|||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
id: egui::Id,
|
id: egui::Id,
|
||||||
) -> Vec<(egui::Response, f32)> {
|
) -> Vec<(egui::Response, f32)> {
|
||||||
let y_margin = 4.0;
|
let y_margin: i8 = 4;
|
||||||
let item_frame = egui::Frame::none()
|
let item_frame = egui::Frame::new()
|
||||||
.rounding(egui::Rounding::same(8.0))
|
.rounding(egui::Rounding::same(8))
|
||||||
.inner_margin(Margin::symmetric(8.0, y_margin));
|
.inner_margin(Margin::symmetric(8, y_margin));
|
||||||
|
|
||||||
(0..self.columns.num_columns())
|
(0..self.columns.num_columns())
|
||||||
.filter_map(|col| {
|
.filter_map(|col| {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ impl<'a> EditDeckView<'a> {
|
|||||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<EditDeckResponse> {
|
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<EditDeckResponse> {
|
||||||
let mut edit_deck_resp = None;
|
let mut edit_deck_resp = None;
|
||||||
|
|
||||||
padding(egui::Margin::symmetric(16.0, 4.0), ui, |ui| {
|
padding(egui::Margin::symmetric(16, 4), ui, |ui| {
|
||||||
if ui.add(delete_button()).clicked() {
|
if ui.add(delete_button()).clicked() {
|
||||||
edit_deck_resp = Some(EditDeckResponse::Delete);
|
edit_deck_resp = Some(EditDeckResponse::Delete);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ pub fn padding<R>(
|
|||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
add_contents: impl FnOnce(&mut egui::Ui) -> R,
|
add_contents: impl FnOnce(&mut egui::Ui) -> R,
|
||||||
) -> egui::InnerResponse<R> {
|
) -> egui::InnerResponse<R> {
|
||||||
egui::Frame::none()
|
egui::Frame::new()
|
||||||
.inner_margin(amount)
|
.inner_margin(amount)
|
||||||
.show(ui, add_contents)
|
.show(ui, add_contents)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,11 +94,11 @@ pub fn render_note_preview(
|
|||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
egui::Frame::none()
|
egui::Frame::new()
|
||||||
.fill(ui.visuals().noninteractive().weak_bg_fill)
|
.fill(ui.visuals().noninteractive().weak_bg_fill)
|
||||||
.inner_margin(egui::Margin::same(8.0))
|
.inner_margin(egui::Margin::same(8))
|
||||||
.outer_margin(egui::Margin::symmetric(0.0, 8.0))
|
.outer_margin(egui::Margin::symmetric(0, 8))
|
||||||
.rounding(egui::Rounding::same(10.0))
|
.rounding(egui::Rounding::same(10))
|
||||||
.stroke(egui::Stroke::new(
|
.stroke(egui::Stroke::new(
|
||||||
1.0,
|
1.0,
|
||||||
ui.visuals().noninteractive().bg_stroke.color,
|
ui.visuals().noninteractive().bg_stroke.color,
|
||||||
|
|||||||
@@ -16,30 +16,22 @@ impl NoteContextSelection {
|
|||||||
pub fn process(&self, ui: &mut egui::Ui, note: &Note<'_>) {
|
pub fn process(&self, ui: &mut egui::Ui, note: &Note<'_>) {
|
||||||
match self {
|
match self {
|
||||||
NoteContextSelection::CopyText => {
|
NoteContextSelection::CopyText => {
|
||||||
ui.output_mut(|w| {
|
ui.ctx().copy_text(note.content().to_string());
|
||||||
w.copied_text = note.content().to_string();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
NoteContextSelection::CopyPubkey => {
|
NoteContextSelection::CopyPubkey => {
|
||||||
ui.output_mut(|w| {
|
|
||||||
if let Some(bech) = Pubkey::new(*note.pubkey()).to_bech() {
|
if let Some(bech) = Pubkey::new(*note.pubkey()).to_bech() {
|
||||||
w.copied_text = bech;
|
ui.ctx().copy_text(bech);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
NoteContextSelection::CopyNoteId => {
|
NoteContextSelection::CopyNoteId => {
|
||||||
ui.output_mut(|w| {
|
|
||||||
if let Some(bech) = NoteId::new(*note.id()).to_bech() {
|
if let Some(bech) = NoteId::new(*note.id()).to_bech() {
|
||||||
w.copied_text = bech;
|
ui.ctx().copy_text(bech);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
NoteContextSelection::CopyNoteJSON => {
|
NoteContextSelection::CopyNoteJSON => match note.json() {
|
||||||
ui.output_mut(|w| match note.json() {
|
Ok(json) => ui.ctx().copy_text(json),
|
||||||
Ok(json) => w.copied_text = json,
|
|
||||||
Err(err) => error!("error copying note json: {err}"),
|
Err(err) => error!("error copying note json: {err}"),
|
||||||
});
|
},
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,8 +189,8 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
.response
|
.response
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn expand_size() -> f32 {
|
pub fn expand_size() -> i8 {
|
||||||
5.0
|
5
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pfp(
|
fn pfp(
|
||||||
@@ -223,8 +223,8 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
let (rect, size, resp) = ui::anim::hover_expand(
|
let (rect, size, resp) = ui::anim::hover_expand(
|
||||||
ui,
|
ui,
|
||||||
egui::Id::new((profile_key, note_key)),
|
egui::Id::new((profile_key, note_key)),
|
||||||
pfp_size,
|
pfp_size as f32,
|
||||||
ui::NoteView::expand_size(),
|
ui::NoteView::expand_size() as f32,
|
||||||
anim_speed,
|
anim_speed,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -246,6 +246,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
|
|
||||||
resp
|
resp
|
||||||
}
|
}
|
||||||
|
|
||||||
None => {
|
None => {
|
||||||
// This has to match the expand size from the above case to
|
// This has to match the expand size from the above case to
|
||||||
// prevent bounciness
|
// prevent bounciness
|
||||||
@@ -255,7 +256,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
ui.put(
|
ui.put(
|
||||||
rect,
|
rect,
|
||||||
ui::ProfilePic::new(self.note_context.img_cache, ui::ProfilePic::no_pfp_url())
|
ui::ProfilePic::new(self.note_context.img_cache, ui::ProfilePic::no_pfp_url())
|
||||||
.size(pfp_size),
|
.size(pfp_size as f32),
|
||||||
)
|
)
|
||||||
.interact(sense)
|
.interact(sense)
|
||||||
}
|
}
|
||||||
@@ -354,7 +355,7 @@ impl<'a, 'd> NoteView<'a, 'd> {
|
|||||||
|
|
||||||
let size = ui.available_size();
|
let size = ui.available_size();
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.add_sized([size.x, self.options().pfp_size()], |ui: &mut egui::Ui| {
|
ui.add_sized([size.x, self.options().pfp_size() as f32], |ui: &mut egui::Ui| {
|
||||||
ui.horizontal_centered(|ui| {
|
ui.horizontal_centered(|ui| {
|
||||||
NoteView::note_header(
|
NoteView::note_header(
|
||||||
ui,
|
ui,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ impl NoteOptions {
|
|||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pfp_size(&self) -> f32 {
|
pub fn pfp_size(&self) -> i8 {
|
||||||
if self.has_small_pfp() {
|
if self.has_small_pfp() {
|
||||||
ProfilePic::small_size()
|
ProfilePic::small_size()
|
||||||
} else if self.has_medium_pfp() {
|
} else if self.has_medium_pfp() {
|
||||||
|
|||||||
@@ -283,12 +283,12 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
self.id_source.unwrap_or_else(|| egui::Id::new("post"))
|
self.id_source.unwrap_or_else(|| egui::Id::new("post"))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outer_margin() -> f32 {
|
pub fn outer_margin() -> i8 {
|
||||||
16.0
|
16
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn inner_margin() -> f32 {
|
pub fn inner_margin() -> i8 {
|
||||||
12.0
|
12
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ui(&mut self, txn: &nostrdb::Transaction, ui: &mut egui::Ui) -> PostResponse {
|
pub fn ui(&mut self, txn: &nostrdb::Transaction, ui: &mut egui::Ui) -> PostResponse {
|
||||||
@@ -308,9 +308,9 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
|
|
||||||
if focused {
|
if focused {
|
||||||
frame = frame.shadow(egui::epaint::Shadow {
|
frame = frame.shadow(egui::epaint::Shadow {
|
||||||
offset: egui::vec2(0.0, 0.0),
|
offset: [0, 0],
|
||||||
blur: 8.0,
|
blur: 8,
|
||||||
spread: 0.0,
|
spread: 0,
|
||||||
color: stroke.color,
|
color: stroke.color,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -327,8 +327,7 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
context_selection = Frame::none()
|
context_selection = Frame::none()
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
let set_width = avail_size.x * 0.8;
|
ui.set_max_width(avail_size.x * 0.8);
|
||||||
ui.set_max_width(set_width);
|
|
||||||
let resp = render_note_preview(
|
let resp = render_note_preview(
|
||||||
ui,
|
ui,
|
||||||
self.note_context,
|
self.note_context,
|
||||||
@@ -346,8 +345,8 @@ impl<'a, 'd> PostView<'a, 'd> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame::none()
|
Frame::new()
|
||||||
.inner_margin(Margin::symmetric(0.0, 8.0))
|
.inner_margin(Margin::symmetric(0, 8))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ScrollArea::horizontal().show(ui, |ui| {
|
ScrollArea::horizontal().show(ui, |ui| {
|
||||||
ui.with_layout(Layout::left_to_right(egui::Align::Min), |ui| {
|
ui.with_layout(Layout::left_to_right(egui::Align::Min), |ui| {
|
||||||
|
|||||||
@@ -54,13 +54,12 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
|
|||||||
|
|
||||||
// This is the offset of the post view's pfp. We use this
|
// This is the offset of the post view's pfp. We use this
|
||||||
// to indent things so that the reply line is aligned
|
// to indent things so that the reply line is aligned
|
||||||
let pfp_offset = ui::PostView::outer_margin()
|
let pfp_offset: i8 = ui::PostView::outer_margin()
|
||||||
+ ui::PostView::inner_margin()
|
+ ui::PostView::inner_margin()
|
||||||
+ ui::ProfilePic::small_size() / 2.0;
|
+ ui::ProfilePic::small_size() / 2;
|
||||||
|
|
||||||
let note_offset = pfp_offset
|
let note_offset: i8 =
|
||||||
- ui::ProfilePic::medium_size() / 2.0
|
pfp_offset - ui::ProfilePic::medium_size() / 2 - ui::NoteView::expand_size() / 2;
|
||||||
- ui::NoteView::expand_size() / 2.0;
|
|
||||||
|
|
||||||
let selection = egui::Frame::none()
|
let selection = egui::Frame::none()
|
||||||
.outer_margin(egui::Margin::same(note_offset))
|
.outer_margin(egui::Margin::same(note_offset))
|
||||||
@@ -103,14 +102,14 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
|
|||||||
// Position the line right above the poster's profile pic in
|
// Position the line right above the poster's profile pic in
|
||||||
// the post box. Use the PostView's margin values to
|
// the post box. Use the PostView's margin values to
|
||||||
// determine this offset.
|
// determine this offset.
|
||||||
rect.min.x = avail_rect.min.x + pfp_offset;
|
rect.min.x = avail_rect.min.x + pfp_offset as f32;
|
||||||
|
|
||||||
// honestly don't know what the fuck I'm doing here. just trying
|
// honestly don't know what the fuck I'm doing here. just trying
|
||||||
// to get the line under the profile picture
|
// to get the line under the profile picture
|
||||||
rect.min.y = avail_rect.min.y
|
rect.min.y = avail_rect.min.y
|
||||||
+ (ui::ProfilePic::medium_size() / 2.0
|
+ (ui::ProfilePic::medium_size() as f32 / 2.0
|
||||||
+ ui::ProfilePic::medium_size()
|
+ ui::ProfilePic::medium_size() as f32
|
||||||
+ ui::NoteView::expand_size() * 2.0)
|
+ ui::NoteView::expand_size() as f32 * 2.0)
|
||||||
+ 1.0;
|
+ 1.0;
|
||||||
|
|
||||||
// For some reason we need to nudge the reply line's height a
|
// For some reason we need to nudge the reply line's height a
|
||||||
@@ -125,7 +124,7 @@ impl<'a, 'd> PostReplyView<'a, 'd> {
|
|||||||
3.0
|
3.0
|
||||||
};
|
};
|
||||||
|
|
||||||
rect.max.y = rect_before_post.max.y + ui::PostView::outer_margin() + nudge;
|
rect.max.y = rect_before_post.max.y + ui::PostView::outer_margin() as f32 + nudge;
|
||||||
|
|
||||||
ui.painter().vline(
|
ui.painter().vline(
|
||||||
rect.left(),
|
rect.left(),
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ fn singleline_textedit(data: &mut String) -> impl egui::Widget + '_ {
|
|||||||
TextEdit::singleline(data)
|
TextEdit::singleline(data)
|
||||||
.min_size(vec2(0.0, 40.0))
|
.min_size(vec2(0.0, 40.0))
|
||||||
.vertical_align(egui::Align::Center)
|
.vertical_align(egui::Align::Center)
|
||||||
.margin(Margin::symmetric(12.0, 10.0))
|
.margin(Margin::symmetric(12, 10))
|
||||||
.desired_width(f32::INFINITY)
|
.desired_width(f32::INFINITY)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,13 +150,13 @@ fn multiline_textedit(data: &mut String) -> impl egui::Widget + '_ {
|
|||||||
TextEdit::multiline(data)
|
TextEdit::multiline(data)
|
||||||
// .min_size(vec2(0.0, 40.0))
|
// .min_size(vec2(0.0, 40.0))
|
||||||
.vertical_align(egui::Align::TOP)
|
.vertical_align(egui::Align::TOP)
|
||||||
.margin(Margin::symmetric(12.0, 10.0))
|
.margin(Margin::symmetric(12, 10))
|
||||||
.desired_width(f32::INFINITY)
|
.desired_width(f32::INFINITY)
|
||||||
.desired_rows(1)
|
.desired_rows(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_frame(ui: &mut egui::Ui, contents: impl FnOnce(&mut egui::Ui)) {
|
fn in_frame(ui: &mut egui::Ui, contents: impl FnOnce(&mut egui::Ui)) {
|
||||||
egui::Frame::none().show(ui, |ui| {
|
egui::Frame::new().show(ui, |ui| {
|
||||||
ui.spacing_mut().item_spacing = egui::vec2(0.0, 8.0);
|
ui.spacing_mut().item_spacing = egui::vec2(0.0, 8.0);
|
||||||
contents(ui);
|
contents(ui);
|
||||||
});
|
});
|
||||||
@@ -164,7 +164,7 @@ fn in_frame(ui: &mut egui::Ui, contents: impl FnOnce(&mut egui::Ui)) {
|
|||||||
|
|
||||||
fn button(text: &str, width: f32) -> egui::Button<'static> {
|
fn button(text: &str, width: f32) -> egui::Button<'static> {
|
||||||
Button::new(text)
|
Button::new(text)
|
||||||
.rounding(Rounding::same(8.0))
|
.rounding(Rounding::same(8))
|
||||||
.min_size(vec2(width, 40.0))
|
.min_size(vec2(width, 40.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,14 +154,13 @@ impl<'a, 'd> ProfileView<'a, 'd> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if ui.add(copy_key_widget(&pfp_rect)).clicked() {
|
if ui.add(copy_key_widget(&pfp_rect)).clicked() {
|
||||||
ui.output_mut(|w| {
|
let to_copy = if let Some(bech) = self.pubkey.to_bech() {
|
||||||
w.copied_text = if let Some(bech) = self.pubkey.to_bech() {
|
|
||||||
bech
|
bech
|
||||||
} else {
|
} else {
|
||||||
error!("Could not convert Pubkey to bech");
|
error!("Could not convert Pubkey to bech");
|
||||||
String::new()
|
String::new()
|
||||||
}
|
};
|
||||||
});
|
ui.ctx().copy_text(to_copy)
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.accounts.contains_full_kp(self.pubkey) {
|
if self.accounts.contains_full_kp(self.pubkey) {
|
||||||
@@ -244,7 +243,7 @@ fn copy_key_widget(pfp_rect: &egui::Rect) -> impl egui::Widget + '_ {
|
|||||||
Sense::click(),
|
Sense::click(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let copy_key_rounding = Rounding::same(100.0);
|
let copy_key_rounding = Rounding::same(100);
|
||||||
let fill_color = if resp.hovered() {
|
let fill_color = if resp.hovered() {
|
||||||
ui.visuals().widgets.inactive.weak_bg_fill
|
ui.visuals().widgets.inactive.weak_bg_fill
|
||||||
} else {
|
} else {
|
||||||
@@ -281,7 +280,7 @@ fn edit_profile_button() -> impl egui::Widget + 'static {
|
|||||||
|
|
||||||
painter.rect_filled(
|
painter.rect_filled(
|
||||||
rect,
|
rect,
|
||||||
Rounding::same(8.0),
|
Rounding::same(8),
|
||||||
if resp.hovered() {
|
if resp.hovered() {
|
||||||
ui.visuals().widgets.active.bg_fill
|
ui.visuals().widgets.active.bg_fill
|
||||||
} else {
|
} else {
|
||||||
@@ -290,7 +289,7 @@ fn edit_profile_button() -> impl egui::Widget + 'static {
|
|||||||
);
|
);
|
||||||
painter.rect_stroke(
|
painter.rect_stroke(
|
||||||
rect.shrink(1.0),
|
rect.shrink(1.0),
|
||||||
Rounding::same(8.0),
|
Rounding::same(8),
|
||||||
if resp.hovered() {
|
if resp.hovered() {
|
||||||
ui.visuals().widgets.active.bg_stroke
|
ui.visuals().widgets.active.bg_stroke
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ impl egui::Widget for ProfilePic<'_, '_> {
|
|||||||
|
|
||||||
impl<'cache, 'url> ProfilePic<'cache, 'url> {
|
impl<'cache, 'url> ProfilePic<'cache, 'url> {
|
||||||
pub fn new(cache: &'cache mut Images, url: &'url str) -> Self {
|
pub fn new(cache: &'cache mut Images, url: &'url str) -> Self {
|
||||||
let size = Self::default_size();
|
let size = Self::default_size() as f32;
|
||||||
ProfilePic {
|
ProfilePic {
|
||||||
cache,
|
cache,
|
||||||
url,
|
url,
|
||||||
@@ -48,18 +48,18 @@ impl<'cache, 'url> ProfilePic<'cache, 'url> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn default_size() -> f32 {
|
pub fn default_size() -> i8 {
|
||||||
38.0
|
38
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn medium_size() -> f32 {
|
pub fn medium_size() -> i8 {
|
||||||
32.0
|
32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn small_size() -> f32 {
|
pub fn small_size() -> i8 {
|
||||||
24.0
|
24
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@@ -194,7 +194,7 @@ mod preview {
|
|||||||
let (rect, size, _resp) = ui::anim::hover_expand(
|
let (rect, size, _resp) = ui::anim::hover_expand(
|
||||||
ui,
|
ui,
|
||||||
egui::Id::new(profile.key().unwrap()),
|
egui::Id::new(profile.key().unwrap()),
|
||||||
ui::ProfilePic::default_size(),
|
ui::ProfilePic::default_size() as f32,
|
||||||
expand_size,
|
expand_size,
|
||||||
anim_speed,
|
anim_speed,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ impl<'a, 'cache> SimpleProfilePreview<'a, 'cache> {
|
|||||||
|
|
||||||
impl egui::Widget for SimpleProfilePreview<'_, '_> {
|
impl egui::Widget for SimpleProfilePreview<'_, '_> {
|
||||||
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
fn ui(self, ui: &mut egui::Ui) -> egui::Response {
|
||||||
Frame::none()
|
Frame::new()
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
ui.add(ProfilePic::new(self.cache, get_profile_url(self.profile)).size(48.0));
|
ui.add(ProfilePic::new(self.cache, get_profile_url(self.profile)).size(48.0));
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
|
|||||||
@@ -76,10 +76,10 @@ impl<'a> RelayView<'a> {
|
|||||||
relay_frame(ui).show(ui, |ui| {
|
relay_frame(ui).show(ui, |ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
|
ui.with_layout(Layout::left_to_right(Align::Center), |ui| {
|
||||||
Frame::none()
|
Frame::new()
|
||||||
// This frame is needed to add margin because the label will be added to the outer frame first and centered vertically before the connection status is added so the vertical centering isn't accurate.
|
// This frame is needed to add margin because the label will be added to the outer frame first and centered vertically before the connection status is added so the vertical centering isn't accurate.
|
||||||
// TODO: remove this hack and actually center the url & status at the same time
|
// TODO: remove this hack and actually center the url & status at the same time
|
||||||
.inner_margin(Margin::symmetric(0.0, 4.0))
|
.inner_margin(Margin::symmetric(0, 4))
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
egui::ScrollArea::horizontal()
|
egui::ScrollArea::horizontal()
|
||||||
.id_salt(index)
|
.id_salt(index)
|
||||||
@@ -159,7 +159,7 @@ impl<'a> RelayView<'a> {
|
|||||||
.vertical_align(Align::Center)
|
.vertical_align(Align::Center)
|
||||||
.desired_width(f32::INFINITY)
|
.desired_width(f32::INFINITY)
|
||||||
.min_size(Vec2::new(0.0, 40.0))
|
.min_size(Vec2::new(0.0, 40.0))
|
||||||
.margin(Margin::same(12.0));
|
.margin(Margin::same(12));
|
||||||
ui.add(text_edit);
|
ui.add(text_edit);
|
||||||
ui.add_space(8.0);
|
ui.add_space(8.0);
|
||||||
if ui
|
if ui
|
||||||
@@ -218,8 +218,8 @@ fn delete_button(_dark_mode: bool) -> egui::Button<'static> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn relay_frame(ui: &mut Ui) -> Frame {
|
fn relay_frame(ui: &mut Ui) -> Frame {
|
||||||
Frame::none()
|
Frame::new()
|
||||||
.inner_margin(Margin::same(8.0))
|
.inner_margin(Margin::same(8))
|
||||||
.rounding(ui.style().noninteractive().rounding)
|
.rounding(ui.style().noninteractive().rounding)
|
||||||
.stroke(ui.style().visuals.noninteractive().bg_stroke)
|
.stroke(ui.style().visuals.noninteractive().bg_stroke)
|
||||||
}
|
}
|
||||||
@@ -238,10 +238,10 @@ fn show_connection_status(ui: &mut Ui, status: RelayStatus) {
|
|||||||
RelayStatus::Disconnected => "Not Connected",
|
RelayStatus::Disconnected => "Not Connected",
|
||||||
};
|
};
|
||||||
|
|
||||||
let frame = Frame::none()
|
let frame = Frame::new()
|
||||||
.rounding(Rounding::same(100.0))
|
.rounding(Rounding::same(100))
|
||||||
.fill(bg_color)
|
.fill(bg_color)
|
||||||
.inner_margin(Margin::symmetric(12.0, 4.0));
|
.inner_margin(Margin::symmetric(12, 4));
|
||||||
|
|
||||||
frame.show(ui, |ui| {
|
frame.show(ui, |ui| {
|
||||||
ui.label(RichText::new(label_text).color(fg_color));
|
ui.label(RichText::new(label_text).color(fg_color));
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ impl<'a> DesktopSidePanel<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn show(&mut self, ui: &mut egui::Ui) -> SidePanelResponse {
|
pub fn show(&mut self, ui: &mut egui::Ui) -> SidePanelResponse {
|
||||||
let mut frame = egui::Frame::none().inner_margin(Margin::same(8.0));
|
let mut frame = egui::Frame::new().inner_margin(Margin::same(8));
|
||||||
|
|
||||||
if !ui.visuals().dark_mode {
|
if !ui.visuals().dark_mode {
|
||||||
frame = frame.fill(colors::ALMOST_WHITE);
|
frame = frame.fill(colors::ALMOST_WHITE);
|
||||||
|
|||||||
@@ -60,9 +60,7 @@ impl<'a> SupportView<'a> {
|
|||||||
ui.add(Label::new("Press the button below to copy your most recent logs to your system's clipboard. Then paste it into your email.").wrap());
|
ui.add(Label::new("Press the button below to copy your most recent logs to your system's clipboard. Then paste it into your email.").wrap());
|
||||||
ui.allocate_ui_with_layout(size, Layout::top_down(egui::Align::Center), |ui| {
|
ui.allocate_ui_with_layout(size, Layout::top_down(egui::Align::Center), |ui| {
|
||||||
if ui.add(copy_button).clicked() {
|
if ui.add(copy_button).clicked() {
|
||||||
ui.output_mut(|w| {
|
ui.ctx().copy_text(logs.to_string());
|
||||||
w.copied_text = logs.to_string();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user