Skip to content

Commit 91594c4

Browse files
authored
Merge pull request #58 from sarmadka/main
Added EmbeddedSvg component.
2 parents 1a094bf + b6a1eed commit 91594c4

6 files changed

Lines changed: 80 additions & 0 deletions

File tree

Doc/components.ar.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,5 +448,41 @@ handler this.setTransition(pushing: StackTransition, popping: StackTransition);
448448

449449
تستعمل هذه الطريقة لتحديد الانتقال لحالتي الإضافة والإزالة.
450450

451+
452+
### إسـفيجي_ضمنية (EmbeddedSvg)
453+
454+
تستخدم لتضمين صورة SVG ضمن البرنامج التنفيذي بدل تحميلها بعد بدء البرنامج. هذا الصنف قالب يستلم
455+
معطى واحد وهو المسار إلى ملف SVG.
456+
457+
```
458+
صـنف إسـفيجي_ضمنية [مسار_إسفيجي: نص]
459+
```
460+
461+
<div dir=ltr>
462+
463+
```
464+
class EmbeddedSvg [filename: string]
465+
```
466+
467+
</div>
468+
469+
المثال التالي يوضح طريقة الاستخدام:
470+
471+
```
472+
صـندوق().{
473+
أضف_فروع({ إسـفيجي_ضمنية["المارد/أيقونة.svg"]() })؛
474+
}
475+
```
476+
477+
<div dir=ltr>
478+
479+
```
480+
Box().{
481+
addChildren({ EmbeddedSvg["resources/icon.svg"] });
482+
}
483+
```
484+
485+
</div>
486+
451487
</div>
452488

Doc/components.en.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,21 @@ handler this.setTransition(pushing: StackTransition, popping: StackTransition);
287287

288288
This method is used to specify the transition for pushing and popping operations.
289289

290+
291+
### EmbeddedSvg
292+
293+
Used to embed an SVG image within the executalbe rather than being fetched after the program is
294+
started. This template class takes one argument, which is a path to an SVG file.
295+
296+
```
297+
class EmbeddedSvg [filename: string]
298+
```
299+
300+
The following example shows how to use this component:
301+
302+
```
303+
Box().{
304+
addChildren({ EmbeddedSvg["resources/icon.svg"] });
305+
}
306+
```
307+

WebPlatform.alusus

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import "WebPlatform/Components/Switcher";
5555
import "WebPlatform/Components/RoutingSwitcher";
5656
import "WebPlatform/Components/Stack";
5757
import "WebPlatform/Components/RoutingStack";
58+
import "WebPlatform/Components/EmbeddedSvg";
5859
import "WebPlatform/Resources/ImageResource";
5960
import "WebPlatform/Resources/CanvasResource";
6061
import "WebPlatform/Resources/AudioResource";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@merge module WebPlatform {
2+
//==========================================================================
3+
// EmbeddedSvg
4+
// Used to embed an SVG within the compiled code.
5+
class EmbeddedSvg [filename: string] {
6+
@injection def component: Component;
7+
8+
handler this~init() {
9+
this.view = DocView().{
10+
setHtml(String(1, stringLiteralFromFile[filename]));
11+
}
12+
}
13+
14+
handler this_type(): SrdRef[this_type] {
15+
return SrdRef[this_type]().{ alloc()~init() };
16+
}
17+
}
18+
}

WebPlatform/Utils/string_operations.alusus

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@
2828
}
2929
return result;
3030
}
31+
32+
macro stringLiteralFromFile [filename] preprocess {
33+
def str: String = Fs.readFile(filename);
34+
Spp.astMgr.insertAst(Core.Data.Ast.StringLiteral(str));
35+
}
3136
}

مـنصة_ويب.أسس

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,8 @@
745745
عرف حدد_الانتقال: لقب setTransition؛
746746
}
747747

748+
عرف إسـفيجي_ضمنية: لقب EmbeddedSvg؛
749+
748750
//==========================================================================
749751
// موارد
750752

0 commit comments

Comments
 (0)