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