From 8551642763a1e82b66f7bdd629e95775a28bafeb Mon Sep 17 00:00:00 2001 From: "birbilis@zoomicon.com" Date: Fri, 21 Jan 2022 18:28:39 +0200 Subject: [PATCH] Made btnToggleEditMode/btnToggleStructureVisible, btnToggleTargetsVisible buttons toggle ones and syncing their IsPressed status to respective HUD properties (with change events) --- App/READCOM.App.Globals.dfm | 24 +++- App/READCOM.App.dproj | 16 +-- ...READCOM.Views.Options.StoryItemOptions.pas | 1 - App/Views/READCOM.Views.Main.fmx | 39 +++--- App/Views/READCOM.Views.Main.pas | 107 +++++++++-------- App/Views/READCOM.Views.Menu.HUD.fmx | 44 ++----- App/Views/READCOM.Views.Menu.HUD.pas | 112 ++++++++++++------ .../READCOM.Views.VectorImageStoryItem.pas | 42 +++++-- Zoomicon.Zooming/Zoomicon.Zooming.Models.pas | 1 + 9 files changed, 217 insertions(+), 169 deletions(-) diff --git a/App/READCOM.App.Globals.dfm b/App/READCOM.App.Globals.dfm index 42359ef..f1ef79e 100644 --- a/App/READCOM.App.Globals.dfm +++ b/App/READCOM.App.Globals.dfm @@ -30466,7 +30466,7 @@ object Globals: TGlobals item MultiResBitmap = < item - Size = 16 + Size = 64 end> IconName = 'Anchor' SVGText = @@ -30561,7 +30561,7 @@ object Globals: TGlobals item MultiResBitmap = < item - Size = 16 + Size = 64 end> IconName = 'Delete' SVGText = @@ -30596,7 +30596,7 @@ object Globals: TGlobals item MultiResBitmap = < item - Size = 16 + Size = 64 end> IconName = 'GlobeWithMeridians' SVGText = @@ -30625,7 +30625,7 @@ object Globals: TGlobals item MultiResBitmap = < item - Size = 16 + Size = 64 end> IconName = 'Plus' SVGText = @@ -30665,7 +30665,7 @@ object Globals: TGlobals item MultiResBitmap = < item - Size = 16 + Size = 64 end> IconName = 'Camera' SVGText = @@ -30774,7 +30774,7 @@ object Globals: TGlobals item MultiResBitmap = < item - Size = 16 + Size = 64 end> IconName = 'Signpost' SVGText = @@ -30907,6 +30907,8 @@ object Globals: TGlobals Layers = < item Name = 'Anchor' + SourceRect.Right = 64.000000000000000000 + SourceRect.Bottom = 64.000000000000000000 end> end item @@ -30929,24 +30931,32 @@ object Globals: TGlobals Layers = < item Name = 'Delete' + SourceRect.Right = 64.000000000000000000 + SourceRect.Bottom = 64.000000000000000000 end> end item Layers = < item Name = 'GlobeWithMeridians' + SourceRect.Right = 64.000000000000000000 + SourceRect.Bottom = 64.000000000000000000 end> end item Layers = < item Name = 'Plus' + SourceRect.Right = 64.000000000000000000 + SourceRect.Bottom = 64.000000000000000000 end> end item Layers = < item Name = 'Camera' + SourceRect.Right = 64.000000000000000000 + SourceRect.Bottom = 64.000000000000000000 end> end item @@ -30969,6 +30979,8 @@ object Globals: TGlobals Layers = < item Name = 'Signpost' + SourceRect.Right = 64.000000000000000000 + SourceRect.Bottom = 64.000000000000000000 end> end item diff --git a/App/READCOM.App.dproj b/App/READCOM.App.dproj index 7382113..5d81424 100644 --- a/App/READCOM.App.dproj +++ b/App/READCOM.App.dproj @@ -442,25 +442,25 @@ true - + - ic_launcher.png + splash_image.png true - + ic_launcher.png true - + - ic_notification.png + ic_launcher.png true - + ic_notification.png true @@ -472,9 +472,9 @@ true - + - splash_image.png + ic_notification.png true diff --git a/App/Views/Options/READCOM.Views.Options.StoryItemOptions.pas b/App/Views/Options/READCOM.Views.Options.StoryItemOptions.pas index 50d5c0b..8942e6b 100644 --- a/App/Views/Options/READCOM.Views.Options.StoryItemOptions.pas +++ b/App/Views/Options/READCOM.Views.Options.StoryItemOptions.pas @@ -125,7 +125,6 @@ procedure TStoryItemOptions.SetStoryItem(const Value: IStoryItem); with FStoryItem do begin editUrlAction.Text := GetUrlAction; - //btnToggleHome.IsPressed := Home; btnToggleHome.IsPressed := Home; btnToggleStoryPoint.IsPressed := StoryPoint; btnToggleAnchored.IsPressed := Anchored; diff --git a/App/Views/READCOM.Views.Main.fmx b/App/Views/READCOM.Views.Main.fmx index c4ce297..57be001 100644 --- a/App/Views/READCOM.Views.Main.fmx +++ b/App/Views/READCOM.Views.Main.fmx @@ -23,6 +23,17 @@ object MainForm: TMainForm Size.PlatformDefault = False ParentShowHint = False ShowHint = True + inherited layoutContent: TLayout + Size.Width = 876.000000000000000000 + Size.Height = 616.000000000000000000 + object ZoomFrame: TZoomFrame + Align = Client + Size.Width = 876.000000000000000000 + Size.Height = 616.000000000000000000 + Size.PlatformDefault = False + Proportional = True + end + end inherited layoutButtons: TLayout Size.Width = 876.000000000000000000 Size.Height = 616.000000000000000000 @@ -40,17 +51,9 @@ object MainForm: TMainForm Position.X = 826.000000000000000000 Size.Height = 576.000000000000000000 TabOrder = 174 - end - end - inherited layoutContent: TLayout - Size.Width = 876.000000000000000000 - Size.Height = 616.000000000000000000 - object ZoomFrame: TZoomFrame - Align = Client - Size.Width = 876.000000000000000000 - Size.Height = 616.000000000000000000 - Size.PlatformDefault = False - Proportional = True + inherited btnAdd: TSpeedButton + Visible = True + end end end inherited MultiView: TMultiView @@ -71,24 +74,14 @@ object MainForm: TMainForm OnExecute = HUDactionNextExecute ImageIndex = 2 end - inherited actionEdit: TAction - OnExecute = HUDactionEditExecute - ImageIndex = 0 - end inherited actionAdd: TAction + Visible = True OnExecute = HUDactionAddExecute + ImageIndex = 10 end inherited actionAbout: TAction ImageIndex = 15 end - inherited actionStructure: TAction - OnExecute = HUDactionStructureExecute - ImageIndex = 3 - end - inherited actionTargets: TAction - OnExecute = HUDactionTargetsExecute - ImageIndex = 4 - end inherited actionNew: TAction OnExecute = HUDactionNewExecute ImageIndex = 12 diff --git a/App/Views/READCOM.Views.Main.pas b/App/Views/READCOM.Views.Main.pas index 1715399..80b3164 100644 --- a/App/Views/READCOM.Views.Main.pas +++ b/App/Views/READCOM.Views.Main.pas @@ -27,10 +27,7 @@ TMainForm = class(TForm, IStory) procedure FormCreate(Sender: TObject); procedure FormSaveState(Sender: TObject); procedure HUDactionAddExecute(Sender: TObject); - procedure HUDactionEditExecute(Sender: TObject); - procedure HUDactionStructureExecute(Sender: TObject); procedure FormDestroy(Sender: TObject); - procedure HUDactionTargetsExecute(Sender: TObject); procedure HUDactionLoadExecute(Sender: TObject); procedure HUDactionSaveExecute(Sender: TObject); procedure HUDactionNewExecute(Sender: TObject); @@ -63,17 +60,17 @@ TMainForm = class(TForm, IStory) function GetHomeStoryItem: IStoryItem; procedure SetHomeStoryItem(const Value: IStoryItem); - {Navigation} + {NAVIGATION} - { ActiveStoryItem } - function GetActiveStoryItem: IStoryItem; - procedure SetActiveStoryItem(const Value: IStoryItem); + { ActiveStoryItem } + function GetActiveStoryItem: IStoryItem; + procedure SetActiveStoryItem(const Value: IStoryItem); - procedure ActivateRoot; - procedure ActivateParent; - procedure ActivateHome; - procedure ActivatePrevious; - procedure ActivateNext; + procedure ActivateRoot; + procedure ActivateParent; + procedure ActivateHome; + procedure ActivatePrevious; + procedure ActivateNext; { StoryMode } function GetStoryMode: TStoryMode; @@ -82,9 +79,13 @@ TMainForm = class(TForm, IStory) { StructureView } procedure StructureViewSelection(Sender: TObject; const Selection: TObject); + property StructureView: TStructureView read GetStructureView stored false; + procedure RootStoryItemViewResized(Sender: TObject); - property StructureView: TStructureView read GetStructureView; + procedure HUDEditModeChanged(Sender: TObject; const Value: Boolean); + procedure HUDStructureVisibleChanged(Sender: TObject; const Value: Boolean); + procedure HUDTargetsVisibleChanged(Sender: TObject; const Value: Boolean); public procedure ZoomTo(const StoryItem: IStoryItem = nil); //ZoomTo(nil) zooms to all content @@ -116,9 +117,20 @@ procedure TMainForm.FormCreate(Sender: TObject); procedure InitHUD; begin - HUD.BringToFront; - HUD.BtnMenu.BringToFront; - HUD.layoutButtons.BringToFront; + with HUD do + begin + BringToFront; + BtnMenu.BringToFront; + layoutButtons.BringToFront; + + EditMode := false; + StructureVisible := false; + TargetsVisible := false; + + OnEditModeChanged := HUDEditModeChanged; + OnStructureVisibleChanged := HUDStructureVisibleChanged; + OnTargetsVisibleChanged := HUDTargetsVisibleChanged; + end; end; begin @@ -275,7 +287,7 @@ procedure TMainForm.SetActiveStoryItem(const Value: IStoryItem); if Assigned(Value) then begin var StoryItem := TStoryItem(Value.View); - StoryItem.EditMode := HUD.actionEdit.Checked; //TODO: see StoryMode of IStoryItem instead (or move that to the IStory) + StoryItem.EditMode := HUD.EditMode; //TODO: see StoryMode of IStoryItem instead (or move that to the IStory) //StructureView.SelectedObject := Value.View; //TODO: fix, causes some kind of disruption when doing (automatic) drag-drop (maybe schedule to do at end of drag-drop or to cancel if during drag-drop [if we can detect it] or somehow outside of current event handling) end else @@ -349,19 +361,20 @@ function TMainForm.GetStructureView: TStructureView; procedure TMainForm.SetStoryMode(const Value: TStoryMode); begin FStoryMode := Value; + var isEditMode := (Value = EditMode); if Assigned(ActiveStoryItem) then begin var view := ActiveStoryItem.View as TStoryItem; if Assigned(view) then - view.EditMode := HUD.actionEdit.Checked; //TODO: should add an EditMode property to the Story? + view.EditMode := isEditMode; //TODO: should add an EditMode property to the Story? end; if Assigned(FStructureViewFrameInfo) then with FStructureViewFrameInfo.Frame do begin - DragDropReorder := HUD.actionEdit.Checked; //allow moving items in the structure view to change parent or add to same parent again to change their Z-order - DragDropReparent := HUD.actionEdit.Checked; //allow reparenting //TODO: should do after listening to some event so that the control is scaled/repositioned to show in their parent (note that maybe we should also have parent story items clip their children, esp if their panels) + DragDropReorder := isEditMode; //allow moving items in the structure view to change parent or add to same parent again to change their Z-order + DragDropReparent := isEditMode; //allow reparenting //TODO: should do after listening to some event so that the control is scaled/repositioned to show in their parent (note that maybe we should also have parent story items clip their children, esp if their panels) end; end; @@ -411,35 +424,11 @@ procedure TMainForm.HUDactionSaveExecute(Sender: TObject); {$endregion} -{$region 'View actions'} - -procedure TMainForm.HUDactionStructureExecute(Sender: TObject); -begin - HUD.actionStructureExecute(Sender); - - HUD.MultiViewFrameStand.CloseAllExcept(TStructureView); - - StructureView.GUIRoot := RootStoryItemView; //in case the RootStoryItem has changed - FStructureViewFrameInfo.Show; //this will have been assigned by the StructureView getter if it wasn't -end; - -procedure TMainForm.HUDactionTargetsExecute(Sender: TObject); -begin - //HUD.actionTargetsExecute(Sender); - - if Assigned(ActiveStoryItem) then - ActiveStoryItem.TargetsVisible := HUD.actionTargets.Checked; -end; - -{$endregion} - {$region 'Edit actions'} -procedure TMainForm.HUDactionEditExecute(Sender: TObject); +procedure TMainForm.HUDEditModeChanged(Sender: TObject; const Value: Boolean); begin - HUD.actionEditExecute(Sender); - - if HUD.actionEdit.Checked then + if Value then StoryMode := EditMode else StoryMode := TStoryMode.InteractiveStoryMode; //TODO: should remember previous mode to restore or make EditMode a separate situation @@ -464,6 +453,28 @@ procedure TMainForm.HUDactionAddExecute(Sender: TObject); {$endregion} +{$region 'View actions'} + +procedure TMainForm.HUDStructureVisibleChanged(Sender: TObject; const Value: Boolean); +begin + if Value then + begin + HUD.MultiViewFrameStand.CloseAllExcept(TStructureView); + + StructureView.GUIRoot := RootStoryItemView; //in case the RootStoryItem has changed + FStructureViewFrameInfo.Show; //this will have been assigned by the StructureView getter if it wasn't + end; +end; + +procedure TMainForm.HUDTargetsVisibleChanged(Sender: TObject; const Value: Boolean); +begin + if HUD.TargetsVisible then + if Assigned(ActiveStoryItem) then + ActiveStoryItem.TargetsVisible := Value; +end; + +{$endregion} + {$region 'Navigation actions'} procedure TMainForm.HUDactionHomeExecute(Sender: TObject); @@ -484,7 +495,7 @@ procedure TMainForm.HUDactionNextExecute(Sender: TObject); procedure TMainForm.StructureViewSelection(Sender: TObject; const Selection: TObject); begin if not (StoryMode = EditMode) then //in non-Edit mode - HUD.StructureViewVisible := false; //we want to hide the StructureView before zooming to the item selected + HUD.StructureVisible := false; //we want to hide the StructureView before zooming to the item selected ActiveStoryItem := TStoryItem(Selection); //Make active (will also zoom to it) - assuming this is a TStoryItem since StructureView was filtering for such class //also accepts "nil" (for no selection) //TODO: in EditMode should allow anything to become active, in StoryMode should only allow those items that are Activateable / have some ActivationOrder (maybe rename to FlowOrder and/or add different prescribed flows) @@ -505,7 +516,7 @@ procedure TMainForm.NewRootStoryItem; with newRootStoryItemView do begin Size.Size := TSizeF.Create(ZoomFrame.Width, ZoomFrame.Height); - EditMode := HUD.actionEdit.Checked; //TODO: add EditMode property to IStory or use its originally intended mode one + EditMode := HUD.EditMode; //TODO: add EditMode property to IStory or use its originally intended mode one end; RootStoryItemView := newRootStoryItemView; end; diff --git a/App/Views/READCOM.Views.Menu.HUD.fmx b/App/Views/READCOM.Views.Menu.HUD.fmx index e290af4..b88f1a4 100644 --- a/App/Views/READCOM.Views.Menu.HUD.fmx +++ b/App/Views/READCOM.Views.Menu.HUD.fmx @@ -125,9 +125,8 @@ object StoryHUD: TStoryHUD Size.PlatformDefault = False StyleLookup = 'actiontoolbutton' end - object BtnEdit: TSpeedButton - Action = actionEdit - Enabled = True + object btnToggleEditMode: TSpeedButton + StaysPressed = True Hint = 'Toggle Edit mode'#13#13'Enables/Disables story editing functionality' Images = Globals.SVGIconImageList ImageIndex = 0 @@ -136,10 +135,11 @@ object StoryHUD: TStoryHUD Size.Height = 40.000000000000000000 Size.PlatformDefault = False StyleLookup = 'actiontoolbutton' + Text = 'Edit' + OnClick = btnToggleEditModeClick end - object btnStructure: TSpeedButton - Action = actionStructure - Enabled = True + object btnToggleStructureVisible: TSpeedButton + StaysPressed = True Hint = 'Toggle Structure View'#13#13'Shows/Hides the Structure View side-pane,' + ' which allows to select active StoryItem and to rearrange StoryI' + @@ -151,10 +151,11 @@ object StoryHUD: TStoryHUD Size.Height = 40.000000000000000000 Size.PlatformDefault = False StyleLookup = 'actiontoolbutton' + Text = 'Structure' + OnClick = btnToggleStructureVisibleClick end - object btnTargets: TSpeedButton - Action = actionTargets - Enabled = True + object btnToggleTargetsVisible: TSpeedButton + StaysPressed = True Hint = 'Toggles links to StoryItem Targets'#13#13'Shows/Hides links to StoryIt' + 'em Targets. Targets are used to define where non-Anchored StoryI' + @@ -167,6 +168,8 @@ object StoryHUD: TStoryHUD Size.Height = 40.000000000000000000 Size.PlatformDefault = False StyleLookup = 'actiontoolbutton' + Text = 'Targets' + OnClick = btnToggleTargetsVisibleClick end object btnHelp: TSpeedButton Action = actionHelp @@ -248,14 +251,6 @@ object StoryHUD: TStoryHUD ImageIndex = 2 ImageIndex = 2 end - object actionEdit: TAction - Category = 'Edit' - AutoCheck = True - Text = 'Edit' - ImageIndex = 0 - OnExecute = actionEditExecute - ImageIndex = 0 - end object actionAdd: TAction Category = 'Edit' Text = 'Add' @@ -276,21 +271,6 @@ object StoryHUD: TStoryHUD Text = 'Menu' OnExecute = actionMenuExecute end - object actionStructure: TAction - Category = 'View' - AutoCheck = True - Text = 'Structure' - ImageIndex = 3 - OnExecute = actionStructureExecute - ImageIndex = 3 - end - object actionTargets: TAction - Category = 'View' - AutoCheck = True - Text = 'Targets' - ImageIndex = 4 - ImageIndex = 4 - end object actionNew: TAction Category = 'File' Text = 'New' diff --git a/App/Views/READCOM.Views.Menu.HUD.pas b/App/Views/READCOM.Views.Menu.HUD.pas index cc92876..afe1e06 100644 --- a/App/Views/READCOM.Views.Menu.HUD.pas +++ b/App/Views/READCOM.Views.Menu.HUD.pas @@ -12,10 +12,15 @@ interface READCOM.App.Globals; type + + TEditModeChangedEvent = procedure (Sender: TObject; const Value: Boolean) of object; + TStructureVisibleChangedEvent = procedure (Sender: TObject; const Value: Boolean) of object; + TTargetsVisibleChangedEvent = procedure (Sender: TObject; const Value: Boolean) of object; + TStoryHUD = class(TFrame) btnAdd: TSpeedButton; btnPrevious: TSpeedButton; - BtnEdit: TSpeedButton; + btnToggleEditMode: TSpeedButton; BtnMenu: TSpeedButton; btnNext: TSpeedButton; layoutNavigation: TLayout; @@ -23,17 +28,14 @@ TStoryHUD = class(TFrame) actionPrevious: TAction; actionNext: TAction; actionAdd: TAction; - actionEdit: TAction; actionAbout: TAction; actionMenu: TAction; layoutButtons: TLayout; MultiView: TMultiView; - btnStructure: TSpeedButton; - actionStructure: TAction; + btnToggleStructureVisible: TSpeedButton; MultiViewFrameStand: TFrameStand; layoutContent: TLayout; - actionTargets: TAction; - btnTargets: TSpeedButton; + btnToggleTargetsVisible: TSpeedButton; layoutButtonsSide: TFlowLayout; layoutEdit: TFlowLayout; actionLoad: TAction; @@ -47,28 +49,45 @@ TStoryHUD = class(TFrame) actionHelp: TAction; btnHelp: TSpeedButton; btnAbout: TSpeedButton; - procedure actionEditExecute(Sender: TObject); procedure actionAboutExecute(Sender: TObject); procedure actionMenuExecute(Sender: TObject); - procedure actionStructureExecute(Sender: TObject); procedure actionHelpExecute(Sender: TObject); + procedure btnToggleStructureVisibleClick(Sender: TObject); + procedure btnToggleEditModeClick(Sender: TObject); + procedure btnToggleTargetsVisibleClick(Sender: TObject); protected FAboutFrame: TAboutFrame; FMultiViewOpenedWidth: Single; + FEditMode: Boolean; + FStructureVisible: Boolean; + FTargetsVisible: Boolean; + + FEditModeChanged: TEditModeChangedEvent; + FStructureVisibleChanged: TStructureVisibleChangedEvent; + FTargetsVisibleChanged: TTargetsVisibleChangedEvent; + {EditMode} - function GetEditMode: Boolean; procedure SetEditMode(const Value: Boolean); virtual; - {StructureViewVisible} - function IsStructureViewVisible: Boolean; - procedure SetStructureViewVisible(const Value: Boolean); + {StructureVisible} + procedure SetStructureVisible(const Value: Boolean); + + {TargetsVisible} + procedure SetTargetsVisible(const Value: Boolean); public constructor Create(AOwner: TComponent); override; - property EditMode: Boolean read GetEditMode write SetEditMode default false; - property StructureViewVisible: Boolean read IsStructureViewVisible write SetStructureViewVisible default false; + + published + property EditMode: Boolean read FEditMode write SetEditMode default false; + property StructureVisible: Boolean read FStructureVisible write SetStructureVisible default false; + property TargetsVisible: Boolean read FTargetsVisible write SetTargetsVisible default false; + + property OnEditModeChanged: TEditModeChangedEvent read FEditModeChanged write FEditModeChanged; + property OnStructureVisibleChanged: TStructureVisibleChangedEvent read FStructureVisibleChanged write FStructureVisibleChanged; + property OnTargetsVisibleChanged: TTargetsVisibleChangedEvent read FTargetsVisibleChanged write FTargetsVisibleChanged; end; implementation @@ -81,43 +100,60 @@ constructor TStoryHUD.Create(AOwner: TComponent); begin inherited; - EditMode := false; - + FEditMode := false; FMultiViewOpenedWidth := MultiView.Width; - StructureViewVisible := false; //hide the side panel + FTargetsVisible := false; + + StructureVisible := false; //calling the "setter" to hide the side panel (which is open in design mode to define its width) end; {$REGION 'Properties'} {$region 'EditMode'} -function TStoryHUD.GetEditMode: Boolean; -begin - result := actionEdit.Checked; -end; - procedure TStoryHUD.SetEditMode(const Value: Boolean); begin - actionEdit.Checked := Value; //see if it causes firing of event on change + FEditMode := Value; + btnToggleEditMode.IsPressed := Value; //don't use "Pressed", need to use "IsPressed" + + layoutEdit.Visible := Value; //show Edit-related buttons + + if not Value then + StructureVisible := false; //hide StructureView when existing EditMode + + if Assigned(FEditModeChanged) then + FEditModeChanged(Self, Value); end; {$endregion} {$region 'StrucureViewVisible'} -function TStoryHUD.IsStructureViewVisible: Boolean; +procedure TStoryHUD.SetStructureVisible(const Value: Boolean); begin - result := (MultiView.Width <> 0); -end; + FStructureVisible := Value; + btnToggleStructureVisible.IsPressed := Value; //don't use "Pressed", need to use "IsPressed" -procedure TStoryHUD.SetStructureViewVisible(const Value: Boolean); -begin if Value then MultiView.Width := FMultiViewOpenedWidth else MultiView.Width := 0; - actionStructure.Checked := Value; + if Assigned(FStructureVisibleChanged) then + FStructureVisibleChanged(Self, Value); +end; + +{$endregion} + +{$region 'TargetsVisible'} + +procedure TStoryHUD.SetTargetsVisible(const Value: Boolean); +begin + FTargetsVisible := Value; + btnToggleTargetsVisible.IsPressed := Value; //don't use "Pressed", need to use "IsPressed" + + if Assigned(FTargetsVisibleChanged) then + FTargetsVisibleChanged(Self, Value); end; {$endregion} @@ -131,25 +167,25 @@ procedure TStoryHUD.actionMenuExecute(Sender: TObject); layoutButtons.Visible := actionMenu.Checked; end; -{$endregion} - {$region 'Edit actions'} -procedure TStoryHUD.actionEditExecute(Sender: TObject); +procedure TStoryHUD.btnToggleEditModeClick(Sender: TObject); begin - layoutEdit.Visible := EditMode; //show Edit-related buttons - - if not EditMode then - StructureViewVisible := false; //hide StructureView when existing EditMode + EditMode := not EditMode; //don't use "btnToggleEditMode.Pressed", returns inconsistent values end; {$endregion} {$region 'View actions'} -procedure TStoryHUD.actionStructureExecute(Sender: TObject); +procedure TStoryHUD.btnToggleStructureVisibleClick(Sender: TObject); +begin + StructureVisible := not StructureVisible; //don't use "btnToggleStructureVisible.Pressed", returns inconsistent values +end; + +procedure TStoryHUD.btnToggleTargetsVisibleClick(Sender: TObject); begin - SetStructureViewVisible(actionStructure.Checked); + TargetsVisible := not TargetsVisible; //don't use "btnToggleTargetsVisible.Pressed", returns inconsistent values end; {$endregion} diff --git a/App/Views/READCOM.Views.VectorImageStoryItem.pas b/App/Views/READCOM.Views.VectorImageStoryItem.pas index 7c6b752..d51ac10 100644 --- a/App/Views/READCOM.Views.VectorImageStoryItem.pas +++ b/App/Views/READCOM.Views.VectorImageStoryItem.pas @@ -40,6 +40,8 @@ TVectorImageStoryItem = class(TImageStoryItem, IVectorImageStoryItem, IImageSt function GetSVGText: String; procedure SetSVGText(const Value: String); + procedure Resize; override; + public {$region 'IStoreable'} @@ -71,6 +73,13 @@ implementation {$REGION 'TVectorImageStoryItem'} +procedure TVectorImageStoryItem.Resize; +begin + var tmp := SVGText; + SVGText := ''; + SVGText := tmp; //recalculate bitmap from the SVG //TODO: not sure if the "tmp" step is needed, or if it recalculates the buffer at all (probably doesn't have the new size at this point?) +end; + {$region 'IStoreable'} function TVectorImageStoryItem.GetLoadFilesFilter: String; @@ -139,23 +148,30 @@ procedure TVectorImageStoryItem.SetSVGImage(const Value: TSVGIconImage); function TVectorImageStoryItem.GetSVGText: String; begin - result := (Glyph.MultiResBitmap[0] as TSVGIconFixedBitmapItem).SVGText; + if Assigned(Glyph) then + result := (Glyph.MultiResBitmap[0] as TSVGIconFixedBitmapItem).SVGText + else + result := ''; end; procedure TVectorImageStoryItem.SetSVGText(const Value: String); begin //TODO: should restore default Glyph (keep it to some global/static var once?) if SVGText is set to '' - if FAutoSize then - Glyph.Align := TAlignLayout.None; - var bitmap := Glyph.MultiResBitmap[0] as TSVGIconFixedBitmapItem; - bitmap.SVGText := Value; - if FAutoSize then //TODO: shouldn't hardcode any size here, item should keep its Width/Height when loading this property - begin - //SetSize(bitmap.Width, bitmap.Height); //TODO: seems SVG size doesn't get loaded - //SetSize(100,100); - Glyph.Align := TAlignLayout.Contents; - end; - - FStoreSVG := true; //mark that we loaded custom SVG + if Assigned(Glyph) then + begin + if FAutoSize then + Glyph.Align := TAlignLayout.None; + + var bitmap := Glyph.MultiResBitmap[0] as TSVGIconFixedBitmapItem; + bitmap.SVGText := Value; + if FAutoSize then //TODO: shouldn't hardcode any size here, item should keep its Width/Height when loading this property + begin + //SetSize(bitmap.Width, bitmap.Height); //TODO: seems SVG size doesn't get loaded + //SetSize(100,100); + Glyph.Align := TAlignLayout.Contents; + end; + + FStoreSVG := true; //mark that we loaded custom SVG + end; end; {$endregion} diff --git a/Zoomicon.Zooming/Zoomicon.Zooming.Models.pas b/Zoomicon.Zooming/Zoomicon.Zooming.Models.pas index 88c0f5e..eae7d55 100644 --- a/Zoomicon.Zooming/Zoomicon.Zooming.Models.pas +++ b/Zoomicon.Zooming/Zoomicon.Zooming.Models.pas @@ -22,6 +22,7 @@ interface procedure ZoomTo(const Control: TControl = nil; const KeepRatio: Boolean = true); //ZoomTo(nil) zooms to all content // property Zoom: TPointF read GetZoom write SetZoom; + //property OnZoomChanged: TZoomChangedEvent; //should be able to define an event at an interface and let the mapping (say to a field) details to the implementing class end; implementation