Skip to content

Commit

Permalink
Closes #105, Closes #106, Closes #107 and Fixes #108
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhornyak committed Sep 29, 2023
1 parent b36d280 commit 92c14a3
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 72 deletions.
Binary file modified Src/ScxmlEditor.res
Binary file not shown.
91 changes: 47 additions & 44 deletions Src/TreeEditor/UnitTreeEditorUtils.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/***********************************************************************************
BSD 3-Clause License
BSD 3-Clause License
Copyright (c) 2018, https://github.com/alexzhornyak
All rights reserved.
Copyright (c) 2018, https://github.com/alexzhornyak
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************************/
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************************/

#include <vcl.h>
#pragma hdrstop
Expand Down Expand Up @@ -310,8 +310,7 @@ namespace Editorutils {

const bool bAreNotNested = RectInsideRect(AFromShape->Bounds(), AToShape->Bounds()) == false;

if ((AConnection->Style == csSides || AConnection->Style == csInvertedSides) && bAreBrothers && bAreDifferent && bAreNotNested)
{
if ((AConnection->Style == csSides || AConnection->Style == csInvertedSides) && bAreBrothers && bAreDifferent) {

for (int k = 1; k < AConnection->Points->Count(); k++) {
TPoint AFixed1(AConnection->Points->Item[k - 1].X, AConnection->Points->Item[k - 1].Y);
Expand Down Expand Up @@ -408,27 +407,31 @@ namespace Editorutils {

/* ÀÍÀËÈÇÈÐÓÅÌ ÏÎËÓ×ÅÍÍÛÅ ÏÅÐÅÑÅ×ÅÍÈß */

if (IsTypes.Contains(isFromPrev)) {
switch(AConnection->Style) {
case csSides:
AConnection->Points->Move(k - 1, 0, -ClipArray[isFromPrev].y1clip + ClipArray[isFromPrev].y0clip);
break;
case csInvertedSides:
AConnection->Points->Move(k - 1, ClipArray[isFromPrev].x1clip - ClipArray[isFromPrev].x0clip, 0);
break;
}
// fix: https://github.com/alexzhornyak/ScxmlEditor-Tutorial/issues/107
if (bAreNotNested || k - 1 != 0) {
if (IsTypes.Contains(isFromPrev)) {
switch(AConnection->Style) {
case csSides:
AConnection->Points->Move(k - 1, 0, -ClipArray[isFromPrev].y1clip + ClipArray[isFromPrev].y0clip);
break;
case csInvertedSides:
AConnection->Points->Move(k - 1, ClipArray[isFromPrev].x1clip - ClipArray[isFromPrev].x0clip, 0);
break;
}

}
if (IsTypes.Contains(isFromCur)) {
switch(AConnection->Style) {
case csSides:
AConnection->Points->Move(k - 1, ClipArray[isFromCur].x1clip - ClipArray[isFromCur].x0clip, 0);
break;
case csInvertedSides:
AConnection->Points->Move(k - 1, 0, -ClipArray[isFromCur].y1clip + ClipArray[isFromCur].y0clip);
break;
}
if (IsTypes.Contains(isFromCur)) {
switch(AConnection->Style) {
case csSides:
AConnection->Points->Move(k - 1, ClipArray[isFromCur].x1clip - ClipArray[isFromCur].x0clip, 0);
break;
case csInvertedSides:
AConnection->Points->Move(k - 1, 0, -ClipArray[isFromCur].y1clip + ClipArray[isFromCur].y0clip);
break;
}
}
}

if (IsTypes.Contains(isToPrev)) {
switch(AConnection->Style) {
case csSides:
Expand Down
6 changes: 6 additions & 0 deletions Src/UnitSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ __fastcall TSettingsData::TSettingsData(TComponent* Owner) : TSettingsBase(Owner
FWarningOnBindingsNotFound = true;

FUseVectorImages = false;
FCompletionTimeoutEnabled = true;
FCompletionTimeoutMsec = 50;

FValidateInPredicate = false;
FValidateChildren = true;
Expand Down Expand Up @@ -261,6 +263,8 @@ void __fastcall TSettingsData::Assign(TPersistent* Source) {
FWarningOnInheritanceMismatch = ASettingsData->FWarningOnInheritanceMismatch;
FWarningOnBindingsNotFound = ASettingsData->FWarningOnBindingsNotFound;
FUseVectorImages = ASettingsData->FUseVectorImages;
FCompletionTimeoutEnabled = ASettingsData->FCompletionTimeoutEnabled;
FCompletionTimeoutMsec = ASettingsData->FCompletionTimeoutMsec;
FValidateInPredicate = ASettingsData->FValidateInPredicate;
FValidateChildren = ASettingsData->FValidateChildren;
FValidateXMLText = ASettingsData->FValidateXMLText;
Expand Down Expand Up @@ -480,6 +484,8 @@ void __fastcall TSettingsData::PropSettingsRegisterCategories(TLMDPropertyInspec
APropSettingsInspector->RegisterPropCategory(L"Scxml editor", L"WarningOnInheritanceMismatch");
APropSettingsInspector->RegisterPropCategory(L"Scxml editor", L"WarningOnBindingsNotFound");
APropSettingsInspector->RegisterPropCategory(L"Scxml editor", L"UseVectorImages");
APropSettingsInspector->RegisterPropCategory(L"Scxml editor", L"CompletionTimeoutEnabled");
// APropSettingsInspector->RegisterPropCategory(L"Scxml editor", L"CompletionTimeoutMsec");

APropSettingsInspector->RegisterPropCategory(L"Visual", L"ChartFocusEnabled");
APropSettingsInspector->RegisterPropCategory(L"Visual", L"ChartFocusLineWidth");
Expand Down
6 changes: 6 additions & 0 deletions Src/UnitSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ class TSettingsData: public TSettingsBase
bool FWarningOnBindingsNotFound;

bool FUseVectorImages;
bool FCompletionTimeoutEnabled;
int FCompletionTimeoutMsec;

bool FValidateInPredicate;
bool FValidateChildren;
Expand Down Expand Up @@ -387,6 +389,10 @@ class TSettingsData: public TSettingsBase
__property TAutoCompleteItems * AutoCompleteItems = {read=FAutoCompleteItems, write=SetAutoCompleteItems };
__property UnicodeString ActiveSyntaxScheme = {read=GetActiveSyntaxScheme};
__property UnicodeString WordSeparators = {read=GetWordSeparators};
__property bool CompletionTimeoutEnabled = {read=FCompletionTimeoutEnabled, write=FCompletionTimeoutEnabled, default=true};

// bug in LMD: Completion Timeout is not exposed properly
// __property int CompletionTimeoutMsec = {read=FCompletionTimeoutMsec, write=FCompletionTimeoutMsec, default=50};


// extern editor
Expand Down
1 change: 1 addition & 0 deletions Src/UnitStateMachineConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,7 @@ void __fastcall TStateMachineConnection::AssignStateMachineConnection(TStateMach
FEvent = AStateMachineConnection->FEvent;
FCondition = AStateMachineConnection->FCondition;
FConditionBack = AStateMachineConnection->FConditionBack;
FType = AStateMachineConnection->FType;
FAdjustableSides = AStateMachineConnection->FAdjustableSides;
FContentTrigger->Assign(AStateMachineConnection->FContentTrigger);
FParams->Assign(AStateMachineConnection->FParams);
Expand Down
11 changes: 10 additions & 1 deletion Src/UnitStateMachineUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,16 @@ void __fastcall TStateMachineEditorUnit::DoLoad(const Lmdtypes::TLMDString AFile

// ---------------------------------------------------------------------------
void __fastcall TStateMachineEditorUnit::DoSave(const Lmdtypes::TLMDString AFilePath) {
SaveAssociatedFile("code", AFilePath, FilePath);
try {
SaveAssociatedFile("code", AFilePath, FilePath);
}
catch(Exception * E) {
// Fix: https://github.com/alexzhornyak/ScxmlEditor-Tutorial/issues/105
if (StateMachineDockPanel) {
StateMachineDockPanel->MarkModified(0, L"", false);
}
throw E;
}

const UnicodeString sFileName = ExtractFileName(AFilePath);

Expand Down
52 changes: 28 additions & 24 deletions Src/UnitSyntaxEditor.cpp
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/***********************************************************************************
BSD 3-Clause License
BSD 3-Clause License
Copyright (c) 2018, https://github.com/alexzhornyak
All rights reserved.
Copyright (c) 2018, https://github.com/alexzhornyak
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************************/
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***************************************************************************************/

#include <vcl.h>
#pragma hdrstop
Expand Down Expand Up @@ -89,6 +89,10 @@ __fastcall TFrameSyntaxEditor::TFrameSyntaxEditor(TComponent* Owner) : TFrame(Ow
break;
}
}

EditView->CompletionSettings->ShowCompletionOnTimeout = SettingsData->CompletionTimeoutEnabled;
// bug in LMD: Completion Timeout is not exposed properly
// EditView->CompletionSettings->ShowTimeout = SettingsData->CompletionTimeoutMsec;
}
}

Expand Down
5 changes: 2 additions & 3 deletions Src/UnitSyntaxEditor.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ object FrameSyntaxEditor: TFrameSyntaxEditor
Top = 0
Width = 853
Height = 29
ButtonHeight = 0
ButtonWidth = 0
ButtonWidth = 70
Caption = 'ToolBar1'
Images = ImageList1
List = True
Expand All @@ -58,7 +57,7 @@ object FrameSyntaxEditor: TFrameSyntaxEditor
Left = 304
Top = 248
Bitmap = {
494C01011C00A000380110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C01011C00A0003C0110001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000008000000001002000000000000080
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down

0 comments on commit 92c14a3

Please sign in to comment.