@@ -142,49 +142,65 @@ impl<Message> Widget<Message, cosmic::Theme, cosmic::Renderer> for TabText {
142142 renderer. with_layer ( bounds, |renderer| {
143143 renderer. fill_paragraph (
144144 & state. paragraph ,
145- Point :: new ( bounds. x , bounds. y + bounds . height / 2.0 ) ,
145+ Point :: new ( bounds. x , bounds. height . mul_add ( 0.5 , bounds . y ) ) ,
146146 style. text_color ,
147147 bounds,
148148 ) ;
149- } ) ;
150149
151- if state. overflowed {
152- let background = if self . selected {
153- theme
154- . cosmic ( )
155- . primary
156- . component
157- . selected_state_color ( )
158- . into ( )
159- } else {
160- theme. cosmic ( ) . primary_container_color ( ) . into ( )
161- } ;
162- let transparent = Color {
163- a : 0.0 ,
164- ..background
165- } ;
166-
167- renderer. fill_quad (
168- renderer:: Quad {
169- bounds : Rectangle {
170- x : ( bounds. x + bounds. width - 24. ) . max ( bounds. x ) ,
171- width : 24.0_f32 . min ( bounds. width ) ,
172- ..bounds
173- } ,
174- border : Border {
175- radius : 0.0 . into ( ) ,
176- width : 0.0 ,
177- color : Color :: TRANSPARENT ,
178- } ,
179- shadow : Default :: default ( ) ,
180- } ,
181- Background :: Gradient ( Gradient :: Linear (
182- gradient:: Linear :: new ( Degrees ( 90. ) )
183- . add_stop ( 0.0 , transparent)
184- . add_stop ( 1.0 , background) ,
185- ) ) ,
186- ) ;
187- }
150+ renderer. with_layer ( bounds, |renderer| {
151+ if state. overflowed {
152+ let overlay = match ( theme. cosmic ( ) . is_dark , self . selected ) {
153+ ( true , false ) => Color {
154+ a : 1.0 ,
155+ r : 0.149 ,
156+ g : 0.149 ,
157+ b : 0.149 ,
158+ } ,
159+ ( true , true ) => Color {
160+ a : 1.0 ,
161+ r : 0.196 ,
162+ g : 0.196 ,
163+ b : 0.196 ,
164+ } ,
165+ ( false , false ) => Color {
166+ a : 1.0 ,
167+ r : 0.894 ,
168+ g : 0.894 ,
169+ b : 0.894 ,
170+ } ,
171+ ( false , true ) => Color {
172+ a : 1.0 ,
173+ r : 0.831 ,
174+ g : 0.831 ,
175+ b : 0.831 ,
176+ } ,
177+ } ;
178+
179+ let transparent = Color { a : 0.0 , ..overlay } ;
180+
181+ renderer. fill_quad (
182+ renderer:: Quad {
183+ bounds : Rectangle {
184+ x : ( bounds. x + bounds. width - 27. ) . max ( bounds. x ) ,
185+ width : 27.0_f32 . min ( bounds. width ) ,
186+ ..bounds
187+ } ,
188+ border : Border {
189+ radius : 0.0 . into ( ) ,
190+ width : 0.0 ,
191+ color : Color :: TRANSPARENT ,
192+ } ,
193+ shadow : Default :: default ( ) ,
194+ } ,
195+ Background :: Gradient ( Gradient :: Linear (
196+ gradient:: Linear :: new ( Degrees ( 90. ) )
197+ . add_stop ( 0.0 , transparent)
198+ . add_stop ( 1.0 , overlay) ,
199+ ) ) ,
200+ ) ;
201+ }
202+ } ) ;
203+ } ) ;
188204 }
189205}
190206
0 commit comments