Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/brisklib/brisk
Browse files Browse the repository at this point in the history
  • Loading branch information
dancazarin committed Dec 20, 2024
2 parents b8b00ca + 5e62004 commit d6843b1
Show file tree
Hide file tree
Showing 98 changed files with 942 additions and 942 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{matrix.triplet}}
retention-days: 90
path: |
Brisk-*.tar.xz
Expand Down Expand Up @@ -151,6 +152,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{matrix.triplet}}
retention-days: 90
path: |
Brisk-*.tar.xz
Expand Down Expand Up @@ -198,6 +200,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ${{matrix.triplet}}
retention-days: 90
path: |
Brisk-*.tar.xz
Expand Down Expand Up @@ -231,6 +234,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{github.job}}
retention-days: 10
path: |
build/*.png
build/*.log
Expand Down Expand Up @@ -264,6 +268,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{github.job}}
retention-days: 10
path: |
build/*.png
build/*.log
Expand Down Expand Up @@ -300,6 +305,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{github.job}}
retention-days: 10
path: |
build/*.png
build/*.log
Expand Down Expand Up @@ -331,6 +337,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{github.job}}
retention-days: 10
path: |
build/*.png
build/*.log
Expand Down Expand Up @@ -362,6 +369,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{github.job}}
retention-days: 10
path: |
build/*.png
build/*.log
Expand Down Expand Up @@ -399,6 +407,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{github.job}}
retention-days: 10
path: |
build/*.png
build/*.log
Expand Down Expand Up @@ -432,6 +441,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-artifacts-${{github.job}}
retention-days: 10
path: |
build/*.png
build/*.log
Expand Down Expand Up @@ -482,6 +492,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: showcase-${{matrix.triplet}}
retention-days: 30
path: |
build/showcase
Expand Down Expand Up @@ -526,6 +537,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: showcase-${{matrix.triplet}}
retention-days: 30
path: |
build/Release/showcase.app
Expand Down Expand Up @@ -571,6 +583,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: showcase-${{matrix.triplet}}
retention-days: 30
path: |
build/Release/showcase.exe
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ if (WIN32 AND BRISK_GENERATE_MAP)
add_link_options(/Map)
endif ()

if (BRISK_SAN)
add_compile_options(-fsanitize=${BRISK_SAN})
add_link_options(-fsanitize=${BRISK_SAN})
endif ()

set(DEPS_DIR
"${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}"
CACHE STRING "DEPS_DIR")
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,30 @@ public:
// rcnew Widget{...} is equivalent to std::shared_ptr<Widget>(new Widget{...})
return rcnew Widget{
layout = Layout::Vertical,
new Text{
rcnew Text{
"Switch (widgets/Switch.hpp)",
classes = { "section-header" }, // Widgets can be styled using stylesheets
},

new HLayout{
new Widget{
new Switch{
rcnew HLayout{
rcnew Widget{
rcnew Switch{
// Bind the switch value to the m_toggled variable (bidirectional)
value = Value{ &m_toggled },
new Text{ "Switch" },
rcnew Text{ "Switch" },
},
},
gapColumn = 10_apx, // CSS Flex-like properties
new Text{
rcnew Text{
text = Value{ &m_label }, // Text may be dynamic
visible =
Value{ &m_toggled }, // The Switch widget controls the visibility of this text widget
},
},

// Button widget
new Button{
new Text{ "Click" },
rcnew Button{
rcnew Text{ "Click" },
// Using m_lifetime ensures that callbacks will be detached once the Component is deleted
onClick = m_lifetime |
[this]() {
Expand All @@ -80,15 +80,15 @@ public:
},

// ComboBox widget
new ComboBox{
rcnew ComboBox{
Value{ &m_textAlignment }, // Bind ComboBox value to an enumeration
notManaged(&textAlignList), // Pass the list of name-value pairs to populate the ComboBox
},

// The Builder creates widgets dynamically whenever needed
Builder([this](Widget* target) {
for (int i = 0; i < m_number; ++i) {
target->apply(new Widget{
target->apply(rcnew Widget{
dimensions = { 40_apx, 40_apx },
});
}
Expand Down
52 changes: 26 additions & 26 deletions docs/docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Brisk eliminates the need for markup languages in defining user interfaces. Inst
For example:
```c++
// Label with text defined at creation
Widget* makeLabel(std::string text) {
return new Widget{
RC<Widget> makeLabel(std::string text) {
return rcnew Widget{
padding = 4_apx,
classes = { "label" },
new Text{ std::move(text) },
rcnew Text{ std::move(text) },
};
}
```
Expand All @@ -40,9 +40,9 @@ Here’s an example of creating a `Slider` widget, accompanied by a `Text` widge
```c++
// Slider with a dynamic value display
Widget* makeSlider(float& value) {
return new HLayout{
new Slider{
RC<Widget> makeSlider(float& value) {
return rcnew HLayout{
rcnew Slider{
// Bind the value of the slider to the provided 'value' variable.
value = Value{ &value },
minimum = 0.f,
Expand All @@ -58,7 +58,7 @@ Widget* makeSlider(float& value) {
gapColumn = 10_px,
// Create a Text widget to display the value of the slider.
new Text{
rcnew Text{
// The text is dynamically generated based on the slider value.
text = Value{ &value }.transform([](float v) {
return fmt::format("Value: {:.1f}", v);
Expand All @@ -82,8 +82,8 @@ In the example below, the `Text` widget binds its `text` property to a `temperat
// Temperature widget with dynamic text and color
float temperature = 16.f;

Widget* makeTemperatureWidget() {
return new Text{
RC<Widget> makeTemperatureWidget() {
return rcnew Text{
text = Value{ &temperature }.transform([](float t){
return fmt::format("{:.1f}°C", t);
}),
Expand All @@ -109,18 +109,18 @@ In addition to supporting dynamic widget properties, Brisk allows the entire wid
// Dynamically created widget tree
static int count = 1;

Widget* makeTree() {
return new VLayout{
new Text{ "Squares:" },
RC<Widget> makeTree() {
return rcnew VLayout{
rcnew Text{ "Squares:" },
Builder{ [](Widget* target){
for (int i = 1; i <= count; ++i) {
target->apply(new Text{ fmt::format("{}^2 = {}", i, i * i) });
target->apply(rcnew Text{ fmt::format("{}^2 = {}", i, i * i) });
}
}},
depends = Value{ &count },

new Button{
new Text{ "Next" },
rcnew Button{
rcnew Text{ "Next" },
onClick = [](){
bindings->assign(count, count + 1);
},
Expand Down Expand Up @@ -170,7 +170,7 @@ For example, the `Text` widget is highly configurable with respect to font featu
```c++
// Configuring text with OpenType features
new Text{
rcnew Text{
text = Value{ &m_text },
fontSize = 40,
fontFamily = Lato,
Expand Down Expand Up @@ -200,30 +200,30 @@ public:
// rcnew Widget{...} is equivalent to std::shared_ptr<Widget>(new Widget{...})
return rcnew Widget{
layout = Layout::Vertical,
new Text{
rcnew Text{
"Switch (widgets/Switch.hpp)",
classes = { "section-header" }, // Widgets can be styled using stylesheets
},

new HLayout{
new Widget{
new Switch{
rcnew HLayout{
rcnew Widget{
rcnew Switch{
// Bind the switch value to the m_toggled variable (bidirectional)
value = Value{ &m_toggled },
new Text{ "Switch" },
rcnew Text{ "Switch" },
},
},
gapColumn = 10_apx, // CSS Flex-like properties
new Text{
rcnew Text{
text = Value{ &m_label }, // Text may be dynamic
visible =
Value{ &m_toggled }, // The Switch widget controls the visibility of this text widget
},
},

// Button widget
new Button{
new Text{ "Click" },
rcnew Button{
rcnew Text{ "Click" },
// Using m_lifetime ensures that callbacks will be detached once the Component is deleted
onClick = m_lifetime |
[this]() {
Expand All @@ -233,15 +233,15 @@ public:
},

// ComboBox widget
new ComboBox{
rcnew ComboBox{
Value{ &m_textAlignment }, // Bind ComboBox value to an enumeration
notManaged(&textAlignList), // Pass the list of name-value pairs to populate the ComboBox
},

// The Builder creates widgets dynamically whenever needed
Builder([this](Widget* target) {
for (int i = 0; i < m_number; ++i) {
target->apply(new Widget{
target->apply(rcnew Widget{
dimensions = { 40_apx, 40_apx },
});
}
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/hello_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public:
gapRow = 8_px, // Set vertical gap between elements
alignItems = AlignItems::Center, // Align child widgets to the center
justifyContent = Justify::Center, // Center the layout in the parent
new Text{"Hello, world"}, // Display a text widget with "Hello, world"
new Button{
new Text{"Quit"}, // Button label
rcnew Text{"Hello, world"}, // Display a text widget with "Hello, world"
rcnew Button{
rcnew Text{"Quit"}, // Button label
onClick = m_lifetime | []() { // Quit the application on button click
windowApplication->quit();
},
Expand Down
Loading

0 comments on commit d6843b1

Please sign in to comment.