[DEVELOPMENT ENVIRONMENT]

* NEW: The image editor text tool now has twelve buttons to define the text
  anchor.


git-svn-id: svn://localhost/gambas/trunk@6211 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-03-29 20:00:27 +00:00
parent 98203894df
commit 80b28dda46
16 changed files with 92 additions and 43 deletions

View File

@ -1,7 +1,6 @@
' Gambas class file
Public Enum ACTION_NONE, ACTION_STROKE, ACTION_FILL, ACTION_CLEAR, ACTION_CLIP, ACTION_EXTENT, ACTION_HANDLE, ACTION_MAGNET, ACTION_SELECT
Public Enum MAGNET_NONE, MAGNET_RECTANGLE, MAGNET_ELLIPSE
Private Enum CMD_MOVE_TO, CMD_LINE_TO ', CMD_RECTANGLE, CMD_ELLIPSE
@ -384,7 +383,7 @@ Public Sub Rectangle(X As Integer, Y As Integer, W As Integer, H As Integer)
End
Public Sub Text(X As Integer, Y As Integer, sText As String, sFont As String, iAlign As Integer)
Public Sub Text(X As Integer, Y As Integer, sText As String, sFont As String, iAlign As Integer, bAlignBase As Boolean)
Dim hImage As Image
Dim hOutline As PointF[][]
@ -401,7 +400,28 @@ Public Sub Text(X As Integer, Y As Integer, sText As String, sFont As String, iA
Paint.Begin(hImage)
Paint.Font = Font[sFont]
hExtents = Paint.TextExtents(sText)
Paint.Text(sText, X, Y, hExtents.Width, hExtents.Height, Align.TopNormal + iAlign) ', W, H, iAlign)
Debug iAlign;; bAlignBase
If Align.IsLeft(iAlign) Then
'X = X
Else If Align.IsRight(iAlign) Then
X -= hExtents.Width
Else If Align.IsCenter(iAlign) Then
X -= hExtents.Width / 2
Endif
If bAlignBase Then
Y -= Paint.Font.Ascent
Else If Align.IsTop(iAlign) Then
'Y = Y
Else If Align.IsBottom(iAlign) Then
Y -= hExtents.Height
Else If Align.IsMiddle(iAlign) Then
Y -= hExtents.Height / 2
Endif
Paint.Text(sText, X, Y, hExtents.Width, hExtents.Height, Align.TopLeft) ', W, H, iAlign)
hOutline = Paint.PathOutline
For Each hPoly In hOutline

View File

@ -2763,10 +2763,10 @@ Public Sub btnHide_Click()
End
Public Sub UpdateText(sText As String, sFont As String, iAlign As Integer)
Public Sub UpdateText(sText As String, sFont As String, iAlign As Integer, bAlignBase As Boolean)
$hSelect = $hTextSelect.Copy()
$hSelect.Text($hLastPoint.X, $hLastPoint.Y, sText, sFont, iAlign)
$hSelect.Text($hLastPoint.X, $hLastPoint.Y, sText, sFont, iAlign, bAlignBase)
imvImage.Refresh
End

View File

@ -9,6 +9,8 @@ Private $aClipboard As New CImageClipboard[]
Private $aGradientPos As Float[]
Private $aGradientColors As Integer[]
Private $aTextAlign As String[] = ["nw", "n", "ne", "w", "ce", "e", "bw", "b", "be", "sw", "s", "se"]
Private $iCurrentColor As Integer = -1
Private $aLabel As Label[]
@ -44,6 +46,12 @@ Public Sub _new()
'fchIcon.Filter = ["*.png,*.jpg,*.jpeg,*.xpm,*.gif", ("Image files")]
'fchIcon.Root = Project.Dir
Dim X As Integer
Dim Y As Integer
Dim hButton As ToolButton
Dim W, H, I As Integer
Dim iDefault As Integer
$aGradientColors = [Color.Black, Color.White]
$aGradientPos = [0, 1]
@ -67,6 +75,29 @@ Public Sub _new()
$aGradient.Add(CReportBrush["LinearGradient(0,0.5,1,0.5,[#000000,#FFFFFF],[0,1])"])
$aGradient.Add(CReportBrush["LinearGradient(0,0.5,1,0.5,[#000000,#FFFFFFFF],[0,1])"])
W = panTextAlign.W \ 3
H = panTextAlign.H \ 4
If System.RightToLeft Then
iDefault = 8
Else
iDefault = 6
Endif
For Y = 0 To 3
For X = 0 To 2
hButton = New ToolButton(panTextAlign) As "TextAlign"
hButton.Move(X * W, Y * H, W, H)
hButton.Toggle = True
hButton.Radio = True
hButton.Border = False
hButton.Tag = I
Try hButton.Picture = Picture["img/draw/text-" & $aTextAlign[I] & ".png"]
hButton.Value = I = iDefault
Inc I
Next
Next
End
Public Sub Form_Open()
@ -1287,16 +1318,40 @@ End
Public Sub RefreshTextOption()
Dim iAlign As Integer
Dim hCtrl As ToolButton
Dim bAlignBase As Boolean
If btnAlignCenter.Value Then
iAlign = Align.Center
Else If btnAlignRight.Value Then
iAlign = Align.Right
Else
iAlign = Align.Left
Endif
For Each hCtrl In panTextAlign.Children
If hCtrl.Value Then
iAlign = hCtrl.Tag
Break
Endif
Next
GetCurrent().UpdateText(txtText.Text, fchText.Value, iAlign)
bAlignBase = iAlign >= 6 And iAlign <= 8
Select Case iAlign
Case 0
iAlign = Align.TopLeft
Case 1
iAlign = Align.Top
Case 2
iAlign = Align.TopRight
Case 3, 6
iAlign = Align.Left
Case 4, 7
iAlign = Align.Center
Case 5, 8
iAlign = Align.Right
Case 9
iAlign = Align.BottomLeft
Case 10
iAlign = Align.Bottom
Case 11
iAlign = Align.BottomRight
End Select
GetCurrent().UpdateText(txtText.Text, fchText.Value, iAlign, bAlignBase)
End

View File

@ -433,38 +433,12 @@
Margin = True
{ Panel11 HBox
MoveScaled(1,1,58,8)
{ HPanel11 HPanel
MoveScaled(1,0,12,8)
{ Label14 Label
MoveScaled(1,0,6,4)
Expand = True
Text = ("Font")
}
{ btnAlignLeft ToolButton
MoveScaled(0,4,4,4)
ToolTip = ("Left align")
Picture = Picture["icon:/small/text-left"]
Radio = True
Toggle = True
Value = True
}
{ btnAlignCenter ToolButton
MoveScaled(4,4,4,4)
ToolTip = ("Center align")
Picture = Picture["icon:/small/text-center"]
Radio = True
Toggle = True
}
{ btnAlignRight ToolButton
MoveScaled(8,4,4,4)
ToolTip = ("Right align")
Picture = Picture["icon:/small/text-right"]
Radio = True
Toggle = True
}
Spacing = True
{ panTextAlign Panel
MoveScaled(0,0,8,8)
}
{ fchText FontChooser
MoveScaled(19,0,38,8)
MoveScaled(20,0,38,8)
Expand = True
Border = False
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B