Skip to content

Commit 0396991

Browse files
authored
Merge pull request #71 from NuiCpp/devel
Small Improvements
2 parents 0926d2f + f4f05d6 commit 0396991

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

nui/include/nui/frontend/dom/childless_element.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,17 @@ namespace Nui::Dom
4949
if (value)
5050
element_.call<Nui::val>("setAttribute", Nui::val{std::string{key}}, Nui::val{""});
5151
}
52-
void setAttribute(std::string_view key, int value)
52+
template <typename T>
53+
requires std::integral<T>
54+
void setAttribute(std::string_view key, T value)
5355
{
54-
element_.call<Nui::val>("setAttribute", Nui::val{std::string{key}}, Nui::val{value});
56+
element_.call<Nui::val>("setAttribute", Nui::val{std::string{key}}, Nui::val{static_cast<int>(value)});
5557
}
56-
void setAttribute(std::string_view key, double value)
58+
template <typename T>
59+
requires std::floating_point<T>
60+
void setAttribute(std::string_view key, T value)
5761
{
58-
element_.call<Nui::val>("setAttribute", Nui::val{std::string{key}}, Nui::val{value});
62+
element_.call<Nui::val>("setAttribute", Nui::val{std::string{key}}, Nui::val{static_cast<double>(value)});
5963
}
6064
void setAttribute(std::string_view key, Nui::val value)
6165
{

nui/include/nui/frontend/elements/impl/html_element.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ namespace Nui
345345
// Children functions:
346346
template <typename... ElementT>
347347
requires requires(ElementT&&... elements) {
348-
std::vector<std::function<std::shared_ptr<Dom::Element>(Dom::Element&, Renderer const&)>>{
349-
std::forward<ElementT>(elements)...};
350-
}
348+
std::vector<std::function<std::shared_ptr<Dom::Element>(Dom::Element&, Renderer const&)>>{
349+
std::forward<ElementT>(elements)...};
350+
}
351351
auto operator()(ElementT&&... elements) &&
352352
{
353353
return std::function<std::shared_ptr<Dom::Element>(Dom::Element&, Renderer const&)>{

nui/include/nui/frontend/elements/svg/impl/svg_element.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
#pragma once
22

3+
#include <nui/frontend/elements/impl/html_element.hpp>
4+
35
#define NUI_DECLARE_SVG_ELEMENT_RENAME(NAME, HTML_ACTUAL) \
46
namespace Nui::Elements::Svg \
57
{ \
68
struct NAME : HtmlElement \
79
{ \
8-
constexpr NAME(NAME const&) = default; \
9-
constexpr NAME(NAME&&) = default; \
10-
constexpr NAME(std::vector<Attribute> const& attributes) \
10+
HTML_ELEMENT_CONSTEXPR NAME(NAME const&) = default; \
11+
HTML_ELEMENT_CONSTEXPR NAME(NAME&&) = default; \
12+
HTML_ELEMENT_CONSTEXPR NAME(std::vector<Attribute> const& attributes) \
1113
: HtmlElement{HTML_ACTUAL, &SvgElementBridge, attributes} \
1214
{} \
13-
constexpr NAME(std::vector<Attribute>&& attributes) \
15+
HTML_ELEMENT_CONSTEXPR NAME(std::vector<Attribute>&& attributes) \
1416
: HtmlElement{HTML_ACTUAL, &SvgElementBridge, std::move(attributes)} \
1517
{} \
1618
template <typename... T> \
17-
constexpr NAME(T&&... attributes) \
19+
HTML_ELEMENT_CONSTEXPR NAME(T&&... attributes) \
1820
: HtmlElement{HTML_ACTUAL, &SvgElementBridge, std::forward<T>(attributes)...} \
1921
{} \
2022
}; \

0 commit comments

Comments
 (0)