[GB.FORM]

* BUG: FileChooser: Fix an infinite loop when trying to initialize the path 
  with an unknown file.

[GB.MEDIA.FORM]
* NEW: New component based on gb.media that includes a full media player 
  widget with controls.

[GB.NET.SMTP]
* NEW: SmtpClient is now a virtual control.


git-svn-id: svn://localhost/gambas/trunk@6408 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-08-01 01:37:56 +00:00
parent 27007f708b
commit 73b2d0dd75
32 changed files with 495 additions and 29 deletions

View file

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 3.5.90
Title=More controls for graphical components
Startup=FIconView
Startup=FLCDLabel
Version=3.5.90
VersionFile=1
Component=gb.image

View file

@ -111,11 +111,13 @@ Public Sub FindBookmark({Link} As String) As CBookmark
Dim hBookmark As CBookmark
For Each hBookmark In Me
If Not hBookmark.Exist() Then Continue
If hBookmark.Link = {Link} Then Return hBookmark
Next
If Left({Link}) = "/" Then
For Each hBookmark In Me
If Not hBookmark.Exist() Then Continue
If hBookmark.Path = {Link} Then Return hBookmark
Next
Endif
@ -134,6 +136,7 @@ Public Sub FindBest(sDir As String) As CBookmark
aDir = Split(sDir, "/")
For Each hBookmark In Me
If Not hBookmark.Exist() Then Continue
aBook = Split(hBookmark.Path, "/")
For iInd = 0 To Min(aDir.Max, aBook.Max)
If aBook[iInd] <> aDir[iInd] Then Break

View file

@ -257,7 +257,7 @@ End
Public Sub SetDir(sDir As String)
If sDir = dvwChoose.Current Then Return
If IsBookmarkVisible() Then
SetBookmark($hBookmarkList.FindBest(sDir))
Endif
@ -356,25 +356,30 @@ Public Function GetPath() As String
End
Public Sub SetPath(sPath As String)
Dim bError As Boolean
If Not Exist(sPath) Then bError = True
If txtFile.ReadOnly Then
SetDir(sPath)
Else
SetDir(File.Dir(sPath))
Endif
If GetMulti() Then Return
If Not GetMulti() Then
'DEBUG dvwChoose.Current;; File.Dir(sPath)
'IF dvwChoose.Current = File.Dir(sPath) THEN
fvwChoose.Current = File.Name(sPath)
If txtFile.ReadOnly Then
txtFile.Text = fvwChoose.Current
Else
txtFile.Text = File.Name(sPath)
fvwChoose.Current = File.Name(sPath)
If txtFile.ReadOnly Then
txtFile.Text = fvwChoose.Current
Else
txtFile.Text = File.Name(sPath)
Endif
Endif
'ENDIF
If bError Then Message.Error(("Path not found:") & "\n\n" & sPath)
End

View file

@ -2,14 +2,14 @@
{ Form Form
MoveScaled(0,0,44,19)
Background = &H000000&
Arrangement = Arrange.Fill
{ LCDLabel2 LCDLabel
MoveScaled(2,3,29,11)
Background = &H000000&
Foreground = &HCFFFBF&
MoveScaled(5,3,29,11)
Foreground = &HFFFFFF&
Text = ("12:34")
Alignment = Align.Center
Padding = 8
HighlightColor = &HFF7F00&
}
{ Timer1 #Timer
#MoveScaled(36,11)

View file

@ -0,0 +1,4 @@
[Component]
Key=gb.media.form
Version=3.5.90
Needs=Form

View file

@ -0,0 +1,2 @@
[Desktop Entry]
Icon=./.icon.png

13
comp/src/gb.media.form/.gitignore vendored Normal file
View file

@ -0,0 +1,13 @@
#---- Gambas files to ignore (v1)
*.gambas
.lock
*~
core
core.*
vgcore
vgcore.*
.kdbg*
.*.prof
.lang/*.pot
.gambas/*
#----

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -0,0 +1,31 @@
#MediaView
UserControl
C
_IsControl
C
b
-1
_Group
C
s
Media
_Properties
C
s
*,Border,Control=True,URL{Path}
URL
p
s
Border
p
b
Control
p
b
_new
m

View file

@ -0,0 +1 @@
MediaView

View file

@ -0,0 +1,14 @@
# Gambas Project File 3.0
# Compiled with Gambas 3.5.90
Title=gb.media.form
Startup=FTest
Icon=video.png
Version=3.5.90
VersionFile=1
Component=gb.image
Component=gb.gui
Component=gb.form
Component=gb.media
TabSize=2
Type=Component
Packager=1

View file

@ -0,0 +1,235 @@
' Gambas class file
'Static Private $hLogo As Image
Private $hPlayer As MediaPlayer
Private $hImage As MediaControl
Private $fPos As Float
Private $fLength As Float
Private $hPause1 As Panel
Private $hPause2 As Panel
Private $iMute As Integer
Private Sub MakeMediaPlayer()
If $hPlayer Then Return
$hPlayer = New MediaPlayer As "MediaPlayer"
'$hFilter = New MediaFilter($hPlayer)
$hImage = New MediaControl($hPlayer, "ximagesink")
$hPlayer.Video.Output = $hImage
'$hImage.SetWindow(dwgVideo)
' $aVisualisation = New MediaControl[]
' AddVisualisation("", "")
' AddVisualisation("goom", "Goom")
' AddVisualisation("goom2k1", "Goom2")
' AddVisualisation("libvisual_bumpscope", "Bump")
' AddVisualisation("libvisual_corona", "Corona")
' AddVisualisation("libvisual_infinite", "Infinite")
' AddVisualisation("libvisual_jakdaw", "Jakdaw")
' AddVisualisation("libvisual_jess", "Jess")
' AddVisualisation("monoscope", "Mono")
' AddVisualisation("libvisual_oinksie", "Oinksie")
' AddVisualisation("libvisual_lv_analyzer", "Analyzer")
' AddVisualisation("libvisual_lv_scope", "Scope")
' AddVisualisation("spacescope", "Space")
' AddVisualisation("spectrascope", "Spectra")
' AddVisualisation("synaescope", "Synae")
' AddVisualisation("wavescope", "Wave")
'
' $iVisualisation = 0
' UpdateVisualisation
End
Private Sub ShowPause()
If $hPause1 Then Return
Object.Lock(dwgVideo)
$hPause1 = New Panel(dwgVideo)
$hPause1.Background = Color.White
$hPause2 = New Panel(dwgVideo)
$hPause2.Background = Color.White
Object.Unlock(dwgVideo)
dwgVideo_Arrange
End
Private Sub HidePause()
If Not $hPause1 Then Return
Object.Lock(dwgVideo)
$hPause1.Delete
$hPause2.Delete
$hPause1 = Null
$hPause2 = Null
Object.Unlock(dwgVideo)
End
Public Sub SetUrl(sUrl As String)
MakeMediaPlayer
$hPlayer.URL = Media.URL(sUrl)
End
Public Sub btnPlay_Click()
If Not $hPlayer Then Return
timTime.Start
dwgTime.Refresh
sldVolume_Change
$hImage.SetWindow(dwgVideo)
$hPlayer.Play
HidePause
End
Public Sub btnPause_Click()
If Not $hPlayer Then Return
$hPlayer.Pause
ShowPause
timTime.Stop
End
Public Sub btnStop_Click()
If Not $hPlayer Then Return
$hPlayer.Stop
HidePause
timTime.Stop
$fLength = 0
End
Public Sub dwgVideo_Arrange()
Dim W, H As Integer
H = Desktop.Scale * 8
W = H * 2
'lblTime.Move(dwgVideo.W - W, dwgVideo.H - H, W, H)
If $hPause1 Then $hPause1.Move(dwgVideo.W \ 2 - 32, dwgVideo.H \ 2 - 32, 24, 64)
If $hPause2 Then $hPause2.Move(dwgVideo.W \ 2 + 8, dwgVideo.H \ 2 - 32, 24, 64)
End
Public Sub GetShowControl() As Boolean
Return panControl.Visible
End
Public Sub SetShowControl(bShow As Boolean)
panControl.Visible = bShow
dwgTime.Visible = bShow
End
Public Sub GetBorder() As Boolean
Return panBorder.Border <> Border.None
End
Public Sub SetBorder(bBorder As Boolean) As Boolean
If bBorder Then
panBorder.Border = Border.Plain
panBorder.Margin = True
Else
panBorder.Border = Border.None
panBorder.Margin = False
Endif
End
Private Sub UpdateTime()
Dim fPos As Float
fPos = $hPlayer.Position
If fPos = 0 Then Return
$fPos = fPos
If $fLength = 0 Then $fLength = $hPlayer.Duration
dwgTime.Refresh
End
Public Sub timTime_Timer()
UpdateTime
End
Public Sub dwgTime_Draw()
Dim sText As String
If Not $hPlayer Or If $hPlayer.State = Media.Null Then Return
If $fLength > 0 Then Paint.FillRect(4, 6, (dwgTime.W - 8) * Min(1, $fPos / $fLength), dwgTime.H - 12, &HC0C0C0&)
If $fPos = 0 Then
sText = "00:00:00"
Else
sText = Format(CDate(($fPos + 0.5) / 86400), "hh:nn:ss") '& " / " & Format(CDate($fLength / 86400), "hh:nn:ss")
Endif
Paint.DrawText(sText, 0, 0, dwgTime.W - 4, dwgTime.H, Align.Right)
End
Private Sub SetPos(fPos As Float)
If $hPlayer.State = Media.Paused Or If $hPlayer.State = Media.Playing Then
If $fLength Then
$fPos = fPos * $fLength
$hPlayer.Position = $fPos
dwgTime.Refresh
Endif
Endif
End
Public Sub dwgTime_MouseDown()
If Mouse.Left Then SetPos(Mouse.X / dwgTime.W)
End
Public Sub dwgTime_MouseMove()
If Mouse.Left Then SetPos(Mouse.X / dwgTime.W)
End
Public Sub sldVolume_Change()
sldVolume.Tooltip = CStr(sldVolume.Value) & "%"
If Not $hPlayer Then Return
$hPlayer.Audio.Volume = sldVolume.Value / 100
End
Public Sub btnVolume_Click()
If sldVolume.Enabled Then
$iMute = sldVolume.Value
sldVolume.Value = 0
Else
sldVolume.Value = $iMute
Endif
sldVolume.Enabled = Not sldVolume.Enabled
End

View file

@ -0,0 +1,57 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,64,64)
Arrangement = Arrange.Fill
{ panBorder Panel
MoveScaled(2,3,58,55)
Arrangement = Arrange.Vertical
{ panViewer Panel
MoveScaled(11,2,43,30)
Background = &H000000&
Expand = True
Arrangement = Arrange.Fill
{ dwgVideo DrawingArea
MoveScaled(0,0,24,24)
Background = &H000000&
Expand = True
}
}
{ dwgTime DrawingArea
MoveScaled(9,37,36,3)
Mouse = Mouse.Pointing
}
{ panControl HBox
MoveScaled(0,45,57,4)
{ btnPlay ToolButton
MoveScaled(0,0,4,4)
Picture = Picture["icon:/small/play"]
}
{ btnPause ToolButton
MoveScaled(4,0,4,4)
Picture = Picture["icon:/small/pause"]
}
{ btnStop ToolButton
MoveScaled(8,0,4,4)
Picture = Picture["icon:/small/stop"]
}
{ Panel1 Panel
MoveScaled(13,0,3,4)
Expand = True
}
{ btnVolume ToolButton
MoveScaled(26,0,4,4)
Picture = Picture["icon:/small/volume"]
}
{ sldVolume Slider
MoveScaled(32,0,20,4)
ToolTip = ("100%")
Value = 100
}
}
}
{ timTime #Timer
#MoveScaled(3,11)
Delay = 250
}
}

View file

@ -0,0 +1,2 @@
' Gambas class file

View file

@ -0,0 +1,10 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,79,64)
Arrangement = Arrange.Fill
{ MediaView1 MediaView
MoveScaled(4,5,66,40)
URL = "/media/benoit/Sauvegarde/Les Labos/crap2.mp4"
}
}

View file

@ -0,0 +1,60 @@
' Gambas class file
Export
Inherits UserControl
Public Const _IsControl As Boolean = True
Public Const _Group As String = "Media"
Public Const _Properties As String = "*,Border,Control=True,URL{Path}"
Property URL As String
Property Border As Boolean
Property Control As Boolean
Private $hView As FMediaPlayer
Private $sUrl As String
Public Sub _new()
$hView = New FMediaPlayer(Me)
End
Private Function URL_Read() As String
Return $sUrl
End
Private Sub URL_Write(Value As String)
$sUrl = Value
If Me.Design Then Return
$hView.SetUrl($sUrl)
End
Private Function Control_Read() As Boolean
Return $hView.GetShowControl()
End
Private Sub Control_Write(Value As Boolean)
$hView.SetShowControl(Value)
End
Private Function Border_Read() As Boolean
Return $hView.GetBorder()
End
Private Sub Border_Write(Value As Boolean)
$hView.SetBorder(Value)
End

View file

@ -0,0 +1,11 @@
FTest
gb.media.form
0
0
3.5.90
gb.image
gb.gui
gb.form
gb.media

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -27,7 +27,7 @@ Network
_Properties
C
s
Host,Port,Debug,Encrypt{Net.None;SSL}
Host,Port,User,Password,Encrypt{Net.None;SSL},Debug
Encrypt
p
i

View file

@ -36,7 +36,7 @@ Export
Public Const _IsControl As Boolean = True
Public Const _IsVirtual As Boolean = True
Public Const _Group As String = "Network"
Public Const _Properties As String = "Host,Port,Debug,Encrypt{Net.None;SSL}"
Public Const _Properties As String = "Host,Port,User,Password,Encrypt{Net.None;SSL},Debug"
Private Const SERVER_POSITIVE_RESPONSE As String = "+OK"
Private Const SERVER_NEGATIVE_RESPONSE As String = "-ERR"

View file

@ -1,4 +1,4 @@
[Component]
Key=gb.net.smtp
Version=0.0.4
Version=3.5.90
Requires=gb.net

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -16,6 +16,22 @@ i
#SmtpClient
C
_IsControl
C
b
-1
_IsVirtual
C
b
-1
_Group
C
s
Network
_Properties
C
s
Host,Port,User,Password,Encrypt{Net.None;SSL;TLS}=None
Debug
p
b

View file

@ -2,7 +2,8 @@
# Compiled with Gambas 3.5.90
Title=gb.net.smtp
Startup=Main
Version=0.0.9
Version=3.5.90
VersionFile=1
Component=gb.net
TabSize=2
Type=Component

View file

@ -5,6 +5,11 @@ Export
Static Private $aDay As String[]
Static Private $aMonth As String[]
Public Const _IsControl As Boolean = True
Public Const _IsVirtual As Boolean = True
Public Const _Group As String = "Network"
Public Const _Properties As String = "Host,Port,User,Password,Encrypt{Net.None;SSL;TLS}=None"
Property Debug As Boolean
Property Host As String

View file

@ -2,7 +2,7 @@ Main
gb.net.smtp
0
0
0.0.9
3.5.90
gb.net

View file

@ -1 +1 @@
gb.eval.highlight gb.args gb.settings gb.gui.base gb.form gb.form.stock gb.form.dialog gb.form.mdi gb.db.form gb.desktop gb.web gb.report gb.chart gb.mysql gb.net.smtp gb.net.pop3 gb.memcached gb.map gb.logging gb.markdown
gb.eval.highlight gb.args gb.settings gb.gui.base gb.form gb.form.stock gb.form.dialog gb.form.mdi gb.db.form gb.desktop gb.web gb.report gb.chart gb.mysql gb.net.smtp gb.net.pop3 gb.memcached gb.map gb.logging gb.markdown gb.media.form

View file

@ -3,11 +3,10 @@
{ Form Form
MoveScaled(0,0,110,85)
Icon = Picture["icon.png"]
Border = False
Maximized = True
Arrangement = Arrange.Vertical
{ dwgVideo DrawingArea
MoveScaled(11,25,24,24)
MoveScaled(12,27,24,24)
Background = &H000000&
Expand = True
}

View file

@ -1617,12 +1617,12 @@ BEGIN_PROPERTY(MediaPipeline_Position)
}
else
{
guint64 pos = VPROP(GB_FLOAT) * 1E9;
gint64 pos = VPROP(GB_FLOAT) * 1E9;
if (pos < 0)
pos = 0;
gst_element_seek_simple(ELEMENT, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, pos);
gst_element_seek_simple(ELEMENT, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT, (guint64)pos);
}
END_PROPERTY

View file

@ -721,13 +721,10 @@ static char *input(STREAM *stream, bool line, char *escape)
}
if (len > 0)
//add_string(addr, &len_str, stream->common.buffer + start, len);
addr = STRING_add(addr, buffer + start, len);
else if (len < 0)
addr = STRING_extend(addr, STRING_length(addr) + len);
//STRING_extend_end(addr);
stream->common.buffer = buffer;
stream->common.buffer_pos = buffer_pos;
stream->common.buffer_len = buffer_len;