title bar
add title bar to columns with title specific to the column type. also add column deletion button Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -60,6 +60,27 @@ impl AnimationHelper {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_rect(
|
||||
ui: &mut egui::Ui,
|
||||
animation_name: impl std::hash::Hash,
|
||||
animation_rect: egui::Rect,
|
||||
) -> Self {
|
||||
let id = ui.id().with(animation_name);
|
||||
let response = ui.allocate_rect(animation_rect, Sense::click());
|
||||
|
||||
let animation_progress =
|
||||
ui.ctx()
|
||||
.animate_bool_with_time(id, response.hovered(), ANIM_SPEED);
|
||||
|
||||
Self {
|
||||
rect: animation_rect,
|
||||
center: animation_rect.center(),
|
||||
response,
|
||||
animation_progress,
|
||||
expansion_multiple: ICON_EXPANSION_MULTIPLE,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn scale_1d_pos(&self, min_object_size: f32) -> f32 {
|
||||
let max_object_size = min_object_size * self.expansion_multiple;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::{colors, images, DisplayName};
|
||||
use egui::load::TexturePoll;
|
||||
use egui::{Frame, RichText, Sense, Widget};
|
||||
use egui_extras::Size;
|
||||
use enostr::NoteId;
|
||||
use nostrdb::ProfileRecord;
|
||||
|
||||
pub struct ProfilePreview<'a, 'cache> {
|
||||
@@ -256,3 +257,28 @@ fn about_section_widget<'a>(profile: &'a ProfileRecord<'a>) -> impl egui::Widget
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_display_name_as_string(profile: Option<&'_ ProfileRecord<'_>>) -> String {
|
||||
let display_name = get_display_name(profile);
|
||||
match display_name {
|
||||
DisplayName::One(n) => n.to_string(),
|
||||
DisplayName::Both { display_name, .. } => display_name.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_profile_displayname_string(ndb: &nostrdb::Ndb, pk: &enostr::Pubkey) -> String {
|
||||
let txn = nostrdb::Transaction::new(ndb).expect("Transaction should have worked");
|
||||
let profile = ndb.get_profile_by_pubkey(&txn, pk.bytes()).ok();
|
||||
get_display_name_as_string(profile.as_ref())
|
||||
}
|
||||
|
||||
pub fn get_note_users_displayname_string(ndb: &nostrdb::Ndb, id: &NoteId) -> String {
|
||||
let txn = nostrdb::Transaction::new(ndb).expect("Transaction should have worked");
|
||||
let note = ndb.get_note_by_id(&txn, id.bytes());
|
||||
let profile = if let Ok(note) = note {
|
||||
ndb.get_profile_by_pubkey(&txn, note.pubkey()).ok()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
get_display_name_as_string(profile.as_ref())
|
||||
}
|
||||
|
||||
@@ -370,9 +370,7 @@ mod preview {
|
||||
impl DesktopSidePanelPreview {
|
||||
fn new() -> Self {
|
||||
let mut app = test_data::test_app();
|
||||
app.columns
|
||||
.columns_mut()
|
||||
.push(Column::new(vec![Route::accounts()]));
|
||||
app.columns.add_column(Column::new(vec![Route::accounts()]));
|
||||
DesktopSidePanelPreview { app }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user