@@ -12,7 +12,7 @@ use crate::{
12
12
} ,
13
13
} ;
14
14
15
- use egui:: { pos2, Color32 , Stroke } ;
15
+ use egui:: { pos2, Color32 , RichText , Stroke } ;
16
16
use enostr:: Pubkey ;
17
17
use nostrdb:: { Ndb , Transaction } ;
18
18
@@ -56,7 +56,6 @@ impl<'a> NavTitle<'a> {
56
56
) -> Option < RenderNavAction > {
57
57
let icon_width = 32.0 ;
58
58
let padding_external = 16.0 ;
59
- let padding_internal = 8.0 ;
60
59
let has_back = prev ( self . routes ) . is_some ( ) ;
61
60
62
61
let ( spacing_rect, titlebar_rect) = allocated_response
@@ -77,20 +76,7 @@ impl<'a> NavTitle<'a> {
77
76
( allocated_response, None )
78
77
} ;
79
78
80
- self . title (
81
- ui,
82
- self . routes . last ( ) . unwrap ( ) ,
83
- titlebar_resp. rect ,
84
- icon_width,
85
- if has_back {
86
- padding_internal
87
- } else {
88
- padding_external
89
- } ,
90
- ) ;
91
-
92
- let delete_button_resp =
93
- self . delete_column_button ( ui, titlebar_resp, icon_width, padding_external) ;
79
+ let delete_button_resp = self . title ( ui, self . routes . last ( ) . unwrap ( ) ) ;
94
80
95
81
if delete_button_resp. clicked ( ) {
96
82
Some ( RenderNavAction :: RemoveColumn )
@@ -143,7 +129,6 @@ impl<'a> NavTitle<'a> {
143
129
fn delete_column_button (
144
130
& self ,
145
131
ui : & mut egui:: Ui ,
146
- allocation_response : egui:: Response ,
147
132
icon_width : f32 ,
148
133
padding : f32 ,
149
134
) -> egui:: Response {
@@ -157,26 +142,15 @@ impl<'a> NavTitle<'a> {
157
142
} ;
158
143
let img = egui:: Image :: new ( img_data) . max_width ( img_size) ;
159
144
160
- let button_rect = {
161
- let titlebar_rect = allocation_response. rect ;
162
- let titlebar_width = titlebar_rect. width ( ) ;
163
- let titlebar_center = titlebar_rect. center ( ) ;
164
- let button_center_y = titlebar_center. y ;
165
- let button_center_x =
166
- titlebar_center. x + ( titlebar_width / 2.0 ) - ( max_size / 2.0 ) - padding;
167
- egui:: Rect :: from_center_size (
168
- pos2 ( button_center_x, button_center_y) ,
169
- egui:: vec2 ( max_size, max_size) ,
170
- )
171
- } ;
172
-
173
- let helper = AnimationHelper :: new_from_rect ( ui, "delete-column-button" , button_rect) ;
145
+ let helper =
146
+ AnimationHelper :: new ( ui, "delete-column-button" , egui:: vec2 ( max_size, max_size) ) ;
174
147
175
148
let cur_img_size = helper. scale_1d_pos ( img_size) ;
176
149
177
150
let animation_rect = helper. get_animation_rect ( ) ;
178
151
let animation_resp = helper. take_animation_response ( ) ;
179
- if allocation_response. union ( animation_resp. clone ( ) ) . hovered ( ) {
152
+
153
+ if animation_resp. hovered ( ) {
180
154
img. paint_at ( ui, animation_rect. shrink ( ( max_size - cur_img_size) / 2.0 ) ) ;
181
155
}
182
156
@@ -217,7 +191,7 @@ impl<'a> NavTitle<'a> {
217
191
}
218
192
219
193
fn title_pfp ( & mut self , ui : & mut egui:: Ui , top : & Route ) {
220
- let pfp_size = 48 .0;
194
+ let pfp_size = 32 .0;
221
195
match top {
222
196
Route :: Timeline ( tlr) => match tlr {
223
197
TimelineRoute :: Timeline ( tlid) => {
@@ -249,44 +223,23 @@ impl<'a> NavTitle<'a> {
249
223
}
250
224
}
251
225
252
- fn title (
253
- & mut self ,
254
- ui : & mut egui:: Ui ,
255
- top : & Route ,
256
- titlebar_rect : egui:: Rect ,
257
- icon_width : f32 ,
258
- padding : f32 ,
259
- ) {
260
- let painter = ui. painter_at ( titlebar_rect) ;
261
-
262
- self . title_pfp ( ui, top) ;
263
-
264
- let font = egui:: FontId :: new (
265
- get_font_size ( ui. ctx ( ) , & NotedeckTextStyle :: Body ) ,
266
- egui:: FontFamily :: Name ( NamedFontFamily :: Bold . as_str ( ) . into ( ) ) ,
267
- ) ;
268
-
269
- let max_title_width = titlebar_rect. width ( ) - icon_width - padding * 2. ;
226
+ fn title ( & mut self , ui : & mut egui:: Ui , top : & Route ) -> egui:: Response {
227
+ ui. horizontal ( |ui| {
228
+ ui. spacing_mut ( ) . item_spacing . x = 10.0 ;
270
229
271
- let title_galley = ui. fonts ( |f| {
272
- f. layout (
273
- top. to_string ( ) ,
274
- font,
275
- ui. visuals ( ) . text_color ( ) ,
276
- max_title_width,
277
- )
278
- } ) ;
279
-
280
- let pos = {
281
- let titlebar_center = titlebar_rect. center ( ) ;
282
- let text_height = title_galley. rect . height ( ) ;
230
+ self . title_pfp ( ui, top) ;
283
231
284
- let galley_pos_x = titlebar_rect . left ( ) + padding ;
285
- let galley_pos_y = titlebar_center . y - ( text_height / 2. ) ;
286
- pos2 ( galley_pos_x , galley_pos_y )
287
- } ;
232
+ ui . label (
233
+ RichText :: new ( top . title ( self . columns ) )
234
+ . text_style ( NotedeckTextStyle :: Body . text_style ( ) ) ,
235
+ ) ;
288
236
289
- painter. galley ( pos, title_galley, Color32 :: WHITE ) ;
237
+ ui. with_layout ( egui:: Layout :: right_to_left ( egui:: Align :: Center ) , |ui| {
238
+ self . delete_column_button ( ui, 32.0 , 10.0 )
239
+ } )
240
+ . inner
241
+ } )
242
+ . inner
290
243
}
291
244
}
292
245
0 commit comments