Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ option(BRISK_LTO ON "Use Link Time Optimization in Release builds")
option(BRISK_BROTLI "Enable Brotli compression" ON)
cmake_dependent_option(BRISK_WEBGPU "Enable WebGPU" OFF "WIN32" ON)
cmake_dependent_option(BRISK_D3D11 "Enable D3D11 backend (Windows only)" ON "WIN32" OFF)
option(BRISK_ICU "Link to ICU by default for full Unicode support" ON)
option(BRISK_LOG_TO_STDERR "Write log output to stderr (Windows-specific)" OFF)
option(BRISK_INTERACTIVE_TESTS "Enable interactive tests" OFF)
option(BRISK_RTTI "Enable RTTI for Brisk builds" ON)
Expand Down Expand Up @@ -219,13 +218,12 @@ if (BRISK_TESTS)
${TESTS_GRAPHICS}
LIBRARIES
brisk-graphics
brisk-i18n-icu
${TESTS_GRAPHICS_LIBS}
DEFINITIONS
${TESTS_GRAPHICS_DEFS})
add_autotests(window SOURCES ${TESTS_WINDOW} LIBRARIES brisk-window brisk-i18n-icu)
add_autotests(gui SOURCES ${TESTS_GUI} LIBRARIES brisk-gui brisk-i18n-icu)
add_autotests(widgets SOURCES ${TESTS_WIDGETS} LIBRARIES brisk-widgets brisk-i18n-icu)
add_autotests(window SOURCES ${TESTS_WINDOW} LIBRARIES brisk-window)
add_autotests(gui SOURCES ${TESTS_GUI} LIBRARIES brisk-gui)
add_autotests(widgets SOURCES ${TESTS_WIDGETS} LIBRARIES brisk-widgets)

if (BRISK_OVERRIDE_D3D_WARP)
place_warp_dll(graphics_tests)
Expand Down Expand Up @@ -279,8 +277,6 @@ install(
brisk-gui
brisk-widgets
brisk-executable
brisk-i18n
brisk-i18n-icu
${EXTRA_INSTALL_TARGETS}
EXPORT BriskTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}$<$<CONFIG:Debug>:${BRISK_DBG_SUFFIX}>
Expand Down
4 changes: 2 additions & 2 deletions acquire-deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ if (NOT EXISTS ${DEST_FILE})
message(FATAL_ERROR "vcpkg not found. Please ensure vcpkg is installed and accessible in your PATH.")
endif ()

execute_process(COMMAND ${VCPKG_EXECUTABLE} install --x-install-root ${ROOT}/vcpkg_installed --x-feature=icu
${EXTRA_VCPKG_ARGS} WORKING_DIRECTORY ${ROOT} COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND ${VCPKG_EXECUTABLE} install --x-install-root ${ROOT}/vcpkg_installed
${EXTRA_VCPKG_ARGS} WORKING_DIRECTORY ${ROOT} COMMAND_ERROR_IS_FATAL ANY)
endif ()

file(REMOVE_RECURSE ${ROOT}/vcpkg_exported)
Expand Down
8 changes: 0 additions & 8 deletions cmake/config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ add_library(brisk-gui ALIAS Brisk::Gui)
add_library(brisk-widgets ALIAS Brisk::Widgets)
add_library(brisk-network ALIAS Brisk::Network)
add_library(brisk-executable ALIAS Brisk::Executable)
add_library(brisk-i18n-icu ALIAS Brisk::I18n-Icu)

if (TARGET Brisk::brisk-renderer-webgpu)
add_library(brisk-renderer-webgpu ALIAS Brisk::brisk-renderer-webgpu)
endif ()
Expand All @@ -40,12 +38,6 @@ set(BRISK_BROTLI @BRISK_BROTLI@)
set(BRISK_WEBGPU @BRISK_WEBGPU@)
set(BRISK_D3D11 @BRISK_D3D11@)

if (BRISK_ICU)
target_link_libraries(Brisk::Graphics INTERFACE Brisk::I18n-Icu)
else ()
target_link_libraries(Brisk::Graphics INTERFACE Brisk::I18n)
endif ()

set(_DEP_PUBLIC INTERFACE)
set(_DEP_PRIVATE INTERFACE)
set(_FIND_PACKAGE find_dependency)
Expand Down
2 changes: 1 addition & 1 deletion examples/calc/math.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct Calculator {
std::optional<std::tuple<Number, ExponentiationOperator>> exponentiationOperation;
Number currentOperand;

BindingRegistration registration{ this, uiScheduler };
BindingRegistration registration{ this, mainScheduler };

std::string output() const {
if (editable)
Expand Down
6 changes: 2 additions & 4 deletions examples/crud/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Model {
std::vector<Person> m_list{ { "Hans", "Emil" }, { "Max", "Mustermann" }, { "Roman", "Tisch" } };
};

class ViewModel : public BindableObject<ViewModel, &uiScheduler> {
class ViewModel : public BindableObject<ViewModel> {
public:
ViewModel() {
filter(m_prefix);
Expand Down Expand Up @@ -215,7 +215,5 @@ using namespace Brisk;

int briskMain() {
GuiApplication application;
return application.run([]() {
return rcnew View(rcnew ViewModel());
});
return application.run(rcnew View(rcnew ViewModel()));
}
2 changes: 1 addition & 1 deletion examples/dashboard/src/ViewModel/ViewModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace App {

using namespace Brisk;

class DataSourceViewModel : public BindableObject<DataSourceViewModel, &uiScheduler> {
class DataSourceViewModel : public BindableObject<DataSourceViewModel> {
public:
DataSourceViewModel(Rc<DataSourceModel> model, Value<int> updateTrigger);

Expand Down
7 changes: 3 additions & 4 deletions examples/own-window-gui/own-window-gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int main() {
// Convert mouse coordinates to framebuffer pixels
event.point =
PointF(xpos, ypos) * PointF(SizeF(win->framebufferSize)) / PointF(SizeF(win->windowSize));
win->input.addEvent(std::move(event));
std::ignore = win->input.processEvent(std::move(event));
});

// Set callback for mouse button presses and releases
Expand All @@ -122,9 +122,9 @@ int main() {
event.downPoint = std::nullopt; // Not implemented in this example
event.mods = KeyModifiers::None; // Not implemented in this example
if (action == GLFW_PRESS) {
win->input.addEvent(EventMouseButtonPressed{ event });
std::ignore = win->input.processEvent(EventMouseButtonPressed{ event });
} else {
win->input.addEvent(EventMouseButtonReleased{ event });
std::ignore = win->input.processEvent(EventMouseButtonReleased{ event });
}
});

Expand Down Expand Up @@ -174,7 +174,6 @@ int main() {

// Process Brisk events
mainScheduler->process();
uiScheduler->process();

for (int i = 0; i < numWindows; ++i) {
// Update pixel ratio for rendering (ratio between framebuffer pixels and GUI pixels)
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Binding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseBinding : public BindableObject<ShowcaseBinding, &uiScheduler> {
class ShowcaseBinding : public BindableObject<ShowcaseBinding> {
public:
ShowcaseBinding();
Rc<Widget> build(Rc<Notifications> notifications, Value<bool> globalEnabled);
Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Buttons.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseButtons : public BindableObject<ShowcaseButtons, &uiScheduler> {
class ShowcaseButtons : public BindableObject<ShowcaseButtons> {
public:
ShowcaseButtons() {}

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Dialogs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseDialogs : public BindableObject<ShowcaseDialogs, &uiScheduler> {
class ShowcaseDialogs : public BindableObject<ShowcaseDialogs> {
public:
Rc<Widget> build(Rc<Notifications> notifications, Value<bool> globalEnabled);

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Dropdowns.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseDropdowns : public BindableObject<ShowcaseDropdowns, &uiScheduler> {
class ShowcaseDropdowns : public BindableObject<ShowcaseDropdowns> {
public:
Rc<Widget> build(Rc<Notifications> notifications, Value<bool> globalEnabled);

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Editors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace Brisk {

class ShowcaseEditors : public BindableObject<ShowcaseEditors, &uiScheduler> {
class ShowcaseEditors : public BindableObject<ShowcaseEditors> {
public:
Rc<Widget> build(Rc<Notifications> notifications, Value<bool> globalEnabled);

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Layout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseLayout : public BindableObject<ShowcaseLayout, &uiScheduler> {
class ShowcaseLayout : public BindableObject<ShowcaseLayout> {
public:
Rc<Widget> build(Rc<Notifications> notifications, Value<bool> globalEnabled);

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Messenger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseMessenger : public BindableObject<ShowcaseMessenger, &uiScheduler> {
class ShowcaseMessenger : public BindableObject<ShowcaseMessenger> {
public:
ShowcaseMessenger();

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Typography.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseTypography : public BindableObject<ShowcaseTypography, &uiScheduler> {
class ShowcaseTypography : public BindableObject<ShowcaseTypography> {
public:
Rc<Widget> build(Rc<Notifications> notifications, Value<bool> globalEnabled);

Expand Down
2 changes: 1 addition & 1 deletion examples/showcase/src/Visual.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

namespace Brisk {

class ShowcaseVisual : public BindableObject<ShowcaseVisual, &uiScheduler> {
class ShowcaseVisual : public BindableObject<ShowcaseVisual> {
public:
ShowcaseVisual();

Expand Down
6 changes: 4 additions & 2 deletions examples/splash-screen/splash-screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SplashScreen final : public Component {
window->setRectangle(windowRect); // Applies the centered position and size.
}

std::atomic_int m_progress{ 0 }; // Tracks loading progress (0-100), starting at 0.
int m_progress{ 0 }; // Tracks loading progress (0-100), starting at 0.
};

// Defines the main application component with a simple UI.
Expand Down Expand Up @@ -131,7 +131,9 @@ int briskMain() {
// Simulates a 2-second app loading process, updating the progress bar dynamically.
auto splashTime = std::chrono::steady_clock::now() + std::chrono::milliseconds(2000);
while (std::chrono::steady_clock::now() < splashTime) {
application.cycle(false); // Processes events without blocking during the loading simulation.
application.cycle(
WindowApplication::ProcessEventsMode::CheckOnly); // Processes events without blocking during the
// loading simulation.
// Updates the progress bar based on remaining time, increasing from 0 to 100.
splash->m_progress = 100 - std::chrono::duration_cast<std::chrono::milliseconds>(
splashTime - std::chrono::steady_clock::now())
Expand Down
9 changes: 8 additions & 1 deletion include/brisk/core/Binding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,10 @@ class Bindings {
*/
void registerRegion(BindingAddress region, Rc<Scheduler> queue);

void registerRegion(BindingAddress region) {
registerRegion(region, mainScheduler);
}

/**
* @brief Unregisters a previously registered region.
*
Expand Down Expand Up @@ -1464,6 +1468,9 @@ struct BindingRegistration {
bindings->registerRegion(toBindingAddress(thiz), std::move(queue));
}

template <typename T>
BindingRegistration(const T* thiz) : BindingRegistration(thiz, mainScheduler) {}

/**
* @brief Destructor that unregisters the binding region.
*/
Expand Down Expand Up @@ -2070,7 +2077,7 @@ concept PointerToScheduler = requires(T p) {
{ *p } -> std::convertible_to<Rc<Scheduler>>;
};

template <typename Derived, PointerToScheduler auto scheduler = static_cast<Rc<Scheduler>*>(nullptr)>
template <typename Derived, PointerToScheduler auto scheduler = &mainScheduler>
class BindableObject : public Object,
public std::enable_shared_from_this<BindableObject<Derived, scheduler>> {
private:
Expand Down
3 changes: 0 additions & 3 deletions include/brisk/core/Io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,9 +496,6 @@ fs::path uniqueFileName(std::string_view base, std::string_view numbered, int i
* character from the set of lowercase letters and digits, and `*`
* with 16 random characters from the same set.
*
* The function is thread-safe, using a mutex to ensure that the random
* number generator is accessed in a synchronized manner.
*
* @param pattern A string representing the desired pattern for the
* temporary file name. The pattern can include `?`
* and `*` as placeholders for random characters.
Expand Down
27 changes: 26 additions & 1 deletion include/brisk/core/Threading.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,24 @@

namespace Brisk {

class Thread {
public:
Thread();

~Thread();

std::thread::id get_id() const noexcept;

protected:
bool isTerminated() const noexcept;

virtual void threadBody();

private:
std::thread m_thread;
std::atomic<bool> m_terminate{ false };
};

/**
* @enum ExecuteImmediately
* @brief Defines when and how a scheduled function is dispatched in a task queue.
Expand Down Expand Up @@ -250,6 +268,13 @@ class TaskQueue : public Scheduler {

~TaskQueue();

/**
* @brief Set the Thread Id object
*
* @param threadId
*/
void setThreadId(std::thread::id threadId) noexcept;

/**
* @brief Dispatches a function for execution.
*
Expand Down Expand Up @@ -336,7 +361,7 @@ class TaskQueue : public Scheduler {
/// @brief Represents the task queue and scheduler for the main thread.
extern Rc<TaskQueue> mainScheduler;

extern Rc<TaskQueue> uiScheduler;
extern Rc<Scheduler> noScheduler;

template <typename T>
T waitFuture(VoidFunc waitFunc, std::future<T> future, int intervalMS) {
Expand Down
Loading
Loading