From a174f673343ec97bb69fce749e2a64b067475cda Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 17 Mar 2018 00:08:12 -0300 Subject: [PATCH] Improved detection of changes by form resizing. --- InForm/UiEditor.bas | 6 ++++++ InForm/UiEditorPreview.bas | 24 ++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/InForm/UiEditor.bas b/InForm/UiEditor.bas index 5429aaa..ca4f351 100644 --- a/InForm/UiEditor.bas +++ b/InForm/UiEditor.bas @@ -600,6 +600,12 @@ SUB __UI_BeforeUpdateDisplay ELSEIF CVI(b$) = -6 THEN 'User attempted to load an invalid icon file Answer = MessageBox("Only .ico files are accepted.", "", MsgBox_OkOnly + MsgBox_Exclamation) + ELSEIF CVI(b$) = -7 THEN + 'A new empty form has just been created or a file has just finished loading from disk + Edited = False: echo "reset Edited with signal -7" + ELSEIF CVI(b$) = -8 THEN + 'Preview form was resized + Edited = True: echo "-8 PreviewForm was resized END IF b$ = MKI$(0): PUT #UiEditorFile, OffsetNewDataFromPreview, b$ diff --git a/InForm/UiEditorPreview.bas b/InForm/UiEditorPreview.bas index 6b1be28..0821f79 100644 --- a/InForm/UiEditorPreview.bas +++ b/InForm/UiEditorPreview.bas @@ -23,6 +23,7 @@ DIM SHARED UiPreviewPID AS LONG DIM SHARED ExeIcon AS LONG DIM SHARED AutoNameControls AS _BYTE DIM SHARED UndoPointer AS INTEGER, TotalUndoImages AS INTEGER, MidUndo AS _BYTE +DIM SHARED IsCreating AS _BYTE REDIM SHARED QB64KEYWORDS(0) AS STRING READ_KEYWORDS @@ -64,15 +65,11 @@ $END IF 'Event procedures: --------------------------------------------------------------- SUB __UI_Click (id AS LONG) - DIM b$ - b$ = MKI$(-1) - SendData b$, OffsetNewDataFromPreview + SendSignal -1 END SUB SUB __UI_MouseEnter (id AS LONG) - DIM b$ - b$ = MKI$(-3) - SendData b$, OffsetNewDataFromPreview + SendSignal -3 END SUB SUB __UI_MouseLeave (id AS LONG) @@ -265,6 +262,7 @@ SUB __UI_BeforeUpdateDisplay _SCREENSHOW ELSEIF TempValue = -4 THEN 'Load an existing file + IsCreating = True b$ = SPACE$(2): GET #UiEditorFile, OffsetPropertyValue, b$ b$ = SPACE$(CVI(b$)): GET #UiEditorFile, , b$ DIM FileToLoad AS INTEGER @@ -287,8 +285,10 @@ SUB __UI_BeforeUpdateDisplay END IF UndoPointer = 0 TotalUndoImages = 0 + SendSignal -7 'Form just loaded ELSEIF TempValue = -5 THEN 'Reset request (new form) + IsCreating = True a$ = Unpack$(EmptyForm$) FileToLoad = FREEFILE @@ -299,6 +299,7 @@ SUB __UI_BeforeUpdateDisplay LoadPreview UndoPointer = 0 TotalUndoImages = 0 + SendSignal -7 'New form created ELSEIF TempValue = -1 THEN DIM FloatValue AS _FLOAT 'Editor sent property value @@ -838,7 +839,18 @@ SUB __UI_BeforeInit END SUB SUB __UI_FormResized + STATIC TimesResized AS INTEGER + IF IsCreating THEN TimesResized = 0 + + TimesResized = TimesResized + 1 + + IF TimesResized > 5 THEN + 'Manually resizing a form triggers this event a few times; + 'Loading a form triggers it 2 or three times usually. + TimesResized = 0 + SendSignal -8 + END IF END SUB SUB __UI_OnLoad