Skip to content

Commit a6432a3

Browse files
committed
Initial commit
0 parents  commit a6432a3

File tree

148 files changed

+2070
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+2070
-0
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public/
2+
resources/
3+

.hugo_build.lock

Whitespace-only changes.

archetypes/default.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "{{ replace .Name "-" " " | title }}"
3+
date: {{ .Date }}
4+
draft: true
5+
---
6+

big_capy_logo.png

86.4 KB
Loading

capy2.png

18.8 KB
Loading

capy2_transparent.png

36.7 KB
Loading

capy_big.png

123 KB
Loading

capy_big.xcf

638 KB
Binary file not shown.

capy_big2.png

64.1 KB
Loading

capy_big2.xcf

98.9 KB
Binary file not shown.

capy_big2_dark.png

67.2 KB
Loading

capy_logo.png

79.9 KB
Loading

capy_logo.xcf

574 KB
Binary file not shown.

capy_no_cadre.png

49.6 KB
Loading

capy_no_cadre.xcf

593 KB
Binary file not shown.

capy_open_graph.png

116 KB
Loading

capy_open_graph.xcf

775 KB
Binary file not shown.

capybara.jpg

66.8 KB
Loading

config.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
baseURL = 'https://capy-ui.org'
2+
languageCode = 'en-us'
3+
title = 'Capy UI — Cross Platform GUI Toolkit'
4+
theme = 'capy'
5+
enableEmoji = true
6+
[markup.goldmark.renderer]
7+
unsafe = true
8+
9+
[outputs]
10+
home = ['HTML']

content/blog/capy-0.3.md

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
---
2+
title: "Capy 0.3 Release Notes"
3+
authors: ["Zen1th"]
4+
date: 2023-02-12T10:35:14+01:00
5+
tags: ["capy", "release"]
6+
---
7+
8+
**Reminder: Capy is NOT ready for use in production as I'm still making breaking changes**
9+
10+
[Capy](https://github.com/capy-ui/capy) is a **GUI framework** for Zig made with performance, cross-compilation and native widgets in mind. The goal is to be able to seamlessly cross-compile from any platform to any other one. This includes Windows, Linux, WebAssembly, and soon will include macOS, Android and iOS.
11+
12+
It's been 6 months since the 0.2 update, but Capy is getting forward at its own slow pace.
13+
14+
![image 'showcasing' capy's features](/img/balls-0.3.png)
15+
*[Balls](https://github.com/capy-ui/capy/blob/master/examples/balls.zig)*
16+
17+
## Improved the build process
18+
19+
The build process has been simplified as much as possible.
20+
21+
The 50-line `install()` function you had to copy has been removed. So has the requirement to supply the path where Capy has been installed. Alongside that, a [template](https://github.com/capy-ui/zig-template) has been added which allows to get started with Capy much faster than before.
22+
23+
In practice this means you can do that:
24+
25+
```zig
26+
// Usual build functions..
27+
const exe = b.addExecutable("my-gui-app", "src/main.zig");
28+
exe.setTarget(target);
29+
exe.setBuildMode(mode);
30+
31+
// one-liner for using Capy
32+
try deps.imports.capy.install(exe, .{});
33+
34+
// Usual build functions..
35+
exe.install();
36+
```
37+
38+
## New components
39+
40+
I experimented with using Zig's comptime abilities so that one method could be used to
41+
get, set, and bind a property like if we were in a dynamic language.
42+
This allows to switch from `setText("Hello, World")` to `set("text", "Hello, World")`.
43+
I'm still wondering if this is better and whether `setProperty` would be a better name for it,
44+
but this atleast removes the burden of having to create 3 functions each time you add a property
45+
to a component.
46+
47+
- Added `enabled` property to Button
48+
- Added `CheckBox` component
49+
- Added `Align` component.
50+
51+
It's aim is to replace the former `alignX` and `alignY` properties which
52+
were a confusing bit of API design. Adding Align made the API should now be clearer and easier to understand,
53+
while also simplyfing the implementation of layouting.
54+
55+
```zig
56+
Button(.{ .alignX = 0.5 })
57+
```
58+
becomes
59+
```zig
60+
Align(.{ .x = 0.5 }, Button(.{}))
61+
```
62+
63+
- Added an experimental for-each component (`ColumnList`). You can see it used in the [hacker-news example](https://github.com/capy-ui/capy/blob/master/examples/hacker-news.zig) but
64+
it is currently highly experimental.
65+
- Added ScrollView, which allows to make any component scrollable
66+
67+
## Wrapping containers
68+
Added `wrapping` property, this allows the elements to wrap instead of going off to infinity.
69+
70+
```zig
71+
capy.Row(.{ .wrapping = true, .spacing = 5 }, .{
72+
capy.Button(.{ .label = "Button #0" }),
73+
capy.Button(.{ .label = "Button #1" }),
74+
capy.Button(.{ .label = "Button #2" }),
75+
capy.Button(.{ .label = "Button #3" }),
76+
// ...
77+
})
78+
```
79+
80+
Here's a row with `wrapping` set to `false`, aka old behaviour:
81+
![container with wrapping=false](/img/wrapping-false-0.3.png)
82+
And here is it with `wrapping` set to `true`:
83+
![container with wrapping=true](/img/wrapping-true-0.3.png)
84+
85+
Notice how with `wrapping` set to `false` (equivalent to the old behaviour) components take all the height of the Row, because the Row is only laying them out horizontally, so it gives them all the vertical space.
86+
However, with `wrapping` set to `true`, components may wrap over to bottom which means that Row is laying them out horizontally and vertically, so it gives components their preferred size instead.
87+
88+
Hence, in both pictures, the buttons have the same width.
89+
90+
## Optimized DataWrapper
91+
92+
DataWrapper is what is responsible of giving data binding, animations and other [neat things](https://capy-ui.org/docs/guides/data-binding) to Capy. It's usually used whenever a property is required. This means that it's often used through the entire codebase and can end up in components that might be instantiated hundreds of times. Under this, it's logical to try to reduce the size overhead it gives.
93+
Thus, the data structures of DataWrapper were optimized for size, this resulted in
94+
the overhead being reduced, from 152 bytes down to 128 bytes.
95+
96+
On the other hand, the`dependOn` function was added to DataWrapper. It's meant for values that depend on other values, while avoiding having to manually setup tons of change listeners. This can be used for things like a 'Submit' button, which can dependOn all fields being valid. You can quickly see how it can be used in the [flight booker example](https://github.com/capy-ui/capy/blob/master/examples/7gui/flight-booker.zig)
97+
98+
Optional values can also now be animated using `animate(...)`
99+
100+
### win32 fixes
101+
The native integration for High-DPI was added and is now functional. The only step remaining is to correctly
102+
implement the actual pixel scaling. When it's done, there won't be any change necessary on the
103+
application side as `Window.source_dpi` is already used well for that.
104+
105+
Among that, there were a lot of bug fixes.
106+
- The background is now correctly cleared on resize ([c32e0e1](https://github.com/capy-ui/capy/commit/c32e0e16d62d0649deed63ba3b872e37c5c0f4b4))
107+
- Improved performance and fixed flickering ([352a959](https://github.com/capy-ui/capy/commit/352a95974c4df0f109231100f292efd44b0bb435))
108+
- You can now use `std.log` in Debug builds ([aed5e0f](https://github.com/capy-ui/capy/commit/aed5e0f28eb31bf37547707d8da999a4ebdb4b2f))
109+
- Caption font is now used, this replaces win32's default GUI font that came from Windows 95 ([9bb59a1](https://github.com/capy-ui/capy/commit/9bb59a190089f693dba51e8c8e732f4d743fcbf1))
110+
111+
![image of a capy app on win32](/img/calculator-win32.png)
112+
113+
## First steps on Android
114+
Recently, the first progress towards an Android backend were made.
115+
116+
The Android backend is something I couldn't have managed to do without the efforts the Zig community put
117+
in [ZigAndroidTemplate](https://github.com/MasterQ32/ZigAndroidTemplate), so thanks to them.
118+
119+
Secondly, Android is absolutely not made for native code that creates native views.
120+
But JNI truly can let you do anything Java can.
121+
122+
<br>
123+
<img src="/img/capy-android-two-views.jpg" alt="We've got the TextView and the Button showing!" style="width: 15em;"></img>
124+
<br>
125+
126+
Currently, it only supports TextField, Button, Canvas and Container.
127+
128+
For more information, see the [blog post](/blog/porting-capy-to-android) detailing the port.
129+
130+
## Baby steps on macOS
131+
As always, for macOS, I'm aiming at being able to build your app from Windows/Linux/macOS to macOS.
132+
So far, the plan is to download the macOS SDK automatically in `build.zig`, which is something you can do
133+
as long as you accept the [EULA](https://www.apple.com/legal/sla/docs/xcode.pdf). However this has not
134+
been done yet.
135+
136+
Currently, what has been done is that, if you have a macOS SDK in the `macos-sdk` folder, you can build a basic non-functioning app. It doesn't work, but it calls the `NSWindow` APIs! We're onto a first step!
137+
138+
## A note about the WebAssembly backend
139+
More functions were implemented on the WebAssembly, this quite notably allowed
140+
to run the [OpenStreetMap viewer example](/zig-osm/) online, without any
141+
platform-specific code.
142+
143+
![openstreetmap viewer made in capy running on web](/img/osm-viewer-gtk.png)
144+
145+
However, since Capy upgraded to the new Zig self-hosted compiler and it still hasn't yet reimplemented
146+
async, the backend is currently unusable due to this compiler regression.
147+
148+
- Add viewport meta tag to run on mobile devices ([68dfda0](https://github.com/capy-ui/capy/commit/68dfda0eda529b915bc37d327320bab1af187224))
149+
150+
151+
Lastly, an experimental HTTP module had been added ([03993dd](https://github.com/capy-ui/capy/commit/03993dd10e98d2d674708496ff2d9942f71666cd)) that used the Fetch API on WebAssembly.
152+
On desktop, it used [zfetch](https://github.com/truemedian/zfetch) but when it was archived by its
153+
creator, I had to switch to another library. Sadly no library was as simple to build as zfetch
154+
(that is where a simple `zig build run` is enough to setup everything quick enough and on all major
155+
platforms).
156+
I'm currently counting on Zig's efforts to implement a TLS library and an HTTP client in the standard library. I'll be able to switch once the changes brought in [#13980](https://github.com/ziglang/zig/pull/13980) are stabilized.
157+
158+
## Documentation
159+
160+
The documentation for Capy has switched from GitHub Wiki to a Docusaurus instance.
161+
It's still editable by the public on the [capy-ui/documentation](https://github.com/capy-ui/documentation)
162+
repository.

content/blog/capy-0.4.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: "Capy 0.4 Release Notes"
3+
authors: ["Zen1th"]
4+
date: 2023-02-15T18:35:14+01:00
5+
tags: ["capy", "release"]
6+
draft: true
7+
---
8+
9+
**Reminder: Capy is NOT ready for use in production as I'm still making breaking changes**
10+
11+
[Capy](https://github.com/capy-ui/capy) is a **GUI framework** for Zig made with performance, cross-compilation and native widgets in mind. The goal is to be able to seamlessly cross-compile from any platform to any other one. This includes Windows, Linux, WebAssembly, and soon will include macOS, Android and iOS.
12+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
title: "Making a map viewer from scratch"
3+
date: 2022-08-31T14:09:52+02:00
4+
draft: true
5+
authors: ['Zen1th']
6+
---
7+
8+
<br>
9+
10+
![Image of the map viewer](/img/osm-viewer-gtk.png)
11+
12+
Websites like [Google Maps](https://www.google.com/maps) and [OpenStreetMap](https://openstreetmap.org) are map renderers.
13+
14+
For rendering them on the web without downloading a precise multi-terabyte world map, there's two optimizations:
15+
- Maps are pre-rendered on a server, so that instead of interacting with roads and building paths, a web client only needs to render the image its given.
16+
- Maps are split into tiles, when you're looking at Spain, you don't need to also download images of Antartica. The way this work is that the map is divided in a set of squares.
17+
- Tiles are split into zoom level, this is how map renderers do to only show 'United States' when looking at the USA zoomed out, but you can see the names of each places and roads when zooming in on a city.
18+
19+
Now, there's one huge difference between how Google Maps work and how the OpenStreetMap website works:
20+
- Google Maps uses vector tiles (think SVG), this allows for much more granular zooming, and making place names clickable, among some other features
21+
- OpenStreetMap uses bitmap tiles (think PNG), which makes the web client easier to make and can achieve lower download size (which is important for speed)
22+
23+
## Starting up
24+
To do this, I'm gonna use [Capy](https://capy-ui.org/)
25+
26+
We can scaffold how will the layout look in a file:
27+
```zig
28+
const capy = @import("capy");
29+
pub usingnamespace capy.cross_platform;
30+
31+
// Custom 'MapViewer' component
32+
const MapViewer_Impl = ...;
33+
34+
pub fn MapViewer(config: MapViewer_Impl.Config) MapViewer_Impl {
35+
var map_viewer = MapViewer_Impl.init(config);
36+
// TODO: handlers
37+
return map_viewer;
38+
}
39+
40+
pub fn main() !void {
41+
try capy.backend.init();
42+
var window = try capy.Window.init();
43+
try window.set(
44+
capy.Column(.{}, .{
45+
capy.Row(.{}, .{
46+
capy.Expanded(
47+
capy.TextField(.{})
48+
.setName("location-input")
49+
),
50+
capy.Button(.{ .label = "Go!", .onclick = onGo }),
51+
}),
52+
capy.Expanded(
53+
(try MapViewer(.{}))
54+
.setName("map-viewer")
55+
),
56+
}),
57+
);
58+
window.show();
59+
60+
capy.runEventLoop();
61+
}
62+
```
63+
64+
65+
The source code is available at [examples/osm-viewer.zig](https://github.com/capy-ui/capy/blob/master/examples/osm-viewer.zig).

0 commit comments

Comments
 (0)