@@ -569,7 +569,7 @@ impl<'a> Recorder<'a> {
569
569
file_key,
570
570
tristate_box : TristateBox {
571
571
use_unicode : self . use_unicode ,
572
- id : ComponentId :: TristateBox ,
572
+ id : ComponentId :: TristateBox ( SelectionKey :: File ( file_key ) ) ,
573
573
tristate : file_tristate,
574
574
is_focused,
575
575
} ,
@@ -600,7 +600,9 @@ impl<'a> Recorder<'a> {
600
600
section_key,
601
601
tristate_box : TristateBox {
602
602
use_unicode : self . use_unicode ,
603
- id : ComponentId :: TristateBox ,
603
+ id : ComponentId :: TristateBox ( SelectionKey :: Section (
604
+ section_key,
605
+ ) ) ,
604
606
tristate : section_tristate,
605
607
is_focused : match self . selection_key {
606
608
SelectionKey :: None
@@ -1036,9 +1038,12 @@ impl<'a> Recorder<'a> {
1036
1038
match component_id {
1037
1039
ComponentId :: App | ComponentId :: QuitDialog => StateUpdate :: None ,
1038
1040
ComponentId :: SelectableItem ( selection_key) => StateUpdate :: SelectItem ( selection_key) ,
1039
- ComponentId :: TristateBox => {
1040
- // TODO: implement toggling the checkbox
1041
- StateUpdate :: None
1041
+ ComponentId :: TristateBox ( selection_key) => {
1042
+ if self . selection_key == selection_key {
1043
+ StateUpdate :: ToggleItem ( selection_key)
1044
+ } else {
1045
+ StateUpdate :: SelectItem ( selection_key)
1046
+ }
1042
1047
}
1043
1048
ComponentId :: QuitDialogButton ( QuitDialogButtonId :: GoBack ) => {
1044
1049
StateUpdate :: SetQuitDialog ( None )
@@ -1291,7 +1296,7 @@ impl<'a> Recorder<'a> {
1291
1296
enum ComponentId {
1292
1297
App ,
1293
1298
SelectableItem ( SelectionKey ) ,
1294
- TristateBox ,
1299
+ TristateBox ( SelectionKey ) ,
1295
1300
QuitDialog ,
1296
1301
QuitDialogButton ( QuitDialogButtonId ) ,
1297
1302
}
@@ -1673,18 +1678,19 @@ impl Component for SectionView<'_> {
1673
1678
}
1674
1679
Some ( SectionSelection :: SectionHeader ) | None => false ,
1675
1680
} ;
1681
+ let line_key = LineKey {
1682
+ file_idx,
1683
+ section_idx,
1684
+ line_idx,
1685
+ } ;
1676
1686
let tristate_box = TristateBox {
1677
1687
use_unicode : * use_unicode,
1678
- id : ComponentId :: TristateBox ,
1688
+ id : ComponentId :: TristateBox ( SelectionKey :: Line ( line_key ) ) ,
1679
1689
tristate : Tristate :: from ( * is_toggled) ,
1680
1690
is_focused,
1681
1691
} ;
1682
1692
let line_view = SectionLineView {
1683
- line_key : LineKey {
1684
- file_idx,
1685
- section_idx,
1686
- line_idx,
1687
- } ,
1693
+ line_key,
1688
1694
inner : SectionLineViewInner :: Changed {
1689
1695
tristate_box,
1690
1696
change_type : * change_type,
@@ -1708,9 +1714,14 @@ impl Component for SectionView<'_> {
1708
1714
Some ( SectionSelection :: SectionHeader ) => true ,
1709
1715
Some ( SectionSelection :: ChangedLine ( _) ) | None => false ,
1710
1716
} ;
1717
+ let section_key = SectionKey {
1718
+ file_idx,
1719
+ section_idx,
1720
+ } ;
1721
+ let selection_key = SelectionKey :: Section ( section_key) ;
1711
1722
let tristate_box = TristateBox {
1712
1723
use_unicode : * use_unicode,
1713
- id : ComponentId :: TristateBox ,
1724
+ id : ComponentId :: TristateBox ( selection_key ) ,
1714
1725
tristate : Tristate :: from ( * is_toggled) ,
1715
1726
is_focused,
1716
1727
} ;
@@ -1732,9 +1743,13 @@ impl Component for SectionView<'_> {
1732
1743
Some ( SectionSelection :: SectionHeader ) => true ,
1733
1744
Some ( SectionSelection :: ChangedLine ( _) ) | None => false ,
1734
1745
} ;
1746
+ let section_key = SectionKey {
1747
+ file_idx,
1748
+ section_idx,
1749
+ } ;
1735
1750
let tristate_box = TristateBox {
1736
1751
use_unicode : * use_unicode,
1737
- id : ComponentId :: TristateBox ,
1752
+ id : ComponentId :: TristateBox ( SelectionKey :: Section ( section_key ) ) ,
1738
1753
tristate : Tristate :: from ( * is_toggled) ,
1739
1754
is_focused,
1740
1755
} ;
0 commit comments