| 1 |
{%MainUnit castlecontrols.pas} |
| 2 |
{ |
| 3 |
Copyright 2010-2018 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 |
{$ifdef read_interface} |
| 18 |
|
| 19 |
{ Fill the whole window with a simple color. |
| 20 |
This is very fast, but it unconditionally clears the whole window, |
| 21 |
and there is no blending (if your @link(Color) has some alpha, it is |
| 22 |
just copied to the color buffer). |
| 23 |
|
| 24 |
To clear the rectangle with a color, |
| 25 |
with optional blending, use @link(TCastleRectangleControl) instead. } |
| 26 |
TCastleSimpleBackground = class(TCastleUserInterface) |
| 27 |
strict private |
| 28 |
FColor: TCastleColor; |
| 29 |
procedure SetColor(const Value: TCastleColor); |
| 30 |
public |
| 31 |
constructor Create(AOwner: TComponent); override; |
| 32 |
procedure Render; override; |
| 33 |
property Width {$ifdef FPC}default 0{$endif}; |
| 34 |
property Height {$ifdef FPC}default 0{$endif}; |
| 35 |
{ Background color. By default, this is black color with opaque alpha. } |
| 36 |
property Color: TCastleColor read FColor write SetColor; |
| 37 |
end deprecated 'use TCastleRectangleControl with FullSize=true; note that by default it has White color, while TCastleSimpleBackground has by default Black color.'; |
| 38 |
|
| 39 |
{$endif read_interface} |
| 40 |
|
| 41 |
{$ifdef read_implementation} |
| 42 |
|
| 43 |
{ TCastleSimpleBackground ---------------------------------------------------- } |
| 44 |
|
| 45 |
constructor TCastleSimpleBackground.Create(AOwner: TComponent); |
| 46 |
begin |
| 47 |
inherited; |
| 48 |
FColor := Black; |
| 49 |
// This should have size = 0, to have empty rectangle, to never catch events |
| 50 |
Width := 0; |
| 51 |
Height := 0; |
| 52 |
end; |
| 53 |
|
| 54 |
procedure TCastleSimpleBackground.SetColor(const Value: TCastleColor); |
| 55 |
begin |
| 56 |
if not TCastleColor.PerfectlyEquals(FColor, Value) then |
| 57 |
begin |
| 58 |
FColor := Value; |
| 59 |
VisibleChange([chRender]); |
| 60 |
end; |
| 61 |
end; |
| 62 |
|
| 63 |
procedure TCastleSimpleBackground.Render; |
| 64 |
begin |
| 65 |
inherited; |
| 66 |
RenderContext.Clear([cbColor], Color); |
| 67 |
end; |
| 68 |
|
| 69 |
{$endif read_implementation} |