@@ -16,25 +16,38 @@ use std::{
1616use stereokit_rust:: {
1717 font:: Font ,
1818 sk:: MainThreadToken ,
19- system:: { TextAlign , TextFit , TextStyle as SkTextStyle } ,
19+ system:: { Align , Pivot , TextFit , TextStyle as SkTextStyle } ,
2020 util:: { Color32 , Color128 } ,
2121} ;
2222
2323use super :: { TextAspect , TextStyle } ;
2424
2525static TEXT_REGISTRY : Registry < Text > = Registry :: new ( ) ;
2626
27- fn convert_align ( x_align : super :: XAlign , y_align : super :: YAlign ) -> TextAlign {
27+ fn convert_pivot ( x_align : super :: XAlign , y_align : super :: YAlign ) -> Pivot {
2828 match ( x_align, y_align) {
29- ( super :: XAlign :: Left , super :: YAlign :: Top ) => TextAlign :: TopLeft ,
30- ( super :: XAlign :: Left , super :: YAlign :: Center ) => TextAlign :: CenterLeft ,
31- ( super :: XAlign :: Left , super :: YAlign :: Bottom ) => TextAlign :: BottomLeft ,
32- ( super :: XAlign :: Center , super :: YAlign :: Top ) => TextAlign :: Center ,
33- ( super :: XAlign :: Center , super :: YAlign :: Center ) => TextAlign :: Center ,
34- ( super :: XAlign :: Center , super :: YAlign :: Bottom ) => TextAlign :: BottomCenter ,
35- ( super :: XAlign :: Right , super :: YAlign :: Top ) => TextAlign :: TopRight ,
36- ( super :: XAlign :: Right , super :: YAlign :: Center ) => TextAlign :: CenterRight ,
37- ( super :: XAlign :: Right , super :: YAlign :: Bottom ) => TextAlign :: BottomRight ,
29+ ( super :: XAlign :: Left , super :: YAlign :: Top ) => Pivot :: TopLeft ,
30+ ( super :: XAlign :: Left , super :: YAlign :: Center ) => Pivot :: CenterLeft ,
31+ ( super :: XAlign :: Left , super :: YAlign :: Bottom ) => Pivot :: BottomLeft ,
32+ ( super :: XAlign :: Center , super :: YAlign :: Top ) => Pivot :: Center ,
33+ ( super :: XAlign :: Center , super :: YAlign :: Center ) => Pivot :: Center ,
34+ ( super :: XAlign :: Center , super :: YAlign :: Bottom ) => Pivot :: BottomCenter ,
35+ ( super :: XAlign :: Right , super :: YAlign :: Top ) => Pivot :: TopRight ,
36+ ( super :: XAlign :: Right , super :: YAlign :: Center ) => Pivot :: CenterRight ,
37+ ( super :: XAlign :: Right , super :: YAlign :: Bottom ) => Pivot :: BottomRight ,
38+ }
39+ }
40+ fn convert_align ( x_align : super :: XAlign , y_align : super :: YAlign ) -> Align {
41+ match ( x_align, y_align) {
42+ ( super :: XAlign :: Left , super :: YAlign :: Top ) => Align :: TopLeft ,
43+ ( super :: XAlign :: Left , super :: YAlign :: Center ) => Align :: CenterLeft ,
44+ ( super :: XAlign :: Left , super :: YAlign :: Bottom ) => Align :: BottomLeft ,
45+ ( super :: XAlign :: Center , super :: YAlign :: Top ) => Align :: Center ,
46+ ( super :: XAlign :: Center , super :: YAlign :: Center ) => Align :: Center ,
47+ ( super :: XAlign :: Center , super :: YAlign :: Bottom ) => Align :: BottomCenter ,
48+ ( super :: XAlign :: Right , super :: YAlign :: Top ) => Align :: TopRight ,
49+ ( super :: XAlign :: Right , super :: YAlign :: Center ) => Align :: CenterRight ,
50+ ( super :: XAlign :: Right , super :: YAlign :: Bottom ) => Align :: BottomRight ,
3851 }
3952}
4053
@@ -104,7 +117,7 @@ impl Text {
104117 ) ) ,
105118 data. bounds
106119 . as_ref ( )
107- . map ( |b| convert_align ( b. anchor_align_x , b. anchor_align_y ) ) ,
120+ . map ( |b| convert_pivot ( b. anchor_align_x , b. anchor_align_y ) ) ,
108121 Some ( convert_align ( data. text_align_x , data. text_align_y ) ) ,
109122 None ,
110123 None ,
@@ -124,7 +137,7 @@ impl Text {
124137 ) ) ,
125138 data. bounds
126139 . as_ref ( )
127- . map ( |b| convert_align ( b. anchor_align_x , b. anchor_align_y ) ) ,
140+ . map ( |b| convert_pivot ( b. anchor_align_x , b. anchor_align_y ) ) ,
128141 Some ( convert_align ( data. text_align_x , data. text_align_y ) ) ,
129142 None ,
130143 None ,
0 commit comments