Skip to content

Commit 5e123ed

Browse files
committed
* GraphicsTextModel now is record
* Sciter.GraphicsGetColor alpha parameter now is optional
1 parent c64099a commit 5e123ed

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

EmptyFlow.SciterAPI/Client/HostGraphicsAPI.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ public void GraphicsDrawImage ( nint hgfx, nint image, Vector2 position, Vector2
293293
/// <param name="r">Red.</param>
294294
/// <param name="g">Green.</param>
295295
/// <param name="b">Blue.</param>
296-
/// <param name="a">Alpha.</param>
297-
public uint GraphicsGetColor ( uint r, uint g, uint b, uint a ) {
296+
/// <param name="a">Alpha, be default is 255.</param>
297+
public uint GraphicsGetColor ( uint r, uint g, uint b, uint a = 255 ) {
298298
if ( CheckGraphics () ) return m_graphicsApi.RGBA ( r, g, b, a );
299299

300300
return 0;

EmptyFlow.SciterAPI/Client/Models/GraphicsTextModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace EmptyFlow.SciterAPI.Client.Models {
22

3-
public class GraphicsTextModel {
3+
public record GraphicsTextModel {
44

55
public nint Id { get; set; }
66

EmptyFlow.SciterAPI/EmptyFlow.SciterAPI.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
<Version>1.2.0.0</Version>
2222
<PackageLicenseFile>LICENSE</PackageLicenseFile>
2323
<PackageReleaseNotes>
24-
SciterAPIHost.CreateMainWindow parameters width and height now is not mandatory, if you not specify window it will be centered and half from screen size
24+
SciterAPIHost.CreateMainWindow parameters width and height now is not mandatory, if you not specify it window it will be centered and sized to half from screen size
2525
SciterAPIHost.GraphicsDrawImage added override with Vector2 parameters
2626
SciterAPIHost.GraphicsCreateTextForElement new method for creating text related to element
2727
SciterAPIHost.GraphicsCreateTextForElementWithStyle new method for creating text related to element
2828
SciterAPIHost.GraphicsDrawText full refactored
29+
Added new record GraphicsDrawText for respresent font state
2930
</PackageReleaseNotes>
3031
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
3132
</PropertyGroup>

EmptyFlow.SciterAPI/Structs/SciterSize.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace EmptyFlow.SciterAPI {
44
[StructLayout ( LayoutKind.Sequential )]
5-
public struct SciterSize {
5+
public struct SciterSize { // Original name tagSIZE, SIZE, *PSIZE, *LPSIZE
66
public int cx;
77
public int cy;
88

src/Program.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
var host = new SciterAPIHost ( Path.Combine ( pathToSciter, "bin/windows/x64" ), true, true );
1111
var path = "file://" + Path.Combine ( pathToSciter, "samples/html/details-summary.htm" );
1212
host.Callbacks.AddAttachBehaviourFactory ( "testbehaviour", ( element ) => new TestGraphicsEventHandler ( element, host ) );
13-
host.CreateMainWindow ( 0, 0, enableDebug: true, enableFeature: true );
13+
host.CreateMainWindow ( 300, 300, enableDebug: true, enableFeature: true );
1414
host.AddWindowEventHandler ( new MyWindowEventHandler ( host.MainWindow, host ) );
1515
host.LoadFile ( path );
1616
host.Process ();
@@ -39,20 +39,27 @@ public class TestGraphicsEventHandler : ElementEventHandler {
3939
public TestGraphicsEventHandler ( nint element, SciterAPIHost host ) : base ( element, host ) {
4040
Text = Host.GraphicsCreateTextForElement ( element, "test text!!!111", "test-class" );
4141
Text2 = Host.GraphicsCreateTextForElementWithStyle ( element, "test text!!!111", "font-size: 18px;color: green;" );
42+
Color1 = Host.GraphicsGetColor ( 0, 204, 0 );
43+
Color2 = Host.GraphicsGetColor ( 0, 0, 255 );
4244
}
4345

46+
public uint Color1 { get; set; }
47+
48+
public uint Color2 { get; set; }
49+
4450
public GraphicsTextModel Text { get; set; }
4551

4652
public GraphicsTextModel Text2 { get; set; }
4753

4854
public override void DrawEvent ( DrawEvents command, nint gfx, SciterRectangle area, uint reserved ) {
49-
var color = Host.Graphics.RGBA ( 0, 204, 0, 255 );
50-
var blue = Host.Graphics.RGBA ( 0, 0, 255, 255 );
55+
var (position, size) = Host.GetMainWindowPositionAndSize ();
56+
Console.WriteLine ( $"Position: {position.X} - {position.Y}" );
57+
5158
if ( command == DrawEvents.DRAW_CONTENT ) {
5259
Host.GraphicsSaveState ( gfx );
53-
Host.GraphicsFillColor ( gfx, color );
60+
Host.GraphicsFillColor ( gfx, Color1 );
5461
Host.GraphicsDrawRectangle ( gfx, area.Left, area.Top, area.Left + area.Width, area.Top + area.Height );
55-
Host.GraphicsDrawLine ( gfx, area.LeftTopCorner, area.RightBottomCorner, blue, 10 );
62+
Host.GraphicsDrawLine ( gfx, area.LeftTopCorner, area.RightBottomCorner, Color2, 10 );
5663
Host.GraphicsDrawText ( gfx, Text, new Vector2 ( area.Left, area.Top ), SciterTextPosition.TopLeft );
5764
Host.GraphicsDrawText ( gfx, Text2, new Vector2 ( area.Left, area.Top + 30 ), SciterTextPosition.TopLeft );
5865
Host.GraphicsRestoreState ( gfx );

0 commit comments

Comments
 (0)