[EXAMPLES]
* NEW: Add a browse mode to the PhotoTouch example. git-svn-id: svn://localhost/gambas/trunk@4668 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
1189c52ae1
commit
53fb481eee
11 changed files with 201 additions and 28 deletions
|
@ -1601,7 +1601,7 @@ Private Sub DoRefresh(Optional bReset As Boolean)
|
|||
|
||||
.Clear()
|
||||
|
||||
.Background = If(Len(ProjectFilter), Color.LightBackground, Color.Default)
|
||||
.Background = If(Len(ProjectFilter), Color.Merge(Color.TextBackground, Color.LightBackground, 0.25), Color.Default)
|
||||
|
||||
sKey = Project.Dir
|
||||
.Add(sKey, Name, GetIcon(Project.Dir, 16))
|
||||
|
|
Binary file not shown.
|
@ -11,19 +11,23 @@ msgstr ""
|
|||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Automatic correction"
|
||||
msgstr "Correction automatique"
|
||||
|
||||
#: FBrightness.form:56 FMain.class:107
|
||||
#: FBrightness.form:56 FMain.class:150
|
||||
msgid "Balance"
|
||||
msgstr "Balance"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Blur"
|
||||
msgstr "Flou"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Browse photos"
|
||||
msgstr "Parcourir les photos"
|
||||
|
||||
#: FMain.class:150
|
||||
msgid "Crop image"
|
||||
msgstr "Découper l'image"
|
||||
|
||||
|
@ -31,59 +35,63 @@ msgstr "Découper l'image"
|
|||
msgid "Cut"
|
||||
msgstr "Découper"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Fit to window"
|
||||
msgstr "Zoom à la taille de l'écran"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Flip horizontally"
|
||||
msgstr "Retourner horizontalement"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Flip vertically"
|
||||
msgstr "Retourner verticalement"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Invert"
|
||||
msgstr "Inverser"
|
||||
|
||||
#: FMain.class:55
|
||||
#: FMain.class:95
|
||||
msgid "No image in directory"
|
||||
msgstr "Aucune image dans ce répertoire"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Normalize"
|
||||
msgstr "Normaliser"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Oil painting effect"
|
||||
msgstr "Effet de peinture à l'huile"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Quit"
|
||||
msgstr "Quitter"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Remove speckles"
|
||||
msgstr "Enlever les tâches"
|
||||
|
||||
#: FMain.class:107 FResize.form:40
|
||||
#: FMain.class:150 FResize.form:40
|
||||
msgid "Resize"
|
||||
msgstr "Redimensionner"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Rotate left"
|
||||
msgstr "Rotation vers la gauche"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Rotate right"
|
||||
msgstr "Rotation vers la droite"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Save"
|
||||
msgstr "Enregistrer"
|
||||
|
||||
#: FMain.class:150
|
||||
msgid "Select photo directory"
|
||||
msgstr "Choisir le répertoire des photographies"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Sharpen"
|
||||
msgstr "Netteté"
|
||||
|
||||
|
@ -91,23 +99,23 @@ msgstr "Netteté"
|
|||
msgid "Simple Photo Editor"
|
||||
msgstr "Editeur de photographie simplifié"
|
||||
|
||||
#: FMain.class:58
|
||||
#: FMain.class:98
|
||||
msgid "Unable to load image"
|
||||
msgstr "Impossible de charger l'image"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Undo all changes"
|
||||
msgstr "Annuler tous les changements"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Zoom 100%"
|
||||
msgstr "Zoom 100%"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Zoom in"
|
||||
msgstr "Zoom avant"
|
||||
|
||||
#: FMain.class:107
|
||||
#: FMain.class:150
|
||||
msgid "Zoom out"
|
||||
msgstr "Zoom arrière"
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ Component=gb.image
|
|||
Component=gb.qt4
|
||||
Component=gb.form
|
||||
Component=gb.desktop
|
||||
Component=gb.form.dialog
|
||||
Component=gb.settings
|
||||
Component=gb.image.effect
|
||||
Authors="Benoît Minisini"
|
||||
|
|
|
@ -8,6 +8,8 @@ Private $hTimer As Timer
|
|||
|
||||
Public Sub _new(hObject As Control, sProperty As String, fTarget As Float, iTime As Integer)
|
||||
|
||||
Debug hObject.Tag;; sProperty;; fTarget
|
||||
|
||||
$hObject = hObject
|
||||
$sProperty = sProperty
|
||||
$fTarget = fTarget
|
||||
|
@ -43,6 +45,8 @@ End
|
|||
|
||||
Public Sub Stop()
|
||||
|
||||
$hTimer.Stop
|
||||
$hTimer = Null
|
||||
$hObject = Null
|
||||
|
||||
End
|
||||
|
|
|
@ -15,6 +15,8 @@ Private $sInfo As String
|
|||
Private $sMode As String
|
||||
Private $bModify As Boolean
|
||||
Private $cButton As New Collection
|
||||
Private $bFilm As Boolean = True
|
||||
Private $bReloadFilm As Boolean
|
||||
|
||||
Private $MX As Integer
|
||||
Private $MY As Integer
|
||||
|
@ -22,6 +24,45 @@ Private $MY As Integer
|
|||
Private btnPrev As CButton
|
||||
Private btnNext As CButton
|
||||
|
||||
Private Sub UpdateSaveIcon()
|
||||
|
||||
$cButton["save"].Visible = Exist(CACHE_DIR &/ File.Name($sPath)) Or $bModify
|
||||
|
||||
End
|
||||
|
||||
Private Sub UpdateFilmMode()
|
||||
|
||||
Dim sTag As String
|
||||
Dim hCtrl As Control
|
||||
|
||||
btnPrev.Visible = Not $bFilm
|
||||
btnNext.Visible = Not $bFilm
|
||||
|
||||
For Each hCtrl In $cButton
|
||||
If hCtrl.Tag = "quit" Then
|
||||
hCtrl.Visible = True
|
||||
Else If ["photo", "usb"].Exist(hCtrl.Tag) Then
|
||||
hCtrl.Visible = $bFilm
|
||||
Else
|
||||
hCtrl.Visible = Not $bFilm
|
||||
Endif
|
||||
Next
|
||||
|
||||
If $bFilm Then
|
||||
'ivwImage.IconSize = 128
|
||||
panBrowser.Show
|
||||
svwImage.Hide
|
||||
FillImageBrowser
|
||||
Else
|
||||
panBrowser.Hide
|
||||
svwImage.Show
|
||||
Try $iIndex = CInt(ivwImage.Key)
|
||||
LoadImage
|
||||
Endif
|
||||
|
||||
End
|
||||
|
||||
|
||||
Private Sub LoadImage(Optional bReset As Boolean) As Boolean
|
||||
|
||||
Dim hImage As Image
|
||||
|
@ -62,6 +103,7 @@ Private Sub LoadImage(Optional bReset As Boolean) As Boolean
|
|||
|
||||
$bModify = False
|
||||
SetZoom(0)
|
||||
UpdateSaveIcon
|
||||
dwgInfo.Refresh
|
||||
Me.Refresh
|
||||
|
||||
|
@ -84,6 +126,8 @@ Public Sub _new()
|
|||
Try Mkdir CACHE_ROOT
|
||||
|
||||
cTooltip = [
|
||||
"film": ("Browse photos"),
|
||||
"photo": ("Show photo"),
|
||||
"usb": ("Select photo directory"),
|
||||
"zoom-in": ("Zoom in"),
|
||||
"zoom-out": ("Zoom out"),
|
||||
|
@ -103,10 +147,11 @@ Public Sub _new()
|
|||
"scissors": ("Crop image"),
|
||||
"balance": ("Balance"),
|
||||
"resize": ("Resize"),
|
||||
"save": ("Save"),
|
||||
"undo": ("Undo all changes"),
|
||||
"quit": ("Quit")]
|
||||
|
||||
For Each sImg In ["usb", "-", "zoom-in", "zoom-out", "zoom-original", "zoom-fit", "-", "hflip", "vflip", "rotate-left", "rotate-right", "-", "magic", "invert", "blur", "sharpen", "normalize", "despeckle", "oil", "-", "scissors", "resize", "balance", "<->", "undo", "quit"]
|
||||
For Each sImg In ["film", "photo", "usb", "-", "zoom-in", "zoom-out", "zoom-original", "zoom-fit", "-", "hflip", "vflip", "rotate-left", "rotate-right", "-", "magic", "invert", "blur", "sharpen", "normalize", "despeckle", "oil", "-", "scissors", "resize", "balance", "<->", "save", "undo", "quit"]
|
||||
If sImg = "<->" Then
|
||||
hPanel = New Panel(panToolbar)
|
||||
hPanel.Expand = True
|
||||
|
@ -136,6 +181,8 @@ Public Sub _new()
|
|||
btnNext.Tag = "next"
|
||||
btnNext.Image = Image.Load("next.png")
|
||||
|
||||
panToolbar.Raise
|
||||
|
||||
End
|
||||
|
||||
|
||||
|
@ -227,6 +274,7 @@ End
|
|||
Public Sub Form_Resize()
|
||||
|
||||
panToolbar.Move(0, 0, Me.W, 48 + Desktop.Scale * 2)
|
||||
panMargin.H = panToolbar.H
|
||||
dwgInfo.Move(8, Me.H - dwgInfo.H, Me.W, dwgInfo.H)
|
||||
btnPrev.Move(8, (Me.H - btnPrev.H) / 2)
|
||||
btnNext.Move(Me.W - 8 - btnNext.W, (Me.H - btnNext.H) / 2)
|
||||
|
@ -327,6 +375,16 @@ Private Sub Action(sAction As String)
|
|||
|
||||
Select Case sAction
|
||||
|
||||
Case "film"
|
||||
Me.End
|
||||
SaveImage
|
||||
$bFilm = True
|
||||
UpdateFilmMode
|
||||
|
||||
Case "photo"
|
||||
$bFilm = False
|
||||
UpdateFilmMode
|
||||
|
||||
Case "previous"
|
||||
Dec $iIndex
|
||||
If $iIndex < 0 Then $iIndex = $aPath.Max
|
||||
|
@ -352,7 +410,6 @@ Private Sub Action(sAction As String)
|
|||
Case "quit"
|
||||
SetMode("")
|
||||
SaveImage
|
||||
If Exist(CACHE_DIR) Then Desktop.Open(CACHE_DIR)
|
||||
Me.Close
|
||||
|
||||
Case "balance", "scissors", "resize"
|
||||
|
@ -361,6 +418,7 @@ Private Sub Action(sAction As String)
|
|||
|
||||
Case "usb"
|
||||
SetMode("")
|
||||
Dialog.Title = ("Select photo directory")
|
||||
If Dialog.SelectDirectory() Then Return
|
||||
SetDir(Dialog.Path)
|
||||
|
||||
|
@ -404,6 +462,7 @@ Private Sub Action(sAction As String)
|
|||
End Select
|
||||
|
||||
$bModify = True
|
||||
UpdateSaveIcon
|
||||
UpdateZoom
|
||||
|
||||
End Select
|
||||
|
@ -562,7 +621,8 @@ Private Sub SetDir(sDir As String)
|
|||
$aPath = New String[]
|
||||
Try $aPath = Dir(sDir, "*.{jpg,JPG,jpeg,JPEG,png,PNG,bmp,BMP,gig,GIF}").Sort()
|
||||
$iIndex = 0
|
||||
LoadImage
|
||||
$bReloadFilm = True
|
||||
UpdateFilmMode
|
||||
|
||||
Dec Application.Busy
|
||||
|
||||
|
@ -574,8 +634,11 @@ Private Sub SaveImage() As String
|
|||
If Not $bModify Then Return
|
||||
|
||||
Try Mkdir CACHE_DIR
|
||||
Try Kill CACHE_DIR &/ ".thumb." & File.Name($sPath)
|
||||
$bReloadFilm = True
|
||||
$hImage.Save(CACHE_DIR &/ File.Name($sPath), 80)
|
||||
$bModify = False
|
||||
UpdateSaveIcon
|
||||
Return CACHE_DIR &/ File.Name($sPath)
|
||||
|
||||
Catch
|
||||
|
@ -587,7 +650,10 @@ End
|
|||
Private Sub RemoveImage()
|
||||
|
||||
Kill CACHE_DIR &/ File.Name($sPath)
|
||||
Try Kill CACHE_DIR &/ ".thumb." & File.Name($sPath)
|
||||
$bReloadFilm = True
|
||||
If Dir(CACHE_DIR).Count = 0 Then Rmdir CACHE_DIR
|
||||
UpdateSaveIcon
|
||||
|
||||
Catch
|
||||
|
||||
|
@ -611,7 +677,81 @@ Private Sub ImageMagick(sCommand As String) As Image
|
|||
Kill sPath2
|
||||
|
||||
Dec Application.Busy
|
||||
UpdateSaveIcon
|
||||
|
||||
Return hImage
|
||||
|
||||
End
|
||||
|
||||
Private Sub GetThumb(sPath As String) As Image
|
||||
|
||||
Dim sName As String
|
||||
Dim sThumb As String
|
||||
Dim hImage As Image
|
||||
|
||||
sName = File.Name(sPath)
|
||||
|
||||
If Exist(CACHE_DIR &/ sName) Then sPath = CACHE_DIR &/ sName
|
||||
|
||||
sThumb = CACHE_DIR &/ ".thumb." & sName
|
||||
If Exist(sThumb) Then
|
||||
'If Stat(sThumb).LastModified >= Stat(sPath).LastModified Then
|
||||
hImage = Image.Load(sThumb)
|
||||
'Endif
|
||||
Endif
|
||||
|
||||
If Not hImage Then
|
||||
hImage = Image.Load(sPath)
|
||||
If hImage.W > hImage.H Then
|
||||
hImage = hImage.Stretch(256, 256 * hImage.H / hImage.W)
|
||||
Else
|
||||
hImage = hImage.Stretch(256 * hImage.W / hImage.H, 256)
|
||||
Endif
|
||||
Try Kill sThumb
|
||||
hImage.Save(sThumb)
|
||||
Endif
|
||||
|
||||
Return hImage
|
||||
|
||||
End
|
||||
|
||||
Private Sub FillImageBrowser()
|
||||
|
||||
Dim I As Integer
|
||||
Dim hImage As Image
|
||||
|
||||
If $bReloadFilm Then
|
||||
|
||||
Inc Application.Busy
|
||||
|
||||
Try Mkdir CACHE_DIR
|
||||
ivwImage.Clear
|
||||
ivwImage.GridSize = 280 \ Desktop.Scale
|
||||
For I = 0 To $aPath.Max
|
||||
Try hImage = GetThumb($sDir &/ $aPath[i])
|
||||
If Error Then
|
||||
Error Error.Where; ": "; Error.Text
|
||||
hImage = Picture["icon:/256/image"].Image
|
||||
Endif
|
||||
ivwImage.Add(I, File.Name($aPath[I]), hImage.Picture)
|
||||
Wait
|
||||
Next
|
||||
|
||||
Dec Application.Busy
|
||||
$bReloadFilm = False
|
||||
|
||||
Endif
|
||||
|
||||
ivwImage[$iIndex].Selected = True
|
||||
ivwImage[$iIndex].EnsureVisible
|
||||
|
||||
End
|
||||
|
||||
|
||||
Public Sub ivwImage_DblClick()
|
||||
|
||||
$bFilm = False
|
||||
$iIndex = CInt(ivwImage.Key)
|
||||
UpdateFilmMode
|
||||
|
||||
End
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
Maximized = True
|
||||
Arrangement = Arrange.Fill
|
||||
{ svwImage ScrollArea
|
||||
MoveScaled(24,24,24,24)
|
||||
MoveScaled(5,25,24,24)
|
||||
Visible = False
|
||||
Background = &H000000&
|
||||
Mouse = Mouse.SizeAll
|
||||
Border = False
|
||||
|
@ -33,4 +34,22 @@
|
|||
Foreground = &HFFFFFF&
|
||||
Alignment = Align.Center
|
||||
}
|
||||
{ panBrowser Panel
|
||||
MoveScaled(48,17,24,30)
|
||||
Background = &H000000&
|
||||
Arrangement = Arrange.Vertical
|
||||
Margin = True
|
||||
{ panMargin Panel
|
||||
MoveScaled(4,1,12,10)
|
||||
}
|
||||
{ ivwImage IconView
|
||||
MoveScaled(3,11,16,16)
|
||||
Font = Font["+2"]
|
||||
Background = &H000000&
|
||||
Foreground = &HFFFFFF&
|
||||
Expand = True
|
||||
Mode = Select.Multiple
|
||||
Border = False
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ gb.image
|
|||
gb.qt4
|
||||
gb.form
|
||||
gb.desktop
|
||||
gb.form.dialog
|
||||
gb.settings
|
||||
gb.image.effect
|
||||
|
||||
|
|
BIN
examples/examples/Image/PhotoTouch/film.png
Normal file
BIN
examples/examples/Image/PhotoTouch/film.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
examples/examples/Image/PhotoTouch/photo.png
Normal file
BIN
examples/examples/Image/PhotoTouch/photo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
BIN
examples/examples/Image/PhotoTouch/save.png
Normal file
BIN
examples/examples/Image/PhotoTouch/save.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
Loading…
Reference in a new issue