@@ -744,9 +744,14 @@ impl Slot {
744
744
if cx. debug {
745
745
ui. label ( format ! ( "Item UID: {}" , item_meta. item_uid. 0 ) ) ;
746
746
}
747
- for ( field_id, field) in & item_meta. fields {
747
+ for ( field_id, field, color ) in & item_meta. fields {
748
748
let name = config. field_schema . get_name ( * field_id) . unwrap ( ) ;
749
- ui. label ( format ! ( "{}" , FieldWithName ( name, field) ) ) ;
749
+ let text = format ! ( "{}" , FieldWithName ( name, field) ) ;
750
+ if let Some ( color) = color {
751
+ ui. label ( RichText :: new ( text) . color ( * color) ) ;
752
+ } else {
753
+ ui. label ( text) ;
754
+ }
750
755
}
751
756
ui. label ( "(Click to show details.)" ) ;
752
757
} ) ;
@@ -1266,7 +1271,7 @@ impl SearchState {
1266
1271
let field = self . search_field ;
1267
1272
if field == self . title_field {
1268
1273
self . is_string_match ( & item. title )
1269
- } else if let Some ( ( _, value) ) = item. fields . iter ( ) . find ( |( x, _) | * x == field) {
1274
+ } else if let Some ( ( _, value, _ ) ) = item. fields . iter ( ) . find ( |( x, _ , _) | * x == field) {
1270
1275
self . is_field_match ( value)
1271
1276
} else {
1272
1277
false
@@ -2339,16 +2344,25 @@ impl ProfApp {
2339
2344
2340
2345
fn render_field_as_ui (
2341
2346
field : & Field ,
2347
+ color : Option < Color32 > ,
2342
2348
mode : ItemLinkNavigationMode ,
2343
2349
ui : & mut egui:: Ui ,
2344
2350
) -> Option < ( ItemLocator , Interval ) > {
2345
2351
let mut result = None ;
2346
2352
let label = |ui : & mut egui:: Ui , v| {
2347
- ui. add ( egui:: Label :: new ( v) . wrap ( true ) ) ;
2353
+ if let Some ( color) = color {
2354
+ ui. add ( egui:: Label :: new ( RichText :: new ( v) . color ( color) ) . wrap ( true ) ) ;
2355
+ } else {
2356
+ ui. add ( egui:: Label :: new ( v) . wrap ( true ) ) ;
2357
+ }
2348
2358
} ;
2349
2359
let label_button = |ui : & mut egui:: Ui , v, b| {
2350
2360
label ( ui, v) ;
2351
- ui. button ( b) . clicked ( )
2361
+ if let Some ( color) = color {
2362
+ ui. button ( RichText :: new ( b) . color ( color) ) . clicked ( )
2363
+ } else {
2364
+ ui. button ( b) . clicked ( )
2365
+ }
2352
2366
} ;
2353
2367
match field {
2354
2368
Field :: I64 ( value) => label ( ui, & format ! ( "{value}" ) ) ,
@@ -2376,7 +2390,7 @@ impl ProfApp {
2376
2390
ui. vertical ( |ui| {
2377
2391
for f in fields {
2378
2392
ui. horizontal ( |ui| {
2379
- if let Some ( x) = Self :: render_field_as_ui ( f, mode, ui) {
2393
+ if let Some ( x) = Self :: render_field_as_ui ( f, color , mode, ui) {
2380
2394
result = Some ( x) ;
2381
2395
}
2382
2396
} ) ;
@@ -2411,7 +2425,7 @@ impl ProfApp {
2411
2425
. column ( Column :: auto ( ) )
2412
2426
. column ( Column :: remainder ( ) )
2413
2427
. body ( |mut body| {
2414
- let mut show_row = |k : & str , field : & Field | {
2428
+ let mut show_row = |k : & str , field : & Field , color : Option < Color32 > | {
2415
2429
// We need to manually work out the height of the labels
2416
2430
// so that the table knows how large to make each row.
2417
2431
let width = body. widths ( ) [ 1 ] ;
@@ -2422,24 +2436,29 @@ impl ProfApp {
2422
2436
2423
2437
body. row ( height, |mut row| {
2424
2438
row. col ( |ui| {
2425
- ui. strong ( k) ;
2439
+ if let Some ( color) = color {
2440
+ ui. label ( RichText :: new ( k) . color ( color) . strong ( ) ) ;
2441
+ } else {
2442
+ ui. strong ( k) ;
2443
+ }
2426
2444
} ) ;
2427
2445
row. col ( |ui| {
2428
- if let Some ( x) = Self :: render_field_as_ui ( field, cx. item_link_mode , ui)
2446
+ if let Some ( x) =
2447
+ Self :: render_field_as_ui ( field, color, cx. item_link_mode , ui)
2429
2448
{
2430
2449
result = Some ( x) ;
2431
2450
}
2432
2451
} ) ;
2433
2452
} ) ;
2434
2453
} ;
2435
2454
2436
- show_row ( "Title" , & Field :: String ( item_meta. title . to_string ( ) ) ) ;
2455
+ show_row ( "Title" , & Field :: String ( item_meta. title . to_string ( ) ) , None ) ;
2437
2456
if cx. debug {
2438
- show_row ( "Item UID" , & Field :: U64 ( item_meta. item_uid . 0 ) ) ;
2457
+ show_row ( "Item UID" , & Field :: U64 ( item_meta. item_uid . 0 ) , None ) ;
2439
2458
}
2440
- for ( field_id, field) in & item_meta. fields {
2459
+ for ( field_id, field, color ) in & item_meta. fields {
2441
2460
let name = field_schema. get_name ( * field_id) . unwrap ( ) ;
2442
- show_row ( name, field) ;
2461
+ show_row ( name, field, * color ) ;
2443
2462
}
2444
2463
} ) ;
2445
2464
ui. with_layout ( egui:: Layout :: top_down ( egui:: Align :: Center ) , |ui| {
0 commit comments