^^0^^---- What do you graphics guys think? - Pete - 04-05-2024
Not about the "Bat Signal" that's just for TheBOB's benefit. Helps him find his way here. It's about...
Clickable buttons for a graphics WP routine.
(Requires fonts in attachment. They are really nice ones for mono-spaced use.)
Code: (Select All)
$Color:32
Screen _NewImage(1100, 600, 32)
Color Black, _RGB32(255, 255, 255, 255)
Cls
_Display ' Turn off autodisplay.
_Delay .1
_ScreenMove _Middle
_Delay .1
_Clipboard$ = ""
Type textvar
initiate As Integer ' -1 Indicates the Subroutine has been Initiated.
nof As Integer ' Number of Fonts.
maxchrs As Integer ' The Max Characters of a Text String. IMPORTANT: Cannot be over 255.
fsn As Integer ' Font Selection Number 1 reg, 2 Bold, 3 Italic, 4 Bold Italic.
noa As Integer ' Number of Text Attributes.
lm As Integer ' Left Margin by Pixel.
row As Integer ' Row by Pixel.
rm As Integer ' Right Margin by Pixel.
ccol As Integer ' Numeric Column of a Character.
oldccol As Integer ' Numeric Column of the Previous Cursor Position.
pixcol As Integer ' The Pixel Column the Cursor is On Currently.
insreg As Integer ' Causes a Delay in Changing the Cursor Appearance When the Insert Key is Rapidly Pressed.
reprnt As Integer ' Only Reprints a Row of Characters When Non-zero.
ovr As Integer ' Overwrite mode When Non-zero, Otherwise Insert Mode.
xl As Integer ' Pixel Column for a Character that is Part of a Link.
xm As Integer ' Numeric Column of the Character Being Passed to the Matrix.
mindex As Integer ' Numeric Matrix Index.
fsize As Integer ' Font Size.
underline As Integer ' Underline Text.
link As Integer ' Hyperlink Text.
chr_wdth As Integer ' Character Width in Pixels.
chr_hght As Integer ' Character Height in Pixels.
c_wdth As Integer ' Cursor Width in Pixels
c_hght As Integer ' Cursor Height in Pixels.
numchrs As Integer ' Number of Characters in the Line of Text.
sa As Integer ' Special Attributes for Paragraph, highlighting markers, etc.
cchr As String ' Cursor Character.
t As String ' Row of Text.
m As String ' Text and Attributes to be Saved in an RA File.
url As String ' URL Link to Follow.
linkmap As String ' Maps Pixels for Link ID with Mouse.
shift As Integer ' Shift Keys.
autoshift As Integer ' Used for instances like mouse highlighting to mimic keyboard highighting.
ctrl As Integer ' Ctrl key.
alt As Integer ' Alt key.
hl As Integer ' Highlighting Left (-1) or Right (+1)
arrows As Integer ' Aids the Cursor Update Subroutine When Arrows are Used to Highliht Text.
mouse_button1_row As Integer
button1 As Integer
tcopy As String ' Copied Text
mcopy As String ' Copied Text Matrix
button_map1 As String
End Type
Dim tx As textvar
Type mousevar
mx As Integer
my As Integer
wh As Integer
lb As Integer
rb As Integer
lb_status As Integer
rb_status As Integer
locked As Integer
oldmx As Integer
CursorStyle As Integer
mousekey As String ' Auto Keyboard Input.
End Type
Dim m As mousevar
Type popup
nmi As Integer
setup As Integer
status As Integer
pr1 As Integer
pr2 As Integer
pc1 As Integer
pc2 As Integer
phshadow As Integer
pvshadow As Integer
pwdth As Integer
phght As Integer
pbgcolor As Integer
pbbxcolor As Integer
pbshdcolor As Integer
col_matrix As String
row_matrix As String
restrict As String
End Type
Dim pop As popup
Dim Shared bit As _Bit
ReDim Shared cl(3) As Integer, bc(3) As Integer
ReDim Shared default_cl(3), default_bc(3)
tx.nof = 4
tx.fsize = 18
tx.maxchrs = 256 ' IMPORTANT: Cannot be over 255.
ReDim Shared fnum(tx.nof) As Long
ReDim Shared index_col(tx.maxchrs)
default_cl(1) = 0: default_cl(2) = 0: default_cl(3) = 0
default_bc(1) = 255: default_bc(2) = 255: default_bc(3) = 255
tx.fsn = 1 ' Default font style number.
tx.noa = 12 ' Number of character attributes.
tx.row = 100 ' Current row in pixels.
tx.lm = 100 ' Left margin in pixels.
tx.rm = tx.lm + _Width - 2 * tx.lm
tx.sa = 10 ' Number of special attributes.
cl(1) = default_cl(1): cl(2) = default_cl(2): cl(3) = default_cl(3)
bc(1) = default_bc(1): bc(2) = default_bc(2): bc(3) = default_bc(3)
tx.m$ = String$(tx.sa + tx.maxchrs * (tx.noa + 1), Chr$(0)) ' Algorithm makes a 1 string field, 10 ID fields for highlighting, paragraph, plain text line, etc., and tx.noa attributes fields.
tx.t$ = String$(tx.maxchrs, Chr$(0)) ' Our text.
tx.linkmap$ = String$(_Width, Chr$(0))
' Matrix: 1-maxchrs text, maxchrs + 1 to maxchrs + 10 Special attributes, maxchrs + 11 on are attributes each tx.noa spaces long.
' Example: maxchrs = 255. tx.noa = 12. 1-255 text, 256-265 special attributes, 266-277 attributes for 1st character in text string, 278-289 2nd, etc.
main tx, m, pop
Sub main (tx As textvar, m As mousevar, pop As popup)
Do
_Limit 60
load_font tx, fnum()
skin tx, button1$()
mouse m
If m.my >= tx.mouse_button1_row And m.my <= tx.mouse_button1_row + 17 Then
If Mid$(tx.button_map1$, m.mx, 1) <> Chr$(0) Then
_MouseShow "LINK": m.CursorStyle = 1
Else
_MouseShow "DEFAULT": m.CursorStyle = 0
End If
ElseIf m.CursorStyle Then
_MouseShow "DEFAULT": m.CursorStyle = 0
End If
If m.lb_status = 1 And m.CursorStyle Then
i% = Asc(Mid$(tx.button_map1$, m.mx, 1))
If i% > 126 Then i% = i% - 126: j% = i% Else j% = i% + 126 ' Toggle
tx.button1 = -j%
Select Case i%
Case 1, 2, 3
Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 17) = String$(17, Chr$(j%))
Case 4, 5, 6
If i% <> Asc(Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 1)) - 126 Then ' Radio style buttons once highlighted cannot accept same button clicks.
For k% = 4 To 6
Mid$(tx.button_map1$, tx.lm + (k% - 1) * 26, 17) = String$(17, Chr$(k%))
Next
Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 17) = String$(17, Chr$(j%))
Else
Beep
End If
Case 7
For k% = 4 To 6
Mid$(tx.button_map1$, tx.lm + (k% - 1) * 26, 17) = String$(17, Chr$(k%))
Next
Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 17) = String$(17, Chr$(j%))
Case 8
a = tx.lm + (i% - 1) * 26: b = 30
Line (a, b)-(a + 17, b + 17), Black, B: _Display
_Delay .15
Line (a, b)-(a + 17, b + 17), DarkGray, B: _Display
_Delay .15
End Select
End If
''keyboard tx, m, b$
''text_input tx, m, pop, b$
''popup_main tx, m, pop
Loop
End Sub
Sub load_font (tx As textvar, fnum() As Long)
If fnum(0) = 0 Then ' Bypass this routine if fnum(0) = -1. Fonts in use were already loaded. Reset to zero to reuse this routine.
fnum(0) = -1 ' See remark above.
fnum(1) = _LoadFont("RobotoMono-regular.ttf", tx.fsize)
fnum(2) = _LoadFont("RobotoMono-bold.ttf", tx.fsize)
fnum(3) = _LoadFont("RobotoMono-italic.ttf", tx.fsize)
fnum(4) = _LoadFont("RobotoMono-bolditalic.ttf", tx.fsize)
For i% = 1 To tx.nof
If fnum(i%) <= 0 Then ' Try to load the Windows Lucida Console font.
fnum(1) = _LoadFont(Environ$("SYSTEMROOT") + "\Fonts\lucon.ttf", tx.fsize)
Exit For
End If
Next
If fnum(1) <= 0 Then
tx.fsize = 16 ' Default 8 x 16 font.
fnum(1) = tx.fsize
End If
End If
End Sub
Sub skin (tx As textvar, button1$())
Static initialize
If tx.button1 <= 0 Then
tx.button1 = Abs(tx.button1): If tx.button1 = 0 Then tx.button1 = 999 ' loced out until a button is clicked.
j% = _LoadFont("RobotoMono-regular.ttf", 14)
k% = _LoadFont("RobotoMono-italic.ttf", 14)
a = tx.lm: b = 30: c = 26
If Len(tx.button_map1$) = 0 Then tx.button_map1$ = String$(_Width, Chr$(0))
tx.mouse_button1_row = b
If tx.maxchrs * _PrintWidth("A") + tx.lm < tx.rm Then tx.rm = tx.maxchrs * _PrintWidth("A") + tx.lm
For i% = 1 To 8
If Asc(Mid$(tx.button_map1$, a, 1)) > 126 Then
Line (a, b)-(a + 17, b + 17), Black, B
Line (a + 2, b + 2)-(a - 2 + 17, b - 2 + 17), _RGB32(255, 255, 255, 255), BF
Else
Line (a, b)-(a + 17, b + 17), DarkGray, B
Line (a + 2, b + 2)-(a - 2 + 17, b - 2 + 17), _RGB32(230, 230, 230, 255), BF
End If
Line (a + 17 + 1, b + 3)-(a + 17 + 2, b + 17), _RGB32(210, 210, 210, 255), BF
Line (a + 3, b + 17 + 1)-(a + 17 + 1, b + 17 + 2), _RGB32(210, 210, 210, 255), BF
a = a + c
Next
a = tx.lm: b = 30: c = 26
_Font j%
If Asc(Mid$(tx.button_map1$, a, 1)) > 126 Then
Color _RGB32(0, 0, 0, 255), _RGB32(255, 255, 255, 0)
Else
Color _RGB32(0, 0, 0, 255), _RGB32(230, 230, 230, 0)
End If
For i% = 1 To 8
Select Case i%
Case 1
_PrintString (a + (i% - 1) * c + 5, b + 2), "B"
Case 2
_Font k%
_PrintString (a + (i% - 1) * c + 5, b + 2), "I"
Case 3
_Font j%
_PrintString (a + (i% - 1) * c + 5, b + 1), "u"
Line (a + (i% - 1) * c + 5, b + 17 - 2)-(a + (i% - 1) * c + 13, b + 17 - 2), Black, B
Case 4
Line (a + (i% - 1) * c + 5, b + 5)-(a + (i% - 1) * c + 12, b + 17 - 5), Black, BF
Case 5
Line (a + (i% - 1) * c + 5, b + 5)-(a + (i% - 1) * c + 12, b + 17 - 5), Blue, BF
Case 6
Line (a + (i% - 1) * c + 5, b + 5)-(a + (i% - 1) * c + 12, b + 17 - 5), Red, BF
Case 7
Line (a + (i% - 1) * c + 4, b + 4)-(a + (i% - 1) * c + 14, b + 17 - 4), Yellow, BF
Rem Circle (a + (i% - 1) * c + 8, b + 8), 2, _RGB32(90): Paint Step(0, 0), _RGB32(90)
_PrintString (a + (i% - 1) * c + 5, b + 2), "h"
Case 8
Color Blue, _RGB32(210, 210, 210, 0)
_PrintString (a + (i% - 1) * c + 5, b + 2), "ì"
End Select
' Make mouse map.
If initialize = 0 Then
Mid$(tx.button_map1$, tx.lm + (i% - 1) * c, c) = String$(17, Chr$(i%)) + String$(c - 17, Chr$(0))
End If
Next
_Font fnum(1) ' Default font.
If initialize = 0 Then
Line (tx.lm - 5, tx.row - 5)-(tx.rm + 5, tx.row + _FontHeight + 5), Gray, B ' Text input field.
a = tx.lm + (4 - 1) * c
Line (a, b)-(a + 17, b + 17), Black, B ' Default black text button.
Line (a + 2, b + 2)-(a - 2 + 17, b - 2 + 17), _RGB32(255, 255, 255, 0), BF
Mid$(tx.button_map1$, tx.lm + (4 - 1) * c, c) = String$(17, Chr$(4 + 216))
initialize = -1
End If
_Display
End If
End Sub
Sub mouse (m As mousevar)
' Local vars: i%,j%
If Len(m.mousekey$) And m.lb_status <> 2 Then Exit Sub ' Bypass mouse when an automatic key was issued unless a drag event is occurring.
While _MouseInput
m.wh = m.wh + _MouseWheel
Wend
m.mx = _MouseX
m.my = _MouseY
m.lb = _MouseButton(1)
m.rb = _MouseButton(2)
Select Case m.lb
Case 0
Select Case m.lb_status
Case -2
m.lb_status = 0 ' The clicked event and the release triggered any event structured to occur on release.
If m.locked = -1 Then m.locked = 0
Case -1
m.lb_status = -2 ' The clicked event triggered any event structured to occur on initial button press.
Case 0
' Button has not been pressed yet.
Case 1
m.lb_status = -1 ' Rare but button was released before the next required cycle, so cycle is continued here.
Case 2
m.lb_status = 0 ' The drag event is over because the button was released.
End Select
Case -1
Select Case m.lb_status ' Note drag is determined in the text highlighting routine.
Case -1
' An event occurred and the button is still down.
Case 0
m.lb_status = 1
Case 1
m.lb_status = -1 ' The button is down and triggered any event structured to occur on initial press. The status will remain -1 as long as the button is depressed.
End Select
End Select
Select Case m.rb
Case 0
Select Case m.rb_status
Case -1
m.rb_status = 0 ' An event occurred and the button was released.
Case 0
' Button has not been pressed yet.
Case 1
m.rb_status = 0 ' Button was released with no event occurring.
End Select
Case -1
Select Case m.rb_status
Case -1
' An event occurred and the button is still down.
Case 0
m.rb_status = 1
Case 1
' The button is still down but no event occurred.
End Select
End Select
m.oldmx = m.mx
End Sub
Well I nearly posted this in the help forum, but it works, so no actual help is needed with the coding. My question is more along the lines of the approach. If you had to make this type of routine, would you do it this way or another way such as using a hardware overlay method, using images with _putimage, etc. I'd figure I'd ask so I don't end up getting too comfortable with doing it one way, when using another method would demonstrate better results.
The part of the code that produces the buttons is in both in the main and skin routines.
The fonts to use in it are attached, below.
Pete
RE: ^^0^^---- What do you graphics guys think? - bplus - 04-05-2024
ok so nothing is happening when i try to type something but buttons do respond to clicks, the ink color like radio buttons and type style like options that is nice but why can't i see anything when i type?
RE: ^^0^^---- What do you graphics guys think? - bplus - 04-05-2024
Quote:Well I nearly posted this in the help forum, but it works, so no actual help is needed with the coding. My question is more along the lines of the approach. If you had to make this type of routine, would you do it this way or another way such as using a hardware overlay method, using images with _putimage, etc. I'd figure I'd ask so I don't end up getting too comfortable with doing it one way, when using another method would demonstrate better results.
imo this is part of the wip you've already got 2 posts going...
you guys who start a new post every time you add a feature to a previous post... seems like rookie thing to me ie how many times are you going to attach roboto-moto.zip to download?
and speaking about attachments, it would be more convenient for testers to have code and assets all together in one zip.
so yesterday i learned to be popular i shouldn't criticise others, so how am i doing with that? [i've also been taking smelling lessons from Phil inspired by the man whose name is written so green i'm sure] anyway that's what i think at moment or two, 2 points please...
RE: ^^0^^---- What do you graphics guys think? - TheBOB - 04-05-2024
(04-05-2024, 04:45 AM)Pete Wrote: Not about the "Bat Signal" that's just for TheBOB's benefit. Helps him find his way here. It's about...
Clickable buttons for a graphics WP routine.
(Requires fonts in attachment. They are really nice ones for mono-spaced use.)
Code: (Select All)
$Color:32
Screen _NewImage(1100, 600, 32)
Color Black, _RGB32(255, 255, 255, 255)
Cls
_Display ' Turn off autodisplay.
_Delay .1
_ScreenMove _Middle
_Delay .1
_Clipboard$ = ""
Type textvar
initiate As Integer ' -1 Indicates the Subroutine has been Initiated.
nof As Integer ' Number of Fonts.
maxchrs As Integer ' The Max Characters of a Text String. IMPORTANT: Cannot be over 255.
fsn As Integer ' Font Selection Number 1 reg, 2 Bold, 3 Italic, 4 Bold Italic.
noa As Integer ' Number of Text Attributes.
lm As Integer ' Left Margin by Pixel.
row As Integer ' Row by Pixel.
rm As Integer ' Right Margin by Pixel.
ccol As Integer ' Numeric Column of a Character.
oldccol As Integer ' Numeric Column of the Previous Cursor Position.
pixcol As Integer ' The Pixel Column the Cursor is On Currently.
insreg As Integer ' Causes a Delay in Changing the Cursor Appearance When the Insert Key is Rapidly Pressed.
reprnt As Integer ' Only Reprints a Row of Characters When Non-zero.
ovr As Integer ' Overwrite mode When Non-zero, Otherwise Insert Mode.
xl As Integer ' Pixel Column for a Character that is Part of a Link.
xm As Integer ' Numeric Column of the Character Being Passed to the Matrix.
mindex As Integer ' Numeric Matrix Index.
fsize As Integer ' Font Size.
underline As Integer ' Underline Text.
link As Integer ' Hyperlink Text.
chr_wdth As Integer ' Character Width in Pixels.
chr_hght As Integer ' Character Height in Pixels.
c_wdth As Integer ' Cursor Width in Pixels
c_hght As Integer ' Cursor Height in Pixels.
numchrs As Integer ' Number of Characters in the Line of Text.
sa As Integer ' Special Attributes for Paragraph, highlighting markers, etc.
cchr As String ' Cursor Character.
t As String ' Row of Text.
m As String ' Text and Attributes to be Saved in an RA File.
url As String ' URL Link to Follow.
linkmap As String ' Maps Pixels for Link ID with Mouse.
shift As Integer ' Shift Keys.
autoshift As Integer ' Used for instances like mouse highlighting to mimic keyboard highighting.
ctrl As Integer ' Ctrl key.
alt As Integer ' Alt key.
hl As Integer ' Highlighting Left (-1) or Right (+1)
arrows As Integer ' Aids the Cursor Update Subroutine When Arrows are Used to Highliht Text.
mouse_button1_row As Integer
button1 As Integer
tcopy As String ' Copied Text
mcopy As String ' Copied Text Matrix
button_map1 As String
End Type
Dim tx As textvar
Type mousevar
mx As Integer
my As Integer
wh As Integer
lb As Integer
rb As Integer
lb_status As Integer
rb_status As Integer
locked As Integer
oldmx As Integer
CursorStyle As Integer
mousekey As String ' Auto Keyboard Input.
End Type
Dim m As mousevar
Type popup
nmi As Integer
setup As Integer
status As Integer
pr1 As Integer
pr2 As Integer
pc1 As Integer
pc2 As Integer
phshadow As Integer
pvshadow As Integer
pwdth As Integer
phght As Integer
pbgcolor As Integer
pbbxcolor As Integer
pbshdcolor As Integer
col_matrix As String
row_matrix As String
restrict As String
End Type
Dim pop As popup
Dim Shared bit As _Bit
ReDim Shared cl(3) As Integer, bc(3) As Integer
ReDim Shared default_cl(3), default_bc(3)
tx.nof = 4
tx.fsize = 18
tx.maxchrs = 256 ' IMPORTANT: Cannot be over 255.
ReDim Shared fnum(tx.nof) As Long
ReDim Shared index_col(tx.maxchrs)
default_cl(1) = 0: default_cl(2) = 0: default_cl(3) = 0
default_bc(1) = 255: default_bc(2) = 255: default_bc(3) = 255
tx.fsn = 1 ' Default font style number.
tx.noa = 12 ' Number of character attributes.
tx.row = 100 ' Current row in pixels.
tx.lm = 100 ' Left margin in pixels.
tx.rm = tx.lm + _Width - 2 * tx.lm
tx.sa = 10 ' Number of special attributes.
cl(1) = default_cl(1): cl(2) = default_cl(2): cl(3) = default_cl(3)
bc(1) = default_bc(1): bc(2) = default_bc(2): bc(3) = default_bc(3)
tx.m$ = String$(tx.sa + tx.maxchrs * (tx.noa + 1), Chr$(0)) ' Algorithm makes a 1 string field, 10 ID fields for highlighting, paragraph, plain text line, etc., and tx.noa attributes fields.
tx.t$ = String$(tx.maxchrs, Chr$(0)) ' Our text.
tx.linkmap$ = String$(_Width, Chr$(0))
' Matrix: 1-maxchrs text, maxchrs + 1 to maxchrs + 10 Special attributes, maxchrs + 11 on are attributes each tx.noa spaces long.
' Example: maxchrs = 255. tx.noa = 12. 1-255 text, 256-265 special attributes, 266-277 attributes for 1st character in text string, 278-289 2nd, etc.
main tx, m, pop
Sub main (tx As textvar, m As mousevar, pop As popup)
Do
_Limit 60
load_font tx, fnum()
skin tx, button1$()
mouse m
If m.my >= tx.mouse_button1_row And m.my <= tx.mouse_button1_row + 17 Then
If Mid$(tx.button_map1$, m.mx, 1) <> Chr$(0) Then
_MouseShow "LINK": m.CursorStyle = 1
Else
_MouseShow "DEFAULT": m.CursorStyle = 0
End If
ElseIf m.CursorStyle Then
_MouseShow "DEFAULT": m.CursorStyle = 0
End If
If m.lb_status = 1 And m.CursorStyle Then
i% = Asc(Mid$(tx.button_map1$, m.mx, 1))
If i% > 126 Then i% = i% - 126: j% = i% Else j% = i% + 126 ' Toggle
tx.button1 = -j%
Select Case i%
Case 1, 2, 3
Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 17) = String$(17, Chr$(j%))
Case 4, 5, 6
If i% <> Asc(Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 1)) - 126 Then ' Radio style buttons once highlighted cannot accept same button clicks.
For k% = 4 To 6
Mid$(tx.button_map1$, tx.lm + (k% - 1) * 26, 17) = String$(17, Chr$(k%))
Next
Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 17) = String$(17, Chr$(j%))
Else
Beep
End If
Case 7
For k% = 4 To 6
Mid$(tx.button_map1$, tx.lm + (k% - 1) * 26, 17) = String$(17, Chr$(k%))
Next
Mid$(tx.button_map1$, tx.lm + (i% - 1) * 26, 17) = String$(17, Chr$(j%))
Case 8
a = tx.lm + (i% - 1) * 26: b = 30
Line (a, b)-(a + 17, b + 17), Black, B: _Display
_Delay .15
Line (a, b)-(a + 17, b + 17), DarkGray, B: _Display
_Delay .15
End Select
End If
''keyboard tx, m, b$
''text_input tx, m, pop, b$
''popup_main tx, m, pop
Loop
End Sub
Sub load_font (tx As textvar, fnum() As Long)
If fnum(0) = 0 Then ' Bypass this routine if fnum(0) = -1. Fonts in use were already loaded. Reset to zero to reuse this routine.
fnum(0) = -1 ' See remark above.
fnum(1) = _LoadFont("RobotoMono-regular.ttf", tx.fsize)
fnum(2) = _LoadFont("RobotoMono-bold.ttf", tx.fsize)
fnum(3) = _LoadFont("RobotoMono-italic.ttf", tx.fsize)
fnum(4) = _LoadFont("RobotoMono-bolditalic.ttf", tx.fsize)
For i% = 1 To tx.nof
If fnum(i%) <= 0 Then ' Try to load the Windows Lucida Console font.
fnum(1) = _LoadFont(Environ$("SYSTEMROOT") + "\Fonts\lucon.ttf", tx.fsize)
Exit For
End If
Next
If fnum(1) <= 0 Then
tx.fsize = 16 ' Default 8 x 16 font.
fnum(1) = tx.fsize
End If
End If
End Sub
Sub skin (tx As textvar, button1$())
Static initialize
If tx.button1 <= 0 Then
tx.button1 = Abs(tx.button1): If tx.button1 = 0 Then tx.button1 = 999 ' loced out until a button is clicked.
j% = _LoadFont("RobotoMono-regular.ttf", 14)
k% = _LoadFont("RobotoMono-italic.ttf", 14)
a = tx.lm: b = 30: c = 26
If Len(tx.button_map1$) = 0 Then tx.button_map1$ = String$(_Width, Chr$(0))
tx.mouse_button1_row = b
If tx.maxchrs * _PrintWidth("A") + tx.lm < tx.rm Then tx.rm = tx.maxchrs * _PrintWidth("A") + tx.lm
For i% = 1 To 8
If Asc(Mid$(tx.button_map1$, a, 1)) > 126 Then
Line (a, b)-(a + 17, b + 17), Black, B
Line (a + 2, b + 2)-(a - 2 + 17, b - 2 + 17), _RGB32(255, 255, 255, 255), BF
Else
Line (a, b)-(a + 17, b + 17), DarkGray, B
Line (a + 2, b + 2)-(a - 2 + 17, b - 2 + 17), _RGB32(230, 230, 230, 255), BF
End If
Line (a + 17 + 1, b + 3)-(a + 17 + 2, b + 17), _RGB32(210, 210, 210, 255), BF
Line (a + 3, b + 17 + 1)-(a + 17 + 1, b + 17 + 2), _RGB32(210, 210, 210, 255), BF
a = a + c
Next
a = tx.lm: b = 30: c = 26
_Font j%
If Asc(Mid$(tx.button_map1$, a, 1)) > 126 Then
Color _RGB32(0, 0, 0, 255), _RGB32(255, 255, 255, 0)
Else
Color _RGB32(0, 0, 0, 255), _RGB32(230, 230, 230, 0)
End If
For i% = 1 To 8
Select Case i%
Case 1
_PrintString (a + (i% - 1) * c + 5, b + 2), "B"
Case 2
_Font k%
_PrintString (a + (i% - 1) * c + 5, b + 2), "I"
Case 3
_Font j%
_PrintString (a + (i% - 1) * c + 5, b + 1), "u"
Line (a + (i% - 1) * c + 5, b + 17 - 2)-(a + (i% - 1) * c + 13, b + 17 - 2), Black, B
Case 4
Line (a + (i% - 1) * c + 5, b + 5)-(a + (i% - 1) * c + 12, b + 17 - 5), Black, BF
Case 5
Line (a + (i% - 1) * c + 5, b + 5)-(a + (i% - 1) * c + 12, b + 17 - 5), Blue, BF
Case 6
Line (a + (i% - 1) * c + 5, b + 5)-(a + (i% - 1) * c + 12, b + 17 - 5), Red, BF
Case 7
Line (a + (i% - 1) * c + 4, b + 4)-(a + (i% - 1) * c + 14, b + 17 - 4), Yellow, BF
Rem Circle (a + (i% - 1) * c + 8, b + 8), 2, _RGB32(90): Paint Step(0, 0), _RGB32(90)
_PrintString (a + (i% - 1) * c + 5, b + 2), "h"
Case 8
Color Blue, _RGB32(210, 210, 210, 0)
_PrintString (a + (i% - 1) * c + 5, b + 2), "ì"
End Select
' Make mouse map.
If initialize = 0 Then
Mid$(tx.button_map1$, tx.lm + (i% - 1) * c, c) = String$(17, Chr$(i%)) + String$(c - 17, Chr$(0))
End If
Next
_Font fnum(1) ' Default font.
If initialize = 0 Then
Line (tx.lm - 5, tx.row - 5)-(tx.rm + 5, tx.row + _FontHeight + 5), Gray, B ' Text input field.
a = tx.lm + (4 - 1) * c
Line (a, b)-(a + 17, b + 17), Black, B ' Default black text button.
Line (a + 2, b + 2)-(a - 2 + 17, b - 2 + 17), _RGB32(255, 255, 255, 0), BF
Mid$(tx.button_map1$, tx.lm + (4 - 1) * c, c) = String$(17, Chr$(4 + 216))
initialize = -1
End If
_Display
End If
End Sub
Sub mouse (m As mousevar)
' Local vars: i%,j%
If Len(m.mousekey$) And m.lb_status <> 2 Then Exit Sub ' Bypass mouse when an automatic key was issued unless a drag event is occurring.
While _MouseInput
m.wh = m.wh + _MouseWheel
Wend
m.mx = _MouseX
m.my = _MouseY
m.lb = _MouseButton(1)
m.rb = _MouseButton(2)
Select Case m.lb
Case 0
Select Case m.lb_status
Case -2
m.lb_status = 0 ' The clicked event and the release triggered any event structured to occur on release.
If m.locked = -1 Then m.locked = 0
Case -1
m.lb_status = -2 ' The clicked event triggered any event structured to occur on initial button press.
Case 0
' Button has not been pressed yet.
Case 1
m.lb_status = -1 ' Rare but button was released before the next required cycle, so cycle is continued here.
Case 2
m.lb_status = 0 ' The drag event is over because the button was released.
End Select
Case -1
Select Case m.lb_status ' Note drag is determined in the text highlighting routine.
Case -1
' An event occurred and the button is still down.
Case 0
m.lb_status = 1
Case 1
m.lb_status = -1 ' The button is down and triggered any event structured to occur on initial press. The status will remain -1 as long as the button is depressed.
End Select
End Select
Select Case m.rb
Case 0
Select Case m.rb_status
Case -1
m.rb_status = 0 ' An event occurred and the button was released.
Case 0
' Button has not been pressed yet.
Case 1
m.rb_status = 0 ' Button was released with no event occurring.
End Select
Case -1
Select Case m.rb_status
Case -1
' An event occurred and the button is still down.
Case 0
m.rb_status = 1
Case 1
' The button is still down but no event occurred.
End Select
End Select
m.oldmx = m.mx
End Sub
Well I nearly posted this in the help forum, but it works, so no actual help is needed with the coding. My question is more along the lines of the approach. If you had to make this type of routine, would you do it this way or another way such as using a hardware overlay method, using images with _putimage, etc. I'd figure I'd ask so I don't end up getting too comfortable with doing it one way, when using another method would demonstrate better results.
The part of the code that produces the buttons is in both in the main and skin routines.
The fonts to use in it are attached, below.
Pete
Don't see that you need my help, Pete. The buttons are clear and when you click one it responds graphically... There's a chapter in my graphics tutorial (12: Of Mice and Menus) that describes how to draw and animate buttons, but I doubt that you'd want to go to all that trouble--or that you'd need to.
^^^O^^^
RE: ^^0^^---- What do you graphics guys think? - TerryRitchie - 04-05-2024
(04-05-2024, 11:27 AM)bplus Wrote: ok so nothing is happening when i try to type something but buttons do respond to clicks, the ink color like radio buttons and type style like options that is nice but why can't i see anything when i type?
I'm getting the same thing.
RE: ^^0^^---- What do you graphics guys think? - Pete - 04-05-2024
The typing was stripped out, and so was the popup routine. This is what will soon be a stand alone button routine, which will work in the WP. Sorry you guys have to put up with a 70 year old 'stripper'. Maybe Steve has enough donation money left over to buy you guys something better.
@bplus
So you wouldn't do anything differently, good.
Kidding aside, these posts are new because these two projects are new. This will evolve into a separate buttons library. The other into a popup library. Oh, glad you picked up on the 'radio' aspect. That was fun to code.
The reason why I don't include 'works in progress' in zip files, is because they are unfinished, and probably buggy. I wouldn't want do download such for someone else and have it on my hard drive. Of course I see your point for ease of use to open the zip file, extract, load, and run. Personally, I'd rather do a forum select, copy, then paste the program into an untitled IDE. I then simply dispose of it after testing. Hey, I smell a poll in the works. Woohoo!
As far as criticism goes, it's a good thing for interacting and learning. People who can't use criticism are like subroutines with no calling labels. Oh, about the +2, I considered it, and then gave it to Bob, who also answered the question.
@TerryRitchie
So now that we've established it wasn't set up for typing, how about the buttons? What do you generally use for your on screen game controls?
@TheBOB
Thanks! What do I owe you for an out-of-Gotham run? Oh I know +2 rep points. BTW. Using the @symbol followed by a person's log in name sends a forum PM alert to the individual directing 'they' to your reply. Woke is soooooo stupid!
Pete
RE: ^^0^^---- What do you graphics guys think? - TerryRitchie - 04-05-2024
Everything looks good as I see it.
I wrote a button library years ago that shows how I generally implement buttons.
https://qb64phoenix.com/forum/showthread.php?tid=82
RE: ^^0^^---- What do you graphics guys think? - bplus - 04-05-2024
Yeah I got buttons and textboxes and list boxes too even some sliders see VS (very simple, for me anyway) GUI, Terry has it, the Bob, Fellippe, Rho Sigma... its a right of passage or something?
2 points man doesn't cost you anything how about I trade you 2 points for 2 points
RE: ^^0^^---- What do you graphics guys think? - Pete - 04-05-2024
@bplus
A point SWAP??? DEAL!
+ 2
@TerryRitchie
I downloaded it. I see you use the image approach. I've tried that as well. I like that approach for larger screen effects. If I had TheBOB's talent, I'd probably just make my own with QB64 statements. Oh well...
I got a kick out of the little lever dudes in the demo. Now I'm curious about that whole button copy thing.
It looks like you are using coordinates for button mapping, but I need to explore that further. My matrix methods differ a bit going from graphics to images.
Congrats, btw, on the huge amount of downloads for that lib project. +2
Pete
RE: ^^0^^---- What do you graphics guys think? - TheBOB - 04-05-2024
(04-05-2024, 04:19 PM)Pete Wrote: The typing was stripped out, and so was the popup routine. This is what will soon be a stand alone button routine, which will work in the WP. Sorry you guys have to put up with a 70 year old 'stripper'. Maybe Steve has enough donation money left over to buy you guys something better.
@bplus
So you wouldn't do anything differently, good.
Kidding aside, these posts are new because these two projects are new. This will evolve into a separate buttons library. The other into a popup library. Oh, glad you picked up on the 'radio' aspect. That was fun to code.
The reason why I don't include 'works in progress' in zip files, is because they are unfinished, and probably buggy. I wouldn't want do download such for someone else and have it on my hard drive. Of course I see your point for ease of use to open the zip file, extract, load, and run. Personally, I'd rather do a forum select, copy, then paste the program into an untitled IDE. I then simply dispose of it after testing. Hey, I smell a poll in the works. Woohoo!
As far as criticism goes, it's a good thing for interacting and learning. People who can't use criticism are like subroutines with no calling labels. Oh, about the +2, I considered it, and then gave it to Bob, who also answered the question.
@TerryRitchie
So now that we've established it wasn't set up for typing, how about the buttons? What do you generally use for your on screen game controls?
@TheBOB
Thanks! What do I owe you for an out-of-Gotham run? Oh I know +2 rep points. BTW. Using the @symbol followed by a person's log in name sends a forum PM alert to the individual directing 'they' to your reply. Woke is soooooo stupid!
Pete @Pete
Your're welcome, Commissioner... I never require payment, not even for out-of-Gotham work (I'm a billionaire, you know), but the buckle on my utility belt keeps coming undone. You'll understand if I ask that you have the Joker locked up until it's fixed.
Thank-you.
^^O^^
|