Label: Fix frame drawing and text alignment inside frame.

[GB.GUI.BASE]
* BUG: Label: Clip frame drawing for style that draw an unwanted background.
* BUG: Label: Take the frame width into account when aligning the contents.
This commit is contained in:
Benoît Minisini 2022-12-28 17:47:36 +01:00
parent bd069c9ffd
commit 496960ad4f
4 changed files with 23 additions and 12 deletions

View File

@ -1,6 +1,6 @@
# Gambas Project File 3.0
Title=Common controls and classes for GUI components
Startup=FTestIconView
Startup=FLabel
Icon=.hidden/window.png
Version=3.17.90
VersionFile=1

View File

@ -14,7 +14,6 @@ Static Private Sub GetDesktop() As String
If Not $aDesktopType Then
$aDesktopType = Split(UCase(Application.Env["XDG_CURRENT_DESKTOP"]), ":")
$aDesktopType.ReadOnly = True
Endif
If $aDesktopType.Count = 0 Then
@ -45,9 +44,9 @@ Static Private Sub GetDesktop() As String
If $aDesktopType[0] = "KDE" Then
If Application.Env["KDE_SESSION_VERSION"] = "4" Then
$aDesktopType.Add("KDE4", 0)
$aDesktopType.Add("KDE4")
Else If Application.Env["KDE_SESSION_VERSION"] = "5" Then
$aDesktopType.Add("KDE5", 0)
$aDesktopType.Add("KDE5")
Endif
Endif
@ -56,6 +55,8 @@ Static Private Sub GetDesktop() As String
Endif
$aDesktopType.ReadOnly = True
Return $sDesktop
End

View File

@ -106,7 +106,7 @@ Private Sub GetPadding() As Integer
Case Border.Plain
Inc P
Case Border.Raised, Border.Sunken
P += Style.FrameWidth
P += Style.FrameWidth + 1
End Select
Return P
@ -205,12 +205,20 @@ Public Sub UserControl_Draw()
Dim X As Float
If $iBorder Then
Style.PaintPanel(0, 0, Paint.W, Paint.H, $iBorder)
If $iBorder = Border.Plain Then
F = 1
Else
F = Style.FrameWidth + 1
Endif
Paint.Save
Paint.Rectangle(0, 0, Paint.W, F)
Paint.Rectangle(0, Paint.H - F, Paint.W, F)
Paint.Rectangle(0, 0, F, Paint.H)
Paint.Rectangle(Paint.W - F, 0, F, Paint.H)
Paint.Clip()
Style.PaintPanel(0, 0, Paint.W, Paint.H, $iBorder)
Paint.Restore
Paint.Rectangle(F, F, Paint.W - F * 2, Paint.H - F * 2)
Paint.Clip()
Endif
@ -242,7 +250,11 @@ Public Sub UserControl_Draw()
Endif
'Endif
If Not Me.Enabled Then Paint.Background = Color.Merge(Style.BackgroundOf(Me), Style.ForegroundOf(Me))
If Not Me.Enabled Then
Paint.Background = Color.Merge(Style.BackgroundOf(Me), Style.ForegroundOf(Me))
Else
Paint.Background = Style.ForegroundOf(Me)
Endif
If $bRichText Then
Paint.DrawRichText($sText, X, P, W, Me.H - P * 2, $iAlign)

View File

@ -5,11 +5,9 @@
Font = Font["DejaVu Sans,Italic,+5"]
Spacing = True
{ Label6 Label
MoveScaled(6,3,84,9)
Background = Color.Cyan
AutoResize = True
Alignment = Align.Left
Border = Border.Plain
MoveScaled(6,3,55,9)
Alignment = Align.Center
Border = Border.Raised
Text = ("This is a Label test line")
}
{ Label4 Label