1
1
Fork 0
mirror of https://github.com/FellippeHeitor/InForm.git synced 2025-01-15 03:49:56 +00:00

Adds a toggle to include/remove the GIF extension. +

- Disables Open/Save buttons if no filename is typed/selected.
This commit is contained in:
FellippeHeitor 2018-11-07 15:01:59 -03:00
parent b4cda884a4
commit f9d830323e
3 changed files with 114 additions and 15 deletions

View file

@ -86,6 +86,7 @@ DIM SHARED Hidden AS LONG, CenteredWindow AS LONG
DIM SHARED Resizable AS LONG, AutoScroll AS LONG DIM SHARED Resizable AS LONG, AutoScroll AS LONG
DIM SHARED AutoSize AS LONG, SizeTB AS LONG DIM SHARED AutoSize AS LONG, SizeTB AS LONG
DIM SHARED HideTicks AS LONG, AutoPlayGif AS LONG DIM SHARED HideTicks AS LONG, AutoPlayGif AS LONG
DIM SHARED AddGifExtensionToggle AS LONG
'Open/Save dialog 'Open/Save dialog
DIM SHARED DialogBG AS LONG, FileNameLB AS LONG DIM SHARED DialogBG AS LONG, FileNameLB AS LONG
@ -146,7 +147,8 @@ DIM SHARED prevScreenX AS INTEGER, prevScreenY AS INTEGER
DIM SHARED UndoPointer AS INTEGER, TotalUndoImages AS INTEGER DIM SHARED UndoPointer AS INTEGER, TotalUndoImages AS INTEGER
DIM SHARED totalBytesSent AS _UNSIGNED _INTEGER64 DIM SHARED totalBytesSent AS _UNSIGNED _INTEGER64
DIM SHARED RecentMenuItem(1 TO 9) AS LONG, RecentListBuilt AS _BYTE DIM SHARED RecentMenuItem(1 TO 9) AS LONG, RecentListBuilt AS _BYTE
DIM SHARED AddGifExtension AS _BYTE DIM SHARED LoadedWithGifExtension AS _BYTE, AddGifExtension AS _BYTE
DIM SHARED TotalGifLoaded AS LONG
TYPE newInputBox TYPE newInputBox
ID AS LONG ID AS LONG
@ -419,6 +421,16 @@ SUB __UI_Click (id AS LONG)
CASE AutoPlayGif CASE AutoPlayGif
b$ = MKI$(Control(id).Value) b$ = MKI$(Control(id).Value)
SendData b$, 44 SendData b$, 44
CASE AddGifExtensionToggle
IF Control(AddGifExtensionToggle).Value = False AND TotalGifLoaded > 0 THEN
Answer = MessageBox("Removing the GIF extension will load the existing animations as static frames. Proceed?", "", MsgBox_YesNo + MsgBox_Question)
IF Answer = MsgBox_No THEN
Control(AddGifExtensionToggle).Value = True
ELSE
b$ = "PAUSEALLGIF>" + "<END>"
Send Client, b$
END IF
END IF
CASE ViewMenuPreview CASE ViewMenuPreview
$IF WIN THEN $IF WIN THEN
SHELL _DONTWAIT ".\InForm\UiEditorPreview.exe " + HostPort SHELL _DONTWAIT ".\InForm\UiEditorPreview.exe " + HostPort
@ -459,6 +471,8 @@ SUB __UI_Click (id AS LONG)
Stream$ = "" Stream$ = ""
FormDataReceived = False FormDataReceived = False
AddGifExtension = False AddGifExtension = False
Control(AddGifExtensionToggle).Value = False
LoadedWithGifExtension = False
Edited = False Edited = False
SendSignal -5 SendSignal -5
CASE FileMenuSave CASE FileMenuSave
@ -503,7 +517,8 @@ SUB __UI_Click (id AS LONG)
IF OpenDialogOpen THEN IF OpenDialogOpen THEN
DIM FileToOpen$, FreeFileNum AS INTEGER DIM FileToOpen$, FreeFileNum AS INTEGER
FileToOpen$ = CurrentPath$ + PathSep$ + Text(FileNameTextBox) FileToOpen$ = CurrentPath$ + PathSep$ + Text(FileNameTextBox)
ThisFileName$ = Text(FileNameTextBox) ThisFileName$ = LTRIM$(RTRIM$(Text(FileNameTextBox)))
IF ThisFileName$ = "" THEN EXIT SUB
IF UCASE$(RIGHT$(ThisFileName$, 4)) <> ".FRM" THEN IF UCASE$(RIGHT$(ThisFileName$, 4)) <> ".FRM" THEN
ThisFileName$ = ThisFileName$ + ".frm" ThisFileName$ = ThisFileName$ + ".frm"
END IF END IF
@ -679,10 +694,28 @@ SUB __UI_Click (id AS LONG)
IF OpenDialogOpen THEN IF OpenDialogOpen THEN
FileToOpen$ = CurrentPath$ + PathSep$ + Text(FileNameTextBox) FileToOpen$ = CurrentPath$ + PathSep$ + Text(FileNameTextBox)
IF _FILEEXISTS(FileToOpen$) THEN IF _FILEEXISTS(FileToOpen$) THEN
LoadedWithGifExtension = False
IF _FILEEXISTS(LEFT$(FileToOpen$, LEN(FileToOpen$) - 4) + ".bas") THEN
FreeFileNum = FREEFILE
OPEN LEFT$(FileToOpen$, LEN(FileToOpen$) - 4) + ".bas" FOR BINARY AS #FreeFileNum
b$ = SPACE$(LOF(FreeFileNum))
GET #FreeFileNum, 1, b$
CLOSE #FreeFileNum
IF INSTR(b$, CHR$(10) + "'$INCLUDE:'InForm\extensions\gifplay.bm'") > 0 THEN
LoadedWithGifExtension = True
END IF
END IF
AddToRecentList FileToOpen$ AddToRecentList FileToOpen$
ThisFileName$ = Text(FileNameTextBox) ThisFileName$ = Text(FileNameTextBox)
'Send open command 'Send open command
IF LoadedWithGifExtension = False THEN
LoadedWithGifExtension = 1 'Set to 1 to check whether a loaded file already had the gif extension
Control(AddGifExtensionToggle).Value = False
ELSE
Control(AddGifExtensionToggle).Value = True
END IF
AddGifExtension = False AddGifExtension = False
b$ = "OPENFILE>" + FileToOpen$ + "<END>" b$ = "OPENFILE>" + FileToOpen$ + "<END>"
Send Client, b$ Send Client, b$
@ -1108,6 +1141,16 @@ SUB __UI_BeforeUpdateDisplay
Control(KeyboardComboBT).Redraw = True Control(KeyboardComboBT).Redraw = True
END IF END IF
IF OpenDialogOpen THEN
IF LEN(RTRIM$(LTRIM$(Text(FileNameTextBox)))) = 0 THEN
Control(OpenBT).Disabled = True
Control(SaveBT).Disabled = True
ELSE
Control(OpenBT).Disabled = False
Control(SaveBT).Disabled = False
END IF
END IF
IF RecentListBuilt = False THEN IF RecentListBuilt = False THEN
'Build list of recent projects 'Build list of recent projects
RecentListBuilt = True RecentListBuilt = True
@ -1295,9 +1338,9 @@ SUB __UI_BeforeUpdateDisplay
GET #Client, , incomingData$ GET #Client, , incomingData$
Stream$ = Stream$ + incomingData$ Stream$ = Stream$ + incomingData$
STATIC bytesIn~&&, refreshes~& 'STATIC bytesIn~&&, refreshes~&
refreshes~& = refreshes~& + 1 'refreshes~& = refreshes~& + 1
bytesIn~&& = bytesIn~&& + LEN(incomingData$) 'bytesIn~&& = bytesIn~&& + LEN(incomingData$)
'Caption(StatusBar) = "Received:" + STR$(bytesIn~&&) + " bytes | Sent:" + STR$(totalBytesSent) + " bytes" 'Caption(StatusBar) = "Received:" + STR$(bytesIn~&&) + " bytes | Sent:" + STR$(totalBytesSent) + " bytes"
$IF WIN THEN $IF WIN THEN
@ -2010,6 +2053,7 @@ SUB __UI_BeforeUpdateDisplay
Control(AutoSize).Value = PreviewControls(FirstSelected).AutoSize Control(AutoSize).Value = PreviewControls(FirstSelected).AutoSize
Control(HideTicks).Value = (PreviewControls(FirstSelected).Height = __UI_Type(__UI_Type_TrackBar).MinimumHeight) Control(HideTicks).Value = (PreviewControls(FirstSelected).Height = __UI_Type(__UI_Type_TrackBar).MinimumHeight)
Control(AutoPlayGif).Value = PreviewAutoPlayGif(FirstSelected) Control(AutoPlayGif).Value = PreviewAutoPlayGif(FirstSelected)
IF LEN(PreviewContextMenu(FirstSelected)) THEN IF LEN(PreviewContextMenu(FirstSelected)) THEN
DIM ItemFound AS _BYTE DIM ItemFound AS _BYTE
ItemFound = SelectItem(ContextMenuControlsList, PreviewContextMenu(FirstSelected)) ItemFound = SelectItem(ContextMenuControlsList, PreviewContextMenu(FirstSelected))
@ -2261,6 +2305,7 @@ SUB __UI_BeforeUpdateDisplay
'Properties relative to the form 'Properties relative to the form
Control(CenteredWindow).Disabled = False Control(CenteredWindow).Disabled = False
Control(Resizable).Disabled = False Control(Resizable).Disabled = False
Control(AddGifExtensionToggle).Disabled = False
Caption(TextLB) = "Icon file" Caption(TextLB) = "Icon file"
FOR i = 1 TO UBOUND(InputBox) FOR i = 1 TO UBOUND(InputBox)
@ -2317,6 +2362,7 @@ SUB __UI_BeforeUpdateDisplay
NEXT NEXT
'Custom cases 'Custom cases
Control(AutoPlayGif).Disabled = NOT Control(AddGifExtensionToggle).Value
Control(AutoSize).Disabled = Control(WordWrap).Value Control(AutoSize).Disabled = Control(WordWrap).Value
IF Control(HasBorder).Value = True AND PreviewControls(FirstSelected).Type <> __UI_Type_Frame THEN IF Control(HasBorder).Value = True AND PreviewControls(FirstSelected).Type <> __UI_Type_Frame THEN
Control(SizeTB).Disabled = False Control(SizeTB).Disabled = False
@ -2676,6 +2722,12 @@ SUB __UI_OnLoad
FreeFileNum = FREEFILE FreeFileNum = FREEFILE
DIM uB$ DIM uB$
OPEN COMMAND$ FOR BINARY AS #FreeFileNum OPEN COMMAND$ FOR BINARY AS #FreeFileNum
b$ = SPACE$(LOF(FreeFileNum))
GET #FreeFileNum, 1, b$
SEEK #FreeFileNum, 1
IF INSTR(b$, CHR$(10) + "'$INCLUDE:'InForm\extensions\gifplay.bm'") > 0 THEN
LoadedWithGifExtension = True
END IF
DO DO
IF EOF(FreeFileNum) THEN EXIT DO IF EOF(FreeFileNum) THEN EXIT DO
LINE INPUT #FreeFileNum, b$ LINE INPUT #FreeFileNum, b$
@ -2711,6 +2763,16 @@ SUB __UI_OnLoad
CASE ELSE CASE ELSE
IF LCASE$(RIGHT$(COMMAND$, 7)) = ".frmbin" OR LCASE$(RIGHT$(COMMAND$, 4)) = ".frm" THEN IF LCASE$(RIGHT$(COMMAND$, 7)) = ".frmbin" OR LCASE$(RIGHT$(COMMAND$, 4)) = ".frm" THEN
FileToOpen$ = COMMAND$ FileToOpen$ = COMMAND$
IF _FILEEXISTS(LEFT$(FileToOpen$, LEN(FileToOpen$) - 4) + ".bas") THEN
FreeFileNum = FREEFILE
OPEN LEFT$(FileToOpen$, LEN(FileToOpen$) - 4) + ".bas" FOR BINARY AS #FreeFileNum
b$ = SPACE$(LOF(FreeFileNum))
GET #FreeFileNum, 1, b$
CLOSE #FreeFileNum
IF INSTR(b$, CHR$(10) + "'$INCLUDE:'InForm\extensions\gifplay.bm'") > 0 THEN
LoadedWithGifExtension = True
END IF
END IF
END IF END IF
END SELECT END SELECT
@ -2735,6 +2797,13 @@ SUB __UI_OnLoad
OPEN "InForm/UiEditorPreview.frmbin" FOR BINARY AS #FreeFileNum OPEN "InForm/UiEditorPreview.frmbin" FOR BINARY AS #FreeFileNum
PUT #FreeFileNum, 1, b$ PUT #FreeFileNum, 1, b$
CLOSE #FreeFileNum CLOSE #FreeFileNum
IF LoadedWithGifExtension = False THEN
LoadedWithGifExtension = 1 'Query whether this file contains the gif extension
Control(AddGifExtensionToggle).Value = False
ELSE
Control(AddGifExtensionToggle).Value = True
END IF
AddToRecentList FileToOpen$
END IF END IF
END IF END IF
@ -2841,6 +2910,7 @@ SUB __UI_OnLoad
i = i + 1: Toggles(i) = AutoSize i = i + 1: Toggles(i) = AutoSize
i = i + 1: Toggles(i) = HideTicks i = i + 1: Toggles(i) = HideTicks
i = i + 1: Toggles(i) = AutoPlayGif i = i + 1: Toggles(i) = AutoPlayGif
i = i + 1: Toggles(i) = AddGifExtensionToggle
REDIM _PRESERVE Toggles(1 TO i) AS LONG REDIM _PRESERVE Toggles(1 TO i) AS LONG
ToolTip(FontTB) = "Multiple fonts can be specified by separating them with a question mark (?)." + CHR$(10) + "The first font that can be found/loaded is used." ToolTip(FontTB) = "Multiple fonts can be specified by separating them with a question mark (?)." + CHR$(10) + "The first font that can be found/loaded is used."
@ -3473,6 +3543,7 @@ SUB LoadPreview
DIM NewLeft AS INTEGER, NewTop AS INTEGER, NewName AS STRING DIM NewLeft AS INTEGER, NewTop AS INTEGER, NewName AS STRING
DIM NewParentID AS STRING, FloatValue AS _FLOAT, Dummy AS LONG DIM NewParentID AS STRING, FloatValue AS _FLOAT, Dummy AS LONG
DIM FormData$ DIM FormData$
STATIC PrevTotalGifLoaded AS LONG
TIMER(__UI_EventsTimer) OFF TIMER(__UI_EventsTimer) OFF
TIMER(__UI_RefreshTimer) OFF TIMER(__UI_RefreshTimer) OFF
@ -3480,6 +3551,8 @@ SUB LoadPreview
FormData$ = LastFormData$ FormData$ = LastFormData$
AddGifExtension = False AddGifExtension = False
TotalGifLoaded = 0
IF LoadedWithGifExtension = 1 THEN PrevTotalGifLoaded = 0
b$ = ReadSequential$(FormData$, 4) b$ = ReadSequential$(FormData$, 4)
@ -3656,7 +3729,12 @@ SUB LoadPreview
PreviewKeyCombos(Dummy) = b$ PreviewKeyCombos(Dummy) = b$
CASE -45 'Animated Gif CASE -45 'Animated Gif
PreviewAnimatedGif(Dummy) = True PreviewAnimatedGif(Dummy) = True
TotalGifLoaded = TotalGifLoaded + 1
AddGifExtension = True AddGifExtension = True
IF LoadedWithGifExtension = 1 THEN
LoadedWithGifExtension = True
Control(AddGifExtensionToggle).Value = True
END IF
CASE -46 'Auto-play Gif CASE -46 'Auto-play Gif
PreviewAutoPlayGif(Dummy) = True PreviewAutoPlayGif(Dummy) = True
CASE -1 'new control CASE -1 'new control
@ -3672,6 +3750,13 @@ SUB LoadPreview
LoadError: LoadError:
TIMER(__UI_EventsTimer) ON TIMER(__UI_EventsTimer) ON
TIMER(__UI_RefreshTimer) ON TIMER(__UI_RefreshTimer) ON
IF LoadedWithGifExtension = 1 THEN LoadedWithGifExtension = False
IF PrevTotalGifLoaded <> TotalGifLoaded THEN
IF PrevTotalGifLoaded = 0 THEN
Control(AddGifExtensionToggle).Value = True
END IF
PrevTotalGifLoaded = TotalGifLoaded
END IF
END SUB END SUB
SUB SendData (b$, Property AS INTEGER) SUB SendData (b$, Property AS INTEGER)
@ -3857,8 +3942,10 @@ SUB SaveForm (ExitToQB64 AS _BYTE, SaveOnlyFrm AS _BYTE)
IF Answer = MsgBox_No THEN EXIT SUB IF Answer = MsgBox_No THEN EXIT SUB
END IF END IF
IF AddGifExtension THEN AddGifExtension = Control(AddGifExtensionToggle).Value
Answer = MessageBox("Add the GIF extension?\n(choosing 'No' will load GIF images as static images)", "", MsgBox_YesNo + MsgBox_Question)
IF (AddGifExtension OR Control(AddGifExtensionToggle).Value) AND LoadedWithGifExtension = False AND TotalGifLoaded = 0 THEN
Answer = MessageBox("Are you sure you want to include the GIF extension?\n(no animated GIFs have been added to this form)", "", MsgBox_YesNo + MsgBox_Question)
AddGifExtension = (Answer = MsgBox_Yes) AddGifExtension = (Answer = MsgBox_Yes)
END IF END IF
@ -3888,8 +3975,8 @@ SUB SaveForm (ExitToQB64 AS _BYTE, SaveOnlyFrm AS _BYTE)
CLOSE #TextFileNum CLOSE #TextFileNum
IF i = 1 THEN IF i = 1 THEN
IF INSTR(b$, "': External modules: ---------------------------------------------------------------") > 0 THEN IF INSTR(b$, "': Event procedures: ---------------------------------------------------------------") > 0 THEN
BackupCode$ = MID$(b$, INSTR(b$, "': External modules: ---------------------------------------------------------------")) BackupCode$ = MID$(b$, INSTR(b$, "': Event procedures: ---------------------------------------------------------------"))
PreserveBackup = True PreserveBackup = True
END IF END IF
END IF END IF
@ -4206,10 +4293,6 @@ SUB SaveForm (ExitToQB64 AS _BYTE, SaveOnlyFrm AS _BYTE)
END IF END IF
NEXT NEXT
PRINT #TextFileNum, PRINT #TextFileNum,
IF PreserveBackup THEN
PRINT #TextFileNum, BackupCode$
GOTO BackupRestored
END IF
PRINT #TextFileNum, "': External modules: ---------------------------------------------------------------" PRINT #TextFileNum, "': External modules: ---------------------------------------------------------------"
IF AddGifExtension THEN IF AddGifExtension THEN
PRINT #TextFileNum, "'$INCLUDE:'InForm\extensions\gifplay.bi'" PRINT #TextFileNum, "'$INCLUDE:'InForm\extensions\gifplay.bi'"
@ -4221,6 +4304,10 @@ SUB SaveForm (ExitToQB64 AS _BYTE, SaveOnlyFrm AS _BYTE)
PRINT #TextFileNum, "'$INCLUDE:'InForm\extensions\gifplay.bm'" PRINT #TextFileNum, "'$INCLUDE:'InForm\extensions\gifplay.bm'"
END IF END IF
PRINT #TextFileNum, PRINT #TextFileNum,
IF PreserveBackup THEN
PRINT #TextFileNum, BackupCode$
GOTO BackupRestored
END IF
PRINT #TextFileNum, "': Event procedures: ---------------------------------------------------------------" PRINT #TextFileNum, "': Event procedures: ---------------------------------------------------------------"
FOR i = 0 TO 14 FOR i = 0 TO 14
SELECT EVERYCASE i SELECT EVERYCASE i
@ -4263,7 +4350,7 @@ SUB SaveForm (ExitToQB64 AS _BYTE, SaveOnlyFrm AS _BYTE)
END IF END IF
CASE 2 CASE 2
IF AddGifExtension THEN IF AddGifExtension = True AND TotalGifLoaded > 0 THEN
PRINT #TextFileNum, PRINT #TextFileNum,
PRINT #TextFileNum, " 'The lines below ensure your GIFs will display properly;" PRINT #TextFileNum, " 'The lines below ensure your GIFs will display properly;"
PRINT #TextFileNum, " 'Please refer to the documentation in 'InForm/extensions/README - gifplay.txt'" PRINT #TextFileNum, " 'Please refer to the documentation in 'InForm/extensions/README - gifplay.txt'"

View file

@ -610,6 +610,10 @@ SUB __UI_LoadForm
SetCaption __UI_NewID, "Auto-play" SetCaption __UI_NewID, "Auto-play"
Control(__UI_NewID).CanHaveFocus = True Control(__UI_NewID).CanHaveFocus = True
__UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "AddGifExtensionToggle", 181, 20, 12, 232, __UI_GetID("ControlToggles"))
SetCaption __UI_NewID, "Include GIF extension"
Control(__UI_NewID).CanHaveFocus = True
__UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "ColorPropertiesList", 161, 21, 10, 20, __UI_GetID("ColorMixer")) __UI_NewID = __UI_NewControl(__UI_Type_DropdownList, "ColorPropertiesList", 161, 21, 10, 20, __UI_GetID("ColorMixer"))
AddItem __UI_NewID, "ForeColor" AddItem __UI_NewID, "ForeColor"
AddItem __UI_NewID, "BackColor" AddItem __UI_NewID, "BackColor"
@ -710,7 +714,7 @@ SUB __UI_LoadForm
Control(__UI_NewID).CanHaveFocus = True Control(__UI_NewID).CanHaveFocus = True
__UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "SaveFrmOnlyCB", 300, 23, 25, 484, __UI_GetID("OpenFrame")) __UI_NewID = __UI_NewControl(__UI_Type_CheckBox, "SaveFrmOnlyCB", 300, 23, 25, 484, __UI_GetID("OpenFrame"))
SetCaption __UI_NewID, "Don't save .bas project (.frm only)" SetCaption __UI_NewID, "Don't save .bas project (Save .frm only)"
Control(__UI_NewID).Value = False Control(__UI_NewID).Value = False
Control(__UI_NewID).CanHaveFocus = True Control(__UI_NewID).CanHaveFocus = True
@ -914,6 +918,7 @@ SUB __UI_AssignIDs
ContextMenuControlsList = __UI_GetID("ContextMenuControlsList") ContextMenuControlsList = __UI_GetID("ContextMenuControlsList")
HideTicks = __UI_GetID("HideTicks") HideTicks = __UI_GetID("HideTicks")
AutoPlayGif = __UI_GetID("AutoPlayGif") AutoPlayGif = __UI_GetID("AutoPlayGif")
AddGifExtensionToggle = __UI_GetID("AddGifExtensionToggle")
FileMenuRecent = __UI_GetID("FileMenuRecent") FileMenuRecent = __UI_GetID("FileMenuRecent")
FileMenuRecent1 = __UI_GetID("FileMenuRecent1") FileMenuRecent1 = __UI_GetID("FileMenuRecent1")
FileMenuRecent2 = __UI_GetID("FileMenuRecent2") FileMenuRecent2 = __UI_GetID("FileMenuRecent2")

View file

@ -318,6 +318,13 @@ SUB __UI_BeforeUpdateDisplay
LockedControls(TotalLockedControls) = i LockedControls(TotalLockedControls) = i
END IF END IF
NEXT NEXT
CASE "PAUSEALLGIF"
FOR i = 1 TO UBOUND(Control)
IF AutoPlayGif(i) THEN
AutoPlayGif(i) = False
StopGif i
END IF
NEXT
END SELECT END SELECT
LOOP LOOP