TabPanel: ShowTabBar is a new property that toggles the tab bar visibility.
[GB.FORM] * NEW: TabPanel: ShowTabBar is a new property that toggles the tab bar visibility.
This commit is contained in:
parent
7ae6634069
commit
1cc95c2353
4 changed files with 56 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
|||
# Gambas Project File 3.0
|
||||
Title=More controls for graphical components
|
||||
Startup=FTestMenuButton
|
||||
Startup=FTestTabPanel
|
||||
Icon=.hidden/icon.png
|
||||
Version=3.16.90
|
||||
VersionFile=1
|
||||
|
@ -10,7 +10,7 @@ Component=gb.form
|
|||
Component=gb.settings
|
||||
Component=gb.form.stock
|
||||
Authors="Benoît Minisini"
|
||||
Environment="GB_GUI=gb.gtk3\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive"
|
||||
Environment="GB_GUI=gb.qt5\n GB_STOCK_DEBUG=1\n LANG=zh_CN.UTF-8\n LC_ALL=en_US.UTF-8\n LC_ALL=zh_CN.UTF-8\n GTK_DEBUG=interactive"
|
||||
TabSize=2
|
||||
Translate=1
|
||||
Language=en
|
||||
|
|
|
@ -30,6 +30,7 @@ Property CloseButton As Boolean
|
|||
Property Read TabBarSize As Integer
|
||||
Property TabBarPaddingStart As Integer
|
||||
Property TabBarPaddingEnd As Integer
|
||||
Property ShowTabBar As Boolean
|
||||
|
||||
Private $hTabBar As DrawingArea
|
||||
Private $hTabBarContainer As DrawingArea
|
||||
|
@ -65,6 +66,7 @@ Private $iTabBarContainerH As Integer
|
|||
Private $hTabBarLeft As DrawingArea
|
||||
Private $hTabBarRight As DrawingArea
|
||||
Private $bUpdateLayout As Boolean
|
||||
Private $bShowTabBar As Boolean
|
||||
|
||||
Public Sub _new()
|
||||
|
||||
|
@ -248,12 +250,13 @@ Private Sub UpdateLayout()
|
|||
|
||||
If $bUpdateLayout Then Return
|
||||
$bUpdateLayout = True
|
||||
|
||||
$bShowTabBar = $hTabBar.Visible
|
||||
|
||||
W = Me.W
|
||||
H = TabBarSize_Read()
|
||||
$hTabBar.Height = H + 1
|
||||
|
||||
|
||||
Y = If(Align.Top, 0, $hTabBar.Y)
|
||||
|
||||
If $hClosePanel Then
|
||||
|
@ -266,7 +269,7 @@ Private Sub UpdateLayout()
|
|||
$hClosePanel.Move(X + W, Y, H, H + 1)
|
||||
Endif
|
||||
$hCloseAll.Move(0, 0, H, H)
|
||||
$hClosePanel.Show
|
||||
$hClosePanel.Visible = $bShowTabBar
|
||||
$hClosePanel.Raise
|
||||
Else
|
||||
$hClosePanel.Hide
|
||||
|
@ -506,13 +509,16 @@ End
|
|||
|
||||
Private Sub UpdateCurrentContainer()
|
||||
|
||||
Dim D As Integer
|
||||
|
||||
If $iCurrent < 0 Then Return
|
||||
|
||||
If $bBorder Then
|
||||
If Not $hTabBar.Visible Then D = 1
|
||||
If $iOrientation = Align.Top Then
|
||||
$aCont[$iCurrent].Move(1, 0, $hPanel.W - 2, $hPanel.H - 1)
|
||||
$aCont[$iCurrent].Move(1, D, $hPanel.W - 2, $hPanel.H - D)
|
||||
Else
|
||||
$aCont[$iCurrent].Move(1, 1, $hPanel.W - 2, $hPanel.H - 1)
|
||||
$aCont[$iCurrent].Move(1, 1, $hPanel.W - 2, $hPanel.H - D)
|
||||
Endif
|
||||
Else
|
||||
$aCont[$iCurrent].Move(0, 0, $hPanel.W, $hPanel.H)
|
||||
|
@ -520,7 +526,6 @@ Private Sub UpdateCurrentContainer()
|
|||
|
||||
End
|
||||
|
||||
|
||||
Private Sub UpdateContainer()
|
||||
|
||||
Dim iInd As Integer
|
||||
|
@ -687,17 +692,21 @@ End
|
|||
Public Sub Panel_Draw()
|
||||
|
||||
If $bBorder Then
|
||||
Draw.Foreground = Color.LightForeground
|
||||
Select Case $iOrientation
|
||||
Case Align.Top
|
||||
Draw.Line(0, 0, 0, $hPanel.H - 1)
|
||||
Draw.Line(0, $hPanel.H - 1, $hPanel.W - 1, $hPanel.H - 1)
|
||||
Draw.Line($hPanel.W - 1, $hPanel.H - 1, $hPanel.W - 1, 0)
|
||||
Case Align.Bottom
|
||||
Draw.Line(0, $hPanel.H - 1, 0, 0)
|
||||
Draw.Line(0, 0, $hPanel.W - 1, 0)
|
||||
Draw.Line($hPanel.W - 1, 0, $hPanel.W - 1, $hPanel.H - 1)
|
||||
End Select
|
||||
If $hTabBar.Visible Then
|
||||
Draw.Foreground = Color.LightForeground
|
||||
Select Case $iOrientation
|
||||
Case Align.Top
|
||||
Draw.Line(0, 0, 0, $hPanel.H - 1)
|
||||
Draw.Line(0, $hPanel.H - 1, $hPanel.W - 1, $hPanel.H - 1)
|
||||
Draw.Line($hPanel.W - 1, $hPanel.H - 1, $hPanel.W - 1, 0)
|
||||
Case Align.Bottom
|
||||
Draw.Line(0, $hPanel.H - 1, 0, 0)
|
||||
Draw.Line(0, 0, $hPanel.W - 1, 0)
|
||||
Draw.Line($hPanel.W - 1, 0, $hPanel.W - 1, $hPanel.H - 1)
|
||||
End Select
|
||||
Else
|
||||
Paint.DrawRect(0, 0, $hPanel.W, $hPanel.H, Color.LightForeground)
|
||||
Endif
|
||||
Endif
|
||||
|
||||
End
|
||||
|
@ -984,9 +993,11 @@ Private Sub CloseButton_Write(Value As Boolean)
|
|||
Me._Container = hSave
|
||||
|
||||
Else
|
||||
|
||||
$hClosePanel.Delete
|
||||
$hClosePanel = Null
|
||||
$hCloseAll = Null
|
||||
|
||||
Endif
|
||||
|
||||
TabBar_Arrange
|
||||
|
@ -1079,6 +1090,20 @@ End
|
|||
|
||||
Private Function TabBarSize_Read() As Integer
|
||||
|
||||
Return $hTabBar.Font.Height + Desktop.Scale * 1.75
|
||||
If $hTabBar.Visible Then Return $hTabBar.Font.Height + Desktop.Scale * 1.75
|
||||
|
||||
End
|
||||
|
||||
Private Function ShowTabBar_Read() As Boolean
|
||||
|
||||
Return $hTabBar.Visible
|
||||
|
||||
End
|
||||
|
||||
Private Sub ShowTabBar_Write(Value As Boolean)
|
||||
|
||||
If $hTabBar.Visible = Value Then Return
|
||||
$hTabBar.Visible = Value
|
||||
UpdateLayout
|
||||
|
||||
End
|
||||
|
|
|
@ -83,3 +83,9 @@ Public Sub Button3_Click()
|
|||
TabPanel2.TabBarPaddingEnd = 16 - TabPanel2.TabBarPaddingEnd
|
||||
|
||||
End
|
||||
|
||||
Public Sub Button4_Click()
|
||||
|
||||
TabPanel2.ShowTabBar = Not TabPanel2.ShowTabBar
|
||||
|
||||
End
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#Translate = False
|
||||
Foreground = Color.Orange
|
||||
Expand = True
|
||||
Border = False
|
||||
Closable = True
|
||||
CloseButton = True
|
||||
Moveable = True
|
||||
|
@ -34,7 +33,7 @@
|
|||
Index = 0
|
||||
}
|
||||
{ Panel1 HBox
|
||||
MoveScaled(7,47,66,4)
|
||||
MoveScaled(7,47,80,4)
|
||||
{ Button1 Button
|
||||
MoveScaled(0,0,16,4)
|
||||
Text = ("Border")
|
||||
|
@ -47,9 +46,13 @@
|
|||
MoveScaled(34,0,16,4)
|
||||
Text = ("Padding")
|
||||
}
|
||||
{ Button4 Button
|
||||
MoveScaled(51,0,16,4)
|
||||
Text = ("TabBar")
|
||||
}
|
||||
}
|
||||
{ Timer1 #Timer
|
||||
#MoveScaled(75,45)
|
||||
#MoveScaled(78,38)
|
||||
Enabled = True
|
||||
Delay = 100
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue