Skip to content

Commit

Permalink
Removed PositionSelector (can now drag AreaSelector), Click on ChildS…
Browse files Browse the repository at this point in the history
…toryItem selects it properly in EditMode, Resize of AreaSelector resizes selected item to that new size, Added UseStoryTimer toggle button to autonavigate to Next StoryPoint every 8sec, Zooming correctly to ActiveStoryItem after LoadFromSavedState
  • Loading branch information
birbilis@zoomicon.com committed Feb 24, 2022
1 parent bdfd281 commit fd5e84e
Show file tree
Hide file tree
Showing 17 changed files with 371 additions and 111 deletions.
40 changes: 40 additions & 0 deletions App/READCOM.App.Globals.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -68812,6 +68812,38 @@ object Globals: TGlobals
'9831 .1829 .1829 .9831 0 0)" fill="none" stroke="#000" stroke-mi' +
'terlimit="10" stroke-width="2"/>'#10' </g>'#10'</svg>'#10
Opacity = 1.000000000000000000
end
item
MultiResBitmap = <
item
Size = 30
end>
IconName = 'Timer'
SVGText =
'<svg id="emoji" viewBox="0 0 72 72" xmlns="http://www.w3.org/200' +
'0/svg">'#10' <g id="color">'#10' <circle cx="35.9047" cy="36.0138" r' +
'="27.0345" fill="#fcea2b"/>'#10' <circle cx="36.0058" cy="36.0369' +
'" r="21.8709" fill="#fff"/>'#10' </g>'#10' <g id="line">'#10' <path fil' +
'l="none" stroke="#000" stroke-linecap="round" stroke-linejoin="r' +
'ound" stroke-width="2" d="M55.1092,25.38a21.8626,21.8626,0,1,1-8' +
'.0938-8.2451"/>'#10' <path fill="none" stroke="#000" stroke-linec' +
'ap="round" stroke-linejoin="round" stroke-width="2" d="M62.9392,' +
'35.9973a27.0463,27.0463,0,1,1-5.265-16.0382"/>'#10' <polyline fil' +
'l="none" stroke="#000" stroke-linecap="round" stroke-linejoin="r' +
'ound" stroke-width="2" points="47.394 21.578 58.432 20.418 57.27' +
'2 9.38"/>'#10' <polyline fill="none" stroke="#000" stroke-linecap' +
'="round" stroke-linejoin="round" stroke-width="2" points="49.975' +
' 36.354 35.987 36.354 35.891 36.354 35.891 18.52"/>'#10' <line x1' +
'="35.8906" x2="35.8906" y1="53.9106" y2="50.0661" fill="none" st' +
'roke="#000" stroke-linecap="round" stroke-linejoin="round" strok' +
'e-width="2"/>'#10' <polyline fill="none" stroke="#000" stroke-lin' +
'ecap="round" stroke-linejoin="round" stroke-width="2" points="21' +
'.143 36.354 18.086 36.354 18.086 36.354"/>'#10' <circle cx="35.89' +
'06" cy="36.3538" r="3.7371"/>'#10' <circle cx="48.6938" cy="47.93' +
'71" r="1.4802"/>'#10' <circle cx="23.0873" cy="24.7172" r="1.4802' +
'"/>'#10' <circle cx="23.0873" cy="47.9371" r="1.4802"/>'#10' </g>'#10'</' +
'svg>'#10
Opacity = 1.000000000000000000
end>
Destination = <
item
Expand Down Expand Up @@ -68990,6 +69022,14 @@ object Globals: TGlobals
SourceRect.Bottom = 30.000000000000000000
end>
end
item
Layers = <
item
Name = 'Timer'
SourceRect.Right = 30.000000000000000000
SourceRect.Bottom = 30.000000000000000000
end>
end
item
Layers = <>
end>
Expand Down
10 changes: 5 additions & 5 deletions App/READCOM.App.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -456,15 +456,15 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png" Configuration="Release" Class="Android_LauncherIcon72">
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png" Configuration="Release" Class="Android_NotificationIcon72">
<Platform Name="Android">
<RemoteName>ic_launcher.png</RemoteName>
<RemoteName>ic_notification.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png" Configuration="Release" Class="Android_NotificationIcon36">
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png" Configuration="Release" Class="Android_LauncherIcon72">
<Platform Name="Android">
<RemoteName>ic_notification.png</RemoteName>
<RemoteName>ic_launcher.png</RemoteName>
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
Expand All @@ -474,7 +474,7 @@
<Overwrite>true</Overwrite>
</Platform>
</DeployFile>
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png" Configuration="Release" Class="Android_NotificationIcon72">
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png" Configuration="Release" Class="Android_NotificationIcon36">
<Platform Name="Android">
<RemoteName>ic_notification.png</RemoteName>
<Overwrite>true</Overwrite>
Expand Down
8 changes: 8 additions & 0 deletions App/Views/READCOM.Views.Main.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ object MainForm: TMainForm
OnCreate = FormCreate
OnDestroy = FormDestroy
OnKeyDown = FormKeyDown
OnResize = FormResize
OnSaveState = FormSaveState
DesignerMasterStyle = 0
inline HUD: TStoryHUD
Expand Down Expand Up @@ -58,6 +59,13 @@ object MainForm: TMainForm
Action = HUD.actionFlipVertically
end
end
object StoryTimer: TTimer
Enabled = False
Interval = 100
OnTimer = StoryTimerTimer
Left = 86
Top = 24
end
end
inherited MultiView: TMultiView
NavigationPaneOptions.CollapsedWidth = 0.000000000000000000
Expand Down
77 changes: 66 additions & 11 deletions App/Views/READCOM.Views.Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface
TMainForm = class(TForm, IStory)
HUD: TStoryHUD;
ZoomFrame: TZoomFrame;
StoryTimer: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormSaveState(Sender: TObject);
procedure FormDestroy(Sender: TObject);
Expand All @@ -39,10 +40,13 @@ TMainForm = class(TForm, IStory)
procedure HUDactionFlipHorizontallyExecute(Sender: TObject);
procedure HUDactionFlipVerticallyExecute(Sender: TObject);
procedure HUDactionAddTextStoryItemExecute(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure StoryTimerTimer(Sender: TObject);
private
function GetStructureView: TStructureView;

protected
FTimerStarted: Boolean;
FStoryMode: TStoryMode;
FStructureViewFrameInfo: FrameStand.TFrameInfo<TStructureView>;

Expand Down Expand Up @@ -89,6 +93,7 @@ TMainForm = class(TForm, IStory)
procedure HUDEditModeChanged(Sender: TObject; const Value: Boolean);
procedure HUDStructureVisibleChanged(Sender: TObject; const Value: Boolean);
procedure HUDTargetsVisibleChanged(Sender: TObject; const Value: Boolean);
procedure HUDUseStoryTimerChanged(Sender: TObject; const Value: Boolean);

public
procedure ZoomTo(const StoryItem: IStoryItem = nil); //ZoomTo(nil) zooms to all content
Expand Down Expand Up @@ -135,10 +140,12 @@ procedure TMainForm.FormCreate(Sender: TObject);
OnEditModeChanged := HUDEditModeChanged;
OnStructureVisibleChanged := HUDStructureVisibleChanged;
OnTargetsVisibleChanged := HUDTargetsVisibleChanged;
OnUseStoryTimerChanged := HUDUseStoryTimerChanged;
end;
end;

begin
FTimerStarted := false;
InitHUD;
//ZoomFrame.ScrollBox.AniCalculations.AutoShowing := true; //fade the toolbars when not active //TODO: doesn't work with direct mouse drags near the bottom and right edges (scrollbars do show when scrolling e.g. with mousewheel) since there's other HUD content above them (the navigation and the edit sidebar panes)
LoadSavedStateOrNewRootStoryItem;
Expand Down Expand Up @@ -176,6 +183,11 @@ procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Cha
end;
end;

procedure TMainForm.FormResize(Sender: TObject);
begin
ActiveStoryItem := ActiveStoryItem; //keep the ActiveStoryItem in view
end;

{$ENDREGION}

{$region 'IStory'}
Expand Down Expand Up @@ -290,32 +302,39 @@ procedure TMainForm.SetActiveStoryItem(const Value: IStoryItem); //TODO: should
begin
if Assigned(partialRoot) then
begin
TStoryItem(partialRoot).EditMode := false; //TODO: see StoryMode of IStoryItem instead
TStoryItem(partialRoot).Enabled := true; //re-enable if previously disabled due to EditMode of its parent
var StoryItem := TStoryItem(partialRoot.View);
StoryItem.EditMode := false; //TODO: see StoryMode of IStoryItem instead
StoryItem.Enabled := true; //restore any items that had been left disabled accidentally
//StoryItem.Enabled := (StoryMode <> EditMode) and (StoryItem <> RootStoryItemView); //TODO: test

//Do for item's children too if any
for var StoryItem in partialRoot.StoryItems do
RecursiveClearEditMode(StoryItem);
for var ChildStoryItem in partialRoot.StoryItems do
RecursiveClearEditMode(ChildStoryItem);
end;
end;

begin
TStoryItem.ActiveStoryItem := Value;
ZoomTo(Value);

RecursiveClearEditMode(RootStoryItemView); //Clear EditMode from all items recursively

//Set any current editmode to the newly active item
if Assigned(Value) then
begin
begin
var StoryItem := TStoryItem(Value.View);
StoryItem.EditMode := HUD.EditMode; //TODO: see StoryMode of IStoryItem instead (or move that to the IStory)
StructureView.SelectedObject := Value.View;
end
with StoryItem do
begin
EditMode := HUD.EditMode; //TODO: see StoryMode of IStoryItem instead (or move that to the IStory)
//AreaSelector := RootStoryItemView.AreaSelector; //re-use RootStoryItem's AreaSelector (so that we don't get drawing artifacts when resizing area selector and is always on top of everything when extending outside of ActiveStoryItem's bounds - since that can have children that are not inside its area, like a speech bubble for a character) //TODO: not working correctly
end;
//Change StructureView selection
StructureView.SelectedObject := StoryItem;
end
else
StructureView.SelectedObject := nil;

//HUD.actionDelete.Visible := (ActiveStoryItem.View <> RootStoryItem.View); //doesn't seem to work (neither HUD.btnDelete.Visible does), but have implemented delete of RootStoryItem as a call to actionNew.Execute instead

TStoryItem.ActiveStoryItem := Value;
ZoomTo(Value);
end;

{$endregion}
Expand Down Expand Up @@ -423,6 +442,26 @@ procedure TMainForm.ZoomTo(const StoryItem: IStoryItem);

{$REGION 'Events'}

{$region 'Timer'}

procedure TMainForm.StoryTimerTimer(Sender: TObject); //TODO: should show some timer animation at top-right when the story timer is enabled (AnimatedStoryMode)
begin
//special case used at app startup
if not FTimerStarted then //TODO: should check if we loaded from saved state and remember if we were playing the timer and continue [see CCR.PrefsIniFile github repo maybe to keep app settings])
begin
ActiveStoryItem := ActiveStoryItem; //re-apply ActiveStoryItem (needed upon app first loading to ZoomTo ActiveStoryItem from loaded saved state
StoryTimer.Enabled := false;
exit;
end;

ActivateNextStoryPoint;

if ActiveStoryItem.Home then
HUD.UseStoryTimer := false; //TODO: should instead define EndStoryPoint(s) and stop the timer once the end is reached
end;

{$endregion}

{$region 'Actions'}

{$region 'File actions'}
Expand Down Expand Up @@ -555,6 +594,16 @@ procedure TMainForm.HUDTargetsVisibleChanged(Sender: TObject; const Value: Boole
ActiveStoryItem.TargetsVisible := Value;
end;

procedure TMainForm.HUDUseStoryTimerChanged(Sender: TObject; const Value: Boolean);
begin
with StoryTimer do
begin
Enabled := HUD.UseStoryTimer;
Interval := 8000; //proceed ever 8sec (TODO: should be easily adjustable)
end;
FTimerStarted := true;
end;

{$endregion}

{$region 'Navigation actions'}
Expand Down Expand Up @@ -640,6 +689,12 @@ function TMainForm.LoadSavedState: Boolean;
end;
end;
end;

with StoryTimer do
begin
Interval := 100;
Enabled := true; //used to re-apply ActiveStoryItem so that we can zoom to it after the form has fully sized (FormShow event doesn't do this properly)
end;
end;

procedure TMainForm.FormSaveState(Sender: TObject);
Expand Down
24 changes: 22 additions & 2 deletions App/Views/READCOM.Views.Menu.HUD.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,26 @@ object StoryHUD: TStoryHUD
Text = 'Targets'
OnClick = btnToggleTargetsVisibleClick
end
object btnToggleUseStoryTimer: TSpeedButton
StaysPressed = True
Hint =
'Toggles Story Timer mode'#13#13'Starts/stops automated Next StoryPoint' +
' navigation'
Images = Globals.SVGIconImageList
ImageIndex = 22
Margins.Left = 3.000000000000000000
Margins.Top = 3.000000000000000000
Margins.Right = 3.000000000000000000
Margins.Bottom = 6.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 325.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 40.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'actiontoolbutton'
Text = 'Story Timer'
OnClick = btnToggleUseStoryTimerClick
end
object btnHelp: TSpeedButton
Action = actionHelp
Enabled = True
Expand All @@ -212,7 +232,7 @@ object StoryHUD: TStoryHUD
Margins.Right = 3.000000000000000000
Margins.Bottom = 3.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 325.000000000000000000
Position.Y = 374.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 40.000000000000000000
Size.PlatformDefault = False
Expand All @@ -229,7 +249,7 @@ object StoryHUD: TStoryHUD
Margins.Right = 3.000000000000000000
Margins.Bottom = 3.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 371.000000000000000000
Position.Y = 420.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 40.000000000000000000
Size.PlatformDefault = False
Expand Down
Loading

0 comments on commit fd5e84e

Please sign in to comment.