From 9d9b28318baa2b0a8e424cd8f1e45f84107beb99 Mon Sep 17 00:00:00 2001 From: Vyn Date: Mon, 25 Nov 2024 15:27:18 +0100 Subject: [PATCH] Add Svg 'sync/refresh' icon + Add template helper to setup Selenite --- components/Button.slint | 3 ++- components/Svg.slint | 1 + cpp/CMakeLists.txt | 1 + cpp/include/selenite/selenite.h | 22 ++++++++++++++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/components/Button.slint b/components/Button.slint index 3e3f372..1ce4428 100644 --- a/components/Button.slint +++ b/components/Button.slint @@ -42,7 +42,8 @@ export component VButton inherits Rectangle { padding: 8px; commands: root.icon-svg; stroke: icon-colorize; - stroke-width: 2px; + fill: icon-colorize; + stroke-width: 1px; width: icon-size; height: icon-size; } diff --git a/components/Svg.slint b/components/Svg.slint index 953f51a..1b8b813 100644 --- a/components/Svg.slint +++ b/components/Svg.slint @@ -7,6 +7,7 @@ export global Svg { out property reset: "M18 28A12 12 0 1 0 6 16v6.2l-3.6-3.6L1 20l6 6l6-6l-1.4-1.4L8 22.2V16a10 10 0 1 1 10 10Z"; out property trash: "M19 4h-3.5l-1-1h-5l-1 1H5v2h14M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6z"; out property plus: "M11 13H5v-2h6V5h2v6h6v2h-6v6h-2z"; + out property refresh: "M4 20v-2h2.75l-.4-.35q-1.225-1.225-1.787-2.662T4 12.05q0-2.775 1.663-4.937T10 4.25v2.1Q8.2 7 7.1 8.563T6 12.05q0 1.125.425 2.188T7.75 16.2l.25.25V14h2v6zm10-.25v-2.1q1.8-.65 2.9-2.212T18 11.95q0-1.125-.425-2.187T16.25 7.8L16 7.55V10h-2V4h6v2h-2.75l.4.35q1.225 1.225 1.788 2.663T20 11.95q0 2.775-1.662 4.938T14 19.75"; out property pen: "M3 17.46v3.04c0 .28.22.5.5.5h3.04c.13 0 .26-.05.35-.15L17.81 9.94l-3.75-3.75L3.15 17.1q-.15.15-.15.36M20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83l3.75 3.75z"; out property visible: "M2.933 3.491C4.056 2.681 5.456 2 7 2s2.944.682 4.067 1.491c1.128.812 2.02 1.784 2.56 2.437l.005.005c.241.3.368.681.368 1.067s-.127.766-.368 1.067l-.005.005c-.54.653-1.432 1.625-2.56 2.437C9.944 11.32 8.544 12 7 12s-2.944-.682-4.067-1.49C1.805 9.696.913 8.724.373 8.071l-.005-.005A1.7 1.7 0 0 1 0 7c0-.386.127-.766.368-1.067l.005-.005c.54-.653 1.432-1.625 2.56-2.437M7 9.25a2.25 2.25 0 1 0 0-4.5a2.25 2.25 0 0 0 0 4.5"; out property not-visible: "M.264 1.324a.75.75 0 0 1 1.06-1.06l2.629 2.628C4.86 2.393 5.893 2.04 7 2.04c1.532 0 2.92.677 4.035 1.48c1.118.805 2.003 1.769 2.539 2.417l.004.005c.24.298.366.675.366 1.058s-.126.76-.366 1.058l-.004.006a14.5 14.5 0 0 1-2.249 2.2l2.411 2.412a.75.75 0 0 1-1.06 1.06zm8.753 6.633a2.232 2.232 0 0 0-2.974-2.974zm-8.59-2.02c.319-.387.762-.885 1.305-1.395l7.104 7.104A5.7 5.7 0 0 1 7 11.96c-1.532 0-2.92-.676-4.035-1.479C1.847 9.675.962 8.711.426 8.064l-.004-.006A1.7 1.7 0 0 1 .056 7c0-.383.126-.76.366-1.058l.004-.005Z"; diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 7b756ce..1cdd509 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -10,4 +10,5 @@ add_library(selenite src/palette.cpp ) +target_include_directories(selenite PRIVATE "include") target_include_directories(selenite PRIVATE "external/rei-json/include") diff --git a/cpp/include/selenite/selenite.h b/cpp/include/selenite/selenite.h index 2ce85b4..08c45e7 100644 --- a/cpp/include/selenite/selenite.h +++ b/cpp/include/selenite/selenite.h @@ -1,2 +1,24 @@ #pragma once #include "palette.h" + +template +SlintColor seleniteColorToSlint(const SeleniteColor &color) +{ + return SlintColor::from_rgb_uint8(color.r, color.g, color.b); +} + +template +void setSelenitePalette(const UiPalette &uiPalette, const selenite::Palette &palette) +{ + uiPalette.set_accent(seleniteColorToSlint(palette.primary)); + uiPalette.set_background(seleniteColorToSlint(palette.background)); + uiPalette.set_pane(seleniteColorToSlint(palette.pane)); + uiPalette.set_foreground(seleniteColorToSlint(palette.foreground)); + uiPalette.set_foreground_hint(seleniteColorToSlint(palette.foregroundHint)); + uiPalette.set_control_background(seleniteColorToSlint(palette.background3)); + uiPalette.set_control_foreground(seleniteColorToSlint(palette.foreground)); + uiPalette.set_card_background(seleniteColorToSlint(palette.background2)); + uiPalette.set_green(seleniteColorToSlint(palette.green)); + uiPalette.set_orange(seleniteColorToSlint(palette.orange)); + uiPalette.set_red(seleniteColorToSlint(palette.red)); +}