Skip to content

Commit fd5e84e

Browse files
Removed PositionSelector (can now drag AreaSelector), Click on ChildStoryItem 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
1 parent bdfd281 commit fd5e84e

17 files changed

+371
-111
lines changed

App/READCOM.App.Globals.dfm

+40
Original file line numberDiff line numberDiff line change
@@ -68812,6 +68812,38 @@ object Globals: TGlobals
6881268812
'9831 .1829 .1829 .9831 0 0)" fill="none" stroke="#000" stroke-mi' +
6881368813
'terlimit="10" stroke-width="2"/>'#10' </g>'#10'</svg>'#10
6881468814
Opacity = 1.000000000000000000
68815+
end
68816+
item
68817+
MultiResBitmap = <
68818+
item
68819+
Size = 30
68820+
end>
68821+
IconName = 'Timer'
68822+
SVGText =
68823+
'<svg id="emoji" viewBox="0 0 72 72" xmlns="http://www.w3.org/200' +
68824+
'0/svg">'#10' <g id="color">'#10' <circle cx="35.9047" cy="36.0138" r' +
68825+
'="27.0345" fill="#fcea2b"/>'#10' <circle cx="36.0058" cy="36.0369' +
68826+
'" r="21.8709" fill="#fff"/>'#10' </g>'#10' <g id="line">'#10' <path fil' +
68827+
'l="none" stroke="#000" stroke-linecap="round" stroke-linejoin="r' +
68828+
'ound" stroke-width="2" d="M55.1092,25.38a21.8626,21.8626,0,1,1-8' +
68829+
'.0938-8.2451"/>'#10' <path fill="none" stroke="#000" stroke-linec' +
68830+
'ap="round" stroke-linejoin="round" stroke-width="2" d="M62.9392,' +
68831+
'35.9973a27.0463,27.0463,0,1,1-5.265-16.0382"/>'#10' <polyline fil' +
68832+
'l="none" stroke="#000" stroke-linecap="round" stroke-linejoin="r' +
68833+
'ound" stroke-width="2" points="47.394 21.578 58.432 20.418 57.27' +
68834+
'2 9.38"/>'#10' <polyline fill="none" stroke="#000" stroke-linecap' +
68835+
'="round" stroke-linejoin="round" stroke-width="2" points="49.975' +
68836+
' 36.354 35.987 36.354 35.891 36.354 35.891 18.52"/>'#10' <line x1' +
68837+
'="35.8906" x2="35.8906" y1="53.9106" y2="50.0661" fill="none" st' +
68838+
'roke="#000" stroke-linecap="round" stroke-linejoin="round" strok' +
68839+
'e-width="2"/>'#10' <polyline fill="none" stroke="#000" stroke-lin' +
68840+
'ecap="round" stroke-linejoin="round" stroke-width="2" points="21' +
68841+
'.143 36.354 18.086 36.354 18.086 36.354"/>'#10' <circle cx="35.89' +
68842+
'06" cy="36.3538" r="3.7371"/>'#10' <circle cx="48.6938" cy="47.93' +
68843+
'71" r="1.4802"/>'#10' <circle cx="23.0873" cy="24.7172" r="1.4802' +
68844+
'"/>'#10' <circle cx="23.0873" cy="47.9371" r="1.4802"/>'#10' </g>'#10'</' +
68845+
'svg>'#10
68846+
Opacity = 1.000000000000000000
6881568847
end>
6881668848
Destination = <
6881768849
item
@@ -68990,6 +69022,14 @@ object Globals: TGlobals
6899069022
SourceRect.Bottom = 30.000000000000000000
6899169023
end>
6899269024
end
69025+
item
69026+
Layers = <
69027+
item
69028+
Name = 'Timer'
69029+
SourceRect.Right = 30.000000000000000000
69030+
SourceRect.Bottom = 30.000000000000000000
69031+
end>
69032+
end
6899369033
item
6899469034
Layers = <>
6899569035
end>

App/READCOM.App.dproj

+5-5
Original file line numberDiff line numberDiff line change
@@ -456,15 +456,15 @@
456456
<Overwrite>true</Overwrite>
457457
</Platform>
458458
</DeployFile>
459-
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png" Configuration="Release" Class="Android_LauncherIcon72">
459+
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png" Configuration="Release" Class="Android_NotificationIcon72">
460460
<Platform Name="Android">
461-
<RemoteName>ic_launcher.png</RemoteName>
461+
<RemoteName>ic_notification.png</RemoteName>
462462
<Overwrite>true</Overwrite>
463463
</Platform>
464464
</DeployFile>
465-
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png" Configuration="Release" Class="Android_NotificationIcon36">
465+
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_LauncherIcon_72x72.png" Configuration="Release" Class="Android_LauncherIcon72">
466466
<Platform Name="Android">
467-
<RemoteName>ic_notification.png</RemoteName>
467+
<RemoteName>ic_launcher.png</RemoteName>
468468
<Overwrite>true</Overwrite>
469469
</Platform>
470470
</DeployFile>
@@ -474,7 +474,7 @@
474474
<Overwrite>true</Overwrite>
475475
</Platform>
476476
</DeployFile>
477-
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_72x72.png" Configuration="Release" Class="Android_NotificationIcon72">
477+
<DeployFile LocalName="$(BDS)\bin\Artwork\Android\FM_NotificationIcon_36x36.png" Configuration="Release" Class="Android_NotificationIcon36">
478478
<Platform Name="Android">
479479
<RemoteName>ic_notification.png</RemoteName>
480480
<Overwrite>true</Overwrite>

App/Views/READCOM.Views.Main.fmx

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ object MainForm: TMainForm
1313
OnCreate = FormCreate
1414
OnDestroy = FormDestroy
1515
OnKeyDown = FormKeyDown
16+
OnResize = FormResize
1617
OnSaveState = FormSaveState
1718
DesignerMasterStyle = 0
1819
inline HUD: TStoryHUD
@@ -58,6 +59,13 @@ object MainForm: TMainForm
5859
Action = HUD.actionFlipVertically
5960
end
6061
end
62+
object StoryTimer: TTimer
63+
Enabled = False
64+
Interval = 100
65+
OnTimer = StoryTimerTimer
66+
Left = 86
67+
Top = 24
68+
end
6169
end
6270
inherited MultiView: TMultiView
6371
NavigationPaneOptions.CollapsedWidth = 0.000000000000000000

App/Views/READCOM.Views.Main.pas

+66-11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface
2323
TMainForm = class(TForm, IStory)
2424
HUD: TStoryHUD;
2525
ZoomFrame: TZoomFrame;
26+
StoryTimer: TTimer;
2627
procedure FormCreate(Sender: TObject);
2728
procedure FormSaveState(Sender: TObject);
2829
procedure FormDestroy(Sender: TObject);
@@ -39,10 +40,13 @@ TMainForm = class(TForm, IStory)
3940
procedure HUDactionFlipHorizontallyExecute(Sender: TObject);
4041
procedure HUDactionFlipVerticallyExecute(Sender: TObject);
4142
procedure HUDactionAddTextStoryItemExecute(Sender: TObject);
43+
procedure FormResize(Sender: TObject);
44+
procedure StoryTimerTimer(Sender: TObject);
4245
private
4346
function GetStructureView: TStructureView;
4447

4548
protected
49+
FTimerStarted: Boolean;
4650
FStoryMode: TStoryMode;
4751
FStructureViewFrameInfo: FrameStand.TFrameInfo<TStructureView>;
4852

@@ -89,6 +93,7 @@ TMainForm = class(TForm, IStory)
8993
procedure HUDEditModeChanged(Sender: TObject; const Value: Boolean);
9094
procedure HUDStructureVisibleChanged(Sender: TObject; const Value: Boolean);
9195
procedure HUDTargetsVisibleChanged(Sender: TObject; const Value: Boolean);
96+
procedure HUDUseStoryTimerChanged(Sender: TObject; const Value: Boolean);
9297

9398
public
9499
procedure ZoomTo(const StoryItem: IStoryItem = nil); //ZoomTo(nil) zooms to all content
@@ -135,10 +140,12 @@ procedure TMainForm.FormCreate(Sender: TObject);
135140
OnEditModeChanged := HUDEditModeChanged;
136141
OnStructureVisibleChanged := HUDStructureVisibleChanged;
137142
OnTargetsVisibleChanged := HUDTargetsVisibleChanged;
143+
OnUseStoryTimerChanged := HUDUseStoryTimerChanged;
138144
end;
139145
end;
140146

141147
begin
148+
FTimerStarted := false;
142149
InitHUD;
143150
//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)
144151
LoadSavedStateOrNewRootStoryItem;
@@ -176,6 +183,11 @@ procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Cha
176183
end;
177184
end;
178185

186+
procedure TMainForm.FormResize(Sender: TObject);
187+
begin
188+
ActiveStoryItem := ActiveStoryItem; //keep the ActiveStoryItem in view
189+
end;
190+
179191
{$ENDREGION}
180192

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

296310
//Do for item's children too if any
297-
for var StoryItem in partialRoot.StoryItems do
298-
RecursiveClearEditMode(StoryItem);
311+
for var ChildStoryItem in partialRoot.StoryItems do
312+
RecursiveClearEditMode(ChildStoryItem);
299313
end;
300314
end;
301315

302316
begin
303-
TStoryItem.ActiveStoryItem := Value;
304-
ZoomTo(Value);
305-
306317
RecursiveClearEditMode(RootStoryItemView); //Clear EditMode from all items recursively
307318

308319
//Set any current editmode to the newly active item
309320
if Assigned(Value) then
310-
begin
321+
begin
311322
var StoryItem := TStoryItem(Value.View);
312-
StoryItem.EditMode := HUD.EditMode; //TODO: see StoryMode of IStoryItem instead (or move that to the IStory)
313-
StructureView.SelectedObject := Value.View;
314-
end
323+
with StoryItem do
324+
begin
325+
EditMode := HUD.EditMode; //TODO: see StoryMode of IStoryItem instead (or move that to the IStory)
326+
//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
327+
end;
328+
//Change StructureView selection
329+
StructureView.SelectedObject := StoryItem;
330+
end
315331
else
316332
StructureView.SelectedObject := nil;
317333

318334
//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
335+
336+
TStoryItem.ActiveStoryItem := Value;
337+
ZoomTo(Value);
319338
end;
320339

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

424443
{$REGION 'Events'}
425444

445+
{$region 'Timer'}
446+
447+
procedure TMainForm.StoryTimerTimer(Sender: TObject); //TODO: should show some timer animation at top-right when the story timer is enabled (AnimatedStoryMode)
448+
begin
449+
//special case used at app startup
450+
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])
451+
begin
452+
ActiveStoryItem := ActiveStoryItem; //re-apply ActiveStoryItem (needed upon app first loading to ZoomTo ActiveStoryItem from loaded saved state
453+
StoryTimer.Enabled := false;
454+
exit;
455+
end;
456+
457+
ActivateNextStoryPoint;
458+
459+
if ActiveStoryItem.Home then
460+
HUD.UseStoryTimer := false; //TODO: should instead define EndStoryPoint(s) and stop the timer once the end is reached
461+
end;
462+
463+
{$endregion}
464+
426465
{$region 'Actions'}
427466

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

597+
procedure TMainForm.HUDUseStoryTimerChanged(Sender: TObject; const Value: Boolean);
598+
begin
599+
with StoryTimer do
600+
begin
601+
Enabled := HUD.UseStoryTimer;
602+
Interval := 8000; //proceed ever 8sec (TODO: should be easily adjustable)
603+
end;
604+
FTimerStarted := true;
605+
end;
606+
558607
{$endregion}
559608

560609
{$region 'Navigation actions'}
@@ -640,6 +689,12 @@ function TMainForm.LoadSavedState: Boolean;
640689
end;
641690
end;
642691
end;
692+
693+
with StoryTimer do
694+
begin
695+
Interval := 100;
696+
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)
697+
end;
643698
end;
644699

645700
procedure TMainForm.FormSaveState(Sender: TObject);

App/Views/READCOM.Views.Menu.HUD.fmx

+22-2
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,26 @@ object StoryHUD: TStoryHUD
201201
Text = 'Targets'
202202
OnClick = btnToggleTargetsVisibleClick
203203
end
204+
object btnToggleUseStoryTimer: TSpeedButton
205+
StaysPressed = True
206+
Hint =
207+
'Toggles Story Timer mode'#13#13'Starts/stops automated Next StoryPoint' +
208+
' navigation'
209+
Images = Globals.SVGIconImageList
210+
ImageIndex = 22
211+
Margins.Left = 3.000000000000000000
212+
Margins.Top = 3.000000000000000000
213+
Margins.Right = 3.000000000000000000
214+
Margins.Bottom = 6.000000000000000000
215+
Position.X = 3.000000000000000000
216+
Position.Y = 325.000000000000000000
217+
Size.Width = 41.000000000000000000
218+
Size.Height = 40.000000000000000000
219+
Size.PlatformDefault = False
220+
StyleLookup = 'actiontoolbutton'
221+
Text = 'Story Timer'
222+
OnClick = btnToggleUseStoryTimerClick
223+
end
204224
object btnHelp: TSpeedButton
205225
Action = actionHelp
206226
Enabled = True
@@ -212,7 +232,7 @@ object StoryHUD: TStoryHUD
212232
Margins.Right = 3.000000000000000000
213233
Margins.Bottom = 3.000000000000000000
214234
Position.X = 3.000000000000000000
215-
Position.Y = 325.000000000000000000
235+
Position.Y = 374.000000000000000000
216236
Size.Width = 41.000000000000000000
217237
Size.Height = 40.000000000000000000
218238
Size.PlatformDefault = False
@@ -229,7 +249,7 @@ object StoryHUD: TStoryHUD
229249
Margins.Right = 3.000000000000000000
230250
Margins.Bottom = 3.000000000000000000
231251
Position.X = 3.000000000000000000
232-
Position.Y = 371.000000000000000000
252+
Position.Y = 420.000000000000000000
233253
Size.Width = 41.000000000000000000
234254
Size.Height = 40.000000000000000000
235255
Size.PlatformDefault = False

0 commit comments

Comments
 (0)