TabPanel: Add TabBarPaddingStart and TabBarPaddingEnd properties.

[GB.FORM]
* NEW: TabPanel: Add TabBarPaddingStart and TabBarPaddingEnd properties. They allow to define space on the left and the right of the tab bar, so that you can put some widgets on top.
* BUG: ButtonBox: Settings the Filter property to FALSE correctly destroy the internal associated button, and prevent the control to crash if you set the property again.
This commit is contained in:
gambas 2020-01-07 20:26:15 +01:00
parent 2429cff72b
commit 6586d508ec
5 changed files with 105 additions and 14 deletions

View file

@ -231,8 +231,8 @@ Public Sub Background_Arrange()
X = FW
For Each hCtrl In aCtrl
hCtrl.W = Desktop.Scale * 3
hCtrl.Move(X, FH, hCtrl.W, H)
X += hCtrl.W
hCtrl.Move(X, FH, H, H)
X += H
Next
If $hFilter Then
$hTextBox.Move(X, FH, Me.W - FW - X - H, H)
@ -244,8 +244,8 @@ Public Sub Background_Arrange()
X = Me.W - FW
For Each hCtrl In aCtrl
hCtrl.W = Desktop.Scale * 3
X -= hCtrl.W
hCtrl.Move(X, FH, hCtrl.W, H)
X -= H
hCtrl.Move(X, FH, H, H)
Next
If $hFilter Then
$hFilter.Move(FW, FH, H, H)
@ -332,6 +332,7 @@ Private Sub Filter_Write(Value As Boolean)
$hTimer.Delay = 500
Else
$hFilter.Delete
$hFilter = Null
Endif
Background_Arrange

View file

@ -87,8 +87,6 @@ Public Sub Clear()
End
Public Sub Add((Color) As Integer)
Dim iPos As Integer

View file

@ -80,6 +80,7 @@ Event Layout(Page As Integer)
Event Draw(Page As Integer, Width As Integer, Height As Integer)
Event Finished
Event Zoom
Private $bDesaturate As Boolean
Public Sub _new()

View file

@ -27,6 +27,8 @@ Property Read Current As _TabPanelContainer
Property Background As Integer
Property Moveable As Boolean
Property CloseButton As Boolean
Property TabBarPaddingStart As Integer
Property TabBarPaddingEnd As Integer
Private $hTabBar As DrawingArea
Private $hTabBarContainer As DrawingArea
@ -59,6 +61,10 @@ Private $hClosePanel As DrawingArea
Private $hObserver As Observer
Private $iTabBarContainerH As Integer
Private $hTabBarLeft As DrawingArea
Private $hTabBarRight As DrawingArea
Private $bUpdateLayout As Boolean
Public Sub _new()
$hTabBar = New DrawingArea(Me) As "TabBar"
@ -236,18 +242,44 @@ Private Sub UpdateLayout()
Dim W As Integer
Dim H As Integer
Dim X As Integer
Dim PL, PR As Integer
Dim Y As Integer
If $bUpdateLayout Then Return
$bUpdateLayout = True
$hTabBar.Height = $hTabBar.Font.Height + Desktop.Scale * 2
W = Me.W
H = $hTabBar.H
Y = If(Align.Top, 0, $hTabBar.Y)
PL = TabBarPaddingStart_Read()
PR = TabBarPaddingEnd_Read()
If System.RightToLeft Then
If $hTabBarLeft Then $hTabBarLeft.Move(W - PL, Y, PL, H)
If $hTabBarRight Then $hTabBarRight.Move(0, Y, PR, H)
Swap PL, PR
Else
If $hTabBarLeft Then $hTabBarLeft.Move(0, Y, PL, H)
If $hTabBarRight Then $hTabBarRight.Move(W - PR, Y, PR, H)
Endif
X += PL
W -= PL + PR
If Not $hClosePanel Or If W < H * 3 Then
H = 0
If $hClosePanel Then $hClosePanel.Hide
Else
X = If(System.RightToLeft, H, 0)
W -= H
W -= H - 1
If System.RightToLeft Then
$hClosePanel.Move(X - (H - 1), Y, H - 1, H)
Else
$hClosePanel.Move(X + W, Y, H - 1, H)
Endif
$hCloseAll.Move(0, 0, H - 1, H - 1)
$hClosePanel.Show
$hClosePanel.Raise
Endif
@ -257,12 +289,10 @@ Private Sub UpdateLayout()
Select Case $iOrientation
Case Align.Top
$hTabBar.Move(X, 0, W, $hTabBar.H)
If H And If $hClosePanel Then $hClosePanel.Move(If(System.RightToLeft, 0, W), 0, H, H)
$hPanel.Move(0, $hTabBar.H, Me.W, Me.H - $hTabBar.H)
'$hTabBar.Next = $hPanel
Case Align.Bottom
$hTabBar.Move(X, Me.H - $hTabBar.H, W, $hTabBar.H)
If H And If $hClosePanel Then $hClosePanel.Move(If(System.RightToLeft, 0, W), $hTabBar.Y, H, H)
$hPanel.Move(0, 0, Me.W, Me.H - $hTabBar.H)
'Me._Arrangement = Arrange.Vertical
'$hPanel.Next = $hTabBar
@ -282,6 +312,8 @@ Private Sub UpdateLayout()
$hTabBarContainer.Arrangement = Arrange.Horizontal
_EnsureCurrentVisible
$bUpdateLayout = False
End
Public Sub TabBar_Arrange()
@ -940,7 +972,6 @@ Private Sub CloseButton_Write(Value As Boolean)
Me._Container = Null
$hClosePanel = New DrawingArea(Me) As "ClosePanel"
$hClosePanel.Arrangement = Arrange.Fill
$hCloseAll = New ToolButton($hClosePanel) As "CloseAll"
$hCloseAll.Picture = Picture["icon:/small/close"]
$hCloseAll.Show
@ -980,3 +1011,63 @@ Public Sub CloseAll_Click()
End
Private Function TabBarPaddingStart_Read() As Integer
If $hTabBarLeft Then Return $hTabBarLeft.W
End
Private Sub TabBarPaddingStart_Write(Value As Integer)
Dim hSave As Container
If TabBarPaddingStart_Read() = Value Then Return
If Value > 0 Then
If Not $hTabBarLeft Then
hSave = Me._Container
Me._Container = Null
$hTabBarLeft = New DrawingArea(Me) As "ClosePanel"
Me._Container = hSave
$hTabBarLeft.Ignore = True
Endif
$hTabBarLeft.W = Value
Else
If $hTabBarLeft Then
$hTabBarLeft.Delete
$hTabBarLeft = Null
Endif
Endif
UpdateLayout
End
Private Function TabBarPaddingEnd_Read() As Integer
If $hTabBarRight Then Return $hTabBarRight.W
End
Private Sub TabBarPaddingEnd_Write(Value As Integer)
Dim hSave As Container
If TabBarPaddingEnd_Read() = Value Then Return
If Value > 0 Then
If Not $hTabBarRight Then
hSave = Me._Container
Me._Container = Null
$hTabBarRight = New DrawingArea(Me) As "ClosePanel"
Me._Container = hSave
$hTabBarRight.Ignore = True
Endif
$hTabBarRight.W = Value
Else
If $hTabBarRight Then
$hTabBarRight.Delete
$hTabBarRight = Null
Endif
Endif
UpdateLayout
End

View file

@ -192,7 +192,7 @@ Public Sub DrawingArea_Draw()
Case Align.Top
If $bSelected Then
If Not bFirst Or If bBorder Or If System.RightToLeft Then Draw.Line(0, Me.H - 1, 0, 0)
If Not bFirst Or If bBorder Or If System.RightToLeft Or If hTabPanel.TabBarPaddingStart Then Draw.Line(0, Me.H - 1, 0, 0)
If Not bFirst Or If bBorder Or If Not System.RightToLeft Then Draw.Line(Me.W - 1, 0, Me.W - 1, Me.H - 1)
If bBorder Then Draw.Line(0, 0, Me.W - 1, 0)
Else
@ -201,7 +201,7 @@ Public Sub DrawingArea_Draw()
Case Align.Bottom
If $bSelected Then
If Not bFirst Or If bBorder Or If System.RightToLeft Then Draw.Line(0, 0, 0, Me.H - 1)
If Not bFirst Or If bBorder Or If System.RightToLeft Or If hTabPanel.TabBarPaddingStart Then Draw.Line(0, 0, 0, Me.H - 1)
If Not bFirst Or If bBorder Or If Not System.RightToLeft Then Draw.Line(Me.W - 1, Me.H - 1, Me.W - 1, 0)
If bBorder Then Draw.Line(0, Me.H - 1, Me.W - 1, Me.H - 1)
Else