ui: remove show_pointer
This can just be achieved by on_hover_cursor Didn't realize this. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -422,22 +422,21 @@ impl Chrome {
|
||||
ui.add_space(16.0);
|
||||
//let dark_mode = ui.ctx().style().visuals.dark_mode;
|
||||
{
|
||||
let col_resp = columns_button(ui);
|
||||
if col_resp.clicked() {
|
||||
if columns_button(ui)
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand)
|
||||
.clicked()
|
||||
{
|
||||
self.active = 0;
|
||||
} else if col_resp.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
}
|
||||
ui.add_space(32.0);
|
||||
|
||||
if let Some(dave) = self.get_dave() {
|
||||
let rect = dave_sidebar_rect(ui);
|
||||
let dave_resp = dave_button(dave.avatar_mut(), ui, rect);
|
||||
let dave_resp = dave_button(dave.avatar_mut(), ui, rect)
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if dave_resp.clicked() {
|
||||
self.switch_to_dave();
|
||||
} else if dave_resp.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -712,17 +711,15 @@ fn bottomup_sidebar(
|
||||
) -> Option<ChromePanelAction> {
|
||||
ui.add_space(8.0);
|
||||
|
||||
let pfp_resp = pfp_button(ctx, ui);
|
||||
let settings_resp = settings_button(ui);
|
||||
let pfp_resp = pfp_button(ctx, ui).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
let settings_resp = settings_button(ui).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
let theme_action = match ui.ctx().theme() {
|
||||
egui::Theme::Dark => {
|
||||
let resp = ui
|
||||
.add(Button::new("☀").frame(false))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand)
|
||||
.on_hover_text("Switch to light mode");
|
||||
if resp.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
if resp.clicked() {
|
||||
Some(ChromePanelAction::SaveTheme(ThemePreference::Light))
|
||||
} else {
|
||||
@@ -732,10 +729,8 @@ fn bottomup_sidebar(
|
||||
egui::Theme::Light => {
|
||||
let resp = ui
|
||||
.add(Button::new("🌙").frame(false))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand)
|
||||
.on_hover_text("Switch to dark mode");
|
||||
if resp.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
if resp.clicked() {
|
||||
Some(ChromePanelAction::SaveTheme(ThemePreference::Dark))
|
||||
} else {
|
||||
@@ -744,9 +739,11 @@ fn bottomup_sidebar(
|
||||
}
|
||||
};
|
||||
|
||||
let support_resp = support_button(ui);
|
||||
let support_resp = support_button(ui).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
let wallet_resp = ui.add(wallet_button());
|
||||
let wallet_resp = ui
|
||||
.add(wallet_button())
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
if ctx.args.debug {
|
||||
ui.weak(format!("{}", ctx.frame_history.fps() as i32));
|
||||
@@ -776,14 +773,6 @@ fn bottomup_sidebar(
|
||||
}
|
||||
}
|
||||
|
||||
if pfp_resp.hovered()
|
||||
|| settings_resp.hovered()
|
||||
|| support_resp.hovered()
|
||||
|| wallet_resp.hovered()
|
||||
{
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
|
||||
if pfp_resp.clicked() {
|
||||
Some(ChromePanelAction::Account)
|
||||
} else if settings_resp.clicked() {
|
||||
|
||||
@@ -604,10 +604,9 @@ fn hovering_post_button(
|
||||
let darkmode = ui.ctx().style().visuals.dark_mode;
|
||||
|
||||
// only show the compose button on profile pages and on home
|
||||
let compose_resp = ui.put(rect, ui::post::compose_note_button(darkmode));
|
||||
if compose_resp.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
let compose_resp = ui
|
||||
.put(rect, ui::post::compose_note_button(darkmode))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
if compose_resp.clicked() && !app.columns(app_ctx.accounts).columns().is_empty() {
|
||||
// just use the some side panel logic as the desktop
|
||||
DesktopSidePanel::perform_action(
|
||||
|
||||
@@ -76,14 +76,12 @@ impl<'a> NavTitle<'a> {
|
||||
ui.spacing_mut().item_spacing.x = item_spacing;
|
||||
|
||||
let chev_x = 8.0;
|
||||
let back_button_resp =
|
||||
prev(self.routes).map(|r| self.back_button(ui, r, egui::Vec2::new(chev_x, 15.0)));
|
||||
let back_button_resp = prev(self.routes).map(|r| {
|
||||
self.back_button(ui, r, egui::Vec2::new(chev_x, 15.0))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand)
|
||||
});
|
||||
|
||||
if let Some(back_resp) = &back_button_resp {
|
||||
if back_resp.hovered() || back_resp.clicked() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
} else {
|
||||
if back_button_resp.is_none() {
|
||||
// add some space where chevron would have been. this makes the ui
|
||||
// less bumpy when navigating
|
||||
ui.add_space(chev_x + item_spacing);
|
||||
@@ -216,7 +214,9 @@ impl<'a> NavTitle<'a> {
|
||||
// returns the column index to switch to, if any
|
||||
fn move_button_section(&mut self, ui: &mut egui::Ui) -> Option<usize> {
|
||||
let cur_id = ui.id().with("move");
|
||||
let mut move_resp = ui.add(grab_button());
|
||||
let mut move_resp = ui
|
||||
.add(grab_button())
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
// showing the hover text while showing the move tooltip causes some weird visuals
|
||||
if ui.data(|d| d.get_temp::<bool>(cur_id).is_none()) {
|
||||
@@ -235,8 +235,6 @@ impl<'a> NavTitle<'a> {
|
||||
d.insert_temp(cur_id, true);
|
||||
}
|
||||
});
|
||||
} else if move_resp.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
|
||||
ui.data(|d| d.get_temp(cur_id)).and_then(|val| {
|
||||
@@ -597,11 +595,9 @@ impl<'a> NavTitle<'a> {
|
||||
top: &Route,
|
||||
pfp_size: f32,
|
||||
) -> Option<TitleResponse> {
|
||||
let pfp_r = self.title_pfp(ui, top, pfp_size);
|
||||
|
||||
if pfp_r.as_ref().is_some_and(|r| r.hovered()) {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
let pfp_r = self
|
||||
.title_pfp(ui, top, pfp_size)
|
||||
.map(|r| r.on_hover_cursor(egui::CursorIcon::PointingHand));
|
||||
|
||||
self.title_label(ui, top);
|
||||
|
||||
|
||||
@@ -95,7 +95,9 @@ impl<'a> DesktopSidePanel<'a> {
|
||||
// ui.add_space(24.0);
|
||||
//}
|
||||
|
||||
let compose_resp = ui.add(crate::ui::post::compose_note_button(dark_mode));
|
||||
let compose_resp = ui
|
||||
.add(crate::ui::post::compose_note_button(dark_mode))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
let search_resp = ui.add(search_button());
|
||||
let column_resp = ui.add(add_column_button());
|
||||
|
||||
@@ -129,9 +131,6 @@ impl<'a> DesktopSidePanel<'a> {
|
||||
SidePanelAction::ComposeNote,
|
||||
compose_resp,
|
||||
))
|
||||
} else if compose_resp.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
None
|
||||
} else if search_resp.clicked() {
|
||||
Some(InnerResponse::new(SidePanelAction::Search, search_resp))
|
||||
} else if column_resp.clicked() {
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::timeline::{TimelineCache, TimelineKind, TimelineTab, ViewFilter};
|
||||
use notedeck::{note::root_note_id_from_selected_id, NoteAction, NoteContext, ScrollInfo};
|
||||
use notedeck_ui::{
|
||||
anim::{AnimationHelper, ICON_EXPANSION_MULTIPLE},
|
||||
show_pointer, NoteOptions, NoteView,
|
||||
NoteOptions, NoteView,
|
||||
};
|
||||
|
||||
pub struct TimelineView<'a, 'd> {
|
||||
@@ -127,6 +127,7 @@ fn timeline_ui(
|
||||
.fixed_pos(top_button_pos)
|
||||
.show(ui.ctx(), |ui| Some(ui.add(goto_top_button(top_button_pos))))
|
||||
.inner
|
||||
.map(|r| r.on_hover_cursor(egui::CursorIcon::PointingHand))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@@ -143,12 +144,8 @@ fn timeline_ui(
|
||||
scroll_area = scroll_area.vertical_scroll_offset(offset);
|
||||
}
|
||||
|
||||
if let Some(goto_top_resp) = goto_top_resp {
|
||||
if goto_top_resp.clicked() {
|
||||
scroll_area = scroll_area.vertical_scroll_offset(0.0);
|
||||
} else if goto_top_resp.hovered() {
|
||||
show_pointer(ui);
|
||||
}
|
||||
if goto_top_resp.is_some_and(|r| r.clicked()) {
|
||||
scroll_area = scroll_area.vertical_scroll_offset(0.0);
|
||||
}
|
||||
|
||||
// chrome can ask to scroll to top as well via an app option
|
||||
|
||||
@@ -468,15 +468,15 @@ fn top_buttons_ui(app_ctx: &mut AppContext, ui: &mut egui::Ui) -> Option<DaveAct
|
||||
rect.set_width(32.0);
|
||||
|
||||
let txn = Transaction::new(app_ctx.ndb).unwrap();
|
||||
let r = ui.put(
|
||||
rect,
|
||||
&mut pfp_button(&txn, app_ctx.accounts, app_ctx.img_cache, app_ctx.ndb),
|
||||
);
|
||||
let r = ui
|
||||
.put(
|
||||
rect,
|
||||
&mut pfp_button(&txn, app_ctx.accounts, app_ctx.img_cache, app_ctx.ndb),
|
||||
)
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
if r.clicked() {
|
||||
action = Some(DaveAction::ToggleChrome);
|
||||
} else if r.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
|
||||
rect = rect.translate(egui::vec2(30.0, 0.0));
|
||||
@@ -484,8 +484,6 @@ fn top_buttons_ui(app_ctx: &mut AppContext, ui: &mut egui::Ui) -> Option<DaveAct
|
||||
|
||||
if r.clicked() {
|
||||
action = Some(DaveAction::NewChat);
|
||||
} else if r.hovered() {
|
||||
notedeck_ui::show_pointer(ui);
|
||||
}
|
||||
|
||||
action
|
||||
|
||||
@@ -58,7 +58,3 @@ pub fn hline_with_width(ui: &egui::Ui, range: egui::Rangef) {
|
||||
let stroke = ui.style().visuals.widgets.noninteractive.bg_stroke;
|
||||
ui.painter().hline(range, resize_y, stroke);
|
||||
}
|
||||
|
||||
pub fn show_pointer(ui: &egui::Ui) {
|
||||
ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{show_pointer, ProfilePreview};
|
||||
use crate::ProfilePreview;
|
||||
use egui::Sense;
|
||||
use enostr::Pubkey;
|
||||
use nostrdb::{Ndb, Transaction};
|
||||
@@ -75,18 +75,16 @@ fn mention_ui(
|
||||
get_display_name(profile.as_ref()).username_or_displayname()
|
||||
);
|
||||
|
||||
let resp = ui.add(
|
||||
egui::Label::new(egui::RichText::new(name).color(link_color).size(size))
|
||||
.sense(Sense::click())
|
||||
.selectable(selectable),
|
||||
);
|
||||
let resp = ui
|
||||
.add(
|
||||
egui::Label::new(egui::RichText::new(name).color(link_color).size(size))
|
||||
.sense(Sense::click())
|
||||
.selectable(selectable),
|
||||
)
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
let note_action = if resp.clicked() {
|
||||
show_pointer(ui);
|
||||
Some(NoteAction::Profile(Pubkey::new(*pk)))
|
||||
} else if resp.hovered() {
|
||||
show_pointer(ui);
|
||||
None
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
@@ -189,12 +189,12 @@ pub fn render_note_contents(
|
||||
},
|
||||
|
||||
BlockType::Hashtag => {
|
||||
let resp = ui.colored_label(link_color, format!("#{}", block.as_str()));
|
||||
let resp = ui
|
||||
.colored_label(link_color, format!("#{}", block.as_str()))
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
if resp.clicked() {
|
||||
note_action = Some(NoteAction::Hashtag(block.as_str().to_string()));
|
||||
} else if resp.hovered() {
|
||||
crate::show_pointer(ui);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -669,14 +669,12 @@ fn show_actual_pfp(
|
||||
anim_speed,
|
||||
);
|
||||
|
||||
let resp = resp.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
let mut pfp = ProfilePic::new(images, pic).size(size);
|
||||
let pfp_resp = ui.put(rect, &mut pfp);
|
||||
let action = pfp.action;
|
||||
|
||||
if resp.hovered() || resp.clicked() {
|
||||
crate::show_pointer(ui);
|
||||
}
|
||||
|
||||
pfp_resp.on_hover_ui_at_pointer(|ui| {
|
||||
ui.set_max_width(300.0);
|
||||
ui.add(ProfilePreview::new(profile.as_ref().unwrap(), images));
|
||||
@@ -768,20 +766,17 @@ fn render_note_actionbar(
|
||||
note_key: NoteKey,
|
||||
) -> egui::InnerResponse<Option<NoteAction>> {
|
||||
ui.horizontal(|ui| 's: {
|
||||
let reply_resp = reply_button(ui, note_key);
|
||||
let quote_resp = quote_repost_button(ui, note_key);
|
||||
let reply_resp = reply_button(ui, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
let quote_resp =
|
||||
quote_repost_button(ui, note_key).on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
let to_noteid = |id: &[u8; 32]| NoteId::new(*id);
|
||||
if reply_resp.clicked() {
|
||||
break 's Some(NoteAction::Reply(to_noteid(note_id)));
|
||||
} else if reply_resp.hovered() {
|
||||
crate::show_pointer(ui);
|
||||
}
|
||||
|
||||
if quote_resp.clicked() {
|
||||
break 's Some(NoteAction::Quote(to_noteid(note_id)));
|
||||
} else if quote_resp.hovered() {
|
||||
crate::show_pointer(ui);
|
||||
}
|
||||
|
||||
let Some(Zapper { zaps, cur_acc }) = zapper else {
|
||||
@@ -815,11 +810,8 @@ fn render_note_actionbar(
|
||||
ui.add(x_button(rect)).on_hover_text(err.to_string())
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if zap_resp.hovered() {
|
||||
crate::show_pointer(ui);
|
||||
}
|
||||
.on_hover_cursor(egui::CursorIcon::PointingHand);
|
||||
|
||||
if zap_resp.secondary_clicked() {
|
||||
break 's Some(NoteAction::Zap(ZapAction::CustomizeAmount(target)));
|
||||
|
||||
Reference in New Issue
Block a user