Skip to content

Commit

Permalink
Added btnAddBitmapImageStoryItem to Edit sidebar, Fix show/Hide Bitma…
Browse files Browse the repository at this point in the history
…pImageStoryItem's default Glyph when it gets image content
  • Loading branch information
birbilis@zoomicon.com committed Feb 25, 2022
1 parent fd5e84e commit 51ac497
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 27 deletions.
51 changes: 51 additions & 0 deletions App/READCOM.App.Globals.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -68844,6 +68844,49 @@ object Globals: TGlobals
'"/>'#10' <circle cx="23.0873" cy="47.9371" r="1.4802"/>'#10' </g>'#10'</' +
'svg>'#10
Opacity = 1.000000000000000000
end
item
MultiResBitmap = <
item
Size = 30
end>
IconName = 'FramedPicture'
SVGText =
'<svg id="emoji" viewBox="0 0 72 72" xmlns="http://www.w3.org/200' +
'0/svg">'#10' <g id="color">'#10' <rect x="12" y="12" width="48" heig' +
'ht="48" fill="#A57939" stroke="none" stroke-linecap="round" stro' +
'ke-linejoin="round" stroke-miterlimit="10" stroke-width="2"/>'#10' ' +
' <rect x="18" y="18" width="36" height="36" fill="#92D3F5" stro' +
'ke="none" stroke-linecap="round" stroke-linejoin="round" stroke-' +
'miterlimit="10" stroke-width="2"/>'#10' <circle cx="26" cy="30" r' +
'="4" fill="#FCEA2B" stroke="none" stroke-linecap="round" stroke-' +
'linejoin="round" stroke-miterlimit="10" stroke-width="2"/>'#10' <' +
'path fill="#5C9E31" stroke="#5C9E31" stroke-linecap="round" stro' +
'ke-linejoin="round" stroke-miterlimit="10" stroke-width="2" d="M' +
'50,35c-2.8958-0.8542-6.2795-7.9886-8-8c-4.208-0.0278-6.254,5.836' +
'-11,9c-3,2-3.3745,2.8497-6,4c-2.2824,1-3,3-3.25,3.6406 c-0.3031,' +
'0.7766-1.4751,2.5214-0.9583,3.1094c1.2083,1.375,2.4583,1.5,5,0.7' +
'179c2.147-0.6606,4.9769-4.8074,6.875-6.2179 c2.2708-1.6875,4.645' +
'8-2.5,8.0833-2c2.4795,0.3606,6.66,3.1723,7.8125,3.0625c1.3125-0.' +
'125-1.5937-2.5625-0.5312-4.1875 c1.1327-1.7325,2.9102,0.1529,3.6' +
'354-1.0833C51.9844,36.5,50.632,35.1864,50,35z"/>'#10' </g>'#10' <g id=' +
'"hair"/>'#10' <g id="skin"/>'#10' <g id="skin-shadow"/>'#10' <g id="line"' +
'>'#10' <rect x="12" y="12" width="48" height="48" fill="none" str' +
'oke="#000000" stroke-linecap="round" stroke-linejoin="round" str' +
'oke-miterlimit="10" stroke-width="2"/>'#10' <rect x="18" y="18" w' +
'idth="36" height="36" fill="none" stroke="#000000" stroke-lineca' +
'p="round" stroke-linejoin="round" stroke-miterlimit="10" stroke-' +
'width="2"/>'#10' <circle cx="26" cy="30" r="4" fill="none" stroke' +
'="#000000" stroke-linecap="round" stroke-linejoin="round" stroke' +
'-miterlimit="10" stroke-width="2"/>'#10' <rect x="18" y="18" widt' +
'h="36" height="36" fill="none" stroke="#000000" stroke-linecap="' +
'round" stroke-linejoin="round" stroke-miterlimit="10" stroke-wid' +
'th="2"/>'#10' <path fill="none" stroke="#000000" stroke-linecap="' +
'round" stroke-linejoin="round" stroke-miterlimit="10" stroke-wid' +
'th="2" d="M22,43c0.5259-1.0198,0.7275-1.9672,3-3c2.6096-1.1859,3' +
'-2,6-4c4.746-3.164,6.792-9.0278,11-9c1.7205,0.0114,5,7,8,8"/>'#10' ' +
'</g>'#10'</svg>'#10
Opacity = 1.000000000000000000
end>
Destination = <
item
Expand Down Expand Up @@ -69030,6 +69073,14 @@ object Globals: TGlobals
SourceRect.Bottom = 30.000000000000000000
end>
end
item
Layers = <
item
Name = 'FramedPicture'
SourceRect.Right = 30.000000000000000000
SourceRect.Bottom = 30.000000000000000000
end>
end
item
Layers = <>
end>
Expand Down
21 changes: 19 additions & 2 deletions App/Views/READCOM.Views.BitmapImageStoryItem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ TBitmapImageStoryItem = class(TImageStoryItem, IBitmapImageStoryItem, IImageSt
{Clipboard}
procedure Paste(const Clipboard: IFMXExtendedClipboardService); overload; override;
procedure PasteImage(const BitmapSurface: TBitmapSurface); override;

{Image}
function GetImage: TImage; override;
procedure SetImage(const Value: TImage); override;
Expand All @@ -47,6 +46,7 @@ TBitmapImageStoryItem = class(TImageStoryItem, IBitmapImageStoryItem, IImageSt
procedure SetEditMode(const Value: Boolean); override;

procedure Loaded; override;
procedure UpdateGlyphVisibility;

public
constructor Create(AOwner: TComponent); override;
Expand Down Expand Up @@ -97,12 +97,19 @@ constructor TBitmapImageStoryItem.Create(AOwner: TComponent);
SendToBack;
HitTest := false;
end;

Glyph.Visible := true;
end;

procedure TBitmapImageStoryItem.UpdateGlyphVisibility;
begin
Glyph.Visible := not Assigned(ImageControl.Bitmap.Image); //hide default Glyph if we have a bitmap image
end;

procedure TBitmapImageStoryItem.Loaded;
begin
inherited;
Glyph.Visible := not Assigned(ImageControl.Bitmap.Image); //hide default Glyph if we have a bitmap image
UpdateGlyphVisibility;
end;

{$endregion}
Expand All @@ -127,6 +134,10 @@ procedure TBitmapImageStoryItem.Paste(const Clipboard: IFMXExtendedClipboardServ
procedure TBitmapImageStoryItem.PasteImage(const BitmapSurface: TBitmapSurface);
begin
ImageControl.Bitmap.Assign(BitmapSurface);
UpdateGlyphVisibility;

if FAutoSize then
SetSize(ImageControl.Bitmap.Width, ImageControl.Bitmap.Height); //TODO: probably not needed
end;

{$endregion}
Expand All @@ -149,6 +160,8 @@ procedure TBitmapImageStoryItem.Load(const Stream: TStream; const ContentFormat:
procedure TBitmapImageStoryItem.LoadBitmap(const Stream: TStream);
begin
ImageControl.Bitmap.LoadFromStream(Stream); //TODO: does it detect PNG and JPEG automatically?
UpdateGlyphVisibility;

if FAutoSize then
SetSize(ImageControl.Bitmap.Width, ImageControl.Bitmap.Height); //TODO: probably not needed
end;
Expand All @@ -167,6 +180,10 @@ function TBitmapImageStoryItem.GetImage: TImage;
procedure TBitmapImageStoryItem.SetImage(const Value: TImage);
begin
ImageControl.Bitmap.Assign(Value.Bitmap); //can't assign TImage directly
UpdateGlyphVisibility;

if FAutoSize then
SetSize(ImageControl.Bitmap.Width, ImageControl.Bitmap.Height); //TODO: probably not needed
end;

{$endregion}
Expand Down
4 changes: 4 additions & 0 deletions App/Views/READCOM.Views.Main.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ object MainForm: TMainForm
inherited actionHelp: TAction
ImageIndex = 16
end
inherited actionAddBitmapImageStoryItem: TAction
OnExecute = HUDactionAddBitmapImageStoryItemExecute
ImageIndex = 23
end
end
inherited MultiViewFrameStand: TFrameStand
Left = 432
Expand Down
35 changes: 26 additions & 9 deletions App/Views/READCOM.Views.Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface
FMX.Layouts,
READCOM.Views.AudioStoryItem,
SubjectStand,
READCOM.App.Globals;
READCOM.App.Globals, System.Actions, FMX.ActnList;

type

Expand All @@ -25,25 +25,28 @@ TMainForm = class(TForm, IStory)
ZoomFrame: TZoomFrame;
StoryTimer: TTimer;
procedure FormCreate(Sender: TObject);
procedure FormSaveState(Sender: TObject);
procedure FormDestroy(Sender: TObject);

procedure FormSaveState(Sender: TObject);

procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);

procedure HUDactionLoadExecute(Sender: TObject);
procedure HUDactionSaveExecute(Sender: TObject);
procedure HUDactionNewExecute(Sender: TObject);
procedure HUDactionHomeExecute(Sender: TObject);
procedure HUDactionPreviousExecute(Sender: TObject);
procedure HUDactionNextExecute(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure HUDactionAddBitmapImageStoryItemExecute(Sender: TObject);
procedure HUDactionAddTextStoryItemExecute(Sender: TObject);
procedure HUDactionDeleteExecute(Sender: TObject);
procedure HUDactionCopyExecute(Sender: TObject);
procedure HUDactionPasteExecute(Sender: TObject);
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;
Expand Down Expand Up @@ -84,8 +87,8 @@ TMainForm = class(TForm, IStory)
procedure SetStoryMode(const Value: TStoryMode);

{StructureView}
function GetStructureView: TStructureView;
procedure StructureViewSelection(Sender: TObject; const Selection: TObject);
property StructureView: TStructureView read GetStructureView stored false;
procedure UpdateStructureView;

procedure RootStoryItemViewResized(Sender: TObject);
Expand All @@ -95,7 +98,10 @@ TMainForm = class(TForm, IStory)
procedure HUDTargetsVisibleChanged(Sender: TObject; const Value: Boolean);
procedure HUDUseStoryTimerChanged(Sender: TObject; const Value: Boolean);

procedure AddChildStoryItem(const TheStoryItemClass: TStoryItemClass; const TheName: String);

public
property StructureView: TStructureView read GetStructureView stored false;
procedure ZoomTo(const StoryItem: IStoryItem = nil); //ZoomTo(nil) zooms to all content

published
Expand All @@ -117,7 +123,8 @@ implementation
Zoomicon.Helpers.RTL.ClassListHelpers, //for TClassList.Create(TClassArray)
Zoomicon.Helpers.FMX.Controls.ControlHelpers, //for TControl.FlipHorizontally, TControl.FlipVertically
READCOM.Views.PanelStoryItem,
READCOM.Views.TextStoryItem; //TODO: remove
READCOM.Views.BitmapImageStoryItem,
READCOM.Views.TextStoryItem;

{$R *.fmx}

Expand Down Expand Up @@ -502,15 +509,25 @@ procedure TMainForm.HUDEditModeChanged(Sender: TObject; const Value: Boolean);
StoryMode := TStoryMode.InteractiveStoryMode; //TODO: should remember previous mode to restore or make EditMode a separate situation
end;

procedure TMainForm.HUDactionAddBitmapImageStoryItemExecute(Sender: TObject);
begin
//HUD.actionAddBitmapImageStoryItemExecute(Sender);
AddChildStoryItem(TBitmapImageStoryItem, 'BitmapImageStoryItem');
end;

procedure TMainForm.HUDactionAddTextStoryItemExecute(Sender: TObject);
begin
//HUD.actionAddTextStoryItemExecute(Sender);
AddChildStoryItem(TTextStoryItem, 'TextStoryItem');
end;

procedure TMainForm.AddChildStoryItem(const TheStoryItemClass: TStoryItemClass; const TheName: String);
begin
if not Assigned(ActiveStoryItem) then exit;

var OwnerAndParent := ActiveStoryItem.View;

var StoryItem := TTextStoryItem.Create(OwnerAndParent, 'TextStoryItem'); //TODO: should have separate actions for adding such default items (for prototyping) for various StoryItem classes
var StoryItem := TheStoryItemClass.Create(OwnerAndParent, TheName); //TODO: should have separate actions for adding such default items (for prototyping) for various StoryItem classes

with StoryItem do
begin
Expand Down
52 changes: 40 additions & 12 deletions App/Views/READCOM.Views.Menu.HUD.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,41 @@ object StoryHUD: TStoryHUD
Justify = Left
JustifyLastLine = Left
FlowDirection = LeftToRight
object btnAddBitmapImageStoryItem: TSpeedButton
Action = actionAddBitmapImageStoryItem
Anchors = [akTop, akRight]
Enabled = True
Hint =
'Add Bitmap Image'#13#13'Adds a BitmapImageStoryItem placeholder into t' +
'he edited StoryItem'
Images = Globals.SVGIconImageList
ImageIndex = 23
Margins.Left = 3.000000000000000000
Margins.Top = 3.000000000000000000
Margins.Right = 3.000000000000000000
Margins.Bottom = 6.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 3.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'actiontoolbutton'
end
object btnAddTextStoryItem: TSpeedButton
Action = actionAddTextStoryItem
Anchors = [akTop, akRight]
Enabled = True
Hint = 'Add Text'#13#13'Adds a TextStoryItem child into the edited StoryItem'
Hint =
'Add Text'#13#13'Adds a TextStoryItem placeholder into the edited Story' +
'Item'
Images = Globals.SVGIconImageList
ImageIndex = 21
Margins.Left = 3.000000000000000000
Margins.Top = 3.000000000000000000
Margins.Right = 3.000000000000000000
Margins.Bottom = 6.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 3.000000000000000000
Position.Y = 45.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
Expand All @@ -289,15 +311,15 @@ object StoryHUD: TStoryHUD
Action = actionDelete
Anchors = [akTop, akRight]
Enabled = True
Hint = 'Delete'#13#13'Removes the edited StoryItem'
Hint = 'Delete'#13#13'Delete the edited StoryItem'
Images = Globals.SVGIconImageList
ImageIndex = 8
Margins.Left = 3.000000000000000000
Margins.Top = 3.000000000000000000
Margins.Right = 3.000000000000000000
Margins.Bottom = 3.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 45.000000000000000000
Position.Y = 87.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
Expand All @@ -307,15 +329,15 @@ object StoryHUD: TStoryHUD
Action = actionCopy
Anchors = [akTop, akRight]
Enabled = True
Hint = 'Copy'#13#13'Copies the edited StoryItem to the system clipboard'
Hint = 'Copy'#13#13'Copy the edited StoryItem to the Clipboard'
Images = Globals.SVGIconImageList
ImageIndex = 17
Margins.Left = 3.000000000000000000
Margins.Top = 3.000000000000000000
Margins.Right = 3.000000000000000000
Margins.Bottom = 3.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 84.000000000000000000
Position.Y = 126.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
Expand All @@ -326,16 +348,16 @@ object StoryHUD: TStoryHUD
Anchors = [akTop, akRight]
Enabled = True
Hint =
'Paste'#13#13'Pastes a StoryItem from the system clipboard into the edi' +
'ted StoryItem as a new child'
'Paste'#13#13'Paste content from the Clipboard into the edited StoryIte' +
'm'
Images = Globals.SVGIconImageList
ImageIndex = 18
Margins.Left = 3.000000000000000000
Margins.Top = 3.000000000000000000
Margins.Right = 3.000000000000000000
Margins.Bottom = 6.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 123.000000000000000000
Position.Y = 165.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
Expand All @@ -351,23 +373,23 @@ object StoryHUD: TStoryHUD
Margins.Right = 3.000000000000000000
Margins.Bottom = 3.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 165.000000000000000000
Position.Y = 207.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
StyleLookup = 'actiontoolbutton'
end
object btnFlipVertically: TSpeedButton
Anchors = [akTop, akRight]
Hint = 'Flip Vertically'#13#13'Mirrors the edited StoryItem vertically'
Hint = 'Flip Vertically'#13#13'Flips the edited StoryItem vertically'
Images = Globals.SVGIconImageList
ImageIndex = 20
Margins.Left = 3.000000000000000000
Margins.Top = 3.000000000000000000
Margins.Right = 3.000000000000000000
Margins.Bottom = 3.000000000000000000
Position.X = 3.000000000000000000
Position.Y = 204.000000000000000000
Position.Y = 246.000000000000000000
Size.Width = 41.000000000000000000
Size.Height = 33.000000000000000000
Size.PlatformDefault = False
Expand Down Expand Up @@ -487,6 +509,12 @@ object StoryHUD: TStoryHUD
OnExecute = actionHelpExecute
ImageIndex = 16
end
object actionAddBitmapImageStoryItem: TAction
Category = 'Edit'
Text = 'Add BitmapImageStoryItem'
ImageIndex = 23
ImageIndex = 23
end
end
object MultiViewFrameStand: TFrameStand
AnimationShow = 'OnShow*'
Expand Down
Loading

0 comments on commit 51ac497

Please sign in to comment.