Skip to content

Commit

Permalink
Fixed component editor, issue #153
Browse files Browse the repository at this point in the history
Fixed Apply into component editor
Fixed inherited color for SVGIconImage, issue #152
VCL version 2.2.2
  • Loading branch information
carloBarazzetta committed Dec 24, 2020
1 parent 396bcb1 commit 5654778
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 55 deletions.
3 changes: 2 additions & 1 deletion Demo/Source/UMainNew.pas
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ procedure TMainForm.FormCreate(Sender: TObject);
TStringList(SelectThemeRadioGroup.Items).Sort;
SelectThemeRadioGroup.OnClick := nil;
try
SelectThemeRadioGroup.ItemIndex := SelectThemeRadioGroup.Items.IndexOf({$IFDEF D10_1+}'Windows10'{$ELSE}'Windows'{$ENDIF});
SelectThemeRadioGroup.ItemIndex :=
SelectThemeRadioGroup.Items.IndexOf(TStyleManager.ActiveStyle.Name);
finally
SelectThemeRadioGroup.OnClick := SelectThemeRadioGroupClick;
end;
Expand Down
37 changes: 10 additions & 27 deletions Packages/SVGIconImageListEditorUnit.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Align = alClient
BevelOuter = bvNone
TabOrder = 0
ExplicitWidth = 784
object paClient: TPanel
Left = 0
Top = 0
Expand All @@ -49,7 +48,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Align = alClient
BevelOuter = bvNone
TabOrder = 0
ExplicitWidth = 784
object ImageListGroupBox: TGroupBox
Left = 0
Top = 0
Expand All @@ -58,7 +56,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Align = alTop
Caption = 'Properties of ImageList'
TabOrder = 0
ExplicitWidth = 784
object SizeLabel: TLabel
Left = 8
Top = 15
Expand Down Expand Up @@ -127,7 +124,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Height = 315
Align = alClient
TabOrder = 1
ExplicitWidth = 784
object CategorySplitter: TSplitter
Left = 186
Top = 1
Expand All @@ -145,7 +141,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Align = alClient
Caption = '%d Icons collection'
TabOrder = 1
ExplicitWidth = 450
object ImageView: TListView
Left = 2
Top = 17
Expand All @@ -164,7 +159,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
OnDragOver = ImageViewDragOver
OnKeyDown = ImageViewKeyDown
OnSelectItem = ImageViewSelectItem
ExplicitWidth = 446
end
end
object paButtons: TPanel
Expand All @@ -175,7 +169,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Align = alRight
BevelOuter = bvNone
TabOrder = 2
ExplicitLeft = 640
object AddButton: TButton
Left = 4
Top = 17
Expand Down Expand Up @@ -353,7 +346,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Align = alBottom
BevelOuter = bvNone
TabOrder = 2
ExplicitWidth = 784
DesignSize = (
791
38)
Expand All @@ -368,7 +360,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
ModalResult = 1
TabOrder = 0
OnClick = OkButtonClick
ExplicitLeft = 418
end
object ApplyButton: TButton
Left = 608
Expand All @@ -379,7 +370,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Caption = '&Apply'
TabOrder = 2
OnClick = ApplyButtonClick
ExplicitLeft = 601
end
object CancelButton: TButton
Left = 517
Expand All @@ -391,7 +381,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Caption = 'Cancel'
ModalResult = 2
TabOrder = 1
ExplicitLeft = 510
end
object HelpButton: TButton
Left = 700
Expand All @@ -402,7 +391,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Caption = '&Help'
TabOrder = 3
OnClick = HelpButtonClick
ExplicitLeft = 693
end
object SVGErrorStaticText: TStaticText
Left = 6
Expand All @@ -413,7 +401,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
AutoSize = False
TabOrder = 4
Transparent = False
ExplicitWidth = 406
end
end
object paIcon: TPanel
Expand All @@ -424,18 +411,16 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
Align = alBottom
BevelOuter = bvNone
TabOrder = 1
ExplicitWidth = 784
object IconButtonsPanel: TPanel
Left = 698
Left = 694
Top = 0
Width = 93
Width = 97
Height = 200
Align = alRight
BevelOuter = bvNone
TabOrder = 1
ExplicitLeft = 691
object NewButton: TButton
Left = 2
Left = 6
Top = 6
Width = 85
Height = 25
Expand All @@ -444,16 +429,16 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
OnClick = NewButtonClick
end
object ReformatXMLButton: TButton
Left = 2
Top = 152
Left = 6
Top = 163
Width = 85
Height = 25
Caption = 'Reformat &XML'
TabOrder = 2
OnClick = ReformatXMLButtonClick
end
object DeleteButton: TButton
Left = 2
Left = 6
Top = 37
Width = 85
Height = 25
Expand All @@ -465,14 +450,13 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
object ItemGroupBox: TGroupBox
Left = 0
Top = 0
Width = 698
Width = 694
Height = 200
Align = alClient
Caption = 'Selected Icon'
TabOrder = 0
ExplicitWidth = 691
DesignSize = (
698
694
200)
object IconNameLabel: TLabel
Left = 176
Expand Down Expand Up @@ -542,7 +526,7 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
object SVGText: TMemo
Left = 176
Top = 54
Width = 514
Width = 510
Height = 134
Hint = 'SVG Text content'
Anchors = [akLeft, akTop, akRight, akBottom]
Expand All @@ -552,7 +536,6 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
OnEnter = SVGTextEnter
OnExit = SVGTextExit
OnKeyDown = SVGTextKeyDown
ExplicitWidth = 507
end
object FixedColorItemComboBox: TColorBox
Left = 415
Expand All @@ -568,7 +551,7 @@ object SVGIconImageListEditor: TSVGIconImageListEditor
object GrayScaleItemCheckBox: TCheckBox
Left = 563
Top = 30
Width = 85
Width = 81
Height = 17
Caption = 'GrayScale'
TabOrder = 4
Expand Down
55 changes: 40 additions & 15 deletions Packages/SVGIconImageListEditorUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ TSVGIconImageListEditor = class(TForm)
FOpenDialog: TOpenPictureDialogSvg;
FSelectedCategory: string;
FSourceList, FEditingList: TSVGIconImageList;
FImageCollection: TSVGIconImageCollection;
FSVGIconVirtualImageList: TSVGIconVirtualImageList;
FTotIconsLabel: string;
FUpdating: Boolean;
FChanged: Boolean;
Expand All @@ -177,6 +179,8 @@ TSVGIconImageListEditor = class(TForm)
procedure BuildList(Selected: Integer);
procedure UpdateCategories;
procedure Apply;
procedure ApplyToImageCollection;
procedure ApplyToSVGIconVirtualImageList;
procedure UpdateGUI;
function SelectedIcon: TSVGIconItem;
procedure UpdateSizeGUI;
Expand Down Expand Up @@ -261,6 +265,7 @@ function EditSVGIconVirtualImageList(const AImageList: TSVGIconVirtualImageList)
try
Screen.Cursor := crHourglass;
try
FSVGIconVirtualImageList := AImageList;
FSourceList := TSVGIconImageList.Create(LEditor);
FSourceList.Assign(AImageList);
FEditingList.Assign(AImageList);
Expand All @@ -273,8 +278,7 @@ function EditSVGIconVirtualImageList(const AImageList: TSVGIconVirtualImageList)
begin
Screen.Cursor := crHourglass;
try
AImageList.ImageCollection.SVGIconItems.Assign(LEditor.FEditingList.SVGIconItems);
AImageList.Assign(LEditor.FEditingList);
ApplyToSVGIconVirtualImageList;
finally
Screen.Cursor := crDefault;
end;
Expand All @@ -297,6 +301,7 @@ function EditSVGIconImageCollection(const AImageCollection: TSVGIconImageCollect
try
Screen.Cursor := crHourglass;
try
FImageCollection := AImageCollection;
FSourceList := TSVGIconImageList.Create(LEditor);
FSourceList.SVGIconItems.Assign(AImageCollection.SVGIconItems);
FSourceList.Size := 64; //Force 64 pixel size for image collection icons
Expand All @@ -315,10 +320,7 @@ function EditSVGIconImageCollection(const AImageCollection: TSVGIconImageCollect
begin
Screen.Cursor := crHourglass;
try
AImageCollection.SVGIconItems.Assign(LEditor.FEditingList.SVGIconItems);
AImageCollection.GrayScale := GrayScaleCheckBox.Checked;
AImageCollection.FixedColor := FixedColorComboBox.Selected;
AImageCollection.AntiAliasColor := AntialiasColorComboBox.Selected;
ApplyToImageCollection;
finally
Screen.Cursor := crDefault;
end;
Expand All @@ -329,10 +331,8 @@ function EditSVGIconImageCollection(const AImageCollection: TSVGIconImageCollect
Free;
end;
end;

end;


{ TSVGIconImageListEditor }

procedure TSVGIconImageListEditor.UpdateSizeGUI;
Expand All @@ -348,6 +348,20 @@ procedure TSVGIconImageListEditor.ApplyButtonClick(Sender: TObject);
UpdateGUI;
end;

procedure TSVGIconImageListEditor.ApplyToImageCollection;
begin
FImageCollection.SVGIconItems.Assign(FEditingList.SVGIconItems);
FImageCollection.GrayScale := GrayScaleCheckBox.Checked;
FImageCollection.FixedColor := FixedColorComboBox.Selected;
FImageCollection.AntiAliasColor := AntialiasColorComboBox.Selected;
end;

procedure TSVGIconImageListEditor.ApplyToSVGIconVirtualImageList;
begin
FSVGIconVirtualImageList.ImageCollection.SVGIconItems.Assign(FEditingList.SVGIconItems);
FSVGIconVirtualImageList.Assign(FEditingList);
end;

procedure TSVGIconImageListEditor.AddButtonClick(Sender: TObject);
begin
if FOpenDialog.Execute then
Expand Down Expand Up @@ -407,6 +421,10 @@ procedure TSVGIconImageListEditor.UpdateGUI;
SetCategoriesButton.Enabled := LIsItemSelected;
ApplyButton.Enabled := FChanged;
NameEdit.Enabled := LIsItemSelected;
CategoryEdit.Enabled := LIsItemSelected;
FixedColorItemComboBox.Enabled := LIsItemSelected;
GrayScaleItemCheckBox.Enabled := LIsItemSelected;
IconIndexEdit.Enabled := LIsItemSelected;
SVGText.Enabled := LIsItemSelected;
ImageListGroup.Caption := Format(FTotIconsLabel, [FEditingList.Count]);
GrayScaleCheckBox.Checked := SVGIconImageList.GrayScale;
Expand All @@ -416,6 +434,9 @@ procedure TSVGIconImageListEditor.UpdateGUI;
if LIsItemSelected then
begin
IconImage.ImageIndex := SelectedIcon.Index;
IconImage.Opacity := SVGIconImageList.Opacity;
IconImage.FixedColor := SelectedIcon.FixedColor;
IconImage.GrayScale := SVGIconImageList.GrayScale or SelectedIcon.GrayScale;
NameEdit.Text := LIconItem.Name;
CategoryEdit.Text := LIconItem.Category;
IconIndexEdit.Text := LIconItem.Index.ToString;
Expand All @@ -429,6 +450,10 @@ procedure TSVGIconImageListEditor.UpdateGUI;
ItemGroupBox.Caption := '';
NameEdit.Text := '';
SVGText.Lines.Text := '';
CategoryEdit.Text := '';
FixedColorItemComboBox.Selected := clDefault;
GrayScaleItemCheckBox.Checked := False;
IconIndexEdit.Text := '';
end;
finally
FUpdating := False;
Expand Down Expand Up @@ -809,14 +834,14 @@ procedure TSVGIconImageListEditor.Apply;
Exit;
Screen.Cursor := crHourGlass;
try
FSourceList.BeginUpdate;
Try
if Assigned(FImageCollection) then
ApplyToImageCollection
else if Assigned(FSVGIconVirtualImageList) then
ApplyToSVGIconVirtualImageList
else
FSourceList.Assign(FEditingList);
FChanged := False;
FModified := True;
Finally
FSourceList.EndUpdate;
End;
FChanged := False;
FModified := True;
finally
Screen.Cursor := crDefault;
end;
Expand Down
18 changes: 14 additions & 4 deletions Source/SVGIconImage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,20 @@ function TSVGIconImage.Empty: Boolean;

function TSVGIconImage.GetInheritedFixedColor: TColor;
begin
Result := SVG_INHERIT_COLOR;
if not Assigned(FImageList) then
Exit;
if FImageList is TSVGIconImageListBase then
Result := TSVGIconImageListBase(FImageList).FixedColor
else
Result := SVG_INHERIT_COLOR;
begin
if FImageIndex >= 0 then
begin
if FImageIndex < SVGIconItems.Count then
Result := TSVGIconImageListBase(FImageList).SVGIconItems[FImageIndex].FixedColor;
if Result <> SVG_INHERIT_COLOR then
exit;
end;
Result := TSVGIconImageListBase(FImageList).FixedColor;
end;
end;

function TSVGIconImage.GetSVGText: string;
Expand Down Expand Up @@ -260,7 +270,7 @@ function TSVGIconImage.SVGIconItems: TSVGIconItems;
function TSVGIconImage.UsingSVGText: Boolean;
begin
Result := not (Assigned(FImageList) and (FImageIndex >= 0) and
(FImageIndex < FImagelist.Count));
(FImageIndex < SVGIconItems.Count));
end;

procedure TSVGIconImage.Paint;
Expand Down
8 changes: 1 addition & 7 deletions Source/SVGIconImageCollection.pas
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,7 @@ procedure TSVGIconImageCollection.SetGrayScale(const Value: Boolean);

procedure TSVGIconImageCollection.SetSVGIconItems(const Value: TSVGIconItems);
begin
//shouldn't this use assign?
//FSVGItems := Value;

if FSVGItems <> Value then
begin
FSVGItems.Assign(Value);
end;
FSVGItems.Assign(Value);
end;

procedure TSVGIconImageCollection.WriteLeft(Writer: TWriter);
Expand Down
2 changes: 1 addition & 1 deletion Source/SVGIconImageListBase.pas
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface
SvgInterfaces;

const
SVGIconImageListVersion = '2.2.1';
SVGIconImageListVersion = '2.2.2';
DEFAULT_SIZE = 16;

type
Expand Down

0 comments on commit 5654778

Please sign in to comment.