From cc86ebda3225dcca19affba867926cf410646165 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 22 Aug 2018 00:59:16 -0300 Subject: [PATCH] Centralizes the detection of control type in the preview component. Sending .ControlIsSelected was adding too many undesired UndoPointers. --- InForm/UiEditor.bas | 41 ++++++++++---------------------------- InForm/UiEditorPreview.bas | 28 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/InForm/UiEditor.bas b/InForm/UiEditor.bas index 4ef03dc..d9b0226 100644 --- a/InForm/UiEditor.bas +++ b/InForm/UiEditor.bas @@ -858,7 +858,7 @@ SUB __UI_BeforeUpdateDisplay DIM thisData$, thisCommand$ STATIC OriginalImageWidth AS INTEGER, OriginalImageHeight AS INTEGER STATIC PrevFirstSelected AS LONG, PreviewHasMenuActive AS INTEGER - STATIC CheckUpdateDone AS _BYTE + STATIC CheckUpdateDone AS _BYTE, ThisControlTurnsInto AS INTEGER STATIC LastChange AS SINGLE IF TIMER - BlinkStatusBar < 1 THEN @@ -1091,6 +1091,8 @@ SUB __UI_BeforeUpdateDisplay OriginalImageWidth = CVI(thisData$) CASE "ORIGINALIMAGEHEIGHT" OriginalImageHeight = CVI(thisData$) + CASE "TURNSINTO" + ThisControlTurnsInto = CVI(thisData$) CASE "SELECTIONRECTANGLE" PreviewSelectionRectangle = CVI(thisData$) LoseFocus @@ -1128,6 +1130,14 @@ SUB __UI_BeforeUpdateDisplay END IF END IF + IF ThisControlTurnsInto > 0 THEN + Control(EditMenuConvertType).Disabled = False + SetCaption EditMenuConvertType, "Co&nvert to " + RTRIM$(__UI_Type(ThisControlTurnsInto).Name) + ELSE + Control(EditMenuConvertType).Disabled = True + SetCaption EditMenuConvertType, "Co&nvert type" + END IF + DO WHILE LEN(Signal$) 'signals -1 and -3 deprecated for now b$ = LEFT$(Signal$, 2) @@ -1226,8 +1236,6 @@ SUB __UI_BeforeUpdateDisplay Control(InsertMenuMenuItem).Disabled = True END IF - Control(EditMenuConvertType).Disabled = True - SetCaption EditMenuConvertType, "Co&nvert type" Control(EditMenuSetDefaultButton).Disabled = True Control(EditMenuSetDefaultButton).Value = False Control(EditMenuAllowMinMax).Disabled = True @@ -1310,13 +1318,7 @@ SUB __UI_BeforeUpdateDisplay IF INSTR(PreviewControls(FirstSelected).Name, "NumericTextBox") = 0 THEN Caption(ControlProperties) = "Control properties (Type = NumericTextBox):" END IF END IF - - IF __UI_Type(PreviewControls(FirstSelected).Type).TurnsInto THEN - Control(EditMenuConvertType).Disabled = False - SetCaption EditMenuConvertType, "Co&nvert to " + RTRIM$(__UI_Type(__UI_Type(PreviewControls(FirstSelected).Type).TurnsInto).Name) - END IF END IF - ELSEIF TotalSelected = 2 THEN Caption(ControlProperties) = "Control properties: (multiple selection)" @@ -1334,8 +1336,6 @@ SUB __UI_BeforeUpdateDisplay Control(AlignMenuAlignCentersH).Disabled = False Control(AlignMenuDistributeV).Disabled = True Control(AlignMenuDistributeH).Disabled = True - - GOTO EnableConvertMenuItem ELSE SetCaption ControlProperties, "Control properties: (multiple selection)" @@ -1353,25 +1353,6 @@ SUB __UI_BeforeUpdateDisplay Control(AlignMenuAlignCentersH).Disabled = False Control(AlignMenuDistributeV).Disabled = False Control(AlignMenuDistributeH).Disabled = False - - EnableConvertMenuItem: - IF __UI_Type(PreviewControls(FirstSelected).Type).TurnsInto THEN - DIM SearchType AS INTEGER, EnableConvertMenuItemCheck AS _BYTE - SearchType = PreviewControls(FirstSelected).Type - EnableConvertMenuItemCheck = True - FOR i = 1 TO UBOUND(PreviewControls) - IF PreviewControls(i).ControlIsSelected THEN - IF PreviewControls(i).Type <> SearchType THEN - EnableConvertMenuItemCheck = False - EXIT FOR - END IF - END IF - NEXT - IF EnableConvertMenuItemCheck THEN - Control(EditMenuConvertType).Disabled = False - SetCaption EditMenuConvertType, "Co&nvert to " + RTRIM$(__UI_Type(__UI_Type(PreviewControls(FirstSelected).Type).TurnsInto).Name) - END IF - END IF END IF IF FirstSelected = 0 THEN FirstSelected = PreviewFormID diff --git a/InForm/UiEditorPreview.bas b/InForm/UiEditorPreview.bas index 7d1da62..4984d0f 100644 --- a/InForm/UiEditorPreview.bas +++ b/InForm/UiEditorPreview.bas @@ -333,6 +333,7 @@ SUB __UI_BeforeUpdateDisplay END IF STATIC prevImgWidthSent AS INTEGER, prevImgHeightSent AS INTEGER + STATIC prevTurnsInto AS INTEGER IF __UI_FirstSelectedID > 0 THEN IF Control(__UI_FirstSelectedID).Type = __UI_Type_PictureBox AND LEN(Text(__UI_FirstSelectedID)) > 0 THEN IF prevImgWidthSent <> _WIDTH(Control(__UI_FirstSelectedID).HelperCanvas) OR _ @@ -355,6 +356,33 @@ SUB __UI_BeforeUpdateDisplay SendData b$, "ORIGINALIMAGEHEIGHT" END IF END IF + + IF __UI_TotalSelectedControls = 1 THEN + IF prevTurnsInto <> __UI_Type(Control(__UI_FirstSelectedID).Type).TurnsInto THEN + prevTurnsInto = __UI_Type(Control(__UI_FirstSelectedID).Type).TurnsInto + b$ = MKI$(prevTurnsInto) + SendData b$, "TURNSINTO" + END IF + ELSEIF __UI_TotalSelectedControls > 1 THEN + DIM SearchType AS INTEGER, AllControlsTurnInto AS _BYTE + SearchType = Control(__UI_FirstSelectedID).Type + AllControlsTurnInto = True + FOR i = 1 TO UBOUND(Control) + IF Control(i).ControlIsSelected THEN + IF Control(i).Type <> SearchType THEN + AllControlsTurnInto = False + EXIT FOR + END IF + END IF + NEXT + SearchType = __UI_Type(SearchType).TurnsInto + IF NOT AllControlsTurnInto THEN SearchType = 0 + IF prevTurnsInto <> SearchType THEN + prevTurnsInto = SearchType + b$ = MKI$(prevTurnsInto) + SendData b$, "TURNSINTO" + END IF + END IF END IF DO WHILE LEN(Signal$)