And to expand a little bit:
How can I create a new ux component that can be used as a tag. E.g.: and get that to preview in Fuse?
The simplest way of getting started and get something on screen (without diving into the layout framework) is probably to make an absolute sized component where you explicitly set Width and Height in the .ux. You can then focus on drawing something within that element.
All you need for this is to extend Element and implement its OnDraw() method, where you can do either low-level rendering or use higher level primitives.
Here’s a small example that draws a quad inside it’s allocated area on screen and interacts a bit with the UI system:
using Uno;
using Fuse;
using Fuse.Elements;
using Uno.Graphics;
public class Example : Element
{
public float Blue{get;set;} // a property to play with
override protected void OnDraw(Fuse.DrawContext dc)
{
draw
{
float2[] Vertices: new []
{
float2(0, 0), float2(0, 1), float2(1, 1),
float2(0, 0), float2(1, 1), float2(1, 0)
};
float2 Coord: vertex_attrib(Vertices);
ClipPosition: Vector.Transform(float4(Coord*ActualSize,0,1), dc.GetLocalToClipTransform(this));
PixelColor: float4(Coord,Math.Clamp(Blue,0,1),1);
};
}
}
and some UX to test it:
<App Theme="Basic" ClearColor="#eeeeeeff">
<Panel>
<ScrollViewer ClipToBounds="true">
<StackPanel>
<Text>A bit of text to see we are laid out correctly.</Text>
<Text Alignment="Right">(And you can scroll up/down if you want to)</Text>
<Example ux:Name="exElement" Width="100" Height="40" Margin="10" Blue="0.5"/>
<Button Text="Transforms work as well">
<Pressing>
<Rotate Target="exElement" Degrees="30" Duration="0.5" />
<Scale Target="exElement" Factor="0.6" Duration="0.5"/>
</Pressing>
</Button>
</StackPanel>
</ScrollViewer>
</Panel>
</App>
Of course, going down to triangle rendering is too low-level for most use cases which is why we’re building higher level components that can be customized, so this is mainly intended to be a minimal example.
Edit: Small change in the uno code to comply with recent changes in the framework. Now works with the latest version of Fuse