diff --git a/app/src/doc.cgi/.project b/app/src/doc.cgi/.project index 516f4722c..6b7d671ab 100644 --- a/app/src/doc.cgi/.project +++ b/app/src/doc.cgi/.project @@ -1,9 +1,9 @@ # Gambas Project File 3.0 -# Compiled with Gambas 3.0.0 +# Compiled with Gambas 3.1.90 Title=Gambas documentation CGI script Startup=Main Icon=help.png -Version=3.0.0 +Version=3.1.90 VersionFile=1 Component=gb.db Component=gb.eval @@ -11,3 +11,4 @@ TabSize=2 Translate=1 Language=fr License=General Public Licence +Packager=1 diff --git a/app/src/doc.cgi/.src/Main.module b/app/src/doc.cgi/.src/Main.module index eabaea757..d8ad412f0 100644 --- a/app/src/doc.cgi/.src/Main.module +++ b/app/src/doc.cgi/.src/Main.module @@ -2515,7 +2515,7 @@ Private Sub GetDefaultSymbolTitle(hSym As CSymbolInfo) As String If Not sName Then sName = $hSym.Class Endif - Select Case $hSym.Name + Select Case LCase($hSym.Name) Case "_new" sTitle = If($sVersion = "2.0", "NEW ", "New ") & sName Case "_put" @@ -2866,16 +2866,16 @@ Private Function AutoLink(sStr As String) As String Else If aWord[0] = "gb" Then - rPage = DB.Find("page", "sPath = &1 AND sLang = &2", "/comp" &/ LCase(sWord), DEFAULT_LANG) + rPage = DB.Find("page", "sPath = &1 AND sLang = &2", "/comp" &/ sWord, DEFAULT_LANG) If rPage.Available Then Goto FOUND Endif If aWord.Count = 2 Then - rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb.qt" &/ LCase(aWord[0]) &/ "%") - If Not rPage.Available Then - rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb%" &/ LCase(aWord[0]) &/ "%") - Endif + 'rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb.qt" &/ LCase(aWord[0]) &/ "%") + 'If Not rPage.Available Then + rPage = DB.Find("page", "sTitle = &1 AND sLang = &2 AND sPath LIKE &3", aWord[1], DEFAULT_LANG, "/comp/gb%." &/ aWord[0] &/ "/%") + 'Endif sTitle = sWord Endif @@ -4180,8 +4180,8 @@ Private Function GetToDo() As String Else - If sName = "_free" Then Continue - If sName = "_new" Then + If LCase(sName) = "_free" Then Continue + If LCase(sName) = "_new" Then If Not hClass.Creatable Or If hClass.IsVirtual() Then Continue Endif @@ -4329,9 +4329,9 @@ Private Function GetSymbols() As String Endif Select Case hSym.Kind - Case "r", "p" + Case "r", "p", "v" cSymbol[sPrefix & "p"].Add(hSym.Name) - Case "R", "P" + Case "R", "P", "V" cSymbol[sPrefix & "P"].Add(hSym.Name) Case "C" cSymbol[sPrefix & "C"].Add(hSym.Name) @@ -4580,7 +4580,7 @@ Private Function GetSymbolSyntax(hSym As CSymbolInfo) As String sName = hSym.Class sVirtual = GetVirtualClass(sName) - Select Case hSym.Name + Select Case LCase(hSym.Name) Case "_get" @@ -4679,7 +4679,7 @@ Private Function GetSymbolSyntax(hSym As CSymbolInfo) As String Select Case LCase(hSym.Kind) - Case "p" + Case "p", "v" sSyntax = sSyntax & Keyword("Property") & " " Case "r" sSyntax = sSyntax & Keyword("Property Read") & " " diff --git a/examples/examples/Games/GameOfLife/.project b/examples/examples/Games/GameOfLife/.project index ddc2d10f0..4b7355246 100644 --- a/examples/examples/Games/GameOfLife/.project +++ b/examples/examples/Games/GameOfLife/.project @@ -1,9 +1,9 @@ # Gambas Project File 3.0 -# Compiled with Gambas 3.0.90 +# Compiled with Gambas 3.1.90 Title=Game of Life Startup=FMain Icon=glob2-icon-48x48.png -Version=3.0.90 +Version=3.1.90 VersionFile=1 Component=gb.image Component=gb.gui @@ -15,3 +15,4 @@ Maintainer=benoit Vendor=Princeton Address=benoit@localhost License=General Public Licence +Packager=1 diff --git a/examples/examples/Games/GameOfLife/.settings b/examples/examples/Games/GameOfLife/.settings index de803fbb5..b58ef4273 100644 --- a/examples/examples/Games/GameOfLife/.settings +++ b/examples/examples/Games/GameOfLife/.settings @@ -20,8 +20,8 @@ SearchString=True [OpenFile] Active=1 File[1]=".src/FMain.form" -File[2]=".src/FMain.class:14.8" -File[3]=".src/CGameField.class:26.12" +File[2]=".src/FMain.class:7.12" +File[3]=".src/CGameField.class:74.12" Count=3 [Watches] diff --git a/examples/examples/Image/PhotoTouch/.directory b/examples/examples/Image/PhotoTouch/.directory new file mode 100644 index 000000000..06dab1c8a --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.directory @@ -0,0 +1,2 @@ +[Desktop Entry] +Icon=./.icon.png diff --git a/examples/examples/Image/PhotoTouch/.icon.png b/examples/examples/Image/PhotoTouch/.icon.png new file mode 100644 index 000000000..2977cee78 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/.icon.png differ diff --git a/examples/examples/Image/PhotoTouch/.info b/examples/examples/Image/PhotoTouch/.info new file mode 100644 index 000000000..4ec779cb0 --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.info @@ -0,0 +1,39 @@ +#CButton +DrawingArea +C +:Click +: + + +Image +p +Image + +_new +m + + +DrawingArea_Enter +m + + +DrawingArea_Leave +m + + +DrawingArea_MouseDown +m + + +DrawingArea_DblClick +m + + +Timer_Timer +m + + +DrawingArea_Draw +m + + diff --git a/examples/examples/Image/PhotoTouch/.lang/fr.mo b/examples/examples/Image/PhotoTouch/.lang/fr.mo new file mode 100644 index 000000000..28b19914d Binary files /dev/null and b/examples/examples/Image/PhotoTouch/.lang/fr.mo differ diff --git a/examples/examples/Image/PhotoTouch/.lang/fr.po b/examples/examples/Image/PhotoTouch/.lang/fr.po new file mode 100644 index 000000000..1047b28bc --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.lang/fr.po @@ -0,0 +1,24 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"POT-Creation-Date: 2002-11-01 04:27+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: FBrightness.form:55 +msgid "Balance" +msgstr "Balance" + +#: FScissors.form:19 +msgid "Cut" +msgstr "Découper" + +#: .project:1 +msgid "Retouche Photo" +msgstr "" + diff --git a/examples/examples/Image/PhotoTouch/.list b/examples/examples/Image/PhotoTouch/.list new file mode 100644 index 000000000..84ccda50a --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.list @@ -0,0 +1 @@ +CButton diff --git a/examples/examples/Image/PhotoTouch/.project b/examples/examples/Image/PhotoTouch/.project new file mode 100644 index 000000000..6e320d717 --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.project @@ -0,0 +1,17 @@ +# Gambas Project File 3.0 +# Compiled with Gambas 3.1.90 +Title=Simple Photo Editor +Startup=FMain +Icon=icon.png +Version=3.1.90 +VersionFile=1 +Component=gb.image +Component=gb.qt4 +Component=gb.form +Component=gb.desktop +Component=gb.image.effect +Authors="Benoît Minisini" +TabSize=2 +Translate=1 +Language=fr +Packager=1 diff --git a/examples/examples/Image/PhotoTouch/.src/CButton.class b/examples/examples/Image/PhotoTouch/.src/CButton.class new file mode 100644 index 000000000..7ed62f1b8 --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.src/CButton.class @@ -0,0 +1,103 @@ +' Gambas class file + +Export + +Inherits DrawingArea + +Event Click + +Property Image As Image + +Private Const MIN_OPACITY As Float = 0.3 +Private Const MAX_OPACITY As Float = 0.8 + +Private $hObs As Observer +Private $hImage As Image +Private $hDraw As Image +Private $bInside As Boolean +Private $hTimer As Timer +Private $fOpacity As Float = MIN_OPACITY + +Public Sub _new() + + $hObs = New Observer(Me) As "DrawingArea" + $hTimer = New Timer As "Timer" + $hTimer.Delay = 50 + Me.Mouse = Mouse.Pointing + +End + +Public Sub DrawingArea_Enter() + + $bInside = True + $hTimer.Start + +End + +Public Sub DrawingArea_Leave() + + $bInside = False + $hTimer.Start + +End + +Public Sub DrawingArea_MouseDown() + + Raise Click + +End + +Public Sub DrawingArea_DblClick() + + Raise Click + +End + + +Public Sub Timer_Timer() + + If $bInside Then + $fOpacity = Min(MAX_OPACITY, $fOpacity + 0.1) + If $fOpacity >= MAX_OPACITY Then + $hTimer.Stop + Endif + Else + $fOpacity = Max(MIN_OPACITY, $fOpacity - 0.1) + If $fOpacity <= MIN_OPACITY Then + $hTimer.Stop + Endif + Endif + + SetOpacity + +End + + +Public Sub DrawingArea_Draw() + + If Not $hImage Then Return + + Draw.Image($hDraw, 0, 0, Me.W, Me.H) + +End + +Private Function Image_Read() As Image + + Return $hImage + +End + +Private Sub Image_Write(Value As Image) + + $hImage = Value + SetOpacity + +End + +Private Sub SetOpacity() + + $hDraw = $hImage.Copy() + $hDraw.Opacity($fOpacity) + Me.Refresh + +End diff --git a/examples/examples/Image/PhotoTouch/.src/FBrightness.class b/examples/examples/Image/PhotoTouch/.src/FBrightness.class new file mode 100644 index 000000000..4a9eb368f --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.src/FBrightness.class @@ -0,0 +1,79 @@ +' Gambas class file + +Private $bNoChange As Boolean + +Private $MX As Integer +Private $MY As Integer +Private $hRect As Rect + +Private btnUndo As CButton +Private btnApply As CButton + +Public Sub _new() + + btnUndo = New CButton(Me) As "btnUndo" + btnUndo.Move(Me.W - 128 - Desktop.Scale * 3, Desktop.Scale * 3, 64, 64) + btnUndo.Image = Image.Load("undo.png") + + btnApply = New CButton(Me) As "btnApply" + btnApply.Move(btnUndo.X + btnUndo.W + Desktop.Scale, btnUndo.Y, 64, 64) + btnApply.Image = Image.Load("ok.png") + +End + + +Public Sub Form_Open() + + Me.Center + FMain.Begin + +End + +Public Sub Form_Close() + + FMain.End + +End + +Public Sub btnUndo_Click() + + $bNoChange = True + sldBrightness.Value = 50 + sldContrast.Value = 50 + sldGamma.Value = 50 + $bNoChange = False + Balance_Change + +End + +Public Sub btnApply_Click() + + FMain.Apply + Me.Close + +End + +Public Sub Balance_Change() + + If $bNoChange Then Return + FMain.Balance(sldBrightness.Value, sldContrast.Value, sldGamma.Value) + +End + +Public Sub panBrightness_MouseDown() + + $MX = Mouse.ScreenX + $MY = Mouse.ScreenY + $hRect = Rect(Me.X, Me.Y, Me.W, Me.H) + +End + +Public Sub panBrightness_MouseMove() + + Dim X, Y As Integer + + X = Min(Max($hRect.X + Mouse.ScreenX - $MX, 0), FMain.W - $hRect.W) + Y = Min(Max($hRect.Y + Mouse.ScreenY - $MY, 0), FMain.H - $hRect.H) + Me.Move(X, Y) + +End diff --git a/examples/examples/Image/PhotoTouch/.src/FBrightness.form b/examples/examples/Image/PhotoTouch/.src/FBrightness.form new file mode 100644 index 000000000..5b9072a3a --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.src/FBrightness.form @@ -0,0 +1,54 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,74,48) + Background = &HFFFFFF& + Border = False + Stacking = Window.Above + SkipTaskbar = True + Opacity = 50 + { panBrightness Panel + MoveScaled(1,1,72,46) + Background = &H000000& + { PictureBox1 PictureBox + MoveScaled(2,10,10,10) + Picture = Picture["luminosity.png"] + Stretch = True + Alignment = Align.Center + } + { PictureBox2 PictureBox + MoveScaled(2,22,10,10) + Picture = Picture["contrast.png"] + Stretch = True + Alignment = Align.Center + } + { sldBrightness Slider Balance + Name = "sldBrightness" + MoveScaled(15,13,53,3) + Value = 50 + } + { sldContrast Slider Balance + Name = "sldContrast" + MoveScaled(15,25,53,3) + Value = 50 + } + { Label1 Label + MoveScaled(2,2,52,6) + Font = Font["Bold,+5"] + Foreground = Color.TextBackground + AutoResize = True + Text = ("Balance") + } + { PictureBox3 PictureBox + MoveScaled(2,34,10,10) + Picture = Picture["gamma.png"] + Stretch = True + Alignment = Align.Center + } + { sldGamma Slider Balance + Name = "sldGamma" + MoveScaled(15,37,53,3) + Value = 50 + } + } +} diff --git a/examples/examples/Image/PhotoTouch/.src/FMain.class b/examples/examples/Image/PhotoTouch/.src/FMain.class new file mode 100644 index 000000000..8b922a7bd --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.src/FMain.class @@ -0,0 +1,506 @@ +' Gambas class file + +Private CACHE_DIR As String = "~/.cache/gambas/PhotoTouch" + +Private $aPath As String[] +Private $sPath As String +Private $sDir As String +Private $iIndex As Integer +Private $hImage As Image +Private $hZoom As Image +Private $hTemp As Image +Private $fZoom As Float = 1 +Private $sInfo As String +Private $sMode As String +Private $bModify As Boolean + +Private $MX As Integer +Private $MY As Integer + +Private btnPrev As CButton +Private btnNext As CButton + +Private Sub LoadImage(Optional bReset As Boolean) As Boolean + + Dim hImage As Image + + Inc Application.Busy + + Me.End + SaveImage + + If Not bReset Then + Try $sPath = CACHE_DIR &/ $aPath[$iIndex] + If Exist($sPath) Then Try hImage = Image.Load($sPath) + Endif + + If Not hImage Then + Try $sPath = $sDir &/ $aPath[$iIndex] + If $sPath Then Try hImage = Image.Load($sPath) + Endif + + $sInfo = "" + Try $sInfo = File.Name($sPath) & " - " & Format(Stat($sPath).LastModified, gb.LongDate) + If hImage Then + $hImage = hImage + svwImage.ResizeContents($hImage.W, $hImage.H) + svwImage.Show + lblError.Hide + Else + svwImage.Hide + lblError.Show + If $aPath.Count = 0 Then + lblError.Text = ("No image in directory") + $sInfo = "" + Else + lblError.Text = ("Unable to load image") + $sInfo = File.Name($sPath) & " - " & Format(Stat($sPath).LastModified, gb.LongDate) + Endif + Endif + + $bModify = False + SetZoom(0) + dwgInfo.Refresh + Me.Refresh + + Dec Application.Busy + +End + +Public Sub _new() + + Dim hCtrl As Control + Dim sImg As String + Dim hButton As CButton + Dim hPanel As Panel + + Application.MainWindow = Me + + Try Mkdir File.Dir(File.Dir(cache_dir)) + Try Mkdir File.Dir(cache_dir) + Try Mkdir CACHE_DIR + + For Each sImg In ["usb", "-", "zoom-in", "zoom-out", "zoom-original", "zoom-fit", "-", "rotate-left", "rotate-right", "-", "scissors", "luminosity", "<->", "undo", "quit"] + If sImg = "<->" Then + hPanel = New Panel(panToolbar) + hPanel.Expand = True + hPanel.Resize(8, 64) + Else If sImg = "-" Then + hPanel = New Panel(panToolbar) + hPanel.Resize(16, 64) + Else + hButton = New CButton(panToolbar) As "Button" + hButton.Resize(64, 64) + hButton.Image = Image.Load(sImg & ".png") + hButton.Tag = sImg + Endif + Next + + btnPrev = New CButton(Me) As "Button" + btnPrev.Resize(64, 64) + btnPrev.Ignore = True + btnPrev.Tag = "previous" + btnPrev.Image = Image.Load("previous.png") + + btnNext = New CButton(Me) As "Button" + btnNext.Resize(64, 64) + btnNext.Ignore = True + btnNext.Tag = "next" + btnNext.Image = Image.Load("next.png") + +End + + +Public Sub Form_Open() + + SetDir(User.Home) + +End + +Public Sub svwImage_Draw() + + Dim X As Integer + Dim Y As Integer + Dim XR As Integer + Dim YR As Integer + Dim SX, SX2 As Integer + Dim SY, SY2 As Integer + Dim DX As Integer + Dim DY As Integer + Dim C As Integer + Dim SW, SH As Integer + Dim hZoom As Image + Dim iZoom As Integer + + If Not $hImage Then Return + + If $fZoom > 1 Then + + iZoom = $fZoom + + Draw.LineStyle = Line.None + Draw.FillStyle = Fill.Solid + + DX = Max(0, (Me.W - $hImage.W * iZoom) / 2) + DY = Max(0, (Me.H - $hImage.H * iZoom) / 2) + + SX = (Draw.Clip.X - DX) \ iZoom + SY = (Draw.Clip.Y - DY) \ iZoom + SX2 = (Draw.Clip.X - DX + Draw.Clip.W - 1) \ iZoom + SY2 = (Draw.Clip.Y - DY + Draw.Clip.H - 1) \ iZoom + + SX = Max(0, SX) + SX2 = Min($hImage.Width - 1, SX2) + SW = SX2 - SX + 1 + + SY = Max(0, SY) + SY2 = Min($hImage.Height - 1, SY2) + SH = SY2 - SY + 1 + + 'If $fZoom > 5 Then + ' Draw.LineStyle = Line.Solid + ' Draw.Foreground = &H989898 + 'Else + ' Draw.LineStyle = Line.None + 'Endif + + Draw.Zoom($hImage, iZoom, SX * iZoom + DX, SY * iZoom + DY, SX + svwImage.ScrollX \ iZoom, SY + svwImage.ScrollY \ iZoom, SW, SH) + + Else If $fZoom = 1 Then + + If $hImage.W < Me.W Then + X = (Me.W - $hImage.W) / 2 + Else + X = - svwImage.ScrollX + Endif + + If $hImage.H < Me.H Then + Y = (Me.H - $hImage.H) / 2 + Else + Y = - svwImage.ScrollY + Endif + + Draw.Image($hImage, X, Y) + + Else + + If $hZoom.W < Me.W Then + X = (Me.W - $hZoom.W) / 2 + Else + X = - svwImage.ScrollX + Endif + + If $hZoom.H < Me.H Then + Y = (Me.H - $hZoom.H) / 2 + Else + Y = - svwImage.ScrollY + Endif + + Draw.Image($hZoom, X, Y) + + Endif + +End + +Public Sub Form_Resize() + + panToolbar.Move(0, 0, Me.W, 64 + Desktop.Scale * 2) + 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) + +End + +Public Sub Button_Click() + + Action(Last.Tag) + +End + +Private Sub UpdateZoom() + + Dim X, Y As Float + + If Not $hImage Then Return + + If $fZoom < 1 Then + $hZoom = $hImage.Stretch($hImage.W * $fZoom, $hImage.H * $fZoom) + Else + $hZoom = Null + Endif + + X = (svwImage.ScrollX + svwImage.ClientW / 2) / svwImage.ScrollW + Y = (svwImage.ScrollY + svwImage.ClientH / 2) / svwImage.ScrollH + + svwImage.ResizeContents($hImage.W * $fZoom, $hImage.H * $fZoom) + svwImage.Scroll(X * svwImage.ScrollW - svwImage.ClientW / 2, Y * svwImage.ScrollH - svwImage.ClientH / 2) + + Me.Refresh + +End + +Private Sub SetZoom(fZoom As Float) + + If Not $hImage Then Return + + If fZoom = 0 Then + $fZoom = 0 + fZoom = Min(Me.W / $hImage.W, Me.H / $hImage.H) + fZoom = Min(1, fZoom) + Endif + + fZoom = Max(1 / 32, Min(32, fZoom)) + If fZoom = $fZoom Then Return + If fZoom <> 1 Then + If ($hImage.W * fZoom) < 96 Or If ($hImage.H * fZoom) < 96 Then Return + Endif + + $fZoom = fZoom + UpdateZoom + +End + +Public Sub SetMode(sMode As String) + + If $sMode Then + Cancel + FBrightness.Close + FScissors.Close + Endif + + If sMode = $sMode Then + $sMode = "" + Return + Endif + + Select Case sMode + Case "luminosity" + FBrightness.Show + Case "scissors" + FScissors.Show + End Select + + $sMode = sMode + +End + + +Private Sub Action(sAction As String) + + Select Case sAction + + Case "previous" + Dec $iIndex + If $iIndex < 0 Then $iIndex = $aPath.Max + LoadImage + + Case "next" + Inc $iIndex + If $iIndex > $aPath.Max Then $iIndex = 0 + LoadImage + + Case "zoom-in" + SetZoom(2 ^ Int(Log2($fZoom)) * 2) + + Case "zoom-out" + SetZoom(2 ^ Int(Log2($fZoom) - 0.001)) + + Case "zoom-original" + SetZoom(1) + + Case "zoom-fit" + SetZoom(0) + + Case "rotate-left" + If Not $hImage Then Return + $hImage = $hImage.Rotate(Pi(0.5)) + $bModify = True + 'SaveImage + UpdateZoom + + Case "rotate-right" + If Not $hImage Then Return + $hImage = $hImage.Rotate(Pi(-0.5)) + $bModify = True + 'SaveImage + UpdateZoom + + Case "quit" + SetMode("") + SaveImage + If Dir(CACHE_DIR).Count Then Desktop.Open(CACHE_DIR) + Me.Close + + Case "luminosity", "scissors" + If Not $hImage Then Return + SetMode(sAction) + + Case "usb" + SetMode("") + If Dialog.SelectDirectory() Then Return + SetDir(Dialog.Path) + + Case "undo" + SetMode("") + LoadImage(True) + RemoveImage + + End Select + +End + +Public Sub svwImage_MouseDown() + + $MX = Mouse.X + svwImage.ScrollX + $MY = Mouse.Y + svwImage.ScrollY + 'Debug $MX;; $MY + +End + +Public Sub svwImage_MouseMove() + + If Mouse.Left Then + 'Debug Mouse.X - $MX;; Mouse.Y - $MY + svwImage.Scroll($MX - Mouse.X, $MY - Mouse.Y) + Endif + +End + +Public Sub dwgInfo_Draw() + + Dim X, Y As Integer + + Paint.Font = Font["Bold,+3"] + ' Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 128)) + ' For X = -2 To 2 + ' For Y = -2 To 2 + ' If X = 0 And If Y = 0 Then Continue + ' Paint.Text($sInfo, 8 + X, 8 + Y, dwgInfo.W, dwgInfo.H, Align.Left) + ' Next + ' Next + ' Paint.Fill + Paint.LineWidth = 1 + Paint.Brush = Paint.Color(Color.SetAlpha(Color.White, 192)) + Paint.DrawText($sInfo, 0, 0, dwgInfo.W, dwgInfo.H, Align.Left) + +End + +Public Sub Form_KeyPress() + + Select Case Key.Code + + Case Key.Esc + Action("quit") + + End Select + +End + +Public Sub Begin() + + $hTemp = $hImage.Copy() + +End + +Public Sub End() + + $hTemp = Null + UpdateZoom + SetMode("") + 'SaveImage + Me.Refresh + +End + +Public Sub Apply() + + $hTemp = $hImage + +End + +Public Sub Cancel() + + If Not $hTemp Then Return + $hImage = $hTemp.Copy() + UpdateZoom + Me.Refresh + +End + +Public Sub GetImage() As Image + + Return $hImage + +End + +Public Sub Balance(iBrightness As Integer, iContrast As Integer, iGamma As Integer) + + $hImage = $hTemp.Copy() + $hImage.Balance((iBrightness - 50) / 50, (iContrast - 50) / 50, (iGamma - 50) / 50) + $bModify = True + UpdateZoom + Me.Refresh + +End + +Public Sub Cut() + + Dim X, Y, W, H As Integer + Dim hRect As Rect + + W = FScissors.W / $fZoom + H = FScissors.H / $fZoom + X = (svwImage.ScrollX + FScissors.X) / $fZoom + Y = (svwImage.ScrollY + FScissors.Y) / $fZoom + + If $hImage.W * $fZoom <= Me.W Then X -= (Me.W / $fZoom - $hImage.W) / 2 + If $hImage.H * $fZoom <= Me.H Then Y -= (Me.H / $fZoom - $hImage.H) / 2 + + hRect = Rect(X, Y, W, H) + hRect = hRect.Intersection(Rect(0, 0, $hImage.W, $hImage.H)) + + If Not hRect Then Return + + $hImage = $hImage.Copy(hRect.X, hRect.Y, hRect.W, hRect.H) + $bModify = True + $hTemp = $hImage + Me.End + SetZoom(0) + +End + +Private Sub SetDir(sDir As String) + + Inc Application.Busy + + Shell "cd " & Shell(CACHE_DIR) & "; rm -f *" Wait + + $sDir = sDir + $aPath = New String[] + Try $aPath = Dir(sDir, "*.{jpg,JPG,jpeg,JPEG,png,PNG,bmp,BMP,gig,GIF}").Sort() + $iIndex = 0 + LoadImage + + Dec Application.Busy + +End + +Private Sub SaveImage() + + If Not $hImage Then Return + If Not $bModify Then Return + + $hImage.Save(CACHE_DIR &/ File.Name($sPath)) + $bModify = False + +Catch + + Message.Error(Error.Text) + +End + +Private Sub RemoveImage() + + Try Kill CACHE_DIR &/ File.Name($sPath) + +End diff --git a/examples/examples/Image/PhotoTouch/.src/FMain.form b/examples/examples/Image/PhotoTouch/.src/FMain.form new file mode 100644 index 000000000..908d8a00a --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.src/FMain.form @@ -0,0 +1,35 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,82,72) + Border = False + Maximized = True + Arrangement = Arrange.Fill + { svwImage ScrollArea + MoveScaled(24,24,24,24) + Background = &H000000& + Mouse = Mouse.SizeAll + Border = False + ScrollBar = Scroll.None + } + { dwgInfo DrawingArea + MoveScaled(5,64,66,6) + Ignore = True + Painted = True + } + { panToolbar HBox + MoveScaled(1,1,52,13) + Ignore = True + AutoResize = True + Spacing = True + Margin = True + } + { lblError Label + MoveScaled(15,52,46,9) + Visible = False + Font = Font["Bold,+5"] + Background = &H000000& + Foreground = &HFFFFFF& + Alignment = Align.Center + } +} diff --git a/examples/examples/Image/PhotoTouch/.src/FScissors.class b/examples/examples/Image/PhotoTouch/.src/FScissors.class new file mode 100644 index 000000000..fb5973489 --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.src/FScissors.class @@ -0,0 +1,154 @@ +' Gambas class file + +Private $aScissors As Panel[] + +Private Enum S_N, S_S, S_W, S_E, S_NW, S_NE, S_SW, S_SE +Private HANDLE_SIZE As Integer + +Private $aMouse As Integer[] +Private $aOpacity As Integer[] + +Private $MX As Integer +Private $MY As Integer +Private $hRect As Rect + +Private btnCut As CButton + +Private Sub Form_Resize() + + $aScissors[S_NW].Move(0, 0, HANDLE_SIZE, HANDLE_SIZE) + $aScissors[S_NE].Move(Me.W - HANDLE_SIZE, 0, HANDLE_SIZE, HANDLE_SIZE) + $aScissors[S_SW].Move(0, Me.H - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE) + $aScissors[S_SE].Move(Me.W - HANDLE_SIZE, Me.H - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE) + $aScissors[S_N].Move(HANDLE_SIZE, 0, Me.W - HANDLE_SIZE * 2, HANDLE_SIZE) + $aScissors[S_S].Move(HANDLE_SIZE, Me.H - HANDLE_SIZE, Me.W - HANDLE_SIZE * 2, HANDLE_SIZE) + $aScissors[S_W].Move(0, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2) + $aScissors[S_E].Move(Me.W - HANDLE_SIZE, HANDLE_SIZE, HANDLE_SIZE, Me.H - HANDLE_SIZE * 2) + + btnCut.Move(Me.W - 64 - Desktop.Scale * 3, Desktop.Scale * 3) + +End + + +Public Sub Form_Open() + + Dim I As Integer + + $aMouse = [Mouse.SizeN, Mouse.SizeS, Mouse.SizeW, Mouse.SizeE, Mouse.SizeNW, Mouse.SizeNE, Mouse.SizeSW, Mouse.SizeSE] + HANDLE_SIZE = Desktop.Scale + + $aScissors = New Panel[8] + + For I = 0 To 7 + $aScissors[I] = New Panel(Me) As "Panel" + With $aScissors[I] + .Mouse = $aMouse[I] + .Background = Color.White 'IIf(I >= S_NW, Color.RGB(192, 192, 192), Color.White) + .Tag = I + End With + Next + + btnCut = New CButton(Me) As "btnCut" + btnCut.Resize(64, 64) + btnCut.Image = Image.Load("scissors.png") + + Me.Move(FMain.ClientW \ 4, FMain.ClientH \ 4, FMain.ClientW \ 2, FMain.ClientH \ 2) + Form_Resize + +End + +Public Sub Panel_MouseDown() + + $MX = Mouse.ScreenX + $MY = Mouse.ScreenY + $hRect = Rect(Me.X, Me.Y, Me.W, Me.H) + +End + +Public Sub Panel_MouseMove() + + Dim X, Y As Integer + Dim iTag As Integer = Last.Tag + Dim MIN_HEIGHT As Integer = 64 + Desktop.Scale * 6 + Dim MIN_WIDTH As Integer = 64 + Desktop.Scale * 6 + + Select Case Last.Tag + + Case S_N + Y = $hRect.Y + Mouse.ScreenY - $MY + Y = Min($hRect.Bottom - MIN_HEIGHT, Max(0, Y)) + Me.Move(Me.X, Y, Me.W, $hRect.H + $hRect.Y - Y) + + Case S_S + Y = $hRect.H + Mouse.ScreenY - $MY + Y = Min(FMain.H - $hRect.Y, Max(MIN_HEIGHT, Y)) + Me.Move(Me.X, Me.Y, Me.W, Y) + + Case S_W + X = $hRect.X + Mouse.ScreenX - $MX + X = Min($hRect.Right - MIN_WIDTH, Max(0, X)) + Me.Move(X, Me.Y, $hRect.W + $hRect.X - X, Me.H) + + Case S_E + X = $hRect.W + Mouse.ScreenX - $MX + X = Min(FMain.W - $hRect.X, Max(MIN_WIDTH, X)) + Me.Move(Me.X, Me.Y, X, Me.H) + + Case S_NW + Y = $hRect.Y + Mouse.ScreenY - $MY + Y = Min($hRect.Bottom - MIN_HEIGHT, Max(0, Y)) + X = $hRect.X + Mouse.ScreenX - $MX + X = Min($hRect.Right - MIN_WIDTH, Max(0, X)) + Me.Move(X, Y, $hRect.W + $hRect.X - X, $hRect.H + $hRect.Y - Y) + + Case S_NE + Y = $hRect.Y + Mouse.ScreenY - $MY + Y = Min($hRect.Bottom - MIN_HEIGHT, Max(0, Y)) + X = $hRect.W + Mouse.ScreenX - $MX + X = Min(FMain.W - $hRect.X, Max(MIN_WIDTH, X)) + Me.Move(Me.X, Y, X, $hRect.H + $hRect.Y - Y) + + Case S_SW + Y = $hRect.H + Mouse.ScreenY - $MY + Y = Min(FMain.H - $hRect.Y, Max(MIN_HEIGHT, Y)) + X = $hRect.X + Mouse.ScreenX - $MX + X = Min($hRect.Right - MIN_WIDTH, Max(0, X)) + Me.Move(X, Me.Y, $hRect.W + $hRect.X - X, Y) + + Case S_SE + Y = $hRect.H + Mouse.ScreenY - $MY + Y = Min(FMain.H - $hRect.Y, Max(MIN_HEIGHT, Y)) + X = $hRect.W + Mouse.ScreenX - $MX + X = Min(FMain.W - $hRect.X, Max(MIN_WIDTH, X)) + Me.Move(Me.X, Me.Y, X, Y) + + End Select + + Form_Resize + +End + + +Public Sub Form_MouseDown() + + $MX = Mouse.ScreenX + $MY = Mouse.ScreenY + $hRect = Rect(Me.X, Me.Y, Me.W, Me.H) + +End + +Public Sub Form_MouseMove() + + Dim X, Y As Integer + + X = Min(Max($hRect.X + Mouse.ScreenX - $MX, 0), FMain.W - $hRect.W) + Y = Min(Max($hRect.Y + Mouse.ScreenY - $MY, 0), FMain.H - $hRect.H) + Me.Move(X, Y) + +End + +Public Sub btnCut_Click() + + FMain.Cut + +End diff --git a/examples/examples/Image/PhotoTouch/.src/FScissors.form b/examples/examples/Image/PhotoTouch/.src/FScissors.form new file mode 100644 index 000000000..1fee6ae31 --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.src/FScissors.form @@ -0,0 +1,17 @@ +# Gambas Form File 3.0 + +{ Form Form + MoveScaled(0,0,64,64) + Background = &H000000& + Mouse = Mouse.SizeAll + Border = False + Stacking = Window.Above + SkipTaskbar = True + Opacity = 50 + { Label1 Label + MoveScaled(3,3,52,6) + Font = Font["Bold,+5"] + Foreground = Color.TextBackground + Text = ("Cut") + } +} diff --git a/examples/examples/Image/PhotoTouch/.startup b/examples/examples/Image/PhotoTouch/.startup new file mode 100644 index 000000000..b7f2100d3 --- /dev/null +++ b/examples/examples/Image/PhotoTouch/.startup @@ -0,0 +1,12 @@ +FMain +Simple Photo Editor +0 +0 +3.1.90 + +gb.image +gb.qt4 +gb.form +gb.desktop +gb.image.effect + diff --git a/examples/examples/Image/PhotoTouch/contrast.png b/examples/examples/Image/PhotoTouch/contrast.png new file mode 100644 index 000000000..169c5aa6d Binary files /dev/null and b/examples/examples/Image/PhotoTouch/contrast.png differ diff --git a/examples/examples/Image/PhotoTouch/control.png b/examples/examples/Image/PhotoTouch/control.png new file mode 100644 index 000000000..421a091a8 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/control.png differ diff --git a/examples/examples/Image/PhotoTouch/delete.png b/examples/examples/Image/PhotoTouch/delete.png new file mode 100644 index 000000000..52277750a Binary files /dev/null and b/examples/examples/Image/PhotoTouch/delete.png differ diff --git a/examples/examples/Image/PhotoTouch/gamma.png b/examples/examples/Image/PhotoTouch/gamma.png new file mode 100644 index 000000000..77f1298bf Binary files /dev/null and b/examples/examples/Image/PhotoTouch/gamma.png differ diff --git a/examples/examples/Image/PhotoTouch/icon.png b/examples/examples/Image/PhotoTouch/icon.png new file mode 100644 index 000000000..e2c7adfb2 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/icon.png differ diff --git a/examples/examples/Image/PhotoTouch/luminosity.png b/examples/examples/Image/PhotoTouch/luminosity.png new file mode 100644 index 000000000..4830796d0 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/luminosity.png differ diff --git a/examples/examples/Image/PhotoTouch/next.png b/examples/examples/Image/PhotoTouch/next.png new file mode 100644 index 000000000..324909025 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/next.png differ diff --git a/examples/examples/Image/PhotoTouch/ok.png b/examples/examples/Image/PhotoTouch/ok.png new file mode 100644 index 000000000..8c9880757 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/ok.png differ diff --git a/examples/examples/Image/PhotoTouch/previous.png b/examples/examples/Image/PhotoTouch/previous.png new file mode 100644 index 000000000..0e4b53120 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/previous.png differ diff --git a/examples/examples/Image/PhotoTouch/quit.png b/examples/examples/Image/PhotoTouch/quit.png new file mode 100644 index 000000000..1cf561106 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/quit.png differ diff --git a/examples/examples/Image/PhotoTouch/redo.png b/examples/examples/Image/PhotoTouch/redo.png new file mode 100644 index 000000000..8a5a7f6fb Binary files /dev/null and b/examples/examples/Image/PhotoTouch/redo.png differ diff --git a/examples/examples/Image/PhotoTouch/rotate-left.png b/examples/examples/Image/PhotoTouch/rotate-left.png new file mode 100644 index 000000000..75c6bd0de Binary files /dev/null and b/examples/examples/Image/PhotoTouch/rotate-left.png differ diff --git a/examples/examples/Image/PhotoTouch/rotate-right.png b/examples/examples/Image/PhotoTouch/rotate-right.png new file mode 100644 index 000000000..6b4977c15 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/rotate-right.png differ diff --git a/examples/examples/Image/PhotoTouch/scissors.png b/examples/examples/Image/PhotoTouch/scissors.png new file mode 100644 index 000000000..175b8f337 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/scissors.png differ diff --git a/examples/examples/Image/PhotoTouch/undo.png b/examples/examples/Image/PhotoTouch/undo.png new file mode 100644 index 000000000..c6a6a34a2 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/undo.png differ diff --git a/examples/examples/Image/PhotoTouch/usb.png b/examples/examples/Image/PhotoTouch/usb.png new file mode 100644 index 000000000..442f6de8d Binary files /dev/null and b/examples/examples/Image/PhotoTouch/usb.png differ diff --git a/examples/examples/Image/PhotoTouch/zoom-fit.png b/examples/examples/Image/PhotoTouch/zoom-fit.png new file mode 100644 index 000000000..c0f85f2da Binary files /dev/null and b/examples/examples/Image/PhotoTouch/zoom-fit.png differ diff --git a/examples/examples/Image/PhotoTouch/zoom-in.png b/examples/examples/Image/PhotoTouch/zoom-in.png new file mode 100644 index 000000000..ca578f27d Binary files /dev/null and b/examples/examples/Image/PhotoTouch/zoom-in.png differ diff --git a/examples/examples/Image/PhotoTouch/zoom-original.png b/examples/examples/Image/PhotoTouch/zoom-original.png new file mode 100644 index 000000000..0abcda9a2 Binary files /dev/null and b/examples/examples/Image/PhotoTouch/zoom-original.png differ diff --git a/examples/examples/Image/PhotoTouch/zoom-out.png b/examples/examples/Image/PhotoTouch/zoom-out.png new file mode 100644 index 000000000..1f37424dc Binary files /dev/null and b/examples/examples/Image/PhotoTouch/zoom-out.png differ