| 1 |
{%MainUnit castleviewport.pas} |
| 2 |
{ |
| 3 |
Copyright 2018-2021 Michalis Kamburelis. |
| 4 |
|
| 5 |
This file is part of "Castle Game Engine". |
| 6 |
|
| 7 |
"Castle Game Engine" is free software; see the file COPYING.txt, |
| 8 |
included in this distribution, for details about the copyright. |
| 9 |
|
| 10 |
"Castle Game Engine" is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 13 |
|
| 14 |
---------------------------------------------------------------------------- |
| 15 |
} |
| 16 |
|
| 17 |
{ Integration of TCastleTransform / TCastleUserInterface with CastleComponentSerialize. } |
| 18 |
|
| 19 |
{$ifdef read_interface} |
| 20 |
|
| 21 |
type |
| 22 |
{ Helper methods extending TCastleComponentFactory. |
| 23 |
|
| 24 |
Implementation note: Ideally these should be split in CastleUIControls |
| 25 |
and CastleTransform units. But we cannot, as these units should not |
| 26 |
depend on each other, and only last defined helper works. |
| 27 |
|
| 28 |
TODO: FPC trunk has a solution to this ($modeswitch multiscopehelpers) |
| 29 |
https://wiki.lazarus.freepascal.org/Helper_types . |
| 30 |
Since we require FPC >= 3.2.0, maybe we can us it? |
| 31 |
If FPC >= 3.2.0 and our supported Delphi versions support this? } |
| 32 |
TCastleComponentFactoryHelper = class helper for TCastleComponentFactory |
| 33 |
{ Instantiate component. |
| 34 |
Using this is equivalent to using global @link(CastleUIControls.UserInterfaceLoad), |
| 35 |
but this is much faster if you want to instantiate the same file many times. } |
| 36 |
function UserInterfaceLoad(const Owner: TComponent): TCastleUserInterface; |
| 37 |
|
| 38 |
{ Instantiate component. |
| 39 |
Using this is equivalent to using global @link(CastleTransform.TransformLoad), |
| 40 |
but this is much faster if you want to instantiate the same file many times. } |
| 41 |
function TransformLoad(const Owner: TComponent): TCastleTransform; |
| 42 |
end; |
| 43 |
|
| 44 |
{$endif read_interface} |
| 45 |
|
| 46 |
{$ifdef read_implementation} |
| 47 |
|
| 48 |
function TCastleComponentFactoryHelper.UserInterfaceLoad(const Owner: TComponent): TCastleUserInterface; |
| 49 |
begin |
| 50 |
Result := ComponentLoad(Owner) as TCastleUserInterface; |
| 51 |
end; |
| 52 |
|
| 53 |
function TCastleComponentFactoryHelper.TransformLoad(const Owner: TComponent): TCastleTransform; |
| 54 |
begin |
| 55 |
Result := ComponentLoad(Owner) as TCastleTransform; |
| 56 |
end; |
| 57 |
|
| 58 |
{$endif read_implementation} |