TabPanel: Draw tab close buttons so that they adapt to the desktop scale.
[GB.FORM] * BUG: TabPanel: Draw tab close buttons so that they adapt to the desktop scale.
This commit is contained in:
parent
539f17a4bd
commit
e7a98f3ab9
9 changed files with 43 additions and 39 deletions
comp/src/gb.form
|
@ -1,7 +1,6 @@
|
|||
# Gambas Project File 3.0
|
||||
# Compiled with Gambas 3.10.90
|
||||
Title=More controls for graphical components
|
||||
Startup=Main
|
||||
Startup=FTabPanel
|
||||
Version=3.10.90
|
||||
VersionFile=1
|
||||
Component=gb.image
|
||||
|
|
|
@ -129,11 +129,8 @@ Public Sub PaintColor(X As Integer, Y As Integer, W As Integer, H As Integer, iC
|
|||
|
||||
Endif
|
||||
|
||||
|
||||
End
|
||||
|
||||
|
||||
|
||||
#If False
|
||||
Private Sub AddUnique(aStr As String[], sVal As String)
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ Private $hPicture As Picture
|
|||
Private $bShowClose As Boolean
|
||||
Private $bInClose As Boolean
|
||||
|
||||
Private Const BUTTON_SIZE As Integer = 14
|
||||
Static Private BUTTON_SIZE As Integer
|
||||
|
||||
Static Private $bDragging As Boolean
|
||||
Private $bDrag As Boolean
|
||||
|
@ -34,6 +34,8 @@ Private $bInside As Boolean
|
|||
|
||||
Public Sub _new()
|
||||
|
||||
If BUTTON_SIZE = 0 Then BUTTON_SIZE = Desktop.Scale * 2
|
||||
|
||||
$hDrawingArea = New DrawingArea(Me) As "DrawingArea"
|
||||
$hDrawingArea.Mouse = Mouse.Pointing
|
||||
$hDrawingArea.Name = Me.Name & "_DrawingArea"
|
||||
|
@ -69,9 +71,9 @@ Public Sub DrawingArea_Draw()
|
|||
Dim bHighlight As Boolean
|
||||
Dim bFirst As Boolean
|
||||
Dim iIndex As Integer
|
||||
Dim hPict As Picture
|
||||
Dim iBg As Integer
|
||||
Dim hFont As Font
|
||||
Dim S As Float
|
||||
|
||||
hTabPanel = GetParent()
|
||||
|
||||
|
@ -175,12 +177,29 @@ Public Sub DrawingArea_Draw()
|
|||
End Select
|
||||
|
||||
If $bShowClose And If Not $bDragging Then
|
||||
hPict = Picture[If($bInClose, "img/delete-h.png", "img/delete.png")]
|
||||
|
||||
Paint.Save
|
||||
|
||||
If System.RightToLeft Then
|
||||
Draw.Picture(hPict, 2, (Me.H - hPict.H) \ 2)
|
||||
Paint.Translate(4, (Me.H - BUTTON_SIZE) \ 2)
|
||||
Else
|
||||
Draw.Picture(hPict, Me.W - hPict.W - 2, (Me.H - hPict.H) \ 2)
|
||||
Paint.Translate(Me.W - BUTTON_SIZE - 4, (Me.H - BUTTON_SIZE) \ 2)
|
||||
Endif
|
||||
|
||||
S = BUTTON_SIZE / 4
|
||||
Paint.MoveTo(S, S)
|
||||
Paint.RelLineTo(S * 2, S * 2)
|
||||
Paint.MoveTo(S * 3, S)
|
||||
Paint.RelLineTo(- S * 2, S * 2)
|
||||
|
||||
Paint.LineWidth = Desktop.Scale / 4
|
||||
Paint.LineCap = Paint.LineCapRound
|
||||
Paint.Background = If($bInClose, Color.TextForeground, Color.LightForeground)
|
||||
|
||||
Paint.Stroke
|
||||
|
||||
Paint.Restore
|
||||
|
||||
Endif
|
||||
|
||||
If $bSelected And If Me.Parent.HasFocus Then
|
||||
|
@ -224,19 +243,19 @@ Public Sub UpdateLayout()
|
|||
Dim bClosable As Boolean = IsClosable()
|
||||
|
||||
If $bRichText Then
|
||||
S = Me.Parent.Font.RichTextWidth($sText) + 16
|
||||
S = Me.Parent.Font.RichTextWidth($sText) + Desktop.Scale * 2
|
||||
Else
|
||||
S = Me.Parent.Font.TextWidth($sText) + 16
|
||||
S = Me.Parent.Font.TextWidth($sText) + Desktop.Scale * 2
|
||||
Endif
|
||||
|
||||
Select Case $iOrientation
|
||||
Case Align.Left, Align.Right
|
||||
If $hPicture Then S += $hPicture.W '- 4
|
||||
If bClosable Then S += BUTTON_SIZE - 4
|
||||
If $hPicture Then S += $hPicture.H '- 4
|
||||
If bClosable Then S += BUTTON_SIZE
|
||||
Me.H = S
|
||||
Case Else
|
||||
If $hPicture Then S += $hPicture.W '- 4
|
||||
If bClosable Then S += BUTTON_SIZE - 4
|
||||
If bClosable Then S += BUTTON_SIZE
|
||||
Me.W = S
|
||||
End Select
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ Public Sub Form_Open()
|
|||
For I = 0 To TabPanel2.Count - 1
|
||||
TabPanel2.Index = I
|
||||
TabPanel2.Text = "Tab " & (I + 1) & " " & String$(CInt(Rnd(1, 10)), "-")
|
||||
TabPanel2.Picture = Picture["icon:/16/bookmark"]
|
||||
TabPanel2.Picture = Picture["icon:/32/bookmark"]
|
||||
hLabel = New Label(TabPanel2)
|
||||
hLabel.Move(8, 8, 8, 8)
|
||||
hLabel.AutoResize = True
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
' Gambas class file
|
||||
|
||||
|
||||
Public Sub Button1_Click()
|
||||
|
||||
ValueBox1.Type = ValueBox.Date
|
||||
|
||||
End
|
||||
|
||||
Public Sub ValueBox1_Change()
|
||||
|
||||
Debug
|
||||
|
||||
End
|
||||
|
||||
Public Sub Form_Open()
|
||||
|
||||
DateBox1.Value = Date(30, 1, 1)
|
||||
|
||||
End
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
# Gambas Form File 3.0
|
||||
|
||||
{ Form Form
|
||||
MoveScaled(0,0,64,64)
|
||||
Arrangement = Arrange.Vertical
|
||||
{ ValueBox1 ValueBox
|
||||
MoveScaled(9,11,17,4)
|
||||
Alignment = Align.Left
|
||||
}
|
||||
{ ValueBox2 ValueBox
|
||||
MoveScaled(9,16,17,4)
|
||||
}
|
||||
MoveScaled(0,0,58,61)
|
||||
{ TextBox1 TextBox
|
||||
MoveScaled(11,26,24,4)
|
||||
Text = ("Hello world!")
|
||||
}
|
||||
{ Spring1 Spring
|
||||
MoveScaled(32,33,4,6)
|
||||
MoveScaled(25,32,4,6)
|
||||
}
|
||||
{ Button1 Button
|
||||
MoveScaled(26,42,16,4)
|
||||
MoveScaled(19,42,16,4)
|
||||
}
|
||||
{ DateBox1 DateBox
|
||||
MoveScaled(12,4,24,4)
|
||||
}
|
||||
{ ValueBox1 ValueBox
|
||||
MoveScaled(9,13,24,4)
|
||||
Type = ValueBox.Date
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Before (image error) Size: 146 B |
Binary file not shown.
Before (image error) Size: 182 B |
Binary file not shown.
Before (image error) Size: 182 B |
Loading…
Reference in a new issue