mirror of
https://github.com/lc-soft/LCUI.git
synced 2026-12-01 16:56:34 +01:00
feat(widgets): add spinner and shimmer widgets
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
# Shimmer
|
||||
|
||||
Overlays a soft-edged, tiltable highlight band on text, icons, or other content and sweeps it from left to right; the highlight only lands on the content's opaque pixels while the content keeps its own colors.
|
||||
|
||||
<WidgetExample name="shimmer-basic" />
|
||||
|
||||
## Use cases
|
||||
|
||||
- **Suitable**: letting a status line (an icon or plain text) sweep with a soft highlight to signal "in progress / loading"
|
||||
- **Suitable**: adding a sliding highlight to a "generating" hint while text streams in
|
||||
- **Not suitable**: a plain gray skeleton placeholder (Shimmer overlays real content and does not generate a skeleton)
|
||||
- **Not suitable**: progress with a definite percentage or a known duration (use `progress`)
|
||||
- **Not suitable**: a global busy indicator without a fixed shape (use `spinner`)
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx
|
||||
import { Shimmer, ShimmerContent } from "@lcui/react"
|
||||
```
|
||||
|
||||
Shimmer is a self-drawn widget implemented in C: it first composites the content at full strength in its own colors, then overlays a tilted highlight band clipped to the content's opaque pixels. The highlight itself can be configured with a color, period, width, and tilt, either through widget properties or the matching `ui_shimmer_set_*` APIs:
|
||||
|
||||
```tsx
|
||||
<Shimmer running={true} duration={2000} spread={120} angle={20} color="rgba(255,255,255,0.86)">
|
||||
<ShimmerContent>
|
||||
<Text>Generating response…</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
```
|
||||
|
||||
## Composition
|
||||
|
||||
Use the following composition to build a `Shimmer`:
|
||||
|
||||
```
|
||||
Shimmer
|
||||
└── ShimmerContent
|
||||
```
|
||||
|
||||
## Color
|
||||
|
||||
The highlight band takes its color from `color`, and its alpha is the peak strength where it sweeps. Overlaying different colors on the same gray text tints the sweep toward each hue as it passes.
|
||||
|
||||
<WidgetExample name="shimmer-color" />
|
||||
|
||||
## Duration
|
||||
|
||||
`duration` sets how long one sweep takes, in milliseconds; it defaults to `2000`. A smaller value sweeps faster.
|
||||
|
||||
<WidgetExample name="shimmer-duration" />
|
||||
|
||||
## Width
|
||||
|
||||
`spread` sets the width of the highlight band in logical pixels. A narrow band reads as a sharp glint, while a wide one washes over the whole row at once, with the same peak strength and only a different span.
|
||||
|
||||
<WidgetExample name="shimmer-spread" />
|
||||
|
||||
## Angle
|
||||
|
||||
`angle` tilts the band relative to vertical, in degrees. At 0° every row is swept at the same column; when tilted, the glint shears along the height, grazing the top before the lower part.
|
||||
|
||||
<WidgetExample name="shimmer-angle" />
|
||||
|
||||
## Disabling
|
||||
|
||||
Set `running` to `false` to stop the animation: no highlight is added and the content shows in its own colors.
|
||||
|
||||
<WidgetExample name="shimmer-running" />
|
||||
|
||||
## API Reference
|
||||
|
||||
### Shimmer
|
||||
|
||||
The shimmer container; it captures the `ShimmerContent` subtree, composites it at full strength in its own colors, then overlays a tiltable highlight band that fades out on both sides, clipped to the content's opaque pixels. The highlight sweeps from left to right and only shows on the content.
|
||||
|
||||
<FieldTable name="shimmer" />
|
||||
|
||||
### ShimmerContent
|
||||
|
||||
The captured content subtree (such as a status row of text, or an icon plus text), used as a direct child of Shimmer. When omitted, a default placeholder block filling the whole row is used. Shimmer is block-level with a height of 20px by default, which can be overridden with `width`/`height`.
|
||||
|
||||
<FieldTable name="shimmer-content" />
|
||||
@@ -0,0 +1,58 @@
|
||||
# Spinner
|
||||
|
||||
A self-drawn spinning indicator used to express a "loading" state.
|
||||
|
||||
<WidgetExample name="spinner-basic" />
|
||||
|
||||
## Use cases
|
||||
|
||||
- **Suitable**: a loading state that waits for an async result whose progress cannot be predicted
|
||||
- **Suitable**: a busy indicator for a local area such as a button or a card
|
||||
- **Not suitable**: progress with a definite percentage or a known duration (use `progress`)
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx
|
||||
import { Spinner, SpinnerContent } from "@lcui/react"
|
||||
```
|
||||
|
||||
```tsx
|
||||
<Spinner running={true} speed={1} />
|
||||
```
|
||||
|
||||
## Composition
|
||||
|
||||
Use the following composition to build a `Spinner`:
|
||||
|
||||
```
|
||||
Spinner
|
||||
└── SpinnerContent
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Custom Content
|
||||
|
||||
<WidgetExample name="spinner-custom-content" />
|
||||
|
||||
### Sizes
|
||||
|
||||
<WidgetExample name="spinner-size" />
|
||||
|
||||
### Running State
|
||||
|
||||
<WidgetExample name="spinner-running" />
|
||||
|
||||
## API Reference
|
||||
|
||||
### Spinner
|
||||
|
||||
The spinner container; it captures the `SpinnerContent` subtree and draws it rotated about its center. It is 16×16 by default and can be overridden with `width`/`height`.
|
||||
|
||||
<FieldTable name="spinner" />
|
||||
|
||||
### SpinnerContent
|
||||
|
||||
The content subtree captured for rotation, used as a direct child of Spinner. When omitted, a default ring is used, with one side left transparent to form a gap that sweeps around as it rotates.
|
||||
|
||||
<FieldTable name="spinner-content" />
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Shimmer, ShimmerContent, Text, Widget } from "@lcui/react";
|
||||
|
||||
export default function ShimmerAngleDemo() {
|
||||
return (
|
||||
<Widget className="flex flex-col gap-2">
|
||||
<Shimmer className="w-[220px] h-9" running angle={0}>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Flat band</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
<Shimmer className="w-[220px] h-9" running angle={45}>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Tilted band</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_shimmer_angle_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.shimmer-angle-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.shimmer-angle-demo shimmer {
|
||||
width: 220px;
|
||||
height: 36px;
|
||||
}
|
||||
.shimmer-angle-demo shimmer-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
font-size: 15px;
|
||||
color: #46545f;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="shimmer-angle-demo">
|
||||
<shimmer running="true" angle="0">
|
||||
<shimmer-content>
|
||||
<text>Flat band</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
<shimmer running="true" angle="45">
|
||||
<shimmer-content>
|
||||
<text>Tilted band</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* The angle tilts the highlight band. A flat band (0 degrees) crosses each row
|
||||
* at the same column; a 45 degree band shears across the caption so the glint
|
||||
* reaches the top before the bottom. */
|
||||
static const char *shimmer_angle_css = "\
|
||||
.shimmer-angle-demo {\
|
||||
display: flex;\
|
||||
flex-direction: column;\
|
||||
gap: 8px;\
|
||||
}\
|
||||
.shimmer-angle-demo shimmer {\
|
||||
width: 220px;\
|
||||
height: 36px;\
|
||||
}\
|
||||
.shimmer-angle-demo shimmer-content {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
padding: 4px 8px;\
|
||||
font-size: 15px;\
|
||||
color: #46545f;\
|
||||
}\
|
||||
";
|
||||
|
||||
static ui_widget_t *caption(const char *label)
|
||||
{
|
||||
ui_widget_t *shimmer, *content, *text;
|
||||
|
||||
shimmer = ui_create_shimmer();
|
||||
content = ui_create_widget("shimmer-content");
|
||||
text = ui_create_widget("text");
|
||||
ui_text_set_content(text, label);
|
||||
ui_widget_append(content, text);
|
||||
ui_shimmer_set_content(shimmer, content);
|
||||
ui_shimmer_set_running(shimmer, true);
|
||||
return shimmer;
|
||||
}
|
||||
|
||||
void shimmer_angle_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box, *flat, *tilted;
|
||||
|
||||
ui_load_css_string(shimmer_angle_css, "shimmer-angle-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "shimmer-angle-demo");
|
||||
|
||||
flat = caption("Flat band");
|
||||
ui_shimmer_set_angle(flat, 0.0f);
|
||||
|
||||
tilted = caption("Tilted band");
|
||||
ui_shimmer_set_angle(tilted, 45.0f);
|
||||
|
||||
ui_widget_append(box, flat);
|
||||
ui_widget_append(box, tilted);
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Shimmer, ShimmerContent, Text } from "@lcui/react";
|
||||
|
||||
export default function ShimmerDemo() {
|
||||
return (
|
||||
<Shimmer className="w-[220px] h-7">
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Generating response…</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_shimmer_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.shimmer-basic-demo shimmer {
|
||||
width: 220px;
|
||||
height: 28px;
|
||||
}
|
||||
.shimmer-basic-demo shimmer-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
font-size: 15px;
|
||||
color: #46545f;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="shimmer-basic-demo">
|
||||
<shimmer>
|
||||
<shimmer-content>
|
||||
<text>Generating response…</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,37 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* The shimmer sweeps a soft sheen across real text, so the caption stays
|
||||
* readable while it reads as "in progress". Scoped under a unique class; an
|
||||
* inline background-color would be overridden by the theme `*` rule. */
|
||||
static const char *shimmer_basic_css = "\
|
||||
.shimmer-basic-demo shimmer {\
|
||||
width: 220px;\
|
||||
height: 28px;\
|
||||
}\
|
||||
.shimmer-basic-demo shimmer-content {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
padding: 4px 8px;\
|
||||
font-size: 15px;\
|
||||
color: #46545f;\
|
||||
}\
|
||||
";
|
||||
|
||||
void shimmer_basic_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box, *shimmer, *content, *text;
|
||||
|
||||
ui_load_css_string(shimmer_basic_css, "shimmer-basic-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "shimmer-basic-demo");
|
||||
|
||||
shimmer = ui_create_shimmer();
|
||||
content = ui_create_widget("shimmer-content");
|
||||
text = ui_create_widget("text");
|
||||
ui_text_set_content(text, "Generating response...");
|
||||
ui_widget_append(content, text);
|
||||
ui_shimmer_set_content(shimmer, content);
|
||||
|
||||
ui_widget_append(box, shimmer);
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Shimmer, ShimmerContent, Text, Widget } from "@lcui/react";
|
||||
|
||||
export default function ShimmerColorDemo() {
|
||||
return (
|
||||
<Widget className="flex flex-col gap-2">
|
||||
<Shimmer className="w-[220px] h-7" color="#378ADD">
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Generating response…</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
<Shimmer className="w-[220px] h-7" color="rgb(34, 197, 94)">
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Sending request…</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_shimmer_color_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.shimmer-color-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.shimmer-color-demo shimmer {
|
||||
width: 220px;
|
||||
height: 28px;
|
||||
}
|
||||
.shimmer-color-demo shimmer-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
font-size: 15px;
|
||||
color: #46545f;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="shimmer-color-demo">
|
||||
<shimmer color="#378ADD">
|
||||
<shimmer-content>
|
||||
<text>Generating response…</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
<shimmer color="rgb(34 197 94)">
|
||||
<shimmer-content>
|
||||
<text>Sending request…</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,55 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* Two captions, each with a different highlight colour. The `color` sheen is
|
||||
* overlaid only on the text's opaque pixels, so a blue and a green highlight
|
||||
* tint the same grey ink toward their own hue as they sweep. */
|
||||
static const char *shimmer_color_css = "\
|
||||
.shimmer-color-demo {\
|
||||
display: flex;\
|
||||
flex-direction: column;\
|
||||
gap: 8px;\
|
||||
}\
|
||||
.shimmer-color-demo shimmer {\
|
||||
width: 220px;\
|
||||
height: 28px;\
|
||||
}\
|
||||
.shimmer-color-demo shimmer-content {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
padding: 4px 8px;\
|
||||
font-size: 15px;\
|
||||
color: #46545f;\
|
||||
}\
|
||||
";
|
||||
|
||||
static ui_widget_t *caption(const char *label)
|
||||
{
|
||||
ui_widget_t *shimmer, *content, *text;
|
||||
|
||||
shimmer = ui_create_shimmer();
|
||||
content = ui_create_widget("shimmer-content");
|
||||
text = ui_create_widget("text");
|
||||
ui_text_set_content(text, label);
|
||||
ui_widget_append(content, text);
|
||||
ui_shimmer_set_content(shimmer, content);
|
||||
return shimmer;
|
||||
}
|
||||
|
||||
void shimmer_color_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box, *blue, *green;
|
||||
|
||||
ui_load_css_string(shimmer_color_css, "shimmer-color-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "shimmer-color-demo");
|
||||
|
||||
blue = caption("Generating response...");
|
||||
ui_shimmer_set_color(blue, pd_argb(200, 55, 138, 221));
|
||||
|
||||
green = caption("Sending request...");
|
||||
ui_shimmer_set_color(green, pd_argb(200, 34, 197, 94));
|
||||
|
||||
ui_widget_append(box, blue);
|
||||
ui_widget_append(box, green);
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Shimmer, ShimmerContent, Text, Widget } from "@lcui/react";
|
||||
|
||||
export default function ShimmerDurationDemo() {
|
||||
return (
|
||||
<Widget className="flex flex-col gap-2">
|
||||
<Shimmer className="w-[220px] h-7" running>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Default duration</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
<Shimmer className="w-[220px] h-7" running duration={1000}>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Faster duration</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_shimmer_duration_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.shimmer-duration-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.shimmer-duration-demo shimmer {
|
||||
width: 220px;
|
||||
height: 28px;
|
||||
}
|
||||
.shimmer-duration-demo shimmer-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
font-size: 15px;
|
||||
color: #46545f;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="shimmer-duration-demo">
|
||||
<shimmer running="true">
|
||||
<shimmer-content>
|
||||
<text>Default duration</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
<shimmer running="true" duration="1000">
|
||||
<shimmer-content>
|
||||
<text>Faster duration</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,54 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* Two identical sweeps at different durations: the default 2000 ms and a
|
||||
* snappier 1000 ms. Duration is only observable while the shimmer is running,
|
||||
* so both lines keep the animation on. */
|
||||
static const char *shimmer_duration_css = "\
|
||||
.shimmer-duration-demo {\
|
||||
display: flex;\
|
||||
flex-direction: column;\
|
||||
gap: 8px;\
|
||||
}\
|
||||
.shimmer-duration-demo shimmer {\
|
||||
width: 220px;\
|
||||
height: 28px;\
|
||||
}\
|
||||
.shimmer-duration-demo shimmer-content {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
padding: 4px 8px;\
|
||||
font-size: 15px;\
|
||||
color: #46545f;\
|
||||
}\
|
||||
";
|
||||
|
||||
static ui_widget_t *caption(const char *label)
|
||||
{
|
||||
ui_widget_t *shimmer, *content, *text;
|
||||
|
||||
shimmer = ui_create_shimmer();
|
||||
content = ui_create_widget("shimmer-content");
|
||||
text = ui_create_widget("text");
|
||||
ui_text_set_content(text, label);
|
||||
ui_widget_append(content, text);
|
||||
ui_shimmer_set_content(shimmer, content);
|
||||
ui_shimmer_set_running(shimmer, true);
|
||||
return shimmer;
|
||||
}
|
||||
|
||||
void shimmer_duration_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box, *normal, *fast;
|
||||
|
||||
ui_load_css_string(shimmer_duration_css, "shimmer-duration-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "shimmer-duration-demo");
|
||||
|
||||
normal = caption("Default duration");
|
||||
fast = caption("Faster duration");
|
||||
ui_shimmer_set_duration(fast, 1000);
|
||||
|
||||
ui_widget_append(box, normal);
|
||||
ui_widget_append(box, fast);
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Shimmer, ShimmerContent, Text, Widget } from "@lcui/react";
|
||||
|
||||
export default function ShimmerRunningDemo() {
|
||||
return (
|
||||
<Widget className="flex flex-col gap-2">
|
||||
<Shimmer className="w-[220px] h-7" running>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Searching the web…</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
<Shimmer className="w-[220px] h-7" running={false}>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Reading 4 files</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_shimmer_running_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.shimmer-running-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.shimmer-running-demo shimmer {
|
||||
width: 220px;
|
||||
height: 28px;
|
||||
}
|
||||
.shimmer-running-demo shimmer-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
font-size: 15px;
|
||||
color: #46545f;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="shimmer-running-demo">
|
||||
<shimmer running="true">
|
||||
<shimmer-content>
|
||||
<text>Searching the web…</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
<shimmer running="false">
|
||||
<shimmer-content>
|
||||
<text>Reading 4 files</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* The first caption keeps sweeping; the second has the animation turned off,
|
||||
* so its text is composited as-is with no sheen added. `running = false` is the
|
||||
* shimmer's off state: the content renders normally. */
|
||||
static const char *shimmer_running_css = "\
|
||||
.shimmer-running-demo {\
|
||||
display: flex;\
|
||||
flex-direction: column;\
|
||||
gap: 8px;\
|
||||
}\
|
||||
.shimmer-running-demo shimmer {\
|
||||
width: 220px;\
|
||||
height: 28px;\
|
||||
}\
|
||||
.shimmer-running-demo shimmer-content {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
padding: 4px 8px;\
|
||||
font-size: 15px;\
|
||||
color: #46545f;\
|
||||
}\
|
||||
";
|
||||
|
||||
static ui_widget_t *caption(const char *label)
|
||||
{
|
||||
ui_widget_t *shimmer, *content, *text;
|
||||
|
||||
shimmer = ui_create_shimmer();
|
||||
content = ui_create_widget("shimmer-content");
|
||||
text = ui_create_widget("text");
|
||||
ui_text_set_content(text, label);
|
||||
ui_widget_append(content, text);
|
||||
ui_shimmer_set_content(shimmer, content);
|
||||
return shimmer;
|
||||
}
|
||||
|
||||
void shimmer_running_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box, *running, *stopped;
|
||||
|
||||
ui_load_css_string(shimmer_running_css, "shimmer-running-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "shimmer-running-demo");
|
||||
|
||||
running = caption("Searching the web...");
|
||||
ui_shimmer_set_running(running, true);
|
||||
ui_shimmer_set_duration(running, 1000);
|
||||
|
||||
stopped = caption("Reading 4 files");
|
||||
ui_shimmer_set_running(stopped, false);
|
||||
|
||||
ui_widget_append(box, running);
|
||||
ui_widget_append(box, stopped);
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Shimmer, ShimmerContent, Text, Widget } from "@lcui/react";
|
||||
|
||||
export default function ShimmerSpreadDemo() {
|
||||
return (
|
||||
<Widget className="flex flex-col gap-2">
|
||||
<Shimmer className="w-[220px] h-7" running spread={40}>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Narrow spread</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
<Shimmer className="w-[220px] h-7" running spread={160}>
|
||||
<ShimmerContent className="flex items-center px-2 py-1 text-[#46545f]">
|
||||
<Text>Wide spread</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_shimmer_spread_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.shimmer-spread-demo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.shimmer-spread-demo shimmer {
|
||||
width: 220px;
|
||||
height: 28px;
|
||||
}
|
||||
.shimmer-spread-demo shimmer-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
font-size: 15px;
|
||||
color: #46545f;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="shimmer-spread-demo">
|
||||
<shimmer running="true" spread="40">
|
||||
<shimmer-content>
|
||||
<text>Narrow spread</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
<shimmer running="true" spread="160">
|
||||
<shimmer-content>
|
||||
<text>Wide spread</text>
|
||||
</shimmer-content>
|
||||
</shimmer>
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* The spread sets the highlight band's width in logical pixels. A narrow band
|
||||
* reads as a tight glint; a wide one washes across the whole caption at once.
|
||||
* The peak strength is unchanged, only how far it reaches. */
|
||||
static const char *shimmer_spread_css = "\
|
||||
.shimmer-spread-demo {\
|
||||
display: flex;\
|
||||
flex-direction: column;\
|
||||
gap: 8px;\
|
||||
}\
|
||||
.shimmer-spread-demo shimmer {\
|
||||
width: 220px;\
|
||||
height: 28px;\
|
||||
}\
|
||||
.shimmer-spread-demo shimmer-content {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
padding: 4px 8px;\
|
||||
font-size: 15px;\
|
||||
color: #46545f;\
|
||||
}\
|
||||
";
|
||||
|
||||
static ui_widget_t *caption(const char *label)
|
||||
{
|
||||
ui_widget_t *shimmer, *content, *text;
|
||||
|
||||
shimmer = ui_create_shimmer();
|
||||
content = ui_create_widget("shimmer-content");
|
||||
text = ui_create_widget("text");
|
||||
ui_text_set_content(text, label);
|
||||
ui_widget_append(content, text);
|
||||
ui_shimmer_set_content(shimmer, content);
|
||||
ui_shimmer_set_running(shimmer, true);
|
||||
return shimmer;
|
||||
}
|
||||
|
||||
void shimmer_spread_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box, *narrow, *wide;
|
||||
|
||||
ui_load_css_string(shimmer_spread_css, "shimmer-spread-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "shimmer-spread-demo");
|
||||
|
||||
narrow = caption("Narrow spread");
|
||||
ui_shimmer_set_spread(narrow, 40.0f);
|
||||
|
||||
wide = caption("Wide spread");
|
||||
ui_shimmer_set_spread(wide, 160.0f);
|
||||
|
||||
ui_widget_append(box, narrow);
|
||||
ui_widget_append(box, wide);
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Spinner } from "@lcui/react";
|
||||
|
||||
export default function SpinnerDemo() {
|
||||
return <Spinner className="w-10 h-10" />;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_spinner_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.spinner-basic-box spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<w class="spinner-basic-box">
|
||||
<spinner />
|
||||
</w>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,10 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
void spinner_basic_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *spinner;
|
||||
|
||||
spinner = ui_create_spinner();
|
||||
ui_widget_resize(spinner, 40, 40);
|
||||
ui_widget_append(parent, spinner);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Spinner, SpinnerContent, Text } from "@lcui/react";
|
||||
|
||||
export default function SpinnerCustomContentDemo() {
|
||||
return (
|
||||
<div className="flex flex-row items-center gap-7">
|
||||
<Spinner className="w-10 h-10">
|
||||
<SpinnerContent className="relative flex items-center justify-center">
|
||||
<div className="absolute left-[15px] top-[3px] w-[10px] h-[10px] rounded-full bg-blue-500" />
|
||||
<div className="absolute left-[18px] top-[6px] w-1 h-5 rounded bg-red-500" />
|
||||
</SpinnerContent>
|
||||
</Spinner>
|
||||
<Spinner className="w-[96px] h-8">
|
||||
<SpinnerContent className="flex items-center justify-center">
|
||||
<Text className="whitespace-nowrap text-lg text-[#e5484d]">
|
||||
Hello
|
||||
</Text>
|
||||
</SpinnerContent>
|
||||
</Spinner>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_spinner_custom_content_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.spinner-custom-content-demo {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 28px;
|
||||
}
|
||||
.spinner-custom-content-demo .shape {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
.spinner-custom-content-demo .word {
|
||||
width: 96px;
|
||||
height: 32px;
|
||||
}
|
||||
.spinner-custom-content-demo spinner-content {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.spinner-custom-content-demo .c-dot {
|
||||
position: absolute;
|
||||
left: 15px;
|
||||
top: 3px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background-color: #4a90d9;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.spinner-custom-content-demo .c-bar {
|
||||
position: absolute;
|
||||
left: 18px;
|
||||
top: 6px;
|
||||
width: 4px;
|
||||
height: 20px;
|
||||
background-color: #d9534f;
|
||||
border-radius: 2px;
|
||||
}
|
||||
.spinner-custom-content-demo .c-text {
|
||||
white-space: nowrap;
|
||||
font-size: 18px;
|
||||
color: #e5484d;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="spinner-custom-content-demo">
|
||||
<spinner class="shape">
|
||||
<spinner-content>
|
||||
<w class="c-dot" />
|
||||
<w class="c-bar" />
|
||||
</spinner-content>
|
||||
</spinner>
|
||||
<spinner class="word">
|
||||
<spinner-content>
|
||||
<text class="c-text">Hello</text>
|
||||
</spinner-content>
|
||||
</spinner>
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,85 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
static const char *spinner_custom_content_css = "\
|
||||
.spinner-custom-content-demo {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
gap: 28px;\
|
||||
}\
|
||||
.spinner-custom-content-demo spinner-content {\
|
||||
display: flex;\
|
||||
align-items: center;\
|
||||
justify-content: center;\
|
||||
}\
|
||||
.spinner-custom-content-demo spinner-content .c-dot {\
|
||||
position: absolute;\
|
||||
left: 15px;\
|
||||
top: 3px;\
|
||||
width: 10px;\
|
||||
height: 10px;\
|
||||
background-color: #4a90d9;\
|
||||
border-radius: 8px;\
|
||||
}\
|
||||
.spinner-custom-content-demo spinner-content .c-bar {\
|
||||
position: absolute;\
|
||||
left: 18px;\
|
||||
top: 6px;\
|
||||
width: 4px;\
|
||||
height: 20px;\
|
||||
background-color: #d9534f;\
|
||||
border-radius: 2px;\
|
||||
}\
|
||||
.spinner-custom-content-demo spinner-content .c-text {\
|
||||
white-space: nowrap;\
|
||||
font-size: 18px;\
|
||||
color: #e5484d;\
|
||||
}\
|
||||
";
|
||||
|
||||
static ui_widget_t *create_shape_content(void)
|
||||
{
|
||||
ui_widget_t *content, *dot, *bar;
|
||||
|
||||
content = ui_create_widget("spinner-content");
|
||||
dot = ui_create_widget(NULL);
|
||||
bar = ui_create_widget(NULL);
|
||||
ui_widget_add_class(dot, "c-dot");
|
||||
ui_widget_add_class(bar, "c-bar");
|
||||
ui_widget_append(content, dot);
|
||||
ui_widget_append(content, bar);
|
||||
return content;
|
||||
}
|
||||
|
||||
static ui_widget_t *create_text_content(void)
|
||||
{
|
||||
ui_widget_t *content, *text;
|
||||
|
||||
content = ui_create_widget("spinner-content");
|
||||
text = ui_create_widget("text");
|
||||
ui_text_set_content(text, "Hello");
|
||||
ui_widget_add_class(text, "c-text");
|
||||
ui_widget_append(content, text);
|
||||
return content;
|
||||
}
|
||||
|
||||
void spinner_custom_content_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *row, *spinner;
|
||||
|
||||
ui_load_css_string(spinner_custom_content_css,
|
||||
"spinner-custom-content-demo");
|
||||
row = ui_create_widget(NULL);
|
||||
ui_widget_add_class(row, "spinner-custom-content-demo");
|
||||
|
||||
spinner = ui_create_spinner();
|
||||
ui_widget_resize(spinner, 40, 40);
|
||||
ui_spinner_set_content(spinner, create_shape_content());
|
||||
ui_widget_append(row, spinner);
|
||||
|
||||
spinner = ui_create_spinner();
|
||||
ui_widget_resize(spinner, 96, 32);
|
||||
ui_spinner_set_content(spinner, create_text_content());
|
||||
ui_widget_append(row, spinner);
|
||||
|
||||
ui_widget_append(parent, row);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Spinner, Widget } from "@lcui/react";
|
||||
|
||||
export default function SpinnerRunningDemo() {
|
||||
return (
|
||||
<Widget className="flex items-center gap-6">
|
||||
<Spinner className="w-10 h-10" running speed={0.5} />
|
||||
<Spinner className="w-10 h-10" running={false} angle={90} />
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_spinner_running_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.spinner-running-demo {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
}
|
||||
.spinner-running-demo spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="spinner-running-demo">
|
||||
<spinner running="true" speed="0.5" />
|
||||
<spinner running="false" angle="90" />
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,33 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
static const char *spinner_running_css = "\
|
||||
.spinner-running-demo {\
|
||||
display: flex;\
|
||||
flex-direction: row;\
|
||||
align-items: center;\
|
||||
gap: 24px;\
|
||||
}\
|
||||
";
|
||||
|
||||
void spinner_running_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box, *running, *stopped;
|
||||
|
||||
ui_load_css_string(spinner_running_css, "spinner-running-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "spinner-running-demo");
|
||||
|
||||
running = ui_create_spinner();
|
||||
ui_widget_resize(running, 40, 40);
|
||||
ui_spinner_set_running(running, true);
|
||||
ui_spinner_set_speed(running, 0.5f);
|
||||
|
||||
stopped = ui_create_spinner();
|
||||
ui_widget_resize(stopped, 40, 40);
|
||||
ui_spinner_set_running(stopped, false);
|
||||
ui_spinner_set_angle(stopped, 90.0);
|
||||
|
||||
ui_widget_append(box, running);
|
||||
ui_widget_append(box, stopped);
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { Spinner, Widget } from "@lcui/react";
|
||||
|
||||
export default function SpinnerSizeDemo() {
|
||||
return (
|
||||
<Widget className="flex items-center gap-4">
|
||||
<Spinner className="w-6 h-6" />
|
||||
<Spinner className="w-10 h-10" />
|
||||
<Spinner className="w-16 h-16" />
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
/* example.tsx is compiled to example.h by @lcui/cli */
|
||||
#include "example.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_root_append(ui_create_spinner_size_demo());
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
lcui_init();
|
||||
ui_load_xml_file("ui.xml");
|
||||
return lcui_main();
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<lcui-app>
|
||||
<resource type="text/css">
|
||||
.spinner-size-demo {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
}
|
||||
.spinner-size-demo .sz-sm {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
}
|
||||
.spinner-size-demo .sz-md {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
.spinner-size-demo .sz-lg {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
}
|
||||
</resource>
|
||||
<ui>
|
||||
<widget class="spinner-size-demo">
|
||||
<spinner class="sz-sm" />
|
||||
<spinner class="sz-md" />
|
||||
<spinner class="sz-lg" />
|
||||
</widget>
|
||||
</ui>
|
||||
</lcui-app>
|
||||
@@ -0,0 +1,40 @@
|
||||
#include <LCUI.h>
|
||||
|
||||
static const char *spinner_size_css = "\
|
||||
.spinner-size-demo {\
|
||||
display: flex;\
|
||||
flex-direction: row;\
|
||||
align-items: center;\
|
||||
gap: 16px;\
|
||||
}\
|
||||
.spinner-size-demo .sz-sm {\
|
||||
width: 24px;\
|
||||
height: 24px;\
|
||||
}\
|
||||
.spinner-size-demo .sz-md {\
|
||||
width: 40px;\
|
||||
height: 40px;\
|
||||
}\
|
||||
.spinner-size-demo .sz-lg {\
|
||||
width: 64px;\
|
||||
height: 64px;\
|
||||
}\
|
||||
";
|
||||
|
||||
void spinner_size_init(ui_widget_t *parent)
|
||||
{
|
||||
ui_widget_t *box;
|
||||
ui_widget_t *spinner;
|
||||
const char *sizes[] = { "sz-sm", "sz-md", "sz-lg" };
|
||||
size_t i;
|
||||
|
||||
ui_load_css_string(spinner_size_css, "spinner-size-demo");
|
||||
box = ui_create_widget(NULL);
|
||||
ui_widget_add_class(box, "spinner-size-demo");
|
||||
for (i = 0; i < 3; ++i) {
|
||||
spinner = ui_create_spinner();
|
||||
ui_widget_add_class(spinner, sizes[i]);
|
||||
ui_widget_append(box, spinner);
|
||||
}
|
||||
ui_widget_append(parent, box);
|
||||
}
|
||||
@@ -46,6 +46,8 @@
|
||||
{ "slug": "radio-group", "label": { "en": "RadioGroup", "zh-CN": "RadioGroup 单选组" } },
|
||||
{ "slug": "select", "label": { "en": "Select", "zh-CN": "Select 下拉选择" } },
|
||||
{ "slug": "scrollarea", "label": { "en": "ScrollArea", "zh-CN": "ScrollArea 滚动区域" } },
|
||||
{ "slug": "spinner", "label": { "en": "Spinner", "zh-CN": "Spinner 加载指示器" } },
|
||||
{ "slug": "shimmer", "label": { "en": "Shimmer", "zh-CN": "Shimmer 高光" } },
|
||||
{ "slug": "text", "label": { "en": "Text", "zh-CN": "Text 文本" } },
|
||||
{ "slug": "text-input", "label": { "en": "TextInput", "zh-CN": "TextInput 文本输入" } }
|
||||
]
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
// `shimmer-content` 继承公共字段;作为 Shimmer 的直属内容子树,其内部节点会被
|
||||
// 捕获为骨架遮罩,本身不暴露额外可配置属性。
|
||||
export const shimmerContentFields: FieldData[] = [...widgetFields];
|
||||
@@ -0,0 +1,59 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
export const shimmerFields: FieldData[] = [
|
||||
...widgetFields,
|
||||
{
|
||||
name: "running",
|
||||
type: "boolean",
|
||||
default: "true",
|
||||
description: {
|
||||
en: "Whether the sheen animation is running. True by default; when off the content is composited with no highlight added.",
|
||||
"zh-CN": "是否播放扫光动画。默认为 true;关闭时不再叠加高光,内容按原色显示。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "color",
|
||||
type: "string",
|
||||
default: "rgba(255, 255, 255, 0.86)",
|
||||
description: {
|
||||
en: "Highlight colour overlaid on the content's opaque pixels, given as a CSS colour string; its alpha is the peak strength of the sheen.",
|
||||
"zh-CN": "叠加到内容不透明像素上的高光颜色,采用 CSS 颜色字符串;其 alpha 即扫过处的峰值强度。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "duration",
|
||||
type: "number",
|
||||
default: "2000",
|
||||
description: {
|
||||
en: "Time for one full sweep in milliseconds. Defaults to 2000.",
|
||||
"zh-CN": "单次扫过的时长,单位为毫秒。默认为 2000。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "spread",
|
||||
type: "number",
|
||||
default: "-",
|
||||
description: {
|
||||
en: "Width of the highlight band in logical pixels. When unset it defaults to about 45% of the box width and is recomputed on resize; setting it pins a fixed width.",
|
||||
"zh-CN": "高光带宽度,单位为逻辑像素。未设置时默认为框宽的约 45% 并在尺寸变化时重新计算;显式设置后固定为该值。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "angle",
|
||||
type: "number",
|
||||
default: "20",
|
||||
description: {
|
||||
en: "Tilt of the highlight band in degrees, shearing its center line across the height. Defaults to 20.",
|
||||
"zh-CN": "高光带倾斜角,单位为度,使反光中心线沿高度方向错切。默认为 20。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "phase",
|
||||
type: "number",
|
||||
default: "0",
|
||||
description: {
|
||||
en: "Sweep phase in [0, 1). Added for deterministic tests and manual control; while running the animation advances it by the duration.",
|
||||
"zh-CN": "高光带相位,取值范围 [0, 1),用于确定性测试或手动控制;运行状态下由 duration 持续推进。",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,3 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
export const spinnerContentFields: FieldData[] = [...widgetFields];
|
||||
@@ -0,0 +1,32 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
export const spinnerFields: FieldData[] = [
|
||||
...widgetFields,
|
||||
{
|
||||
name: "running",
|
||||
type: "boolean",
|
||||
default: "true",
|
||||
description: {
|
||||
en: "Whether the rotation animation is running. True by default.",
|
||||
"zh-CN": "是否播放旋转动画。默认为 true。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "speed",
|
||||
type: "number",
|
||||
default: "1",
|
||||
description: {
|
||||
en: "Rotation speed in revolutions per second.",
|
||||
"zh-CN": "旋转速度,单位为每秒转数 (rev/s)。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "angle",
|
||||
type: "number",
|
||||
default: "0",
|
||||
description: {
|
||||
en: "Current rotation angle in degrees. While running, the animation drives this value.",
|
||||
"zh-CN": "当前旋转角度,单位为度。运行状态下由动画持续推进。",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,82 @@
|
||||
# Shimmer
|
||||
|
||||
给文本、图标等内容叠加一道左右柔化、可倾斜的高光带,从左往右扫过;高光只落在内容的不透明像素上,内容本身保持原色。
|
||||
|
||||
<WidgetExample name="shimmer-basic" />
|
||||
|
||||
## 适用场景
|
||||
|
||||
- **适用**:让一段状态文本(图标或纯文字)带着柔和高光扫过,表示“进行中/加载”
|
||||
- **适用**:流式输出时给“正在生成”的提示文字加一层滑动高光
|
||||
- **不适用**:纯灰块的骨架占位(Shimmer 叠加在真实内容上,不生成占位骨架)
|
||||
- **不适用**:有明确百分比或已知时长的任务进度(用 `progress`)
|
||||
- **不适用**:无固定形状的全局忙碌指示(用 `spinner`)
|
||||
|
||||
## 用法
|
||||
|
||||
```tsx
|
||||
import { Shimmer, ShimmerContent } from "@lcui/react"
|
||||
```
|
||||
|
||||
Shimmer 是 C 代码自绘部件:先按原色完整合成内容,再把一道带倾斜的高光带裁剪到内容的不透明像素上叠加。高光本身可配置颜色、周期、宽度与倾斜角,通过部件属性或对应的 `ui_shimmer_set_*` 接口设置:
|
||||
|
||||
```tsx
|
||||
<Shimmer running={true} duration={2000} spread={120} angle={20} color="rgba(255,255,255,0.86)">
|
||||
<ShimmerContent>
|
||||
<Text>Generating response…</Text>
|
||||
</ShimmerContent>
|
||||
</Shimmer>
|
||||
```
|
||||
|
||||
## 组合
|
||||
|
||||
使用以下组合来构建 `Shimmer`:
|
||||
|
||||
```
|
||||
Shimmer
|
||||
└── ShimmerContent
|
||||
```
|
||||
|
||||
## 颜色
|
||||
|
||||
高光带叠加的颜色取自 `color`,其 alpha 就是扫过处的峰值强度。同一段灰字上叠不同颜色,扫过时会被“染”向各自的色相。
|
||||
|
||||
<WidgetExample name="shimmer-color" />
|
||||
|
||||
## 时长
|
||||
|
||||
`duration` 决定高光扫过一次所需的时间,单位为毫秒,默认 `2000`。值越小扫得越快。
|
||||
|
||||
<WidgetExample name="shimmer-duration" />
|
||||
|
||||
## 宽度
|
||||
|
||||
`spread` 决定高光带的宽度(逻辑像素)。窄带像一道锐利反光,宽带则一次漫过整行,峰值强度不变、只是覆盖范围不同。
|
||||
|
||||
<WidgetExample name="shimmer-spread" />
|
||||
|
||||
## 倾斜
|
||||
|
||||
`angle` 让高光带相对竖直方向倾斜(度数)。0° 时各行在同一列被扫到,倾斜后反光沿高度错切,先从顶部掠过再到下方。
|
||||
|
||||
<WidgetExample name="shimmer-angle" />
|
||||
|
||||
## 关闭高亮
|
||||
|
||||
把 `running` 设为 `false` 即可关闭动画:此时不再叠加高光,内容按原色正常显示。
|
||||
|
||||
<WidgetExample name="shimmer-running" />
|
||||
|
||||
## API 参考
|
||||
|
||||
### Shimmer
|
||||
|
||||
扫光容器,捕获 `ShimmerContent` 子树;先按原色完整合成内容,再叠加一道可倾斜、左右渐隐的高光带并裁剪到内容不透明处。高光从左往右扫过,只在内容上显现。
|
||||
|
||||
<FieldTable name="shimmer" />
|
||||
|
||||
### ShimmerContent
|
||||
|
||||
被捕获的内容子树(如文本或图标加文字的状态行),作为 Shimmer 的直属子部件使用;省略时使用一个填满整行的默认占位块。Shimmer 默认块级、高度 20px,可用 `width`/`height` 覆盖。
|
||||
|
||||
<FieldTable name="shimmer-content" />
|
||||
@@ -0,0 +1,58 @@
|
||||
# Spinner
|
||||
|
||||
用于表达“加载中”的自绘旋转指示器部件。
|
||||
|
||||
<WidgetExample name="spinner-basic" />
|
||||
|
||||
## 适用场景
|
||||
|
||||
- **适用**:等待异步结果、无法预知进度的加载状态
|
||||
- **适用**:按钮、卡片等局部区域的忙碌指示
|
||||
- **不适用**:有明确百分比或已知时长的任务进度(用 `progress`)
|
||||
|
||||
## 用法
|
||||
|
||||
```tsx
|
||||
import { Spinner, SpinnerContent } from "@lcui/react"
|
||||
```
|
||||
|
||||
```tsx
|
||||
<Spinner running={true} speed={1} />
|
||||
```
|
||||
|
||||
## 组合
|
||||
|
||||
使用以下组合来构建 `Spinner`:
|
||||
|
||||
```
|
||||
Spinner
|
||||
└── SpinnerContent
|
||||
```
|
||||
|
||||
## 示例
|
||||
|
||||
### 自定义内容
|
||||
|
||||
<WidgetExample name="spinner-custom-content" />
|
||||
|
||||
### 不同尺寸
|
||||
|
||||
<WidgetExample name="spinner-size" />
|
||||
|
||||
### 运行状态控制
|
||||
|
||||
<WidgetExample name="spinner-running" />
|
||||
|
||||
## API 参考
|
||||
|
||||
### Spinner
|
||||
|
||||
旋转指示器容器,捕获 `SpinnerContent` 子树并绕其中心旋转绘制。默认自带 16×16 尺寸,可用 `width`/`height` 覆盖。
|
||||
|
||||
<FieldTable name="spinner" />
|
||||
|
||||
### SpinnerContent
|
||||
|
||||
被旋转捕获的内容子树,作为 Spinner 的直接子部件使用;省略时使用默认的圆环,其中一边透明形成随旋转扫过的缺口。
|
||||
|
||||
<FieldTable name="spinner-content" />
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "page.tsx.h"
|
||||
#include "page.h"
|
||||
|
||||
typedef struct {
|
||||
en_widgets_shimmer_page_react_t base;
|
||||
// Add additional states to your component here
|
||||
// ...
|
||||
} en_widgets_shimmer_page_t;
|
||||
|
||||
static void en_widgets_shimmer_page_init(ui_widget_t *w)
|
||||
{
|
||||
ui_widget_add_data(w, en_widgets_shimmer_page_proto,
|
||||
sizeof(en_widgets_shimmer_page_t));
|
||||
|
||||
en_widgets_shimmer_page_react_init(w);
|
||||
// Write the initialization code for your component here
|
||||
// such as state initialization, event binding, etc
|
||||
// ...
|
||||
|
||||
en_widgets_shimmer_page_update(w);
|
||||
}
|
||||
|
||||
static en_widgets_shimmer_page_t *en_widgets_shimmer_page_get(ui_widget_t *w)
|
||||
{
|
||||
return ui_widget_get_data(w, en_widgets_shimmer_page_proto);
|
||||
}
|
||||
|
||||
static void en_widgets_shimmer_page_destroy(ui_widget_t *w)
|
||||
{
|
||||
// Write code here to destroy the relevant resources of the component
|
||||
// ...
|
||||
|
||||
en_widgets_shimmer_page_react_destroy(w);
|
||||
}
|
||||
|
||||
void en_widgets_shimmer_page_update(ui_widget_t *w)
|
||||
{
|
||||
en_widgets_shimmer_page_react_update(w);
|
||||
// Write code here to update other content of your component
|
||||
// ...
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_en_widgets_shimmer_page(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(en_widgets_shimmer_page_proto);
|
||||
}
|
||||
|
||||
void ui_register_en_widgets_shimmer_page(void)
|
||||
{
|
||||
en_widgets_shimmer_page_init_prototype();
|
||||
en_widgets_shimmer_page_proto->init = en_widgets_shimmer_page_init;
|
||||
en_widgets_shimmer_page_proto->destroy =
|
||||
en_widgets_shimmer_page_destroy;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <ui.h>
|
||||
|
||||
void ui_register_en_widgets_shimmer_page(void);
|
||||
|
||||
ui_widget_t *ui_create_en_widgets_shimmer_page(void);
|
||||
|
||||
void en_widgets_shimmer_page_update(ui_widget_t *w);
|
||||
|
||||
void ui_load_en_widgets_shimmer_page_resources(void);
|
||||
@@ -0,0 +1,105 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import CodeBlockCopy from "../../../components/code-block-copy";
|
||||
import ShimmerBasicDemo from "../../../examples/shimmer-basic/index";
|
||||
import ShimmerColorDemo from "../../../examples/shimmer-color/index";
|
||||
import ShimmerDurationDemo from "../../../examples/shimmer-duration/index";
|
||||
import ShimmerSpreadDemo from "../../../examples/shimmer-spread/index";
|
||||
import ShimmerAngleDemo from "../../../examples/shimmer-angle/index";
|
||||
import ShimmerRunningDemo from "../../../examples/shimmer-running/index";
|
||||
import FieldTable from "../../../components/field-table";
|
||||
import { shimmerFields } from "../../../widget-fields/shimmer";
|
||||
import { shimmerContentFields } from "../../../widget-fields/shimmer-content";
|
||||
|
||||
export default function ShimmerDocPage() {
|
||||
return (
|
||||
<Widget className="doc-page">
|
||||
<h1>Shimmer</h1>
|
||||
<p className="doc-page-desc">{`Overlays a soft-edged, tiltable highlight band on text, icons, or other content and sweeps it from left to right; the highlight only lands on the content's opaque pixels while the content keeps its own colors.`}</p>
|
||||
<ShimmerBasicDemo />
|
||||
<Widget className="doc-section">
|
||||
<h2>Use cases</h2>
|
||||
<ul>
|
||||
<li><Text>{`[b]Suitable[/b]: letting a status line (an icon or plain text) sweep with a soft highlight to signal "in progress / loading"`}</Text></li>
|
||||
<li><Text>{`[b]Suitable[/b]: adding a sliding highlight to a "generating" hint while text streams in`}</Text></li>
|
||||
<li><Text>{`[b]Not suitable[/b]: a plain gray skeleton placeholder (Shimmer overlays real content and does not generate a skeleton)`}</Text></li>
|
||||
<li><Text>{`[b]Not suitable[/b]: progress with a definite percentage or a known duration (use [bgcolor=#eee] progress [/bgcolor])`}</Text></li>
|
||||
<li><Text>{`[b]Not suitable[/b]: a global busy indicator without a fixed shape (use [bgcolor=#eee] spinner [/bgcolor])`}</Text></li>
|
||||
</ul>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Usage</h2>
|
||||
<Widget className="code-block" data-language="tsx" data-source="en/widgets/shimmer/0">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color]`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<p>{`Shimmer is a self-drawn widget implemented in C: it first composites the content at full strength in its own colors, then overlays a tilted highlight band clipped to the content's opaque pixels. The highlight itself can be configured with a color, period, width, and tilt, either through widget properties or the matching [bgcolor=#eee] ui_shimmer_set_* [/bgcolor] APIs:`}</p>
|
||||
<Widget className="code-block" data-language="tsx" data-source="en/widgets/shimmer/1">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`<[color=#8250df]Shimmer[/color] running={[color=#0550ae]true[/color]} duration={[color=#0550ae]2000[/color]} spread={[color=#0550ae]120[/color]} angle={[color=#0550ae]20[/color]} color=[color=#0a3069]"rgba(255,255,255,0.86)"[/color]>`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Generating response…[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`</[color=#8250df]Shimmer[/color]>`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Composition</h2>
|
||||
<p>{`Use the following composition to build a [bgcolor=#eee] Shimmer [/bgcolor]:`}</p>
|
||||
<Widget className="code-block" data-language="text" data-source="en/widgets/shimmer/2">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TEXT</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`Shimmer`}</Text>
|
||||
<Text className="code-line">{`└── ShimmerContent`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Color</h2>
|
||||
<p>{`The highlight band takes its color from [bgcolor=#eee] color [/bgcolor], and its alpha is the peak strength where it sweeps. Overlaying different colors on the same gray text tints the sweep toward each hue as it passes.`}</p>
|
||||
<ShimmerColorDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Duration</h2>
|
||||
<p>{`[bgcolor=#eee] duration [/bgcolor] sets how long one sweep takes, in milliseconds; it defaults to [bgcolor=#eee] 2000 [/bgcolor]. A smaller value sweeps faster.`}</p>
|
||||
<ShimmerDurationDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Width</h2>
|
||||
<p>{`[bgcolor=#eee] spread [/bgcolor] sets the width of the highlight band in logical pixels. A narrow band reads as a sharp glint, while a wide one washes over the whole row at once, with the same peak strength and only a different span.`}</p>
|
||||
<ShimmerSpreadDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Angle</h2>
|
||||
<p>{`[bgcolor=#eee] angle [/bgcolor] tilts the band relative to vertical, in degrees. At 0° every row is swept at the same column; when tilted, the glint shears along the height, grazing the top before the lower part.`}</p>
|
||||
<ShimmerAngleDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Disabling</h2>
|
||||
<p>{`Set [bgcolor=#eee] running [/bgcolor] to [bgcolor=#eee] false [/bgcolor] to stop the animation: no highlight is added and the content shows in its own colors.`}</p>
|
||||
<ShimmerRunningDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>API Reference</h2>
|
||||
<h3>Shimmer</h3>
|
||||
<p>{`The shimmer container; it captures the [bgcolor=#eee] ShimmerContent [/bgcolor] subtree, composites it at full strength in its own colors, then overlays a tiltable highlight band that fades out on both sides, clipped to the content's opaque pixels. The highlight sweeps from left to right and only shows on the content.`}</p>
|
||||
<FieldTable fields={shimmerFields} locale="en" />
|
||||
<h3>ShimmerContent</h3>
|
||||
<p>{`The captured content subtree (such as a status row of text, or an icon plus text), used as a direct child of Shimmer. When omitted, a default placeholder block filling the whole row is used. Shimmer is block-level with a height of 20px by default, which can be overridden with [bgcolor=#eee] width [/bgcolor]/[bgcolor=#eee] height [/bgcolor].`}</p>
|
||||
<FieldTable fields={shimmerContentFields} locale="en" />
|
||||
</Widget>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#include "page.tsx.h"
|
||||
#include "page.h"
|
||||
|
||||
typedef struct {
|
||||
en_widgets_spinner_page_react_t base;
|
||||
// Add additional states to your component here
|
||||
// ...
|
||||
} en_widgets_spinner_page_t;
|
||||
|
||||
static void en_widgets_spinner_page_init(ui_widget_t *w)
|
||||
{
|
||||
ui_widget_add_data(w, en_widgets_spinner_page_proto,
|
||||
sizeof(en_widgets_spinner_page_t));
|
||||
|
||||
en_widgets_spinner_page_react_init(w);
|
||||
// Write the initialization code for your component here
|
||||
// such as state initialization, event binding, etc
|
||||
// ...
|
||||
|
||||
en_widgets_spinner_page_update(w);
|
||||
}
|
||||
|
||||
static en_widgets_spinner_page_t *en_widgets_spinner_page_get(ui_widget_t *w)
|
||||
{
|
||||
return ui_widget_get_data(w, en_widgets_spinner_page_proto);
|
||||
}
|
||||
|
||||
static void en_widgets_spinner_page_destroy(ui_widget_t *w)
|
||||
{
|
||||
// Write code here to destroy the relevant resources of the component
|
||||
// ...
|
||||
|
||||
en_widgets_spinner_page_react_destroy(w);
|
||||
}
|
||||
|
||||
void en_widgets_spinner_page_update(ui_widget_t *w)
|
||||
{
|
||||
en_widgets_spinner_page_react_update(w);
|
||||
// Write code here to update other content of your component
|
||||
// ...
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_en_widgets_spinner_page(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(en_widgets_spinner_page_proto);
|
||||
}
|
||||
|
||||
void ui_register_en_widgets_spinner_page(void)
|
||||
{
|
||||
en_widgets_spinner_page_init_prototype();
|
||||
en_widgets_spinner_page_proto->init = en_widgets_spinner_page_init;
|
||||
en_widgets_spinner_page_proto->destroy =
|
||||
en_widgets_spinner_page_destroy;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <ui.h>
|
||||
|
||||
void ui_register_en_widgets_spinner_page(void);
|
||||
|
||||
ui_widget_t *ui_create_en_widgets_spinner_page(void);
|
||||
|
||||
void en_widgets_spinner_page_update(ui_widget_t *w);
|
||||
|
||||
void ui_load_en_widgets_spinner_page_resources(void);
|
||||
@@ -0,0 +1,80 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import CodeBlockCopy from "../../../components/code-block-copy";
|
||||
import SpinnerBasicDemo from "../../../examples/spinner-basic/index";
|
||||
import SpinnerCustomContentDemo from "../../../examples/spinner-custom-content/index";
|
||||
import SpinnerSizeDemo from "../../../examples/spinner-size/index";
|
||||
import SpinnerRunningDemo from "../../../examples/spinner-running/index";
|
||||
import FieldTable from "../../../components/field-table";
|
||||
import { spinnerFields } from "../../../widget-fields/spinner";
|
||||
import { spinnerContentFields } from "../../../widget-fields/spinner-content";
|
||||
|
||||
export default function SpinnerDocPage() {
|
||||
return (
|
||||
<Widget className="doc-page">
|
||||
<h1>Spinner</h1>
|
||||
<p className="doc-page-desc">{`A self-drawn spinning indicator used to express a "loading" state.`}</p>
|
||||
<SpinnerBasicDemo />
|
||||
<Widget className="doc-section">
|
||||
<h2>Use cases</h2>
|
||||
<ul>
|
||||
<li><Text>{`[b]Suitable[/b]: a loading state that waits for an async result whose progress cannot be predicted`}</Text></li>
|
||||
<li><Text>{`[b]Suitable[/b]: a busy indicator for a local area such as a button or a card`}</Text></li>
|
||||
<li><Text>{`[b]Not suitable[/b]: progress with a definite percentage or a known duration (use [bgcolor=#eee] progress [/bgcolor])`}</Text></li>
|
||||
</ul>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Usage</h2>
|
||||
<Widget className="code-block" data-language="tsx" data-source="en/widgets/spinner/0">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Spinner[/color], [color=#8250df]SpinnerContent[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color]`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block" data-language="tsx" data-source="en/widgets/spinner/1">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`<[color=#8250df]Spinner[/color] running={[color=#0550ae]true[/color]} speed={[color=#0550ae]1[/color]} />`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Composition</h2>
|
||||
<p>{`Use the following composition to build a [bgcolor=#eee] Spinner [/bgcolor]:`}</p>
|
||||
<Widget className="code-block" data-language="text" data-source="en/widgets/spinner/2">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TEXT</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`Spinner`}</Text>
|
||||
<Text className="code-line">{`└── SpinnerContent`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>Examples</h2>
|
||||
<h3>Custom Content</h3>
|
||||
<SpinnerCustomContentDemo />
|
||||
<h3>Sizes</h3>
|
||||
<SpinnerSizeDemo />
|
||||
<h3>Running State</h3>
|
||||
<SpinnerRunningDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>API Reference</h2>
|
||||
<h3>Spinner</h3>
|
||||
<p>{`The spinner container; it captures the [bgcolor=#eee] SpinnerContent [/bgcolor] subtree and draws it rotated about its center. It is 16×16 by default and can be overridden with [bgcolor=#eee] width [/bgcolor]/[bgcolor=#eee] height [/bgcolor].`}</p>
|
||||
<FieldTable fields={spinnerFields} locale="en" />
|
||||
<h3>SpinnerContent</h3>
|
||||
<p>{`The content subtree captured for rotation, used as a direct child of Spinner. When omitted, a default ring is used, with one side left transparent to form a gap that sweeps around as it rotates.`}</p>
|
||||
<FieldTable fields={spinnerContentFields} locale="en" />
|
||||
</Widget>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#define caption shimmer_angle__caption
|
||||
#include "../../../../../docs/examples/shimmer-angle/main.c"
|
||||
#undef caption
|
||||
|
||||
typedef struct {
|
||||
shimmer_angle_demo_react_t base;
|
||||
} shimmer_angle_demo_t;
|
||||
|
||||
void shimmer_angle_demo_update(ui_widget_t *w)
|
||||
{
|
||||
shimmer_angle_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_angle_demo_init(ui_widget_t *w)
|
||||
{
|
||||
shimmer_angle_demo_t *_that = ui_widget_add_data(
|
||||
w, shimmer_angle_demo_proto, sizeof(shimmer_angle_demo_t));
|
||||
shimmer_angle_demo_proto->proto->init(w);
|
||||
shimmer_angle_demo_react_init(w);
|
||||
shimmer_angle_init(_that->base.refs.preview);
|
||||
shimmer_angle_demo_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_angle_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
shimmer_angle_demo_proto->proto->destroy(w);
|
||||
shimmer_angle_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_shimmer_angle_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(shimmer_angle_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_shimmer_angle_demo(void)
|
||||
{
|
||||
shimmer_angle_demo_init_prototype();
|
||||
shimmer_angle_demo_proto->init = shimmer_angle_demo_init;
|
||||
shimmer_angle_demo_proto->destroy = shimmer_angle_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function ShimmerAngleDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/shimmer-angle/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color], [color=#8250df]Text[/color], [color=#8250df]Widget[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]ShimmerAngleDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Widget[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex flex-col gap-2"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-9"[/color] [color=#0550ae]running[/color] [color=#0550ae]angle[/color]=[color=#0a3069]{0}[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Flat band[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-9"[/color] [color=#0550ae]running[/color] [color=#0550ae]angle[/color]=[color=#0a3069]{45}[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Tilted band[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/shimmer-angle/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_shimmer_angle_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/shimmer-angle/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* The angle tilts the highlight band. A flat band (0 degrees) crosses each row[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * at the same column; a 45 degree band shears across the caption so the glint[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * reaches the top before the bottom. */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *shimmer_angle_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-angle-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] flex-direction: column;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-angle-demo shimmer {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 220px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 36px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-angle-demo shimmer-content {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] padding: 4px 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] font-size: 15px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] color: #46545f;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]ui_widget_t[/color] *[color=#8250df]caption[/color][color=#0550ae]([color=#953800]const[/color] [color=#953800]char[/color] *label)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *shimmer, *content, *text;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` shimmer = ui_create_shimmer();`}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"shimmer-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` text = ui_create_widget([color=#0a3069]"text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_text_set_content(text, label);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, text);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_content(shimmer, content);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_running(shimmer, [color=#0550ae]true[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] shimmer;`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]shimmer_angle_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box, *flat, *tilted;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(shimmer_angle_css, [color=#0a3069]"shimmer-angle-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"shimmer-angle-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` flat = caption([color=#0a3069]"Flat band"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_angle(flat, [color=#0550ae]0.0f[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` tilted = caption([color=#0a3069]"Tilted band"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_angle(tilted, [color=#0550ae]45.0f[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, flat);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, tilted);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/shimmer-angle/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .shimmer-angle-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` flex-direction: column;`}</Text>
|
||||
<Text className="code-line">{` gap: 8px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-angle-demo shimmer {`}</Text>
|
||||
<Text className="code-line">{` width: 220px;`}</Text>
|
||||
<Text className="code-line">{` height: 36px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-angle-demo shimmer-content {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` padding: 4px 8px;`}</Text>
|
||||
<Text className="code-line">{` font-size: 15px;`}</Text>
|
||||
<Text className="code-line">{` color: #46545f;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"shimmer-angle-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color] [color=#0550ae]angle[/color]=[color=#0a3069]"0"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Flat band[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color] [color=#0550ae]angle[/color]=[color=#0a3069]"45"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Tilted band[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/shimmer-angle/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#include "../../../../../docs/examples/shimmer-basic/main.c"
|
||||
|
||||
typedef struct {
|
||||
shimmer_basic_demo_react_t base;
|
||||
} shimmer_basic_demo_t;
|
||||
|
||||
void shimmer_basic_demo_update(ui_widget_t *w)
|
||||
{
|
||||
shimmer_basic_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_basic_demo_init(ui_widget_t *w)
|
||||
{
|
||||
shimmer_basic_demo_t *_that = ui_widget_add_data(
|
||||
w, shimmer_basic_demo_proto, sizeof(shimmer_basic_demo_t));
|
||||
shimmer_basic_demo_proto->proto->init(w);
|
||||
shimmer_basic_demo_react_init(w);
|
||||
shimmer_basic_init(_that->base.refs.preview);
|
||||
shimmer_basic_demo_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_basic_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
shimmer_basic_demo_proto->proto->destroy(w);
|
||||
shimmer_basic_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_shimmer_basic_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(shimmer_basic_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_shimmer_basic_demo(void)
|
||||
{
|
||||
shimmer_basic_demo_init_prototype();
|
||||
shimmer_basic_demo_proto->init = shimmer_basic_demo_init;
|
||||
shimmer_basic_demo_proto->destroy = shimmer_basic_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function ShimmerBasicDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/shimmer-basic/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color], [color=#8250df]Text[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]ShimmerDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Generating response…[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/shimmer-basic/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_shimmer_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/shimmer-basic/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* The shimmer sweeps a soft sheen across real text, so the caption stays[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * readable while it reads as "in progress". Scoped under a unique class; an[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * inline background-color would be overridden by the theme \`*\` rule. */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *shimmer_basic_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-basic-demo shimmer {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 220px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 28px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-basic-demo shimmer-content {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] padding: 4px 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] font-size: 15px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] color: #46545f;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]shimmer_basic_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box, *shimmer, *content, *text;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(shimmer_basic_css, [color=#0a3069]"shimmer-basic-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"shimmer-basic-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` shimmer = ui_create_shimmer();`}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"shimmer-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` text = ui_create_widget([color=#0a3069]"text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_text_set_content(text, [color=#0a3069]"Generating response..."[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, text);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_content(shimmer, content);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, shimmer);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/shimmer-basic/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .shimmer-basic-demo shimmer {`}</Text>
|
||||
<Text className="code-line">{` width: 220px;`}</Text>
|
||||
<Text className="code-line">{` height: 28px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-basic-demo shimmer-content {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` padding: 4px 8px;`}</Text>
|
||||
<Text className="code-line">{` font-size: 15px;`}</Text>
|
||||
<Text className="code-line">{` color: #46545f;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"shimmer-basic-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Generating response…[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/shimmer-basic/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#define caption shimmer_color__caption
|
||||
#include "../../../../../docs/examples/shimmer-color/main.c"
|
||||
#undef caption
|
||||
|
||||
typedef struct {
|
||||
shimmer_color_demo_react_t base;
|
||||
} shimmer_color_demo_t;
|
||||
|
||||
void shimmer_color_demo_update(ui_widget_t *w)
|
||||
{
|
||||
shimmer_color_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_color_demo_init(ui_widget_t *w)
|
||||
{
|
||||
shimmer_color_demo_t *_that = ui_widget_add_data(
|
||||
w, shimmer_color_demo_proto, sizeof(shimmer_color_demo_t));
|
||||
shimmer_color_demo_proto->proto->init(w);
|
||||
shimmer_color_demo_react_init(w);
|
||||
shimmer_color_init(_that->base.refs.preview);
|
||||
shimmer_color_demo_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_color_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
shimmer_color_demo_proto->proto->destroy(w);
|
||||
shimmer_color_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_shimmer_color_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(shimmer_color_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_shimmer_color_demo(void)
|
||||
{
|
||||
shimmer_color_demo_init_prototype();
|
||||
shimmer_color_demo_proto->init = shimmer_color_demo_init;
|
||||
shimmer_color_demo_proto->destroy = shimmer_color_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function ShimmerColorDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/shimmer-color/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color], [color=#8250df]Text[/color], [color=#8250df]Widget[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]ShimmerColorDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Widget[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex flex-col gap-2"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]color[/color]=[color=#0a3069]"#378ADD"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Generating response…[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]color[/color]=[color=#0a3069]"rgb(34, 197, 94)"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Sending request…[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/shimmer-color/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_shimmer_color_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/shimmer-color/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* Two captions, each with a different highlight colour. The \`color\` sheen is[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * overlaid only on the text's opaque pixels, so a blue and a green highlight[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * tint the same grey ink toward their own hue as they sweep. */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *shimmer_color_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-color-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] flex-direction: column;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-color-demo shimmer {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 220px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 28px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-color-demo shimmer-content {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] padding: 4px 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] font-size: 15px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] color: #46545f;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]ui_widget_t[/color] *[color=#8250df]caption[/color][color=#0550ae]([color=#953800]const[/color] [color=#953800]char[/color] *label)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *shimmer, *content, *text;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` shimmer = ui_create_shimmer();`}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"shimmer-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` text = ui_create_widget([color=#0a3069]"text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_text_set_content(text, label);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, text);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_content(shimmer, content);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] shimmer;`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]shimmer_color_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box, *blue, *green;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(shimmer_color_css, [color=#0a3069]"shimmer-color-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"shimmer-color-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` blue = caption([color=#0a3069]"Generating response..."[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_color(blue, pd_argb([color=#0550ae]200[/color], [color=#0550ae]55[/color], [color=#0550ae]138[/color], [color=#0550ae]221[/color]));`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` green = caption([color=#0a3069]"Sending request..."[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_color(green, pd_argb([color=#0550ae]200[/color], [color=#0550ae]34[/color], [color=#0550ae]197[/color], [color=#0550ae]94[/color]));`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, blue);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, green);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/shimmer-color/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .shimmer-color-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` flex-direction: column;`}</Text>
|
||||
<Text className="code-line">{` gap: 8px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-color-demo shimmer {`}</Text>
|
||||
<Text className="code-line">{` width: 220px;`}</Text>
|
||||
<Text className="code-line">{` height: 28px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-color-demo shimmer-content {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` padding: 4px 8px;`}</Text>
|
||||
<Text className="code-line">{` font-size: 15px;`}</Text>
|
||||
<Text className="code-line">{` color: #46545f;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"shimmer-color-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]color[/color]=[color=#0a3069]"#378ADD"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Generating response…[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]color[/color]=[color=#0a3069]"rgb(34 197 94)"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Sending request…[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/shimmer-color/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#define caption shimmer_duration__caption
|
||||
#include "../../../../../docs/examples/shimmer-duration/main.c"
|
||||
#undef caption
|
||||
|
||||
typedef struct {
|
||||
shimmer_duration_demo_react_t base;
|
||||
} shimmer_duration_demo_t;
|
||||
|
||||
void shimmer_duration_demo_update(ui_widget_t *w)
|
||||
{
|
||||
shimmer_duration_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_duration_demo_init(ui_widget_t *w)
|
||||
{
|
||||
shimmer_duration_demo_t *_that = ui_widget_add_data(
|
||||
w, shimmer_duration_demo_proto, sizeof(shimmer_duration_demo_t));
|
||||
shimmer_duration_demo_proto->proto->init(w);
|
||||
shimmer_duration_demo_react_init(w);
|
||||
shimmer_duration_init(_that->base.refs.preview);
|
||||
shimmer_duration_demo_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_duration_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
shimmer_duration_demo_proto->proto->destroy(w);
|
||||
shimmer_duration_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_shimmer_duration_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(shimmer_duration_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_shimmer_duration_demo(void)
|
||||
{
|
||||
shimmer_duration_demo_init_prototype();
|
||||
shimmer_duration_demo_proto->init = shimmer_duration_demo_init;
|
||||
shimmer_duration_demo_proto->destroy = shimmer_duration_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function ShimmerDurationDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/shimmer-duration/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color], [color=#8250df]Text[/color], [color=#8250df]Widget[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]ShimmerDurationDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Widget[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex flex-col gap-2"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]running[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Default duration[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]running[/color] [color=#0550ae]duration[/color]=[color=#0a3069]{1000}[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Faster duration[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/shimmer-duration/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_shimmer_duration_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/shimmer-duration/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* Two identical sweeps at different durations: the default 2000 ms and a[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * snappier 1000 ms. Duration is only observable while the shimmer is running,[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * so both lines keep the animation on. */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *shimmer_duration_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-duration-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] flex-direction: column;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-duration-demo shimmer {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 220px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 28px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-duration-demo shimmer-content {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] padding: 4px 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] font-size: 15px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] color: #46545f;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]ui_widget_t[/color] *[color=#8250df]caption[/color][color=#0550ae]([color=#953800]const[/color] [color=#953800]char[/color] *label)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *shimmer, *content, *text;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` shimmer = ui_create_shimmer();`}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"shimmer-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` text = ui_create_widget([color=#0a3069]"text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_text_set_content(text, label);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, text);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_content(shimmer, content);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_running(shimmer, [color=#0550ae]true[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] shimmer;`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]shimmer_duration_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box, *normal, *fast;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(shimmer_duration_css, [color=#0a3069]"shimmer-duration-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"shimmer-duration-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` normal = caption([color=#0a3069]"Default duration"[/color]);`}</Text>
|
||||
<Text className="code-line">{` fast = caption([color=#0a3069]"Faster duration"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_duration(fast, [color=#0550ae]1000[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, normal);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, fast);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/shimmer-duration/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .shimmer-duration-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` flex-direction: column;`}</Text>
|
||||
<Text className="code-line">{` gap: 8px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-duration-demo shimmer {`}</Text>
|
||||
<Text className="code-line">{` width: 220px;`}</Text>
|
||||
<Text className="code-line">{` height: 28px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-duration-demo shimmer-content {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` padding: 4px 8px;`}</Text>
|
||||
<Text className="code-line">{` font-size: 15px;`}</Text>
|
||||
<Text className="code-line">{` color: #46545f;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"shimmer-duration-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Default duration[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color] [color=#0550ae]duration[/color]=[color=#0a3069]"1000"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Faster duration[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/shimmer-duration/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#include "../../../../../docs/examples/shimmer-running/main.c"
|
||||
|
||||
typedef struct {
|
||||
shimmer_running_demo_react_t base;
|
||||
} shimmer_running_demo_t;
|
||||
|
||||
void shimmer_running_demo_update(ui_widget_t *w)
|
||||
{
|
||||
shimmer_running_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_running_demo_init(ui_widget_t *w)
|
||||
{
|
||||
shimmer_running_demo_t *_that = ui_widget_add_data(
|
||||
w, shimmer_running_demo_proto, sizeof(shimmer_running_demo_t));
|
||||
shimmer_running_demo_proto->proto->init(w);
|
||||
shimmer_running_demo_react_init(w);
|
||||
shimmer_running_init(_that->base.refs.preview);
|
||||
shimmer_running_demo_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_running_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
shimmer_running_demo_proto->proto->destroy(w);
|
||||
shimmer_running_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_shimmer_running_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(shimmer_running_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_shimmer_running_demo(void)
|
||||
{
|
||||
shimmer_running_demo_init_prototype();
|
||||
shimmer_running_demo_proto->init = shimmer_running_demo_init;
|
||||
shimmer_running_demo_proto->destroy = shimmer_running_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function ShimmerRunningDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/shimmer-running/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color], [color=#8250df]Text[/color], [color=#8250df]Widget[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]ShimmerRunningDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Widget[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex flex-col gap-2"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]running[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Searching the web…[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]running[/color]=[color=#0a3069]{false}[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Reading 4 files[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/shimmer-running/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_shimmer_running_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/shimmer-running/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* The first caption keeps sweeping; the second has the animation turned off,[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * so its text is composited as-is with no sheen added. \`running = false\` is the[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * shimmer's off state: the content renders normally. */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *shimmer_running_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-running-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] flex-direction: column;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-running-demo shimmer {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 220px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 28px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-running-demo shimmer-content {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] padding: 4px 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] font-size: 15px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] color: #46545f;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]ui_widget_t[/color] *[color=#8250df]caption[/color][color=#0550ae]([color=#953800]const[/color] [color=#953800]char[/color] *label)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *shimmer, *content, *text;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` shimmer = ui_create_shimmer();`}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"shimmer-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` text = ui_create_widget([color=#0a3069]"text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_text_set_content(text, label);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, text);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_content(shimmer, content);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] shimmer;`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]shimmer_running_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box, *running, *stopped;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(shimmer_running_css, [color=#0a3069]"shimmer-running-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"shimmer-running-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` running = caption([color=#0a3069]"Searching the web..."[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_running(running, [color=#0550ae]true[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_duration(running, [color=#0550ae]1000[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` stopped = caption([color=#0a3069]"Reading 4 files"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_running(stopped, [color=#0550ae]false[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, running);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, stopped);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/shimmer-running/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .shimmer-running-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` flex-direction: column;`}</Text>
|
||||
<Text className="code-line">{` gap: 8px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-running-demo shimmer {`}</Text>
|
||||
<Text className="code-line">{` width: 220px;`}</Text>
|
||||
<Text className="code-line">{` height: 28px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-running-demo shimmer-content {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` padding: 4px 8px;`}</Text>
|
||||
<Text className="code-line">{` font-size: 15px;`}</Text>
|
||||
<Text className="code-line">{` color: #46545f;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"shimmer-running-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Searching the web…[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"false"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Reading 4 files[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/shimmer-running/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#define caption shimmer_spread__caption
|
||||
#include "../../../../../docs/examples/shimmer-spread/main.c"
|
||||
#undef caption
|
||||
|
||||
typedef struct {
|
||||
shimmer_spread_demo_react_t base;
|
||||
} shimmer_spread_demo_t;
|
||||
|
||||
void shimmer_spread_demo_update(ui_widget_t *w)
|
||||
{
|
||||
shimmer_spread_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_spread_demo_init(ui_widget_t *w)
|
||||
{
|
||||
shimmer_spread_demo_t *_that = ui_widget_add_data(
|
||||
w, shimmer_spread_demo_proto, sizeof(shimmer_spread_demo_t));
|
||||
shimmer_spread_demo_proto->proto->init(w);
|
||||
shimmer_spread_demo_react_init(w);
|
||||
shimmer_spread_init(_that->base.refs.preview);
|
||||
shimmer_spread_demo_update(w);
|
||||
}
|
||||
|
||||
static void shimmer_spread_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
shimmer_spread_demo_proto->proto->destroy(w);
|
||||
shimmer_spread_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_shimmer_spread_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(shimmer_spread_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_shimmer_spread_demo(void)
|
||||
{
|
||||
shimmer_spread_demo_init_prototype();
|
||||
shimmer_spread_demo_proto->init = shimmer_spread_demo_init;
|
||||
shimmer_spread_demo_proto->destroy = shimmer_spread_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function ShimmerSpreadDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/shimmer-spread/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color], [color=#8250df]Text[/color], [color=#8250df]Widget[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]ShimmerSpreadDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Widget[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex flex-col gap-2"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]running[/color] [color=#0550ae]spread[/color]=[color=#0a3069]{40}[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Narrow spread[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Shimmer[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[220px] h-7"[/color] [color=#0550ae]running[/color] [color=#0550ae]spread[/color]=[color=#0a3069]{160}[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center px-2 py-1 text-\\[#46545f]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Wide spread[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/shimmer-spread/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_shimmer_spread_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/shimmer-spread/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* The spread sets the highlight band's width in logical pixels. A narrow band[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * reads as a tight glint; a wide one washes across the whole caption at once.[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781] * The peak strength is unchanged, only how far it reaches. */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *shimmer_spread_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-spread-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] flex-direction: column;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-spread-demo shimmer {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 220px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 28px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].shimmer-spread-demo shimmer-content {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] padding: 4px 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] font-size: 15px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] color: #46545f;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]ui_widget_t[/color] *[color=#8250df]caption[/color][color=#0550ae]([color=#953800]const[/color] [color=#953800]char[/color] *label)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *shimmer, *content, *text;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` shimmer = ui_create_shimmer();`}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"shimmer-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` text = ui_create_widget([color=#0a3069]"text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_text_set_content(text, label);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, text);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_content(shimmer, content);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_running(shimmer, [color=#0550ae]true[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] shimmer;`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]shimmer_spread_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box, *narrow, *wide;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(shimmer_spread_css, [color=#0a3069]"shimmer-spread-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"shimmer-spread-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` narrow = caption([color=#0a3069]"Narrow spread"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_spread(narrow, [color=#0550ae]40.0f[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` wide = caption([color=#0a3069]"Wide spread"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_shimmer_set_spread(wide, [color=#0550ae]160.0f[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, narrow);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, wide);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/shimmer-spread/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .shimmer-spread-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` flex-direction: column;`}</Text>
|
||||
<Text className="code-line">{` gap: 8px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-spread-demo shimmer {`}</Text>
|
||||
<Text className="code-line">{` width: 220px;`}</Text>
|
||||
<Text className="code-line">{` height: 28px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .shimmer-spread-demo shimmer-content {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` padding: 4px 8px;`}</Text>
|
||||
<Text className="code-line">{` font-size: 15px;`}</Text>
|
||||
<Text className="code-line">{` color: #46545f;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"shimmer-spread-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color] [color=#0550ae]spread[/color]=[color=#0a3069]"40"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Narrow spread[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color] [color=#0550ae]spread[/color]=[color=#0a3069]"160"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color]>[/color]Wide spread[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]shimmer[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/shimmer-spread/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#include "../../../../../docs/examples/spinner-basic/main.c"
|
||||
|
||||
typedef struct {
|
||||
spinner_basic_demo_react_t base;
|
||||
} spinner_basic_demo_t;
|
||||
|
||||
void spinner_basic_demo_update(ui_widget_t *w)
|
||||
{
|
||||
spinner_basic_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void spinner_basic_demo_init(ui_widget_t *w)
|
||||
{
|
||||
spinner_basic_demo_t *_that = ui_widget_add_data(
|
||||
w, spinner_basic_demo_proto, sizeof(spinner_basic_demo_t));
|
||||
spinner_basic_demo_proto->proto->init(w);
|
||||
spinner_basic_demo_react_init(w);
|
||||
spinner_basic_init(_that->base.refs.preview);
|
||||
spinner_basic_demo_update(w);
|
||||
}
|
||||
|
||||
static void spinner_basic_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
spinner_basic_demo_proto->proto->destroy(w);
|
||||
spinner_basic_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_spinner_basic_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(spinner_basic_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_spinner_basic_demo(void)
|
||||
{
|
||||
spinner_basic_demo_init_prototype();
|
||||
spinner_basic_demo_proto->init = spinner_basic_demo_init;
|
||||
spinner_basic_demo_proto->destroy = spinner_basic_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function SpinnerBasicDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/spinner-basic/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Spinner[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]SpinnerDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-10 h-10"[/color] />[/color];`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/spinner-basic/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_spinner_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/spinner-basic/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]spinner_basic_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *spinner;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` spinner = ui_create_spinner();`}</Text>
|
||||
<Text className="code-line">{` ui_widget_resize(spinner, [color=#0550ae]40[/color], [color=#0550ae]40[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, spinner);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/spinner-basic/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .spinner-basic-box spinner {`}</Text>
|
||||
<Text className="code-line">{` width: 40px;`}</Text>
|
||||
<Text className="code-line">{` height: 40px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]w[/color] [color=#0550ae]class[/color]=[color=#0a3069]"spinner-basic-box"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]w[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/spinner-basic/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#define create_ring_content spinner_custom_content__create_ring_content
|
||||
#include "../../../../../docs/examples/spinner-custom-content/main.c"
|
||||
#undef create_ring_content
|
||||
|
||||
typedef struct {
|
||||
spinner_custom_content_demo_react_t base;
|
||||
} spinner_custom_content_demo_t;
|
||||
|
||||
void spinner_custom_content_demo_update(ui_widget_t *w)
|
||||
{
|
||||
spinner_custom_content_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void spinner_custom_content_demo_init(ui_widget_t *w)
|
||||
{
|
||||
spinner_custom_content_demo_t *_that =
|
||||
ui_widget_add_data(w, spinner_custom_content_demo_proto,
|
||||
sizeof(spinner_custom_content_demo_t));
|
||||
spinner_custom_content_demo_proto->proto->init(w);
|
||||
spinner_custom_content_demo_react_init(w);
|
||||
spinner_custom_content_init(_that->base.refs.preview);
|
||||
spinner_custom_content_demo_update(w);
|
||||
}
|
||||
|
||||
static void spinner_custom_content_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
spinner_custom_content_demo_proto->proto->destroy(w);
|
||||
spinner_custom_content_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_spinner_custom_content_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(
|
||||
spinner_custom_content_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_spinner_custom_content_demo(void)
|
||||
{
|
||||
spinner_custom_content_demo_init_prototype();
|
||||
spinner_custom_content_demo_proto->init =
|
||||
spinner_custom_content_demo_init;
|
||||
spinner_custom_content_demo_proto->destroy =
|
||||
spinner_custom_content_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function SpinnerCustomContentDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/spinner-custom-content/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Spinner[/color], [color=#8250df]SpinnerContent[/color], [color=#8250df]Text[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]SpinnerCustomContentDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]div[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex flex-row items-center gap-7"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-10 h-10"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]SpinnerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"relative flex items-center justify-center"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]div[/color] [color=#0550ae]className[/color]=[color=#0a3069]"absolute left-\\[15px] top-\\[3px] w-\\[10px] h-\\[10px] rounded-full bg-blue-500"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]div[/color] [color=#0550ae]className[/color]=[color=#0a3069]"absolute left-\\[18px] top-\\[6px] w-1 h-5 rounded bg-red-500"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]SpinnerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Spinner[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-\\[96px] h-8"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]SpinnerContent[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center justify-center"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color] [color=#0550ae]className[/color]=[color=#0a3069]"whitespace-nowrap text-lg text-\\[#e5484d]"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` Hello`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]SpinnerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Spinner[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]div[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/spinner-custom-content/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_spinner_custom_content_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/spinner-custom-content/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *spinner_custom_content_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-custom-content-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 28px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-custom-content-demo spinner-content {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] justify-content: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-custom-content-demo spinner-content .c-dot {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] position: absolute;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] left: 15px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] top: 3px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 10px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 10px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] background-color: #4a90d9;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] border-radius: 8px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-custom-content-demo spinner-content .c-bar {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] position: absolute;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] left: 18px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] top: 6px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 4px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 20px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] background-color: #d9534f;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] border-radius: 2px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-custom-content-demo spinner-content .c-text {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] white-space: nowrap;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] font-size: 18px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] color: #e5484d;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]ui_widget_t[/color] *[color=#8250df]create_shape_content[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *content, *dot, *bar;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"spinner-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` dot = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` bar = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(dot, [color=#0a3069]"c-dot"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(bar, [color=#0a3069]"c-bar"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, dot);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, bar);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] content;`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]ui_widget_t[/color] *[color=#8250df]create_text_content[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *content, *text;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` content = ui_create_widget([color=#0a3069]"spinner-content"[/color]);`}</Text>
|
||||
<Text className="code-line">{` text = ui_create_widget([color=#0a3069]"text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_text_set_content(text, [color=#0a3069]"Hello"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(text, [color=#0a3069]"c-text"[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(content, text);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] content;`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]spinner_custom_content_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *row, *spinner;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(spinner_custom_content_css,`}</Text>
|
||||
<Text className="code-line">{` [color=#0a3069]"spinner-custom-content-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` row = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(row, [color=#0a3069]"spinner-custom-content-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` spinner = ui_create_spinner();`}</Text>
|
||||
<Text className="code-line">{` ui_widget_resize(spinner, [color=#0550ae]40[/color], [color=#0550ae]40[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_spinner_set_content(spinner, create_shape_content());`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(row, spinner);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` spinner = ui_create_spinner();`}</Text>
|
||||
<Text className="code-line">{` ui_widget_resize(spinner, [color=#0550ae]96[/color], [color=#0550ae]32[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_spinner_set_content(spinner, create_text_content());`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(row, spinner);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, row);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/spinner-custom-content/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .spinner-custom-content-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` gap: 28px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-custom-content-demo .shape {`}</Text>
|
||||
<Text className="code-line">{` width: 40px;`}</Text>
|
||||
<Text className="code-line">{` height: 40px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-custom-content-demo .word {`}</Text>
|
||||
<Text className="code-line">{` width: 96px;`}</Text>
|
||||
<Text className="code-line">{` height: 32px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-custom-content-demo spinner-content {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` justify-content: center;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-custom-content-demo .c-dot {`}</Text>
|
||||
<Text className="code-line">{` position: absolute;`}</Text>
|
||||
<Text className="code-line">{` left: 15px;`}</Text>
|
||||
<Text className="code-line">{` top: 3px;`}</Text>
|
||||
<Text className="code-line">{` width: 10px;`}</Text>
|
||||
<Text className="code-line">{` height: 10px;`}</Text>
|
||||
<Text className="code-line">{` background-color: #4a90d9;`}</Text>
|
||||
<Text className="code-line">{` border-radius: 8px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-custom-content-demo .c-bar {`}</Text>
|
||||
<Text className="code-line">{` position: absolute;`}</Text>
|
||||
<Text className="code-line">{` left: 18px;`}</Text>
|
||||
<Text className="code-line">{` top: 6px;`}</Text>
|
||||
<Text className="code-line">{` width: 4px;`}</Text>
|
||||
<Text className="code-line">{` height: 20px;`}</Text>
|
||||
<Text className="code-line">{` background-color: #d9534f;`}</Text>
|
||||
<Text className="code-line">{` border-radius: 2px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-custom-content-demo .c-text {`}</Text>
|
||||
<Text className="code-line">{` white-space: nowrap;`}</Text>
|
||||
<Text className="code-line">{` font-size: 18px;`}</Text>
|
||||
<Text className="code-line">{` color: #e5484d;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"spinner-custom-content-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] [color=#0550ae]class[/color]=[color=#0a3069]"shape"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]w[/color] [color=#0550ae]class[/color]=[color=#0a3069]"c-dot"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]w[/color] [color=#0550ae]class[/color]=[color=#0a3069]"c-bar"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]spinner-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]spinner[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] [color=#0550ae]class[/color]=[color=#0a3069]"word"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]text[/color] [color=#0550ae]class[/color]=[color=#0a3069]"c-text"[/color]>[/color]Hello[color=#116329]</[color=#0550ae]text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]spinner-content[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]spinner[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/spinner-custom-content/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#include "../../../../../docs/examples/spinner-running/main.c"
|
||||
|
||||
typedef struct {
|
||||
spinner_running_demo_react_t base;
|
||||
} spinner_running_demo_t;
|
||||
|
||||
void spinner_running_demo_update(ui_widget_t *w)
|
||||
{
|
||||
spinner_running_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void spinner_running_demo_init(ui_widget_t *w)
|
||||
{
|
||||
spinner_running_demo_t *_that = ui_widget_add_data(
|
||||
w, spinner_running_demo_proto, sizeof(spinner_running_demo_t));
|
||||
spinner_running_demo_proto->proto->init(w);
|
||||
spinner_running_demo_react_init(w);
|
||||
spinner_running_init(_that->base.refs.preview);
|
||||
spinner_running_demo_update(w);
|
||||
}
|
||||
|
||||
static void spinner_running_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
spinner_running_demo_proto->proto->destroy(w);
|
||||
spinner_running_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_spinner_running_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(spinner_running_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_spinner_running_demo(void)
|
||||
{
|
||||
spinner_running_demo_init_prototype();
|
||||
spinner_running_demo_proto->init = spinner_running_demo_init;
|
||||
spinner_running_demo_proto->destroy = spinner_running_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function SpinnerRunningDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/spinner-running/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Spinner[/color], [color=#8250df]Widget[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]SpinnerRunningDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Widget[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center gap-6"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-10 h-10"[/color] [color=#0550ae]running[/color] [color=#0550ae]speed[/color]=[color=#0a3069]{0.5}[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-10 h-10"[/color] [color=#0550ae]running[/color]=[color=#0a3069]{false}[/color] [color=#0550ae]angle[/color]=[color=#0a3069]{90}[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/spinner-running/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_spinner_running_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/spinner-running/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *spinner_running_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-running-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] flex-direction: row;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 24px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]spinner_running_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box, *running, *stopped;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(spinner_running_css, [color=#0a3069]"spinner-running-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"spinner-running-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` running = ui_create_spinner();`}</Text>
|
||||
<Text className="code-line">{` ui_widget_resize(running, [color=#0550ae]40[/color], [color=#0550ae]40[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_spinner_set_running(running, [color=#0550ae]true[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_spinner_set_speed(running, [color=#0550ae]0.5f[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` stopped = ui_create_spinner();`}</Text>
|
||||
<Text className="code-line">{` ui_widget_resize(stopped, [color=#0550ae]40[/color], [color=#0550ae]40[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_spinner_set_running(stopped, [color=#0550ae]false[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_spinner_set_angle(stopped, [color=#0550ae]90.0[/color]);`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, running);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, stopped);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/spinner-running/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .spinner-running-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` flex-direction: row;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` gap: 24px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-running-demo spinner {`}</Text>
|
||||
<Text className="code-line">{` width: 40px;`}</Text>
|
||||
<Text className="code-line">{` height: 40px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"spinner-running-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] [color=#0550ae]running[/color]=[color=#0a3069]"true"[/color] [color=#0550ae]speed[/color]=[color=#0a3069]"0.5"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] [color=#0550ae]running[/color]=[color=#0a3069]"false"[/color] [color=#0550ae]angle[/color]=[color=#0a3069]"90"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/spinner-running/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "index.tsx.h"
|
||||
#include "index.h"
|
||||
|
||||
#include "../../../../../docs/examples/spinner-size/main.c"
|
||||
|
||||
typedef struct {
|
||||
spinner_size_demo_react_t base;
|
||||
} spinner_size_demo_t;
|
||||
|
||||
void spinner_size_demo_update(ui_widget_t *w)
|
||||
{
|
||||
spinner_size_demo_react_update(w);
|
||||
}
|
||||
|
||||
static void spinner_size_demo_init(ui_widget_t *w)
|
||||
{
|
||||
spinner_size_demo_t *_that = ui_widget_add_data(
|
||||
w, spinner_size_demo_proto, sizeof(spinner_size_demo_t));
|
||||
spinner_size_demo_proto->proto->init(w);
|
||||
spinner_size_demo_react_init(w);
|
||||
spinner_size_init(_that->base.refs.preview);
|
||||
spinner_size_demo_update(w);
|
||||
}
|
||||
|
||||
static void spinner_size_demo_destroy(ui_widget_t *w)
|
||||
{
|
||||
spinner_size_demo_proto->proto->destroy(w);
|
||||
spinner_size_demo_react_destroy(w);
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_spinner_size_demo(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(spinner_size_demo_proto);
|
||||
}
|
||||
|
||||
void ui_register_spinner_size_demo(void)
|
||||
{
|
||||
spinner_size_demo_init_prototype();
|
||||
spinner_size_demo_proto->init = spinner_size_demo_init;
|
||||
spinner_size_demo_proto->destroy = spinner_size_demo_destroy;
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import DemoProvider from "../../components/demo-provider";
|
||||
import CodeBlockCopy from "../../components/code-block-copy";
|
||||
|
||||
export default function SpinnerSizeDemo() {
|
||||
return (
|
||||
<DemoProvider>
|
||||
<Widget $ref="preview" className="demo-preview" />
|
||||
<Widget className="code-block">
|
||||
<Widget className="code-block-header">
|
||||
<Widget className="demo-files">
|
||||
<Text className="demo-tab active" data-language="tsx" data-value="example.tsx">example.tsx</Text>
|
||||
<Text className="demo-tab" data-language="tsx" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="c" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="ui.xml" style={{ display: "none" }}>ui.xml</Text>
|
||||
<Text className="demo-tab" data-language="xml" data-value="main.c" style={{ display: "none" }}>main.c</Text>
|
||||
</Widget>
|
||||
<Widget className="demo-languages">
|
||||
<Text className="demo-tab active" data-value="tsx">TSX</Text>
|
||||
<Text className="demo-tab" data-value="c">C</Text>
|
||||
<Text className="demo-tab" data-value="xml">XML</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block-body active" data-language="tsx" data-file="example.tsx" data-source="examples/spinner-size/5">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Spinner[/color], [color=#8250df]Widget[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#cf222e]export[/color] [color=#cf222e]default[/color] [color=#cf222e]function[/color] [color=#8250df]SpinnerSizeDemo[/color]([color=#0550ae][/color]) {`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] (`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Widget[/color] [color=#0550ae]className[/color]=[color=#0a3069]"flex items-center gap-4"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-6 h-6"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-10 h-10"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Spinner[/color] [color=#0550ae]className[/color]=[color=#0a3069]"w-16 h-16"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]Widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` );`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="tsx" data-file="main.c" data-source="examples/spinner-size/6" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]/* example.tsx is compiled to example.h by @lcui/cli */[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]"example.h"[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_root_append(ui_create_spinner_size_demo());`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="c" data-file="main.c" data-source="examples/spinner-size/7" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]static[/color] [color=#953800]const[/color] [color=#953800]char[/color] *spinner_size_css = [color=#0a3069]"\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-size-demo {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] display: flex;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] flex-direction: row;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] align-items: center;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] gap: 16px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-size-demo .sz-sm {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 24px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 24px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-size-demo .sz-md {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 40px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 40px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069].spinner-size-demo .sz-lg {\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] width: 64px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069] height: 64px;\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]}\\[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#0a3069]"[/color];`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]void[/color] [color=#8250df]spinner_size_init[/color][color=#0550ae]([color=#953800]ui_widget_t[/color] *parent)[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *box;`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]ui_widget_t[/color] *spinner;`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]const[/color] [color=#953800]char[/color] *sizes\\[] = { [color=#0a3069]"sz-sm"[/color], [color=#0a3069]"sz-md"[/color], [color=#0a3069]"sz-lg"[/color] };`}</Text>
|
||||
<Text className="code-line">{` [color=#953800]size_t[/color] i;`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{` ui_load_css_string(spinner_size_css, [color=#0a3069]"spinner-size-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` box = ui_create_widget([color=#0550ae]NULL[/color]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(box, [color=#0a3069]"spinner-size-demo"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]for[/color] (i = [color=#0550ae]0[/color]; i < [color=#0550ae]3[/color]; ++i) {`}</Text>
|
||||
<Text className="code-line">{` spinner = ui_create_spinner();`}</Text>
|
||||
<Text className="code-line">{` ui_widget_add_class(spinner, sizes\\[i]);`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(box, spinner);`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` ui_widget_append(parent, box);`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="ui.xml" data-source="examples/spinner-size/8" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]<?xml version=[color=#0a3069]"1.0"[/color] encoding=[color=#0a3069]"UTF-8"[/color] ?>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]<[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]resource[/color] [color=#0550ae]type[/color]=[color=#0a3069]"text/css"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` .spinner-size-demo {`}</Text>
|
||||
<Text className="code-line">{` display: flex;`}</Text>
|
||||
<Text className="code-line">{` flex-direction: row;`}</Text>
|
||||
<Text className="code-line">{` align-items: center;`}</Text>
|
||||
<Text className="code-line">{` gap: 16px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-size-demo .sz-sm {`}</Text>
|
||||
<Text className="code-line">{` width: 24px;`}</Text>
|
||||
<Text className="code-line">{` height: 24px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-size-demo .sz-md {`}</Text>
|
||||
<Text className="code-line">{` width: 40px;`}</Text>
|
||||
<Text className="code-line">{` height: 40px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` .spinner-size-demo .sz-lg {`}</Text>
|
||||
<Text className="code-line">{` width: 64px;`}</Text>
|
||||
<Text className="code-line">{` height: 64px;`}</Text>
|
||||
<Text className="code-line">{` }`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]resource[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]widget[/color] [color=#0550ae]class[/color]=[color=#0a3069]"spinner-size-demo"[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] [color=#0550ae]class[/color]=[color=#0a3069]"sz-sm"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] [color=#0550ae]class[/color]=[color=#0a3069]"sz-md"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]spinner[/color] [color=#0550ae]class[/color]=[color=#0a3069]"sz-lg"[/color] />[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]widget[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ui[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`[color=#116329]</[color=#0550ae]lcui-app[/color]>[/color]`}</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body" data-language="xml" data-file="main.c" data-source="examples/spinner-size/9" style={{ display: "none" }}>
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#6e7781]#[color=#cf222e]include[/color] [color=#0a3069]<LCUI.h>[/color][/color]`}</Text>
|
||||
<Text className="code-line">{` `}</Text>
|
||||
<Text className="code-line">{`[color=#953800]int[/color] [color=#8250df]main[/color][color=#0550ae]([color=#953800]void[/color])[/color]`}</Text>
|
||||
<Text className="code-line">{`{`}</Text>
|
||||
<Text className="code-line">{` lcui_init();`}</Text>
|
||||
<Text className="code-line">{` ui_load_xml_file([color=#0a3069]"ui.xml"[/color]);`}</Text>
|
||||
<Text className="code-line">{` [color=#cf222e]return[/color] lcui_main();`}</Text>
|
||||
<Text className="code-line">{`}`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</DemoProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
// `shimmer-content` 继承公共字段;作为 Shimmer 的直属内容子树,其内部节点会被
|
||||
// 捕获为骨架遮罩,本身不暴露额外可配置属性。
|
||||
export const shimmerContentFields: FieldData[] = [...widgetFields];
|
||||
@@ -0,0 +1,59 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
export const shimmerFields: FieldData[] = [
|
||||
...widgetFields,
|
||||
{
|
||||
name: "running",
|
||||
type: "boolean",
|
||||
default: "true",
|
||||
description: {
|
||||
en: "Whether the sheen animation is running. True by default; when off the content is composited with no highlight added.",
|
||||
"zh-CN": "是否播放扫光动画。默认为 true;关闭时不再叠加高光,内容按原色显示。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "color",
|
||||
type: "string",
|
||||
default: "rgba(255, 255, 255, 0.86)",
|
||||
description: {
|
||||
en: "Highlight colour overlaid on the content's opaque pixels, given as a CSS colour string; its alpha is the peak strength of the sheen.",
|
||||
"zh-CN": "叠加到内容不透明像素上的高光颜色,采用 CSS 颜色字符串;其 alpha 即扫过处的峰值强度。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "duration",
|
||||
type: "number",
|
||||
default: "2000",
|
||||
description: {
|
||||
en: "Time for one full sweep in milliseconds. Defaults to 2000.",
|
||||
"zh-CN": "单次扫过的时长,单位为毫秒。默认为 2000。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "spread",
|
||||
type: "number",
|
||||
default: "-",
|
||||
description: {
|
||||
en: "Width of the highlight band in logical pixels. When unset it defaults to about 45% of the box width and is recomputed on resize; setting it pins a fixed width.",
|
||||
"zh-CN": "高光带宽度,单位为逻辑像素。未设置时默认为框宽的约 45% 并在尺寸变化时重新计算;显式设置后固定为该值。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "angle",
|
||||
type: "number",
|
||||
default: "20",
|
||||
description: {
|
||||
en: "Tilt of the highlight band in degrees, shearing its center line across the height. Defaults to 20.",
|
||||
"zh-CN": "高光带倾斜角,单位为度,使反光中心线沿高度方向错切。默认为 20。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "phase",
|
||||
type: "number",
|
||||
default: "0",
|
||||
description: {
|
||||
en: "Sweep phase in [0, 1). Added for deterministic tests and manual control; while running the animation advances it by the duration.",
|
||||
"zh-CN": "高光带相位,取值范围 [0, 1),用于确定性测试或手动控制;运行状态下由 duration 持续推进。",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,3 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
export const spinnerContentFields: FieldData[] = [...widgetFields];
|
||||
@@ -0,0 +1,32 @@
|
||||
import { widgetFields, FieldData } from "./widget";
|
||||
|
||||
export const spinnerFields: FieldData[] = [
|
||||
...widgetFields,
|
||||
{
|
||||
name: "running",
|
||||
type: "boolean",
|
||||
default: "true",
|
||||
description: {
|
||||
en: "Whether the rotation animation is running. True by default.",
|
||||
"zh-CN": "是否播放旋转动画。默认为 true。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "speed",
|
||||
type: "number",
|
||||
default: "1",
|
||||
description: {
|
||||
en: "Rotation speed in revolutions per second.",
|
||||
"zh-CN": "旋转速度,单位为每秒转数 (rev/s)。",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "angle",
|
||||
type: "number",
|
||||
default: "0",
|
||||
description: {
|
||||
en: "Current rotation angle in degrees. While running, the animation drives this value.",
|
||||
"zh-CN": "当前旋转角度,单位为度。运行状态下由动画持续推进。",
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "page.tsx.h"
|
||||
#include "page.h"
|
||||
|
||||
typedef struct {
|
||||
zh_cn_widgets_shimmer_page_react_t base;
|
||||
// Add additional states to your component here
|
||||
// ...
|
||||
} zh_cn_widgets_shimmer_page_t;
|
||||
|
||||
static void zh_cn_widgets_shimmer_page_init(ui_widget_t *w)
|
||||
{
|
||||
ui_widget_add_data(w, zh_cn_widgets_shimmer_page_proto,
|
||||
sizeof(zh_cn_widgets_shimmer_page_t));
|
||||
|
||||
zh_cn_widgets_shimmer_page_react_init(w);
|
||||
// Write the initialization code for your component here
|
||||
// such as state initialization, event binding, etc
|
||||
// ...
|
||||
|
||||
zh_cn_widgets_shimmer_page_update(w);
|
||||
}
|
||||
|
||||
static zh_cn_widgets_shimmer_page_t *zh_cn_widgets_shimmer_page_get(
|
||||
ui_widget_t *w)
|
||||
{
|
||||
return ui_widget_get_data(w, zh_cn_widgets_shimmer_page_proto);
|
||||
}
|
||||
|
||||
static void zh_cn_widgets_shimmer_page_destroy(ui_widget_t *w)
|
||||
{
|
||||
// Write code here to destroy the relevant resources of the component
|
||||
// ...
|
||||
|
||||
zh_cn_widgets_shimmer_page_react_destroy(w);
|
||||
}
|
||||
|
||||
void zh_cn_widgets_shimmer_page_update(ui_widget_t *w)
|
||||
{
|
||||
zh_cn_widgets_shimmer_page_react_update(w);
|
||||
// Write code here to update other content of your component
|
||||
// ...
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_zh_cn_widgets_shimmer_page(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(
|
||||
zh_cn_widgets_shimmer_page_proto);
|
||||
}
|
||||
|
||||
void ui_register_zh_cn_widgets_shimmer_page(void)
|
||||
{
|
||||
zh_cn_widgets_shimmer_page_init_prototype();
|
||||
zh_cn_widgets_shimmer_page_proto->init =
|
||||
zh_cn_widgets_shimmer_page_init;
|
||||
zh_cn_widgets_shimmer_page_proto->destroy =
|
||||
zh_cn_widgets_shimmer_page_destroy;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <ui.h>
|
||||
|
||||
void ui_register_zh_cn_widgets_shimmer_page(void);
|
||||
|
||||
ui_widget_t *ui_create_zh_cn_widgets_shimmer_page(void);
|
||||
|
||||
void zh_cn_widgets_shimmer_page_update(ui_widget_t *w);
|
||||
|
||||
void ui_load_zh_cn_widgets_shimmer_page_resources(void);
|
||||
@@ -0,0 +1,105 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import CodeBlockCopy from "../../../components/code-block-copy";
|
||||
import ShimmerBasicDemo from "../../../examples/shimmer-basic/index";
|
||||
import ShimmerColorDemo from "../../../examples/shimmer-color/index";
|
||||
import ShimmerDurationDemo from "../../../examples/shimmer-duration/index";
|
||||
import ShimmerSpreadDemo from "../../../examples/shimmer-spread/index";
|
||||
import ShimmerAngleDemo from "../../../examples/shimmer-angle/index";
|
||||
import ShimmerRunningDemo from "../../../examples/shimmer-running/index";
|
||||
import FieldTable from "../../../components/field-table";
|
||||
import { shimmerFields } from "../../../widget-fields/shimmer";
|
||||
import { shimmerContentFields } from "../../../widget-fields/shimmer-content";
|
||||
|
||||
export default function ShimmerDocPage() {
|
||||
return (
|
||||
<Widget className="doc-page">
|
||||
<h1>Shimmer</h1>
|
||||
<p className="doc-page-desc">{`给文本、图标等内容叠加一道左右柔化、可倾斜的高光带,从左往右扫过;高光只落在内容的不透明像素上,内容本身保持原色。`}</p>
|
||||
<ShimmerBasicDemo />
|
||||
<Widget className="doc-section">
|
||||
<h2>适用场景</h2>
|
||||
<ul>
|
||||
<li><Text>{`[b]适用[/b]:让一段状态文本(图标或纯文字)带着柔和高光扫过,表示“进行中/加载”`}</Text></li>
|
||||
<li><Text>{`[b]适用[/b]:流式输出时给“正在生成”的提示文字加一层滑动高光`}</Text></li>
|
||||
<li><Text>{`[b]不适用[/b]:纯灰块的骨架占位(Shimmer 叠加在真实内容上,不生成占位骨架)`}</Text></li>
|
||||
<li><Text>{`[b]不适用[/b]:有明确百分比或已知时长的任务进度(用 [bgcolor=#eee] progress [/bgcolor])`}</Text></li>
|
||||
<li><Text>{`[b]不适用[/b]:无固定形状的全局忙碌指示(用 [bgcolor=#eee] spinner [/bgcolor])`}</Text></li>
|
||||
</ul>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>用法</h2>
|
||||
<Widget className="code-block" data-language="tsx" data-source="zh-CN/widgets/shimmer/0">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Shimmer[/color], [color=#8250df]ShimmerContent[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color]`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<p>{`Shimmer 是 C 代码自绘部件:先按原色完整合成内容,再把一道带倾斜的高光带裁剪到内容的不透明像素上叠加。高光本身可配置颜色、周期、宽度与倾斜角,通过部件属性或对应的 [bgcolor=#eee] ui_shimmer_set_* [/bgcolor] 接口设置:`}</p>
|
||||
<Widget className="code-block" data-language="tsx" data-source="zh-CN/widgets/shimmer/1">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`<[color=#8250df]Shimmer[/color] running={[color=#0550ae]true[/color]} duration={[color=#0550ae]2000[/color]} spread={[color=#0550ae]120[/color]} angle={[color=#0550ae]20[/color]} color=[color=#0a3069]"rgba(255,255,255,0.86)"[/color]>`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]<[color=#0550ae]Text[/color]>[/color]Generating response…[color=#116329]</[color=#0550ae]Text[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{` [color=#116329]</[color=#0550ae]ShimmerContent[/color]>[/color]`}</Text>
|
||||
<Text className="code-line">{`</[color=#8250df]Shimmer[/color]>`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>组合</h2>
|
||||
<p>{`使用以下组合来构建 [bgcolor=#eee] Shimmer [/bgcolor]:`}</p>
|
||||
<Widget className="code-block" data-language="text" data-source="zh-CN/widgets/shimmer/2">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TEXT</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`Shimmer`}</Text>
|
||||
<Text className="code-line">{`└── ShimmerContent`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>颜色</h2>
|
||||
<p>{`高光带叠加的颜色取自 [bgcolor=#eee] color [/bgcolor],其 alpha 就是扫过处的峰值强度。同一段灰字上叠不同颜色,扫过时会被“染”向各自的色相。`}</p>
|
||||
<ShimmerColorDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>时长</h2>
|
||||
<p>{`[bgcolor=#eee] duration [/bgcolor] 决定高光扫过一次所需的时间,单位为毫秒,默认 [bgcolor=#eee] 2000 [/bgcolor]。值越小扫得越快。`}</p>
|
||||
<ShimmerDurationDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>宽度</h2>
|
||||
<p>{`[bgcolor=#eee] spread [/bgcolor] 决定高光带的宽度(逻辑像素)。窄带像一道锐利反光,宽带则一次漫过整行,峰值强度不变、只是覆盖范围不同。`}</p>
|
||||
<ShimmerSpreadDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>倾斜</h2>
|
||||
<p>{`[bgcolor=#eee] angle [/bgcolor] 让高光带相对竖直方向倾斜(度数)。0° 时各行在同一列被扫到,倾斜后反光沿高度错切,先从顶部掠过再到下方。`}</p>
|
||||
<ShimmerAngleDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>关闭高亮</h2>
|
||||
<p>{`把 [bgcolor=#eee] running [/bgcolor] 设为 [bgcolor=#eee] false [/bgcolor] 即可关闭动画:此时不再叠加高光,内容按原色正常显示。`}</p>
|
||||
<ShimmerRunningDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>API 参考</h2>
|
||||
<h3>Shimmer</h3>
|
||||
<p>{`扫光容器,捕获 [bgcolor=#eee] ShimmerContent [/bgcolor] 子树;先按原色完整合成内容,再叠加一道可倾斜、左右渐隐的高光带并裁剪到内容不透明处。高光从左往右扫过,只在内容上显现。`}</p>
|
||||
<FieldTable fields={shimmerFields} locale="zh-CN" />
|
||||
<h3>ShimmerContent</h3>
|
||||
<p>{`被捕获的内容子树(如文本或图标加文字的状态行),作为 Shimmer 的直属子部件使用;省略时使用一个填满整行的默认占位块。Shimmer 默认块级、高度 20px,可用 [bgcolor=#eee] width [/bgcolor]/[bgcolor=#eee] height [/bgcolor] 覆盖。`}</p>
|
||||
<FieldTable fields={shimmerContentFields} locale="zh-CN" />
|
||||
</Widget>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
#include "page.tsx.h"
|
||||
#include "page.h"
|
||||
|
||||
typedef struct {
|
||||
zh_cn_widgets_spinner_page_react_t base;
|
||||
// Add additional states to your component here
|
||||
// ...
|
||||
} zh_cn_widgets_spinner_page_t;
|
||||
|
||||
static void zh_cn_widgets_spinner_page_init(ui_widget_t *w)
|
||||
{
|
||||
ui_widget_add_data(w, zh_cn_widgets_spinner_page_proto,
|
||||
sizeof(zh_cn_widgets_spinner_page_t));
|
||||
|
||||
zh_cn_widgets_spinner_page_react_init(w);
|
||||
// Write the initialization code for your component here
|
||||
// such as state initialization, event binding, etc
|
||||
// ...
|
||||
|
||||
zh_cn_widgets_spinner_page_update(w);
|
||||
}
|
||||
|
||||
static zh_cn_widgets_spinner_page_t *zh_cn_widgets_spinner_page_get(
|
||||
ui_widget_t *w)
|
||||
{
|
||||
return ui_widget_get_data(w, zh_cn_widgets_spinner_page_proto);
|
||||
}
|
||||
|
||||
static void zh_cn_widgets_spinner_page_destroy(ui_widget_t *w)
|
||||
{
|
||||
// Write code here to destroy the relevant resources of the component
|
||||
// ...
|
||||
|
||||
zh_cn_widgets_spinner_page_react_destroy(w);
|
||||
}
|
||||
|
||||
void zh_cn_widgets_spinner_page_update(ui_widget_t *w)
|
||||
{
|
||||
zh_cn_widgets_spinner_page_react_update(w);
|
||||
// Write code here to update other content of your component
|
||||
// ...
|
||||
}
|
||||
|
||||
ui_widget_t *ui_create_zh_cn_widgets_spinner_page(void)
|
||||
{
|
||||
return ui_create_widget_with_prototype(
|
||||
zh_cn_widgets_spinner_page_proto);
|
||||
}
|
||||
|
||||
void ui_register_zh_cn_widgets_spinner_page(void)
|
||||
{
|
||||
zh_cn_widgets_spinner_page_init_prototype();
|
||||
zh_cn_widgets_spinner_page_proto->init =
|
||||
zh_cn_widgets_spinner_page_init;
|
||||
zh_cn_widgets_spinner_page_proto->destroy =
|
||||
zh_cn_widgets_spinner_page_destroy;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <ui.h>
|
||||
|
||||
void ui_register_zh_cn_widgets_spinner_page(void);
|
||||
|
||||
ui_widget_t *ui_create_zh_cn_widgets_spinner_page(void);
|
||||
|
||||
void zh_cn_widgets_spinner_page_update(ui_widget_t *w);
|
||||
|
||||
void ui_load_zh_cn_widgets_spinner_page_resources(void);
|
||||
@@ -0,0 +1,80 @@
|
||||
import { Text, Widget } from "@lcui/react";
|
||||
import CodeBlockCopy from "../../../components/code-block-copy";
|
||||
import SpinnerBasicDemo from "../../../examples/spinner-basic/index";
|
||||
import SpinnerCustomContentDemo from "../../../examples/spinner-custom-content/index";
|
||||
import SpinnerSizeDemo from "../../../examples/spinner-size/index";
|
||||
import SpinnerRunningDemo from "../../../examples/spinner-running/index";
|
||||
import FieldTable from "../../../components/field-table";
|
||||
import { spinnerFields } from "../../../widget-fields/spinner";
|
||||
import { spinnerContentFields } from "../../../widget-fields/spinner-content";
|
||||
|
||||
export default function SpinnerDocPage() {
|
||||
return (
|
||||
<Widget className="doc-page">
|
||||
<h1>Spinner</h1>
|
||||
<p className="doc-page-desc">{`用于表达“加载中”的自绘旋转指示器部件。`}</p>
|
||||
<SpinnerBasicDemo />
|
||||
<Widget className="doc-section">
|
||||
<h2>适用场景</h2>
|
||||
<ul>
|
||||
<li><Text>{`[b]适用[/b]:等待异步结果、无法预知进度的加载状态`}</Text></li>
|
||||
<li><Text>{`[b]适用[/b]:按钮、卡片等局部区域的忙碌指示`}</Text></li>
|
||||
<li><Text>{`[b]不适用[/b]:有明确百分比或已知时长的任务进度(用 [bgcolor=#eee] progress [/bgcolor])`}</Text></li>
|
||||
</ul>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>用法</h2>
|
||||
<Widget className="code-block" data-language="tsx" data-source="zh-CN/widgets/spinner/0">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`[color=#cf222e]import[/color] { [color=#8250df]Spinner[/color], [color=#8250df]SpinnerContent[/color] } [color=#cf222e]from[/color] [color=#0a3069]"@lcui/react"[/color]`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="code-block" data-language="tsx" data-source="zh-CN/widgets/spinner/1">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TypeScript</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`<[color=#8250df]Spinner[/color] running={[color=#0550ae]true[/color]} speed={[color=#0550ae]1[/color]} />`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>组合</h2>
|
||||
<p>{`使用以下组合来构建 [bgcolor=#eee] Spinner [/bgcolor]:`}</p>
|
||||
<Widget className="code-block" data-language="text" data-source="zh-CN/widgets/spinner/2">
|
||||
<Widget className="code-block-header">
|
||||
<Text className="code-block-title">TEXT</Text>
|
||||
</Widget>
|
||||
<Widget className="code-block-body">
|
||||
<CodeBlockCopy />
|
||||
<Text className="code-line">{`Spinner`}</Text>
|
||||
<Text className="code-line">{`└── SpinnerContent`}</Text>
|
||||
</Widget>
|
||||
</Widget>
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>示例</h2>
|
||||
<h3>自定义内容</h3>
|
||||
<SpinnerCustomContentDemo />
|
||||
<h3>不同尺寸</h3>
|
||||
<SpinnerSizeDemo />
|
||||
<h3>运行状态控制</h3>
|
||||
<SpinnerRunningDemo />
|
||||
</Widget>
|
||||
<Widget className="doc-section">
|
||||
<h2>API 参考</h2>
|
||||
<h3>Spinner</h3>
|
||||
<p>{`旋转指示器容器,捕获 [bgcolor=#eee] SpinnerContent [/bgcolor] 子树并绕其中心旋转绘制。默认自带 16×16 尺寸,可用 [bgcolor=#eee] width [/bgcolor]/[bgcolor=#eee] height [/bgcolor] 覆盖。`}</p>
|
||||
<FieldTable fields={spinnerFields} locale="zh-CN" />
|
||||
<h3>SpinnerContent</h3>
|
||||
<p>{`被旋转捕获的内容子树,作为 Spinner 的直接子部件使用;省略时使用默认的圆环,其中一边透明形成随旋转扫过的缺口。`}</p>
|
||||
<FieldTable fields={spinnerContentFields} locale="zh-CN" />
|
||||
</Widget>
|
||||
</Widget>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "widgets/button.h"
|
||||
#include "widgets/anchor.h"
|
||||
#include "widgets/canvas.h"
|
||||
#include "widgets/spinner.h"
|
||||
#include "widgets/shimmer.h"
|
||||
#include "widgets/progress.h"
|
||||
#include "widgets/scrollarea.h"
|
||||
#include "widgets/scrollbar.h"
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* include/LCUI/widgets/shimmer.h: -- LCUI's Shimmer widget
|
||||
*
|
||||
* Copyright (c) 2026, Liu Chao <hello@lcui.dev> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found
|
||||
* in the LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_SHIMMER_H
|
||||
#define LCUI_INCLUDE_WIDGETS_SHIMMER_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
/*
|
||||
* A self-drawn effect that sweeps a soft highlight across real content.
|
||||
*
|
||||
* The shimmer captures its `shimmer-content` subtree into a reusable offscreen
|
||||
* buffer (retaining its alpha as a mask), composites that content at full
|
||||
* strength so it keeps its original colours, then adds a tilted, gradient
|
||||
* sheen band on top. The band is masked to the content's alpha, so the
|
||||
* highlight only lands on the content's opaque pixels and fades out at its
|
||||
* left and right edges and across its tilt. `color` supplies the highlight
|
||||
* hue and its alpha the peak strength; `duration` the time of one sweep;
|
||||
* `spread` the band width; `angle` its tilt. With `running` set to false the
|
||||
* content is shown as-is, with no sheen.
|
||||
*
|
||||
* The `shimmer-content` child is a real child of the shimmer but is styled
|
||||
* offscreen (position: absolute; left/top: -100%) so the normal window render
|
||||
* path culls it while the offscreen capture still records it. A shimmer created
|
||||
* without an explicit `shimmer-content` child gets a default one so it is
|
||||
* immediately visible; callers and TSX may declare their own.
|
||||
*/
|
||||
|
||||
/* Create a shimmer widget with a default `shimmer-content` subtree. */
|
||||
LCUI_API ui_widget_t *ui_create_shimmer(void);
|
||||
|
||||
/* Start or stop the sweep animation. Running is on by default; when off the
|
||||
* content is composited with no sheen added. */
|
||||
LCUI_API void ui_shimmer_set_running(ui_widget_t *w, bool running);
|
||||
|
||||
/* Set the highlight colour that is overlaid on the content's opaque pixels;
|
||||
* its alpha is the peak strength of the sheen. Defaults to a semi-transparent
|
||||
* white. */
|
||||
LCUI_API void ui_shimmer_set_color(ui_widget_t *w, pd_color_t color);
|
||||
|
||||
/* Set the time for one full sweep in milliseconds. Defaults to 2000. */
|
||||
LCUI_API void ui_shimmer_set_duration(ui_widget_t *w, unsigned ms);
|
||||
|
||||
/* Set the highlight band width in logical pixels; when unset it defaults to
|
||||
* about 45% of the box width, recomputed on resize. */
|
||||
LCUI_API void ui_shimmer_set_spread(ui_widget_t *w, float px);
|
||||
|
||||
/* Set the tilt of the highlight band in degrees. Defaults to 20. */
|
||||
LCUI_API void ui_shimmer_set_angle(ui_widget_t *w, float degrees);
|
||||
|
||||
/* Set the sweep phase in [0, 1); while running the animation overrides it.
|
||||
* Added for deterministic tests and previews. */
|
||||
LCUI_API void ui_shimmer_set_phase(ui_widget_t *w, float phase);
|
||||
|
||||
/* Replace the direct `shimmer-content` child with the given subtree. */
|
||||
LCUI_API void ui_shimmer_set_content(ui_widget_t *w, ui_widget_t *content);
|
||||
|
||||
LCUI_API void ui_register_shimmer(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif /* LCUI_INCLUDE_WIDGETS_SHIMMER_H */
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* include/LCUI/widgets/spinner.h: -- LCUI's Spinner widget
|
||||
*
|
||||
* Copyright (c) 2026, Liu Chao <hello@lcui.dev> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found
|
||||
* in the LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef LCUI_INCLUDE_WIDGETS_SPINNER_H
|
||||
#define LCUI_INCLUDE_WIDGETS_SPINNER_H
|
||||
|
||||
#include <LCUI/common.h>
|
||||
#include <ui.h>
|
||||
|
||||
LCUI_BEGIN_HEADER
|
||||
|
||||
/*
|
||||
* A self-drawn rotating loading indicator.
|
||||
*
|
||||
* The spinner captures its `spinner-content` subtree into a reusable offscreen
|
||||
* buffer and composites it back to the window rotated around the content box
|
||||
* center. The `spinner-content` child is a real child of the spinner but is
|
||||
* styled offscreen (position: absolute; left/top: -100000px) so the normal
|
||||
* window render path culls it while the offscreen capture still records it.
|
||||
*
|
||||
* A spinner created without an explicit `spinner-content` child gets a default
|
||||
* one so it is immediately visible; callers and TSX may declare their own.
|
||||
*/
|
||||
|
||||
/* Create a spinner widget with a default `spinner-content` subtree. */
|
||||
LCUI_API ui_widget_t *ui_create_spinner(void);
|
||||
|
||||
/* Start or stop the rotation animation. Running is on by default. */
|
||||
LCUI_API void ui_spinner_set_running(ui_widget_t *w, bool running);
|
||||
|
||||
/* Set the rotation speed in revolutions per second (default 1.0). */
|
||||
LCUI_API void ui_spinner_set_speed(ui_widget_t *w, float revolutions_per_sec);
|
||||
|
||||
/* Replace the direct `spinner-content` child with the given subtree. */
|
||||
LCUI_API void ui_spinner_set_content(ui_widget_t *w, ui_widget_t *content);
|
||||
|
||||
/* Set the rotation angle in degrees; while running the animation overrides it.
|
||||
*/
|
||||
LCUI_API void ui_spinner_set_angle(ui_widget_t *w, double degrees);
|
||||
|
||||
LCUI_API void ui_register_spinner(void);
|
||||
|
||||
LCUI_END_HEADER
|
||||
|
||||
#endif /* LCUI_INCLUDE_WIDGETS_SPINNER_H */
|
||||
@@ -17,6 +17,8 @@ void lcui_widgets_init(void)
|
||||
ui_register_portal();
|
||||
ui_register_text();
|
||||
ui_register_canvas();
|
||||
ui_register_spinner();
|
||||
ui_register_shimmer();
|
||||
ui_register_anchor();
|
||||
ui_register_button();
|
||||
ui_register_icon();
|
||||
|
||||
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* src/widgets/draw_backend.h: internal drawing seam for self-drawn widgets
|
||||
*
|
||||
* Copyright (c) 2026, Liu Chao <hello@lcui.dev> All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* This file is part of LCUI, distributed under the MIT License found
|
||||
* in the LICENSE.TXT file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#ifndef SRC_WIDGETS_DRAW_BACKEND_H
|
||||
#define SRC_WIDGETS_DRAW_BACKEND_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <pandagl.h>
|
||||
#include <ui.h>
|
||||
|
||||
/* An opaque offscreen surface. It owns a backend-specific pixel buffer (an
|
||||
* ARGB canvas internally) and its own physical size derived from a logical
|
||||
* size multiplied by the active device scale. Widget code never sees the
|
||||
* pixel buffer or the scale: it only names surfaces and works in logical
|
||||
* coordinates. The concrete type lives solely in the software backend. */
|
||||
typedef struct ui_draw_surface ui_draw_surface_t;
|
||||
|
||||
/* Allocate an empty surface with no backing until resized. */
|
||||
ui_draw_surface_t *ui_draw_surface_create(void);
|
||||
|
||||
/* Release a surface and its backing. Safe to call with NULL. */
|
||||
void ui_draw_surface_destroy(ui_draw_surface_t *s);
|
||||
|
||||
/* Resize the surface so its backing covers ceil(logical * device_scale) in
|
||||
* both axes. The backing is supersampled internally (an integer multiple of
|
||||
* the device resolution) to improve the quality of rotation and compositing;
|
||||
* callers still work purely in device pixels, and a supersampled surface is
|
||||
* box-downsampled back to device resolution when it is blended onto a target.
|
||||
* The buffer is (re)allocated only when the physical size changes; otherwise
|
||||
* this is a no-op and returns 0. Content is not preserved across a resize.
|
||||
* Returns 1 when the backing was rebuilt, 0 when unchanged. */
|
||||
int ui_draw_surface_resize(ui_draw_surface_t *s, float logical_w,
|
||||
float logical_h);
|
||||
|
||||
/* Report the logical size the surface was last resized to. Returns 0 and
|
||||
* fills w/h when the surface has a positive physical size, else -1. */
|
||||
int ui_draw_surface_logical_size(const ui_draw_surface_t *s, float *w,
|
||||
float *h);
|
||||
|
||||
/* Capture a widget subtree into dst, retaining the subtree's alpha. dst must
|
||||
* already be resized to the target size; this performs no allocation and does
|
||||
* not touch the layout. The subtree is rasterised at the surface's internal
|
||||
* supersampled resolution (the active device scale times the supersample
|
||||
* factor) so the backing is filled at full quality. Returns 0 on success. */
|
||||
int ui_draw_capture(ui_widget_t *widget, ui_draw_surface_t *dst);
|
||||
|
||||
/* Rotate src around its center by radians into dst. dst must already be
|
||||
* resized to the same physical size as src; the existing backing is reused so
|
||||
* this allocates nothing. src and dst must be different surfaces. Returns 0 on
|
||||
* success. */
|
||||
int ui_draw_rotate_into(const ui_draw_surface_t *src, ui_draw_surface_t *dst,
|
||||
double radians);
|
||||
|
||||
/* Fill the entire surface with transparent pixels. Returns 0 on success. */
|
||||
int ui_draw_clear(ui_draw_surface_t *dst);
|
||||
|
||||
/* Fill a logical-rectangle with an RGBA color, converting to physical pixels
|
||||
* internally. dst must already be resized. Returns 0 on success. */
|
||||
int ui_draw_fill_rect(ui_draw_surface_t *dst, float x_logical, float y_logical,
|
||||
float w_logical, float h_logical, unsigned char r,
|
||||
unsigned char g, unsigned char b, unsigned char a);
|
||||
|
||||
/* Fill dst with a tilted, gradient highlight "sheen": a soft-edged band of the
|
||||
* given color whose alpha peaks at `color.a` along the band's center line and
|
||||
* fades smoothly to 0 at both sides, so it reads as a sliding sheen rather than
|
||||
* a solid slab. The band is centered horizontally at `center_x_logical` (its
|
||||
* middle row), `spread_logical` wide, and rotated by `angle_deg` about that
|
||||
* middle row so its center line is sheared across the height. The whole surface
|
||||
* is written every call (transparent outside the band), evaluated per physical
|
||||
* pixel with no allocation; dst must already be resized. Returns 0 on success.
|
||||
*/
|
||||
int ui_draw_fill_sheen(ui_draw_surface_t *dst, pd_color_t color,
|
||||
float center_x_logical, float spread_logical,
|
||||
float angle_deg);
|
||||
|
||||
/* Copy src into dst (same physical size) into dst's existing backing. Returns
|
||||
* 0 on success. */
|
||||
int ui_draw_copy(const ui_draw_surface_t *src, ui_draw_surface_t *dst);
|
||||
|
||||
/* Multiply dst alpha by mask alpha in place (destination-in). Both surfaces
|
||||
* must be valid; this allocates nothing. Returns 0 on success. */
|
||||
int ui_draw_mask_into(const ui_draw_surface_t *mask, ui_draw_surface_t *dst);
|
||||
|
||||
/* Lighten dst toward the sheen's colour WITHOUT touching dst's alpha: for each
|
||||
* pixel, t = sheen.alpha/255 and dst.rgb = dst.rgb*(1-t) + sheen.rgb*t, while
|
||||
* dst.alpha is left exactly as-is. This is the highlight-composite for shimmer:
|
||||
* it recolours the content's ink (including antialiased edges) but never
|
||||
* rewrites their coverage, so text edges do not get a resampled halo. Both
|
||||
* surfaces must be the same physical size and valid; allocates nothing. Returns
|
||||
* 0 on success. */
|
||||
int ui_draw_sheen_over(ui_draw_surface_t *dst, const ui_draw_surface_t *sheen);
|
||||
|
||||
/* Composite a surface onto a paint target at (x, y) in target pixel space,
|
||||
* scaling the surface's source alpha by opacity (typically 1.0). Coordinates
|
||||
* are device pixels: a supersampled surface is box-downsampled to device
|
||||
* resolution as part of the blend. Returns 0 on success. */
|
||||
int ui_draw_blend_surface(pd_context_t *target, const ui_draw_surface_t *src,
|
||||
int x, int y, bool with_alpha, float opacity);
|
||||
|
||||
/* Composite a sub-rectangle [src_x, src_y, src_w, src_h] of a surface onto a
|
||||
* paint target at the non-negative offset (dst_x, dst_y). The source rect is in
|
||||
* device pixels and is box-downsampled from the backing when the surface is
|
||||
* supersampled. This is the partial-repaint-safe form: pd_canvas_mix does not
|
||||
* skip the source rows that a negative offset would push above the target, so
|
||||
* blitting the whole box surface at a negative offset smears the top of the
|
||||
* surface into the visible sub-region. Callers pass an already-clipped
|
||||
* destination offset. No allocation. Returns 0 on success; a degenerate rect is
|
||||
* a no-op returning 0.
|
||||
*/
|
||||
int ui_draw_blend_surface_rect(pd_context_t *target,
|
||||
const ui_draw_surface_t *src, int src_x,
|
||||
int src_y, int src_w, int src_h, int dst_x,
|
||||
int dst_y, bool with_alpha, float opacity);
|
||||
|
||||
/* Composite src onto dst at offset (0, 0) in dst's own pixel space, keeping
|
||||
* dst's pixels under src's alpha (dst is typically a transparent display
|
||||
* buffer being built up from scratch layers). src is clipped to dst's bounds;
|
||||
* opacity scales src's source alpha like ui_draw_blend_surface. Both surfaces
|
||||
* must be valid; this allocates nothing. Returns 0 on success. */
|
||||
int ui_draw_surface_composite(ui_draw_surface_t *dst,
|
||||
const ui_draw_surface_t *src, bool with_alpha,
|
||||
float opacity);
|
||||
|
||||
/* A cached display layer: it owns one final-composition surface ("display")
|
||||
* at the physical size for a logical box, plus a dirty flag. Self-drawn
|
||||
* widgets use it as a render gate: run the full render pass into the display
|
||||
* surface only when ui_draw_layer_needs_render() says so, then present the
|
||||
* dirty sub-rectangle of the cache to the paint target. Presenting never
|
||||
* re-renders, so a widget whose overlap with the dirty region changes (for
|
||||
* example another window uncovers part of it) blits the cache instead of
|
||||
* paying for a full redraw. Widget code never sees the backing or the scale. */
|
||||
typedef struct ui_draw_layer ui_draw_layer_t;
|
||||
|
||||
/* Allocate an empty layer with no display backing and dirty set (so the first
|
||||
* needs_render() is true). */
|
||||
ui_draw_layer_t *ui_draw_layer_create(void);
|
||||
|
||||
/* Release a layer and its display surface. Safe to call with NULL. */
|
||||
void ui_draw_layer_destroy(ui_draw_layer_t *l);
|
||||
|
||||
/* Ensure the display surface covers ceil(logical * device_scale) for the
|
||||
* given logical box. When the physical size (or scale) changes the backing is
|
||||
* rebuilt and the layer is marked dirty; a stable frame is a cheap no-op that
|
||||
* allocates nothing. Returns 1 when the backing changed, 0 when not. */
|
||||
int ui_draw_layer_ensure(ui_draw_layer_t *l, float logical_w, float logical_h);
|
||||
|
||||
/* Mark the cache stale: call whenever the widget's content, geometry, or
|
||||
* animation state changes so the next paint runs the full render pass. */
|
||||
void ui_draw_layer_invalidate(ui_draw_layer_t *l);
|
||||
|
||||
/* Whether the full render pass must run before the next present. */
|
||||
int ui_draw_layer_needs_render(ui_draw_layer_t *l);
|
||||
|
||||
/* The display surface, as the widget's full-render target. The render writes
|
||||
* the final composited result into it, including the widget's own alpha;
|
||||
* transparent places must stay transparent. Valid after ensure() succeeded. */
|
||||
ui_draw_surface_t *ui_draw_layer_surface(ui_draw_layer_t *l);
|
||||
|
||||
/* Clear the dirty flag once the full render pass has written the display
|
||||
* surface. */
|
||||
void ui_draw_layer_mark_rendered(ui_draw_layer_t *l);
|
||||
|
||||
/* Blit the intersection of the display surface with the paint target's dirty
|
||||
* rect, at a non-negative target offset, onto paint. box_x/box_y/box_w/box_h
|
||||
* are the widget's content box in physical pixels of its canvas coordinate
|
||||
* space (the same origin as the widget's paint ox/oy/area). Nothing outside
|
||||
* the box is drawn; an empty intersection draws nothing. The cache is never
|
||||
* re-rendered here: if the widget skipped its full pass because
|
||||
* needs_render() was false, this blits the cached pixels. Returns 1 when
|
||||
* something was blitted, 0 otherwise. */
|
||||
int ui_draw_layer_present(ui_draw_layer_t *l, pd_context_t *paint, int box_x,
|
||||
int box_y, int box_w, int box_h);
|
||||
|
||||
#endif /* SRC_WIDGETS_DRAW_BACKEND_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user