--------------------------------------------------------------------------------
/demo/CreateWidget/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file main.cpp
25 | * \brief The demo to create a simple widget in VUILib
26 | */
27 |
28 | #include
29 |
30 | int main() {
31 | VApplication application;
32 | VMainWindow window(&application, 640, 480, "Hello, VUILib");
33 | VWidget widget(&application, 640, 480, "VUILib Widget");
34 |
35 | return application.Run();
36 | }
--------------------------------------------------------------------------------
/demo/PanelTester/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file main.cpp
25 | * \brief The demo to use the panel control
26 | */
27 |
28 | /**
29 | * \file main.cpp
30 | * \brief The demo to create a simple widget in VUILib
31 | */
32 |
33 | #include
34 | #include
35 | #include
36 | #include
37 |
38 | void CreatePanelViewer(VApplication *Target) {
39 | auto window = new VMainWindow(Target, 640, 480, "Panel Viewer");
40 |
41 | auto panel = new VPanel(window);
42 |
43 | auto rectangleBackground = new VRectangleControl(panel);
44 | auto rectangle1 = new VRectangleControl(panel);
45 | auto rectangle2 = new VRectangleControl(panel);
46 | auto rectangle3 = new VRectangleControl(panel);
47 | auto rectangle4 = new VRectangleControl(panel);
48 |
49 | panel->P_PanelAlign.Register(rectangle1, "left");
50 | panel->P_PanelAlign.Register(rectangle2, "right");
51 | panel->P_PanelAlign.Register(rectangle3, "top");
52 | panel->P_PanelAlign.Register(rectangle4, "bottom");
53 | panel->P_PanelAlign.Register(rectangleBackground, "center");
54 |
55 | rectangle1->SetOpacity(0.5);
56 | rectangle1->SetBackgroundColor(SK_ColorBLUE);
57 | rectangle2->SetBackgroundColor(SK_ColorCYAN);
58 | rectangle2->SetOpacity(0.5);
59 | rectangle3->SetBackgroundColor(SK_ColorGREEN);
60 | rectangle3->SetOpacity(0.5);
61 | rectangle4->SetOpacity(0.5);
62 |
63 | rectangleBackground->Resize(100, 100);
64 | rectangleBackground->LockSizing();
65 |
66 | panel->Arrange();
67 |
68 | window->Show();
69 | }
70 | void CreateStackPanelViewer(VApplication *Target) {
71 | auto window = new VWidget(Target, 640, 480, "Stack Panel Viewer");
72 |
73 | auto panel = new VStackPanel(window);
74 |
75 | auto rectangleBackground = new VRectangleControl(panel);
76 | auto rectangle1 = new VRectangleControl(400, 60, panel);
77 | auto rectangle2 = new VRectangleControl(400, 50, panel);
78 | auto rectangle3 = new VRectangleControl(400, 50, panel);
79 | auto rectangle4 = new VRectangleControl(400, 50, panel);
80 |
81 | panel->P_StackAlign.Register(rectangle1, "left");
82 | panel->P_StackAlign.Register(rectangle2, "right");
83 | panel->P_Margin.Register(rectangle2, 20);
84 | panel->P_StackAlign.Register(rectangle3, "center");
85 | panel->P_StackAlign.Register(rectangle4, "right");
86 | panel->P_MarginTop.Register(rectangle4, 12);
87 | panel->P_StackAlign.Register(rectangleBackground, "center");
88 |
89 | rectangle1->SetOpacity(0.5);
90 | rectangle1->SetBackgroundColor(SK_ColorGREEN);
91 | rectangle2->SetBackgroundColor(SK_ColorCYAN);
92 | rectangle2->SetOpacity(0.5);
93 | rectangle3->SetBackgroundColor(SK_ColorRED);
94 | rectangle3->SetOpacity(0.5);
95 | rectangle4->SetOpacity(0.5);
96 |
97 | rectangleBackground->Resize(100, 100);
98 | rectangleBackground->LockSizing();
99 |
100 | panel->Arrange();
101 |
102 | window->Show();
103 | }
104 |
105 | int main() {
106 | VApplication application;
107 |
108 | CreatePanelViewer(&application);
109 | CreateStackPanelViewer(&application);
110 |
111 | return application.Run();
112 | }
--------------------------------------------------------------------------------
/demo/SimpleButton/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file main.cpp
25 | * \brief A demo in VUILib for just a simple button creation
26 | */
27 |
28 | #include
29 | #include
30 |
31 | int main() {
32 | VApplication application;
33 | VMainWindow window(&application, 640, 480, "Hello, VUILib");
34 |
35 | VPushButton button(&window, 200, 400, "Hello World!");
36 | button.SetRichText(R"(
Hello
Worldin Rich Text!
)");
37 |
38 | window.Show();
39 |
40 | return application.Run();
41 | }
--------------------------------------------------------------------------------
/demo/TestSkia/main.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file main.cpp
25 | * \brief This is a demo which test the Skia wrapper of VUILib
26 | */
27 |
28 | #include
29 |
30 | // #include
31 |
32 | sk_sp GLInterface;
33 |
34 | #define WIDTH 640
35 | #define HEIGHT 480
36 |
37 | sk_sp TextBlob;
38 | SkPaint *Paint;
39 | SkPaint *BlurPaint;
40 |
41 | GLFWwindow *GLWindow;
42 |
43 | /**
44 | * Init OpenGL interface object
45 | */
46 | void InitGLInterface();
47 | /**
48 | * Create GLFW window
49 | */
50 | void InitWindow();
51 | /**
52 | * Init Skia resource
53 | */
54 | void InitResource();
55 | /**
56 | * The frame buffer call back function
57 | */
58 | void FrameBufferCallBack(GLFWwindow *Window, int Width, int Height);
59 | /**
60 | * The error call back function of GLFW
61 | * @param Error The error code
62 | * @param Description The description string of the error
63 | */
64 | void ErrorCallBack(int Error, const char *Description);
65 | /**
66 | * Call Skia API to draw context
67 | */
68 | void Draw(int Width, int Height);
69 |
70 | int main() {
71 | InitWindow();
72 | InitResource();
73 | InitGLInterface();
74 |
75 | Draw(WIDTH, HEIGHT);
76 | while (!glfwWindowShouldClose(GLWindow)) {
77 | glfwPollEvents();
78 | }
79 |
80 | return 0;
81 | }
82 |
83 | void InitGLInterface() {
84 | GLInterface = sk_make_sp();
85 | }
86 | void InitWindow() {
87 | glfwSetErrorCallback(ErrorCallBack);
88 | if (!glfwInit()) {
89 | exit(EXIT_FAILURE);
90 | }
91 |
92 | GLWindow = glfwCreateWindow(WIDTH, HEIGHT, "Skia Tester", nullptr, nullptr);
93 | if (!GLWindow) {
94 | printf("Failed to create GLFW window!");
95 | glfwTerminate();
96 | exit(EXIT_FAILURE);
97 | }
98 | glfwSetFramebufferSizeCallback(GLWindow, FrameBufferCallBack);
99 |
100 | glfwMakeContextCurrent(GLWindow);
101 | }
102 | void InitResource() {
103 | const SkScalar sigma = 3.65f;
104 | const SkScalar textSize = 40.0f;
105 | const uint8_t blurAlpha = 127;
106 | auto face = SkTypeface::MakeFromName(
107 | "Times New Roman", {SkFontStyle::kNormal_Weight, SkFontStyle::kNormal_Width, SkFontStyle::kItalic_Slant});
108 | auto font = SkFont(face, textSize);
109 | TextBlob = SkTextBlob::MakeFromString("Hello VUILib, hello Skia,\r\n hello GLFW", SkFont(face, textSize), SkTextEncoding::kUTF8);
110 | Paint = new SkPaint();
111 | Paint->setAntiAlias(true);
112 |
113 | BlurPaint = new SkPaint(*Paint);
114 |
115 | BlurPaint->setAlpha(blurAlpha);
116 | BlurPaint->setMaskFilter(SkMaskFilter::MakeBlur(kNormal_SkBlurStyle, sigma, 0));
117 | }
118 | void FrameBufferCallBack(GLFWwindow *Window, int Width, int Height) {
119 | Draw(Width, Height);
120 | }
121 | void Draw(int Width, int Height) {
122 | sk_sp glRenderTarget =
123 | sk_make_sp({.Width = Width, .Height = Height, .X = 0, .Y = 0});
124 | sk_sp glContext = sk_make_sp &>(GLInterface);
125 | sk_sp glSurface =
126 | sk_make_sp &, const sk_sp &>(glRenderTarget, glContext);
127 |
128 | auto canvas = glSurface->GetNativeSurface()->getCanvas();
129 |
130 | const SkScalar x = 8.0f;
131 | const SkScalar y = 52.0f;
132 |
133 | canvas->drawColor(SK_ColorWHITE);
134 | canvas->drawTextBlob(TextBlob.get(), x, y, *BlurPaint);
135 | canvas->drawTextBlob(TextBlob.get(), x, y, *Paint);
136 |
137 | canvas->flush();
138 | glContext->GetNativeContext()->flushAndSubmit();
139 |
140 | glfwSwapBuffers(GLWindow);
141 | }
142 | void ErrorCallBack(int Error, const char *Description) {
143 | fputs(Description, stderr);
144 | }
--------------------------------------------------------------------------------
/include/app/vApplication.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vApplication.h
25 | * \brief The application class in the VUILib
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | /**
34 | * The interface for application to call the VUILib's widget event loop
35 | */
36 | class VApplicationWidgetInterface {
37 | public:
38 | /**
39 | * Every time on the event loop this function will be called
40 | */
41 | virtual void OnOnceLoop() = 0;
42 | };
43 |
44 | /**
45 | * The application class in VUILib
46 | */
47 | class VApplication {
48 | public:
49 | /**
50 | * Create the application in default mode; By default, it will
51 | * create a theme in light mode with the blue theme color
52 | */
53 | VApplication();
54 |
55 | public:
56 | /**
57 | * Get the theme property by the specified name
58 | * @param Name The id of the theme property
59 | * @return The reference of the property instance
60 | */
61 | VStyleProperty &GetThemeProperty(const OString &Name);
62 | /**
63 | * Get the value of the specified name in specified type
64 | * @tparam Type The type of the property
65 | * @param Name The name of the property
66 | * @return The value of the property in the specified name
67 | */
68 | template Type *GetThemePropertyValue(const OString &Name) {
69 | return _style.GetPropertyValue(Name);
70 | }
71 |
72 | public:
73 | /**
74 | * Call this function to run the application
75 | * @return The return for main function
76 | */
77 | int Run();
78 |
79 | private:
80 | friend class VWidget;
81 | friend class VMainWindow;
82 |
83 | protected:
84 | GLFWwindow *_mainWindow;
85 | VRadixStyleType _styleType;
86 | VStyleFunction _style;
87 |
88 | protected:
89 | std::unordered_map _interfaces;
90 | };
91 |
--------------------------------------------------------------------------------
/include/base/binding/vBindingType.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vBindingType.h
25 | * \brief A wrapper type for two-way binding
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * This is a class for two-way binding, the control defines property with
34 | * this data class. This class will maintain an instance of the type and
35 | * a pointer referred to the type.
36 | * @tparam Type The data type
37 | * @tparam Parameter The constructor parameter for the data type
38 | */
39 | template class VBindingType {
40 | public:
41 | /**
42 | * In default, VBindingType will create an empty pointer
43 | */
44 | VBindingType() : _pointer(nullptr), _instance() {
45 | }
46 | /**
47 | * Construct a binding type with the parameter of the
48 | * Type construction
49 | * @param Construct The construction parameter to construct a object
50 | */
51 | explicit VBindingType(Parameter... Construct) : _pointer(nullptr), _instance(Construct...) {
52 | }
53 |
54 | public:
55 | /**
56 | * Bind a pointer; VBindingType assumes that the pointer is always available.
57 | * @param Pointer The pointer to be bound.
58 | */
59 | void Bind(Type *Pointer) {
60 | _pointer = Pointer;
61 | }
62 | /**
63 | * Unbind, discard the pointer. Binding object will not copy the value into the
64 | * cache of binding object.
65 | */
66 | void Unbind() {
67 | _pointer = nullptr;
68 | }
69 |
70 | public:
71 | /**
72 | * Spaceship operator
73 | * @param Value The value for judgement
74 | */
75 | std::strong_ordering friend operator<=>(const VBindingType &Object, const Type &Value) {
76 | if (Object._pointer != nullptr) {
77 | return *(Object._pointer) <=> Value;
78 | }
79 |
80 | return Object._instance <=> Value;
81 | }
82 | /**
83 | * Spaceship operator
84 | * @param Value The value for judgement
85 | */
86 | std::strong_ordering friend operator<=>(const Type &Value, const VBindingType &Object) {
87 | if (Object._pointer != nullptr) {
88 | return Value <=> *(Object._pointer);
89 | }
90 |
91 | return Value <=> Object._instance;
92 | }
93 | bool operator==(const Type &Value) {
94 | if (_pointer != nullptr) {
95 | return Value == *_pointer;
96 | }
97 |
98 | return Value == _instance;
99 | }
100 |
101 | public:
102 | /**
103 | * Get the pointer of instance
104 | * @return The pointer of data type
105 | */
106 | Type *Pointer() noexcept {
107 | /*
108 | * If the _pointer != nullptr, return the pointer.
109 | * However, nobody can sure whether the _pointer object
110 | * has been released or not.
111 | *
112 | * TODO: Add a VMemoryLogger to help the memory manage.
113 | */
114 | if (_pointer != nullptr) {
115 | return _pointer;
116 | } else {
117 | return &_instance;
118 | }
119 | }
120 | /**
121 | * Get the reference of instance
122 | * @return The reference of data type
123 | */
124 | Type &operator*() noexcept {
125 | /*
126 | * If the _pointer != nullptr, return the pointer.
127 | * However, nobody can sure whether the _pointer object
128 | * has been released or not.
129 | *
130 | * TODO: Add a VMemoryLogger to help the memory manage.
131 | */
132 | if (_pointer != nullptr) {
133 | return *_pointer;
134 | } else {
135 | return _instance;
136 | }
137 | }
138 |
139 | private:
140 | Type *_pointer;
141 | Type _instance;
142 | };
143 |
--------------------------------------------------------------------------------
/include/base/command/vCommand.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vCommand.h
25 | * \brief The command class
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * An empty structure for VCommand's placeholder
34 | */
35 | struct VPlaceHolderObject {};
36 |
37 | /**
38 | * The command class for VUILib. It just like a event which has not connection method
39 | * @tparam ObjectType The object type for class function, if not use the VPlaceHolderObject type
40 | * @tparam Parameter The parameter list of command
41 | */
42 | template class VCommand {
43 | public:
44 | /**
45 | * The alias to VEvent class
46 | */
47 | using Delegate = VEvent;
48 |
49 | public:
50 | /**
51 | * Construct the command by a function pointer of delegate
52 | * @param Pointer The pointer referred to command callback function
53 | */
54 | explicit VCommand(Delegate::FunctionPointer Pointer) {
55 | _commandEvent.Connect(Pointer);
56 | }
57 | /**
58 | * Construct the command by a member function pointer
59 | * @param Object The object pointer referred to the target object
60 | * @param Pointer The pointer referred to the member function
61 | */
62 | VCommand(ObjectType *Object, Delegate::template ClassFunctionPointer Pointer) {
63 | _commandEvent.template Connect(Object, Pointer);
64 | }
65 |
66 | public:
67 | /***
68 | * Emit the command
69 | * @param CallList The call parameter list
70 | */
71 | void operator()(Parameter... CallList) {
72 | _commandEvent.Emit(CallList...);
73 | }
74 | /***
75 | * Emit the command
76 | * @param CallList The call parameter list
77 | */
78 | void OnCommand(Parameter... CallList) {
79 | _commandEvent.Emit(CallList...);
80 | }
81 |
82 | private:
83 | Delegate _commandEvent;
84 | };
--------------------------------------------------------------------------------
/include/base/message/vKeyMap.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vKeyMap.h
25 | * \brief The key map between GLFW and the VUILib
26 | */
27 |
28 | #pragma once
29 |
30 | #define VKEY_SPACE GLFW_KEY_SPACE
31 | #define VKEY_APOSTROPHE GLFW_KEY_APOSTROPHE
32 | #define VKEY_COMMA GLFW_KEY_COMMA
33 | #define VKEY_MINUS GLFW_KEY_MINUS
34 | #define VKEY_PERIOD GLFW_KEY_PERIOD
35 | #define VKEY_SLASH GLFW_KEY_SLASH
36 | #define VKEY_0 GLFW_KEY_0
37 | #define VKEY_1 GLFW_KEY_1
38 | #define VKEY_2 GLFW_KEY_2
39 | #define VKEY_3 GLFW_KEY_3
40 | #define VKEY_4 GLFW_KEY_4
41 | #define VKEY_5 GLFW_KEY_5
42 | #define VKEY_6 GLFW_KEY_6
43 | #define VKEY_7 GLFW_KEY_7
44 | #define VKEY_8 GLFW_KEY_8
45 | #define VKEY_9 GLFW_KEY_9
46 | #define VKEY_SEMICOLON GLFW_KEY_SEMICOLON
47 | #define VKEY_EQUAL GLFW_KEY_EQUAL
48 | #define VKEY_A GLFW_KEY_A
49 | #define VKEY_B GLFW_KEY_B
50 | #define VKEY_C GLFW_KEY_C
51 | #define VKEY_D GLFW_KEY_D
52 | #define VKEY_E GLFW_KEY_E
53 | #define VKEY_F GLFW_KEY_F
54 | #define VKEY_G GLFW_KEY_G
55 | #define VKEY_H GLFW_KEY_H
56 | #define VKEY_I GLFW_KEY_I
57 | #define VKEY_J GLFW_KEY_J
58 | #define VKEY_K GLFW_KEY_K
59 | #define VKEY_L GLFW_KEY_L
60 | #define VKEY_M GLFW_KEY_M
61 | #define VKEY_N GLFW_KEY_N
62 | #define VKEY_O GLFW_KEY_O
63 | #define VKEY_P GLFW_KEY_P
64 | #define VKEY_Q GLFW_KEY_Q
65 | #define VKEY_R GLFW_KEY_R
66 | #define VKEY_S GLFW_KEY_S
67 | #define VKEY_T GLFW_KEY_T
68 | #define VKEY_U GLFW_KEY_U
69 | #define VKEY_V GLFW_KEY_V
70 | #define VKEY_W GLFW_KEY_W
71 | #define VKEY_X GLFW_KEY_X
72 | #define VKEY_Y GLFW_KEY_Y
73 | #define VKEY_Z GLFW_KEY_Z
74 | #define VKEY_LEFT_BRACKET GLFW_KEY_LEFT_BRACKET
75 | #define VKEY_BACKSLASH GLFW_KEY_BACKSLASH
76 | #define VKEY_RIGHT_BRACKET GLFW_KEY_RIGHT_BRACKET
77 | #define VKEY_GRAVE_ACCENT GLFW_KEY_GRAVE_ACCENT
78 | #define VKEY_WORLD_1 GLFW_KEY_WORLD_1
79 | #define VKEY_WORLD_2 GLFW_KEY_WORLD_2
--------------------------------------------------------------------------------
/include/base/test/vTest.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vTest.h
25 | * \brief The test library
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | #include
34 |
35 | #define VUnitTest(MODULE, X) __VTest_MARCO_##MODULE##X()
36 | #define VUnitTestM(MODULE, X) __VTest_MARCO_##MODULE##X
37 |
38 | /***
39 | * The test task class
40 | */
41 | class VTestTask {
42 | public:
43 | VTestTask(std::function Function, const std::string &TaskName);
44 |
45 | public:
46 | /***
47 | * Start test
48 | * @return Whether the test task failed
49 | */
50 | [[nodiscard]] bool Conduct() const {
51 | return _task();
52 | }
53 |
54 | private:
55 | std::function _task;
56 |
57 | public:
58 | std::string TaskID;
59 | };
60 |
61 | /***
62 | * The test conductor class
63 | */
64 | class VTestConductor {
65 | public:
66 | VTestConductor() = default;
67 |
68 | public:
69 | /***
70 | * Add testing task
71 | * @param Task The test task
72 | */
73 | void AddTask(const VTestTask &Task);
74 | /***
75 | * Start the test task
76 | */
77 | void StartTasks();
78 |
79 | private:
80 | std::vector _taskList;
81 | };
--------------------------------------------------------------------------------
/include/base/vBase.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vBase.h
25 | * \brief The base library in VUILib
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | #include
35 | #include
36 |
37 | #pragma warning(disable : 4244)
38 |
39 | namespace std {
40 | /**
41 | * The template specialization for std::hash in order to provide for unordered_map key
42 | */
43 | template <> struct hash {
44 | _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef ostr::text argument_type;
45 | _CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t result_type;
46 | _NODISCARD size_t operator()(const ostr::text _Keyval) const noexcept {
47 | return hash().operator()(_Keyval.c_str());
48 | }
49 | };
50 | } // namespace std
51 |
52 | using OString = ostr::text;
53 | using OStringView = ostr::text_view;
54 |
55 | namespace VConcept {
56 | template class C, typename... Ts> std::true_type IsBaseOfImpl(const C *);
57 |
58 | template class C> std::false_type IsBaseOfImpl(...);
59 |
60 | template class C, typename T> using IsBaseOf = decltype(IsBaseOfImpl(std::declval()));
61 | } // namespace VConcept
62 |
63 | template
64 | requires std::is_integral_v or std::is_floating_point_v
65 | std::vector VRange(const RangeType &Start, const RangeType &End, const RangeType &Step = RangeType(1)) {
66 | std::vector result;
67 | for (RangeType count = Start; count < End; count += Step) {
68 | result.emplace_back(count);
69 | }
70 |
71 | return result;
72 | }
--------------------------------------------------------------------------------
/include/control/button/vAbstractButton.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vAbstractButton.h
25 | * \brief The abstract button of the button control in VUILib
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The abstract button in the VUILib, which provide a set of the
34 | * signals of the button which is generally used
35 | */
36 | class VAbstractButton : public VObject {
37 | public:
38 | /**
39 | * Construct the button with default size (generally is 80x20), with the
40 | * specified parent object
41 | */
42 | explicit VAbstractButton();
43 | /**
44 | * Construct the button with specified size, with the specified parent object
45 | * @param Parent The parent object pointer
46 | * @param Width The specified width size
47 | * @param Height The specified height size
48 | */
49 | VAbstractButton(const int &Width, const int &Height);
50 |
51 | public:
52 | /**
53 | * When the button was clicked, the event will be triggered
54 | */
55 | VEvent<> OnClicked;
56 | /**
57 | * When the button was hovered by mouse, this event will be triggered
58 | */
59 | VEvent<> OnHover;
60 | /**
61 | * When the button was left from the button, this event will be triggered
62 | */
63 | VEvent<> OnLeft;
64 |
65 | private:
66 | /**
67 | * Init the button object
68 | * @param Parent The specified parent of the button object
69 | * @param Width The width of the button
70 | * @param Height The height of the button
71 | */
72 | void InitAbstractButton(const int &Width, const int &Height);
73 | };
--------------------------------------------------------------------------------
/include/control/button/vPushButton.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vPushButton.h
25 | * \brief The push button class in VUILib
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | /**
35 | * The push button in the VUILib, this button provide a property "text"
36 | * as the display text on the button
37 | */
38 | class VPushButton : public VAbstractButton {
39 | public:
40 | /**
41 | * Create the button in default size with the specified parent
42 | * @param Parent The parent of the button object
43 | * @param Text The text on the button
44 | */
45 | VPushButton(VObject *Parent, const OString &Text);
46 | /**
47 | * Create the button in default size with the specified parent and
48 | * geometry size
49 | * @param Parent The parent of the button object
50 | * @param Width The width of the button object
51 | * @param Height The height of the button object
52 | * @param Text The text on the button
53 | */
54 | VPushButton(VObject *Parent, const int &Width, const int &Height, const OString &Text);
55 |
56 | public:
57 | /**
58 | * Set the rich text context of the button
59 | * @param Text The rich text code
60 | */
61 | void SetRichText(const OString &Text);
62 | /**
63 | * Set the plain text of the button, which doesn't support the rich text
64 | * @param Text The text in plain form
65 | */
66 | void SetPlainText(const OString &Text);
67 | /**
68 | * Get the plain text of the button, which will format every rich text control
69 | * symbol
70 | * @return The text in plain form
71 | */
72 | [[nodiscard]] OString GetPlainText() const;
73 |
74 | public:
75 | void OnPaint(sk_sp &Surface) override;
76 |
77 | private:
78 | /**
79 | * Init the property of the button
80 | * @param Text The text display on the button
81 | */
82 | void InitProperty(const OString &Text);
83 |
84 | private:
85 | VStringProperty *_text;
86 | VHTMLAST *_AST;
87 | };
--------------------------------------------------------------------------------
/include/control/shape/vRectangleControl.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRectangleControl.h
25 | * \brief The basic shape control of a rectangle
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The rectangle control, the rectangle control will display a rectangle on the screen
34 | */
35 | class VRectangleControl : public VObject {
36 | public:
37 | /**
38 | * Init the rectangle control with specified geometry information
39 | * @param Width The width of the rectangle control
40 | * @param Height The height of the rectangle control
41 | * @param Parent The parent of the rectangle control
42 | */
43 | VRectangleControl(const int &Width, const int &Height, VObject *Parent);
44 | /**
45 | * Init the rectangle control with specified parent
46 | * @param Parent The parent of the rectangle control
47 | */
48 | explicit VRectangleControl(VObject *Parent);
49 |
50 | public:
51 | /**
52 | * Set the radius of the border
53 | * @param Radius The border radius
54 | */
55 | void SetBorderRadius(const float &Radius);
56 | /**
57 | * Set the background color
58 | * @param Color The color of the background
59 | */
60 | void SetBackgroundColor(const SkColor &Color);
61 | /**
62 | * Set the border color
63 | * @param Color The color of the border
64 | */
65 | void SetBorderColor(const SkColor &Color);
66 |
67 | public:
68 | void OnPaint(sk_sp &Surface) override;
69 |
70 | private:
71 | /**
72 | * Init the property by default with the color in white
73 | */
74 | void InitProperty();
75 |
76 | private:
77 | VFloatProperty *_borderRadius;
78 | VColorProperty *_backgroundColor;
79 | VColorProperty *_borderColor;
80 | };
--------------------------------------------------------------------------------
/include/layout/vPanelLayout.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vPanelLayout.h
25 | * \brief The panel layout in VUILib, the basic panel base class
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The default panel default class in VUILib, it provides one property for all child class:
34 | * panel.align : Allow "left" or "right", "top", "bottom", "center"
35 | * The control will overlap when them share the same position flag
36 | */
37 | class VPanel : public VObject {
38 | public:
39 | explicit VPanel(VObject *Parent);
40 | VPanel(VObject *Parent, const int &Width, const int &Height);
41 |
42 | public:
43 | /**
44 | * Measure the rectangle size of the panel, return the rectangle related to the origin point (0, 0)
45 | * @return The size rectangle related to the origin point (0, 0)
46 | */
47 | virtual VRect SizeMeasure();
48 | /**
49 | * Arrange the panel child objects
50 | */
51 | virtual void Arrange();
52 |
53 | public:
54 | void OnLayoutRearrange() override;
55 |
56 | public:
57 | void OnPaint(sk_sp &Surface) override {
58 | }
59 |
60 | public:
61 | static constexpr const char *PN_PanelAlign = "panel.align";
62 | static constexpr const char *PN_PanelAlignLeft = "left";
63 | static constexpr const char *PN_PanelAlignCenter = "center";
64 | static constexpr const char *PN_PanelAlignRight = "right";
65 |
66 | public:
67 | VPropertyRegister P_PanelAlign;
68 | };
--------------------------------------------------------------------------------
/include/layout/vStackPanelLayout.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vStackPanelLayout.h
25 | * \brief The stack panel, every element in stack panel will be arranged from top to bottom
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The stack panel, every element in stack panel will be arranged from top to bottom
34 | * it provides one property for all child class:
35 | * stack.align : Allow "left" or "right", "center"
36 | * stack.margin.top : Allow a number to set the margin related to the top
37 | * stack.margin.bottom : Allow a number to set the margin related to the bottom
38 | */
39 | class VStackPanel : public VObject {
40 | public:
41 | explicit VStackPanel(VObject *Parent);
42 | VStackPanel(VObject *Parent, const int &Width, const int &Height);
43 |
44 | public:
45 | /**
46 | * Measure the rectangle size of the panel, return the rectangle related to the origin point (0, 0)
47 | * @return The size rectangle related to the origin point (0, 0)
48 | */
49 | virtual VRect SizeMeasure();
50 | /**
51 | * Arrange the panel child objects
52 | */
53 | virtual void Arrange();
54 |
55 | public:
56 | void OnLayoutRearrange() override;
57 |
58 | public:
59 | void OnPaint(sk_sp &Surface) override {
60 | }
61 |
62 | public:
63 | static constexpr const char *PN_StackAlign = "stack.align";
64 | static constexpr const char *PN_StackAlignLeft = "left";
65 | static constexpr const char *PN_StackAlignCenter = "center";
66 | static constexpr const char *PN_StackAlignRight = "right";
67 | static constexpr const char *PN_MarginTop = "stack.margin.top";
68 | static constexpr const char *PN_MarginBottom = "stack.margin.bottom";
69 |
70 | public:
71 | VPropertyRegister P_StackAlign;
72 | VPropertyRegister P_Margin;
73 | VPropertyRegister P_MarginTop;
74 | VPropertyRegister P_MarginBottom;
75 | };
--------------------------------------------------------------------------------
/include/layout/vWrapPanelLayout.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vWrapPanelLayout.h
25 | * \brief The wrap panel in VUILib, it arranges elements in the specified direction
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The wrap panel, it arranges elements in the specified direction.
34 | * It allows the "direction" property, when the property is "vertical" it
35 | * will arrange the elements in vertical direction, by default it will arrange
36 | * the elements in horizontal direction
37 | */
38 | class VWrapPanel : public VObject {
39 | public:
40 | explicit VWrapPanel(VObject *Parent);
41 | VWrapPanel(VObject *Parent, const int &Width, const int &Height);
42 |
43 | public:
44 | /**
45 | * Measure the rectangle size of the panel, return the rectangle related to the origin point (0, 0)
46 | * @return The size rectangle related to the origin point (0, 0)
47 | */
48 | virtual VRect SizeMeasure();
49 | /**
50 | * Arrange the panel child objects
51 | */
52 | virtual void Arrange();
53 |
54 | public:
55 | void OnLayoutRearrange() override;
56 |
57 | public:
58 | void OnPaint(sk_sp &Surface) override {
59 |
60 | }
61 |
62 | private:
63 | /**
64 | * Init the panel's property
65 | */
66 | void InitProperty();
67 |
68 | private:
69 | VStringProperty *_direction;
70 | };
--------------------------------------------------------------------------------
/include/mvvm/vModelBase.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vModelBase.h
25 | * \brief The model layer base class in MVVM
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The class is the base class for model layer in MVVM for VUILib
34 | */
35 | class VModelBase {
36 | public:
37 | VModelBase() = default;
38 |
39 | public:
40 | /**
41 | * When data on changing, view model layer can emit this signal
42 | * or just depend on two-way binding.
43 | */
44 | VEvent OnChange;
45 | };
46 |
47 | template
48 | concept VIsModelClass = std::is_base_of::value;
--------------------------------------------------------------------------------
/include/mvvm/vViewBase.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vViewBase.h
25 | * \brief The view layer base class in MVVM
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The class is the base class for view layer in MVVM for VUILib
34 | * @tparam Model The model layer class type, make sure the class can be directly free
35 | * @tparam Parameter The init parameter for the model class
36 | */
37 | template
38 | requires VIsViewModel
39 | class VViewBase : public VViewModel {
40 | public:
41 | /**
42 | * Constructing the model by the parameter of model class
43 | * @param ModelParameter The parameter to construct the model class
44 | */
45 | explicit VViewBase(Parameter... ModelParameter) {
46 | InitModel(std::forward(ModelParameter...));
47 | }
48 | /**
49 | * Constructing the model by an existed model instance, the view model class
50 | * will take over the life cycle of a model pointer
51 | * @param ModelPointer
52 | */
53 | explicit VViewBase(ViewModel *ViewModelPointer) : _viewModelPointer(ViewModelPointer) {
54 | }
55 | ~VViewBase() {
56 | // Make sure every model pointer is directly deletable.
57 | delete _viewModelPointer;
58 | }
59 |
60 | private:
61 | /**
62 | * Init the model base class
63 | * @param ModelParameter The parameter for the base class
64 | */
65 | inline void InitModel(Parameter... ModelParameter) {
66 | _viewModelPointer = new ViewModel;
67 | }
68 |
69 | protected:
70 | ViewModel *_viewModelPointer;
71 | };
--------------------------------------------------------------------------------
/include/mvvm/vViewModelBase.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vViewModelBase.h
25 | * \brief The view model layer base class in MVVM
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The class is the base class for view model layer in MVVM for VUILib
34 | * @tparam Model The model layer class type, make sure the class can be directly free
35 | * @tparam Parameter The init parameter for the model class
36 | */
37 | template
38 | requires VIsModelClass
39 | class VViewModel : public Model {
40 | public:
41 | /**
42 | * Constructing the model by the parameter of model class
43 | * @param ModelParameter The parameter to construct the model class
44 | */
45 | explicit VViewModel(Parameter... ModelParameter) {
46 | InitModel(std::forward(ModelParameter...));
47 | }
48 | /**
49 | * Constructing the model by an exists model instance, the view model class
50 | * will take over the life cycle of model pointer
51 | * @param ModelPointer
52 | */
53 | explicit VViewModel(Model *ModelPointer) : _modelPointer(ModelPointer) {
54 | }
55 | ~VViewModel() {
56 | // Make sure every model pointer are directly deletable.
57 | delete _modelPointer;
58 | }
59 |
60 | private:
61 | /**
62 | * Init the model base class
63 | * @param ModelParameter The parameter for the base class
64 | */
65 | inline void InitModel(Parameter... ModelParameter) {
66 | _modelPointer = new Model;
67 | }
68 |
69 | protected:
70 | Model *_modelPointer;
71 | };
72 |
73 | template
74 | concept VIsViewModel = VConcept::IsBaseOf::value;
--------------------------------------------------------------------------------
/include/parser/html/vHTMLAST.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vHTMLAST.h
25 | * \brief The HTML AST generator in VUILib
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The exception for missing comparison in HTML AST, it provides a format
34 | * function for exception info and will directly print the information
35 | * on the console whether in debug mode or not
36 | */
37 | class VHTMLASTMissingComparison : public std::exception {
38 | public:
39 | VHTMLASTMissingComparison(const OString &What, const int &Line, const int &Position);
40 |
41 | public:
42 | const char *what() const {
43 | return reinterpret_cast(_info.c_str());
44 | }
45 |
46 | private:
47 | OString _info;
48 | };
49 |
50 | /**
51 | * The tree node of HTML AST
52 | */
53 | class VHTMLASTNode {
54 | public:
55 | /**
56 | * The default construction of AST node
57 | */
58 | VHTMLASTNode() = default;
59 | ~VHTMLASTNode();
60 |
61 | public:
62 | /**
63 | * Judge whether this node exist a child node with specified ID
64 | * @param Id The specified ID of the child node
65 | * @return If the return value is true, it's existing, nor not exist
66 | */
67 | [[nodiscard]] bool ExistChild(const OString &Id) const;
68 | /**
69 | * Get the child with specified ID
70 | * @param Id The specified ID of the child node
71 | * @return If the child dose not existing, it will return nullptr, nor
72 | * returning the readonly pointer to children
73 | */
74 | [[nodiscard]] std::optional GetChild(const OString &Id) const;
75 | /**
76 | * Get the beginning iterator of the children list
77 | * @return The beginning iterator
78 | */
79 | [[nodiscard]] auto begin() const {
80 | return _childNode.begin();
81 | }
82 | /**
83 | * Get the end iterator of the children list
84 | * @return The end iterator
85 | */
86 | [[nodiscard]] auto end() const {
87 | return _childNode.end();
88 | }
89 | /**
90 | * Get the id of the HTML AST node
91 | * @return The id of the HTML AST node
92 | */
93 | [[nodiscard]] const OString GetId() const {
94 | return _id;
95 | }
96 |
97 | public:
98 | /**
99 | * The property of the node
100 | */
101 | std::unordered_map Property;
102 | /**
103 | * The context of the node
104 | */
105 | OString Context;
106 |
107 | private:
108 | friend class VHTMLAST;
109 |
110 | private:
111 | std::vector _childNode;
112 | OString _id;
113 | };
114 |
115 | /**
116 | * The AST generator of HTML in VUILib
117 | */
118 | class VHTMLAST {
119 | public:
120 | /**
121 | * Construct the AST generator by the HTML code
122 | * @param Code The code of HTML
123 | */
124 | explicit VHTMLAST(const OString &Code);
125 | ~VHTMLAST();
126 |
127 | public:
128 | /**
129 | * Get the root node of the AST tree
130 | * @return The pointer referred to root node
131 | */
132 | [[nodiscard]] VHTMLASTNode *GetRoot() const;
133 |
134 | private:
135 | /**
136 | * Generate the AST
137 | * @param Parent The parent node of the AST
138 | * @return The root ast node pointer
139 | */
140 | VHTMLASTNode *GenerateAST();
141 |
142 | private:
143 | VHTMLASTNode *_root;
144 | VHTMLLexer _lexer;
145 | };
--------------------------------------------------------------------------------
/include/parser/html/vHTMLEscapeCharacter.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vHTMLEscapeCharacter.h
25 | * \brief The escape character in the HTML language for the VUILib HTML parser
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | class VHTMLInvalidEscapeCharacter : public std::exception {
33 | public:
34 | VHTMLInvalidEscapeCharacter(const OString &Character);
35 |
36 | public:
37 | const char *what() const {
38 | return reinterpret_cast(_info.c_str());
39 | }
40 |
41 | private:
42 | OString _info;
43 | };
44 |
45 | /**
46 | * The helper class for escape character mapping
47 | */
48 | class VHTMLEscapeMap {
49 | public:
50 | /**
51 | * Convert the escape character into the specified
52 | * @param Character The escape character with & control symbol and ; end symbol
53 | * @return The converted string from escape symbol
54 | */
55 | static OString EscapeConvert(const OString &Character);
56 | };
--------------------------------------------------------------------------------
/include/renderer/vColorFactory.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vColorFactory.h
25 | * \brief The color factory class in VUILib renderer
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | #include
34 |
35 | /**
36 | * The color helper in VUILib renderer, all of
37 | */
38 | class VColorFactory {
39 | public:
40 | /**
41 | * Create a color object from the hex string
42 | * @param Color The hex color string, which can start with '#' or not
43 | * @return The SkColor object formatted from the hex string
44 | */
45 | static SkColor MakeFromHexString(const OString &Color) {
46 | auto length = Color.size();
47 | if ((length < 6 || length > 7) || Color[0] == '#' && length == 6) {
48 | throw std::logic_error("Wrong hex string format!");
49 | }
50 | if (Color[0] != '#' && length == 7) {
51 | auto str = ostr::format("Wrong hex string, do you mean #{}?", Color.subview(1, 6));
52 | auto errorFormat = new char[str.size() + 1];
53 | strcpy_s(errorFormat, str.size(), str.c_str());
54 | throw std::logic_error(errorFormat);
55 | }
56 | auto hexString = length == 7 ? Color.subview(1, 6) : Color;
57 | OString standardString;
58 | for (auto count = 0; count < hexString.size(); ++count) {
59 | auto character = char32_t(hexString[count]);
60 | if (character >= 'A' && character <= 'Z') {
61 | character += 32;
62 | }
63 |
64 | standardString += character;
65 | }
66 |
67 | auto rString = hexString.subview(0, 2);
68 | auto gString = hexString.subview(2, 2);
69 | auto bString = hexString.subview(4, 2);
70 |
71 | auto r = ToDecimal(rString, 16);
72 | auto g = ToDecimal(gString, 16);
73 | auto b = ToDecimal(bString, 16);
74 |
75 | return VColorFactory::MakeRGB(r, g, b);
76 | }
77 | /**
78 | * Make a SkColor object from the Red, Green, Blue value
79 | * @param R The red value
80 | * @param G The green value
81 | * @param B The blue value
82 | * @return A SkColor object with specified color
83 | */
84 | static SkColor MakeRGB(const short &R, const short &G, const short &B) {
85 | return SkColorSetRGB(R, G, B);
86 | }
87 | /**
88 | * Make a SkColor object from the Red, Green, Blue and alpha value
89 | * @param A The alpha value
90 | * @param R The red value
91 | * @param G The green value
92 | * @param B The blue value
93 | * @return A SkColor object with specified color in target alpha value
94 | */
95 | static SkColor MakeARGB(const short &A, const short &R, const short &G, const short &B) {
96 | return SkColorSetARGB(A, R, G, B);
97 | }
98 | /**
99 | * Get the alpha value of the color
100 | * @param Color The target color
101 | * @return The alpha value of the color
102 | */
103 | static short GetA(const SkColor &Color) {
104 | return SkColorGetA(Color);
105 | }
106 | /**
107 | * Get the red value of the color
108 | * @param Color The target color
109 | * @return The red value of the color
110 | */
111 | static short GetR(const SkColor &Color) {
112 | return SkColorGetR(Color);
113 | }
114 | /**
115 | * Get the blue value of the color
116 | * @param Color The target color
117 | * @return The blue value of the color
118 | */
119 | static short GetB(const SkColor &Color) {
120 | return SkColorGetB(Color);
121 | }
122 | /**
123 | * Get the green value of the color
124 | * @param Color The target color
125 | * @return The green value of the color
126 | */
127 | static short GetG(const SkColor &Color) {
128 | return SkColorGetG(Color);
129 | }
130 |
131 | private:
132 | /**
133 | * Convert the string from specified radix to the decimal number
134 | * @param string The origin string
135 | * @param radix The source radix
136 | * @return The number in decimal number converted from the radix
137 | */
138 | static int ToDecimal(OString string, int radix) {
139 | int result = 0;
140 | for (int count = 0; count < string.size(); count++) {
141 | auto ch = char32_t(string[count]);
142 |
143 | if (ch >= '0' && ch <= '9') {
144 | result = result * radix + (ch - '0');
145 | } else {
146 | result = result * radix + (ch - 'a' + 10);
147 | }
148 | }
149 |
150 | return result;
151 | }
152 | };
--------------------------------------------------------------------------------
/include/renderer/vGLHeader.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vGLHeader.h
25 | * \brief The OpenGL header
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
--------------------------------------------------------------------------------
/include/renderer/vRenderContext.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRenderContext.h
25 | * \brief The render context wrapper of Skia
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | /**
34 | * The render context wrapper of Skia
35 | */
36 | class VRenderContext : public SkRefCnt {
37 | public:
38 | /**
39 | * Construct the render context by interface
40 | * @param Interface The interface's pointer
41 | */
42 | explicit VRenderContext(const sk_sp &Interface);
43 | ~VRenderContext() = default;
44 |
45 | public:
46 | /**
47 | * Get the native object(Skia object) of render context
48 | * @return The skia render context object
49 | */
50 | auto &GetNativeContext() {
51 | return _context;
52 | }
53 |
54 | private:
55 | sk_sp _context;
56 | };
--------------------------------------------------------------------------------
/include/renderer/vRenderInterface.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRenderInterface.h
25 | * \brief The GLInterface wrapper of Skia
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The GLInterface wrapper of Skia
34 | */
35 | class VRenderInterface : public SkRefCnt {
36 | public:
37 | /**
38 | * Construct the render interface by default with Skia
39 | * GrGLMakeNativeInterface API
40 | */
41 | VRenderInterface();
42 | ~VRenderInterface() = default;
43 |
44 | public:
45 | /**
46 | * Get the native object(Skia object) of render interface
47 | * @return The skia render interface object
48 | */
49 | auto &GetNativeInterface() {
50 | return _interface;
51 | }
52 |
53 | private:
54 | sk_sp _interface;
55 | };
--------------------------------------------------------------------------------
/include/renderer/vRenderTarget.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRenderTarget.h
25 | * \brief A render target wrapper of Skia
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | struct VRenderTargetViewport {
33 | int Width;
34 | int Height;
35 | int X;
36 | int Y;
37 | };
38 |
39 | /**
40 | * The render target class, usually combine with a widget
41 | */
42 | class VRenderTarget : public SkRefCnt {
43 | public:
44 | /**
45 | * Construct the render target by viewport
46 | * @param Viewport The viewport of render target
47 | */
48 | explicit VRenderTarget(const VRenderTargetViewport &Viewport);
49 |
50 | public:
51 | /**
52 | * Get the native object(Skia object) of render target
53 | * @return The skia render target object
54 | */
55 | auto &GetNativeRenderTarget() {
56 | return _renderTarget;
57 | }
58 |
59 | private:
60 | GrBackendRenderTarget _renderTarget;
61 | };
--------------------------------------------------------------------------------
/include/renderer/vSurface.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vSurface.h
25 | * \brief The surface class of VRenderer
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | /**
35 | * The surface wrapper of Skia surface class
36 | */
37 | class VSurface : public SkRefCnt {
38 | public:
39 | /**
40 | * Allocates raster surface, in general, create a surface in memory.
41 | * Pixel memory will be deleted when VSurface is deleted.
42 | * @param Width The width of raster surface
43 | * @param Height The height of raster surface
44 | */
45 | VSurface(const int &Width, const int &Height);
46 | /**
47 | * Create a new surface object with an existed skia surface pointer
48 | * @param Surface The sk_sp pointer referred to the surface object
49 | */
50 | VSurface(sk_sp &&Surface);
51 | /**
52 | * Construct the surface by render target and render a context object.
53 | * @param RenderTarget The render target object
54 | * @param Context The render context object.
55 | */
56 | explicit VSurface(const sk_sp &RenderTarget, const sk_sp &Context);
57 | ~VSurface() = default;
58 |
59 | public:
60 | /**
61 | * Get the native surface object
62 | * @return The SkSurface object in a smart pointer
63 | */
64 | auto &GetNativeSurface() {
65 | return _surface;
66 | }
67 |
68 | private:
69 | sk_sp _surface;
70 | };
--------------------------------------------------------------------------------
/include/style/vRadixStyle.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining af this software and associated documentation
5 | * files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use,
6 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to
7 | * whom the Software is furnished to do so, subject to the following conditions:
8 | *
9 | * The above copyright notice and this permission notice shall be included in all
10 | * copies or substantial portions of the Software.
11 | *
12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18 | * SOFTWARE.
19 | */
20 |
21 | /**
22 | * \file vRadixStyle.h
23 | * \brief The default style factory in Radix theme
24 | */
25 |
26 | #pragma once
27 |
28 | #include
29 | #include
30 |
31 | /**
32 | * This helper will create the theme color which determined by the
33 | * theme color specified by user
34 | */
35 | class VRadixColorHelper {
36 | public:
37 | /**
38 | * Get the specified gradient color in specified level; Radix theme design a
39 | * set of color format rules; Obey it
40 | * @param Level The gradient color level
41 | * @param BackgroundColor The background color
42 | * @param ThemeColor The theme color
43 | * @return The color in specified color level
44 | */
45 | static SkColor GetGradientColor(const int &Level, const SkColor &BackgroundColor, const SkColor &ThemeColor) {
46 | if (Level > 12) {
47 | throw std::logic_error("Gradient level shouldn't greater than 12!");
48 | }
49 | auto alpha = Level / 12 * 255;
50 | auto r = (VColorFactory::GetR(ThemeColor) * alpha + VColorFactory::GetR(BackgroundColor) * 256) / 256;
51 | auto g = (VColorFactory::GetG(ThemeColor) * alpha + VColorFactory::GetG(BackgroundColor) * 256) / 256;
52 | auto b = (VColorFactory::GetB(ThemeColor) * alpha + VColorFactory::GetB(BackgroundColor) * 256) / 256;
53 |
54 | return VColorFactory::MakeRGB(r, g, b);
55 | }
56 | };
57 |
58 | /**
59 | * VUILib provide two types of style
60 | */
61 | enum class VRadixStyleType {
62 | light,
63 | dark
64 | };
65 |
66 | /**
67 | * This class will product two style functions in dark or light format
68 | */
69 | class VRadixStyleFactory {
70 | public:
71 | /**
72 | * Get the style function in specified theme format
73 | * @param Style The theme format, light or dark
74 | * @param ThemeColor The theme color
75 | * @return The style function in specified theme style
76 | */
77 | static VStyleFunction GetStyle(const VRadixStyleType &Style, const SkColor &ThemeColor) {
78 | switch (Style) {
79 | case VRadixStyleType::light: {
80 | auto backgroundColor = VColorFactory::MakeRGB(255, 255, 255);
81 |
82 | VStyleFunction style;
83 | auto windowBackgroundColor =
84 | std::make_unique(VRadixColorHelper::GetGradientColor(0, backgroundColor, ThemeColor));
85 |
86 | style.RegisterProperty("window.background.color", std::move(windowBackgroundColor));
87 |
88 | return style;
89 | }
90 | case VRadixStyleType::dark: {
91 | auto backgroundColor = VColorFactory::MakeRGB(11, 11, 11);
92 |
93 | VStyleFunction style;
94 | auto windowBackgroundColor =
95 | std::make_unique(VRadixColorHelper::GetGradientColor(0, backgroundColor, ThemeColor));
96 |
97 | style.RegisterProperty("window.background.color", std::move(windowBackgroundColor));
98 |
99 | return style;
100 | }
101 | }
102 | }
103 | };
--------------------------------------------------------------------------------
/include/style/vStyleCollection.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vStyleCollection.h
25 | * \brief The style set collection in VUILib, it collects a set of
26 | * VStyleFunction to meet the requirement
27 | */
28 |
29 | #pragma once
30 |
31 | #include
32 |
33 | /**
34 | * The style set collection in VUILib, it collects a set of
35 | * VStyleFunction to meet the requirement. By default, it will
36 | * create two sets; One is light, one is dark.
37 | */
38 | class VStyleCollection {
39 | public:
40 | VStyleCollection();
41 |
42 | private:
43 | std::unordered_map _collection;
44 | };
--------------------------------------------------------------------------------
/include/style/vStyleFunction.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vStyleFunction.h
25 | * \brief The function method to store the style sheet
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | using VStyleProperty = VObjectProperty;
34 |
35 | /**
36 | * The style function store class for the style system in VUILib
37 | */
38 | class VStyleFunction final {
39 | public:
40 | VStyleFunction() = default;
41 |
42 | public:
43 | /**
44 | * Get the property by the specified name
45 | * @param Name The name of the property
46 | * @return The reference of the property instance
47 | */
48 | VStyleProperty &GetProperty(const OString &Name);
49 |
50 | protected:
51 | /**
52 | * Add a property to the object
53 | * @tparam Type The type of the target value
54 | * @param Name The property name
55 | * @param Pointer The pointer referred to the pointer
56 | */
57 | template
58 | requires std::is_base_of_v
59 | void RegisterProperty(const OString &Name, std::unique_ptr &&Pointer) {
60 | return RegisterProperty(Name, std::move(reinterpret_cast &&>(Pointer)));
61 | }
62 | /**
63 | * Add a property to the object
64 | * @param Name The property name
65 | * @param Pointer The pointer referred to the pointer
66 | */
67 | void RegisterProperty(const OString &Name, std::unique_ptr &&Pointer);
68 | /**
69 | * Get the property value in specified type format
70 | * @tparam Type The type of the target value
71 | * @param Name The property name
72 | */
73 | template
74 | requires std::is_base_of_v
75 | Type *GetPropertyValue(const OString &Name) {
76 | return GetProperty(Name).GetValue()->Cast();
77 | }
78 |
79 | private:
80 | friend class VRadixStyleFactory;
81 | friend class VApplication;
82 |
83 | protected:
84 | VPropertyList _propertyList;
85 | };
--------------------------------------------------------------------------------
/include/widget/vGLFWCallback.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vGLFWCallback.h
25 | * \brief The callback function wrapper
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The base GLFW callback base class for GLFW callback function to be called
34 | */
35 | class VGLFWWidget {
36 | public:
37 | // "Repainting" dose not means "RearrangeLayout Rearranging" but "RearrangeLayout Rearranging" means "Repainting"
38 | virtual void OnGLFWLayoutRearranging(const int &Width, const int &Height) = 0;
39 | virtual void OnGLFWRepaint(const int &Width, const int &Height) = 0;
40 | virtual void OnGLFWMouseMove(const int &X, const int &Y) = 0;
41 | virtual void OnGLFWMouseClick(const int &X, const int &Y, const int &Button, const int &Action,
42 | const int &Mods) = 0;
43 | };
44 |
45 | void VGLFWRegisterObject(VGLFWWidget *Widget, GLFWwindow *Window);
46 | void VGLFWLayoutRearrangingCallback(GLFWwindow *Window, int Width, int Height);
47 | void VGLFWFramebufferSizeCallback(GLFWwindow *Window, int Width, int Height);
48 | void VGLFWMouseMoveCallback(GLFWwindow *Window, double X, double Y);
49 | void VGLFWMouseClickCallback(GLFWwindow *Window, int Button, int Action, int Mods);
--------------------------------------------------------------------------------
/include/widget/vGLFWException.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vGLFWException.h
25 | * \brief The type exception for GLFW
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | class VGLFWFailure : public std::exception {
34 | public:
35 | VGLFWFailure(const char *Message) : std::exception() {
36 | printf("VUILib Exception : GLFW Failure %s", Message);
37 | }
38 | };
39 | class VGLFWInstanceCreationFailed : public std::exception {
40 | public:
41 | VGLFWInstanceCreationFailed(const char *InstanceType) : std::exception() {
42 | const auto message = std::format("Failed to create GLFW instance(type:{})", InstanceType);
43 | printf("VUILib Exception : GLFW Failure. %s", message.c_str());
44 | }
45 | };
46 | class VGLFWInvalidInstance : public std::exception {
47 | public:
48 | VGLFWInvalidInstance(const char *InstanceType) : std::exception() {
49 | const auto message = std::format("Invalid instance(type:{})", InstanceType);
50 | printf("VUILib Exception : GLFW Failure. %s", message.c_str());
51 | }
52 | };
--------------------------------------------------------------------------------
/include/widget/vMainWindow.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vMainWindow.h
25 | * \brief The major window in the VUILib, the lifetime of the main window
26 | * is also the lifetime of the program
27 | */
28 |
29 | #pragma once
30 |
31 | #include
32 |
33 | /**
34 | * The major window in the VUILib, the lifetime of the main window
35 | * is also the lifetime of the program, it will bind to the main window
36 | * of the application object which determined the main loop's lifetime
37 | */
38 | class VMainWindow : public VWidget {
39 | public:
40 | /**
41 | * Construct the widget with only geometry information
42 | * @param Application The application instance of the widget
43 | * @param Width The width of the widget
44 | * @param Height The height of the widget
45 | * @param Title The title of the widget
46 | */
47 | VMainWindow(VApplication *Application, const int &Width, const int &Height, const OString &Title);
48 | /**
49 | * Create a widget with geometry information on a specified monitor,
50 | * it will create a full-screen window by the specified geometry information.
51 | * @param Application The application instance of the widget
52 | * @param Width The width of the widget
53 | * @param Height The height of the widget
54 | * @param Title The title of the widget
55 | * @param Monitor The specified monitor where window to be shown
56 | */
57 | VMainWindow(VApplication *Application, const int &Width, const int &Height, const OString &Title,
58 | VMonitor &Monitor);
59 | };
--------------------------------------------------------------------------------
/include/widget/vMonitor.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vMonitor.h
25 | * \brief The monitor wrapper of GLFW API
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | #include
34 |
35 | /**
36 | * The status for the monitor class
37 | *
38 | * When the monitor connect, it will be a valid monitor
39 | * instance, otherwise invalid
40 | */
41 | enum class VMonitorStatus {
42 | Valid,
43 | Invalid
44 | };
45 |
46 | /**
47 | * This class is a wrapper of GLFW monitor API, which will
48 | * maintain a GLFWmonitor pointer. When a monitor was connected
49 | * the instance of the monitor will be marked as valid, otherwise invalid.
50 | */
51 | class VMonitor {
52 | public:
53 | /**
54 | * Alias of int, used by the GLFW API
55 | */
56 | using MonitorEventType = int;
57 |
58 | public:
59 | /**
60 | * Create a monitor class by the monitor index
61 | * @param Index The index of the monitor, depending on the OS
62 | */
63 | explicit VMonitor(const int &Index);
64 | /**
65 | * By default, VMonitor will create the primary monitor instance
66 | */
67 | VMonitor();
68 |
69 | public:
70 | /**
71 | * Get the status of the monitor
72 | * @return If the monitor is connected or created properly, it will return
73 | * VMonitorStatus::Valid otherwise VMonitorStatus::Invalid
74 | */
75 | [[nodiscard]] VMonitorStatus GetStatus() const;
76 |
77 | public:
78 | /**
79 | * Get the width pixel of the monitor
80 | * @return The width pixel
81 | */
82 | [[nodiscard]] int GetWidth() const;
83 | /**
84 | * Get the height pixel of the monitor
85 | * @return The width pixel
86 | */
87 | [[nodiscard]] int GetHeight() const;
88 |
89 | private:
90 | /**
91 | * Function for GLFW monitor callback, it will emit the event
92 | * _monitorOnEvent to spread message to each instance of VMonitor
93 | * @param Monitor Provided by GLFW
94 | * @param Event Provided by GLFW
95 | */
96 | static void GLFWMonitorCallback(GLFWmonitor *Monitor, MonitorEventType Event) {
97 | _monitorOnEvent.Emit(Monitor, Event);
98 | }
99 | /**
100 | * The actual callback of the monitor event, when the monitor connected
101 | * this monitor instance will be marked as valid, otherwise invalid.
102 | * @param Monitor The monitor GLFW API pointer
103 | * @param Event The event type
104 | */
105 | void OnMonitor(GLFWmonitor *Monitor, MonitorEventType Event);
106 |
107 | private:
108 | friend class VWidget;
109 |
110 | private:
111 | /**
112 | * The event to convert GLFW message into VUILib's message bus
113 | */
114 | static VEvent _monitorOnEvent;
115 |
116 | private:
117 | VMonitorStatus _status;
118 | GLFWmonitor *_glfwMonitor;
119 | const GLFWvidmode *_glfwVideoMode;
120 | };
--------------------------------------------------------------------------------
/include/window/vWindowView.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vWindowView.h
25 | * \brief The extent of the view class in window form
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | /**
35 | * To inherit of the view base class in window form
36 | * @tparam ViewModel The view model class type
37 | * @tparam Parameter The construction parameter of the view mode class
38 | */
39 | template
40 | requires VIsViewModel
41 | class VWindowView : public VViewBase, VWidget {
42 | public:
43 | /**
44 | * Constructing the window view by the parameter of view model class and
45 | * the geometry information of the window
46 | * @param ModelParameter The parameter to construct the model class
47 | * @param Width The width of the widget
48 | * @param Height The height of the widget
49 | * @param Title The title of the widget
50 | */
51 | VWindowView(const int &Width, const int &Height, const OString &Title, Parameter... ModelParameter)
52 | : VViewBase(ModelParameter...), VWidget(Width, Height, Title) {
53 | }
54 | /**
55 | * Constructing the window view by the parameter of view model class and
56 | * the geometry information of the window in the specified monitor
57 | * @param ModelParameter The parameter to construct the model class
58 | * @param Width The width of the widget
59 | * @param Height The height of the widget
60 | * @param Title The title of the widget
61 | * @param Monitor The specified monitor where window to be shown
62 | */
63 | VWindowView(const int &Width, const int &Height, const OString &Title, VMonitor &Monitor,
64 | Parameter... ModelParameter)
65 | : VViewBase(ModelParameter...) {
66 | }
67 | ~VWindowView() override = default;
68 | };
--------------------------------------------------------------------------------
/include/write/vRichTextRenderer.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRichTextRenderer.h
25 | * \brief The HTML AST based rich text renderer in VUILib
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 |
32 | /**
33 | * The rich text renderer in VUILib
34 | */
35 | class VRichTextRenderer {
36 | public:
37 | /**
38 | * Construct the rich text renderer with the HTML AST
39 | * @param AST The HTML AST tree of the rich text
40 | */
41 | explicit VRichTextRenderer(VHTMLAST *AST);
42 |
43 | public:
44 | /**
45 | * Render the rich text on the canvas
46 | * @param Canvas The reference of the canvas
47 | * @param Bound The bound of the text area
48 | */
49 | void Render(SkCanvas *Canvas, const VRect &Bound);
50 |
51 | public:
52 | /**
53 | * Register a specified type label into the renderer
54 | * @tparam Type The type of the label interface
55 | */
56 | template
57 | requires std::is_base_of_v
58 | void RegisterLabel() {
59 | auto instance = new Type();
60 | if (!_interfaceManager.contains(instance->GetID())) {
61 | _interfaceManager.insert({instance->GetID(), instance});
62 | }
63 | }
64 |
65 | public:
66 | void SetLineSpace(const int &Value);
67 | [[nodiscard]] const int GetLineSpace() const;
68 | void SetWordSpace(const int &Value);
69 | [[nodiscard]] const int GetWordSpace() const;
70 |
71 | private:
72 | /**
73 | * Init the renderer default font set
74 | */
75 | void InitFontSet();
76 | /**
77 | * Init the native label interface
78 | */
79 | void InitLabels();
80 |
81 | private:
82 | VHTMLAST *_ast;
83 |
84 | private:
85 | SkScalar _lineSpace;
86 | SkScalar _wordSpace;
87 |
88 | private:
89 | std::vector _lineWidths;
90 | std::vector _lineHeights;
91 |
92 | private:
93 | sk_sp _otherTypeFace;
94 | sk_sp _englishTypeFace;
95 | SkFont _englishFont;
96 | SkFont _otherFont;
97 | SkColor _color;
98 | SkScalar _size;
99 |
100 | private:
101 | VRichTextLabelInterfaceManager _interfaceManager;
102 | };
--------------------------------------------------------------------------------
/libs/skia/README.txt:
--------------------------------------------------------------------------------
1 | Please build your Skia and put the lib files in this folder
--------------------------------------------------------------------------------
/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | int main() {
11 | // Start VTest
12 | VTestTask baseEventTest(VUnitTestM(BaseEvent, Recall), "base.event.free_function.recall");
13 | VTestTask baseEventBlockTest(VUnitTestM(BaseEvent, Block), "base.event.free_function.block");
14 | VTestTask baseEventRemoveTest(VUnitTestM(BaseEvent, Remove), "base.event.free_function.remove");
15 | VTestTask baseClassEventTest(VUnitTestM(BaseEventClass, Recall), "base.event.class.recall");
16 | VTestTask baseClassEventBlockTest(VUnitTestM(BaseEventClass, Block), "base.event.class.block");
17 | VTestTask baseClassEventRemoveTest(VUnitTestM(BaseEventClass, Remove), "base.event.class.remove");
18 | VTestTask baseBindingValueTest(VUnitTestM(BaseBinding, ValueTest), "base.binding.value");
19 | VTestTask baseBindingBindingValueTest(VUnitTestM(BaseBinding, BindingValueTest), "base.binding.reference.value");
20 | VTestTask baseBindingUnbindTest(VUnitTestM(BaseBinding, BindingValueTest), "base.binding.unbind");
21 | VTestTask baseBindingValueCompareTest(VUnitTestM(BaseBinding, ValueCompareTest), "base.binding.compare.value");
22 | VTestTask baseCommandRecall(VUnitTestM(BaseCommand, Recall), "base.command.recall");
23 | VTestTask baseCommandClassRecall(VUnitTestM(BaseCommand, ClassRecall), "base.command.class.recall");
24 | VTestTask baseGeometryPointConstruction(VUnitTestM(BaseGeometryPoint, Init), "base.geometry.point.init");
25 | VTestTask baseGeometryPointCalculate(VUnitTestM(BaseGeometryPoint, Calculate), "base.geometry.point.calculate");
26 | VTestTask baseGeometryPointCompare(VUnitTestM(BaseGeometryPoint, Compare), "base.geometry.point.compare");
27 | VTestTask baseGeometryRectConstruction(VUnitTestM(BaseGeometryRect, Init), "base.geometry.rect.init");
28 | VTestTask baseGeometryRectCompare(VUnitTestM(BaseGeometryRect, Compare), "base.geometry.rect.compare");
29 | VTestTask baseObjectCreate(VUnitTestM(ObjectProperty, Create), "base.object.create");
30 | VTestTask baseObjectRead(VUnitTestM(ObjectProperty, Read), "base.object.read");
31 | VTestTask baseObjectMemoryLeak(VUnitTestM(ObjectProperty, Read), "base.object.memory.leak");
32 | VTestTask rendererColorFactoryHexCreate(VUnitTestM(RendererColorFactory, HexCreate), "renderer.color.hex_create");
33 | VTestTask parserHTMLLexer(VUnitTestM(HTMLParser, Lexer), "parser.html.lexer");
34 | VTestTask parserHTMLAST(VUnitTestM(HTMLParser, AST), "parser.html.AST");
35 |
36 |
37 | VTestConductor conductor;
38 |
39 | conductor.AddTask(baseEventTest);
40 | conductor.AddTask(baseEventBlockTest);
41 | conductor.AddTask(baseEventRemoveTest);
42 | conductor.AddTask(baseClassEventTest);
43 | conductor.AddTask(baseClassEventBlockTest);
44 | conductor.AddTask(baseClassEventRemoveTest);
45 | conductor.AddTask(baseBindingValueTest);
46 | conductor.AddTask(baseBindingBindingValueTest);
47 | conductor.AddTask(baseBindingUnbindTest);
48 | conductor.AddTask(baseBindingValueCompareTest);
49 | conductor.AddTask(baseCommandRecall);
50 | conductor.AddTask(baseCommandClassRecall);
51 | conductor.AddTask(baseGeometryPointConstruction);
52 | conductor.AddTask(baseGeometryPointCalculate);
53 | conductor.AddTask(baseGeometryPointCompare);
54 | conductor.AddTask(baseGeometryRectConstruction);
55 | conductor.AddTask(baseGeometryRectCompare);
56 | conductor.AddTask(baseObjectCreate);
57 | conductor.AddTask(baseObjectRead);
58 | conductor.AddTask(baseObjectMemoryLeak);
59 | conductor.AddTask(rendererColorFactoryHexCreate);
60 | conductor.AddTask(parserHTMLLexer);
61 | conductor.AddTask(parserHTMLAST);
62 |
63 | conductor.StartTasks();
64 |
65 | return 0;
66 | }
--------------------------------------------------------------------------------
/readme/radix logo.svg:
--------------------------------------------------------------------------------
1 |
22 |
--------------------------------------------------------------------------------
/source/app/vApplication.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vApplication.cpp
25 | * \brief The application class in the VUILib
26 | */
27 |
28 | #include
29 |
30 | VApplication::VApplication() : _mainWindow(nullptr) {
31 | _style = VRadixStyleFactory::GetStyle(VRadixStyleType::dark, VColorFactory::MakeRGB(28, 42, 89));
32 |
33 | glfwInit();
34 | }
35 |
36 | VStyleProperty &VApplication::GetThemeProperty(const OString &Name) {
37 | return _style.GetProperty(Name);
38 | }
39 | int VApplication::Run() {
40 | if (_mainWindow == nullptr) {
41 | throw std::logic_error("Application should set the main window to enter the main loop!");
42 | }
43 |
44 | while (!glfwWindowShouldClose(_mainWindow)) {
45 | glfwPollEvents();
46 |
47 | for (auto &interface : _interfaces) {
48 | interface.second->OnOnceLoop();
49 | }
50 | }
51 |
52 | return 0;
53 | }
--------------------------------------------------------------------------------
/source/base/binding/vBindingType.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vBindingType.cpp
25 | * \brief A wrapper type for two-way binding
26 | */
27 |
28 | #include
29 |
--------------------------------------------------------------------------------
/source/base/command/vCommand.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vCommand.cpp
25 | * \brief The command class
26 | */
27 |
--------------------------------------------------------------------------------
/source/base/message/vMessage.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vMessage.cpp
25 | * \brief The message type in the VUILib
26 | */
27 |
28 | #include
29 |
30 | VBaseMessage::VBaseMessage(Window Trigger) : Target(Trigger) {
31 | }
32 | VMouseMovedMessage::VMouseMovedMessage(Window Trigger, const int &IX, const int &IY)
33 | : VBaseMessage(Trigger), Point(IX, IY) {
34 | }
35 | VMouseClickedMessage::VMouseClickedMessage(Window Trigger, const int &IX, const int &IY, const VMouseButton &IButton,
36 | const VClickType &IClick, const VAdditionKey &IAdditionKey)
37 | : VBaseMessage(Trigger), Point(IX, IY), Button(IButton), Click(IClick), AdditionKey(IAdditionKey) {
38 | }
39 | VRepaintMessage::VRepaintMessage(Window Trigger, const VRect &Rectangle)
40 | : VBaseMessage(Trigger), DirtyRectangle(Rectangle) {
41 | }
42 | VKeyDownMessage::VKeyDownMessage(Window Trigger, const int &IKey, const VAdditionKey &IAdditionKey)
43 | : VBaseMessage(Trigger), Key(IKey), AdditionKey(IAdditionKey) {
44 | }
45 | VKeyUpMessage::VKeyUpMessage(Window Trigger, const int &IKey, const VAdditionKey &IAdditionKey)
46 | : VBaseMessage(Trigger), Key(IKey), AdditionKey(IAdditionKey) {
47 | }
48 | VLayoutMessage::VLayoutMessage(Window Trigger, const int &IWidth, const int &IHeight)
49 | : VBaseMessage(Trigger), Width(IWidth), Height(IHeight) {
50 |
51 | }
--------------------------------------------------------------------------------
/source/base/object/vObjectProperty.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vObjectProperty.cpp
25 | * \brief The property class for VObject class
26 | */
27 |
28 | #include
29 |
30 | VPropertyValueBase::VPropertyValueBase(VPropertyType Type) : _type(Type) {
31 | }
32 | VIntProperty::VIntProperty() : VPropertyValueBase(VPropertyType::Int), _value(0) {
33 | }
34 | VIntProperty::VIntProperty(const int &Value) : VPropertyValueBase(VPropertyType::Int), _value(Value) {
35 | }
36 | VLongProperty::VLongProperty() : VPropertyValueBase(VPropertyType::Long), _value(0) {
37 | }
38 | VLongProperty::VLongProperty(const long &Value) : VPropertyValueBase(VPropertyType::Long), _value(Value) {
39 | }
40 | VFloatProperty::VFloatProperty() : VPropertyValueBase(VPropertyType::Float), _value(0.f) {
41 | }
42 | VFloatProperty::VFloatProperty(const float &Value) : VPropertyValueBase(VPropertyType::Long), _value(Value) {
43 | }
44 | VBooleanProperty::VBooleanProperty() : VPropertyValueBase(VPropertyType::Boolean), _value() {
45 | }
46 | VBooleanProperty::VBooleanProperty(const bool &Value) : VPropertyValueBase(VPropertyType::Boolean), _value(Value) {
47 | }
48 | VStringProperty::VStringProperty() : VPropertyValueBase(VPropertyType::String), _value() {
49 | }
50 | VStringProperty::VStringProperty(const OString &Value) : VPropertyValueBase(VPropertyType::String), _value(Value) {
51 | }
52 | VRectProperty::VRectProperty() : VPropertyValueBase(VPropertyType::Rect), _value() {
53 | }
54 | VRectProperty::VRectProperty(const VRect &Value) : VPropertyValueBase(VPropertyType::Rect), _value(Value) {
55 | }
56 | VPointProperty::VPointProperty() : VPropertyValueBase(VPropertyType::Point), _value() {
57 | }
58 | VPointProperty::VPointProperty(const VPoint &Value) : VPropertyValueBase(VPropertyType::Point), _value(Value) {
59 | }
60 | VColorProperty::VColorProperty() : VPropertyValueBase(VPropertyType::Color), _value() {
61 | }
62 | VColorProperty::VColorProperty(const SkColor &Value) : VPropertyValueBase(VPropertyType::Color), _value(Value) {
63 | }
64 | VObjectProperty::VObjectProperty(const OString &Name, std::unique_ptr &&Value)
65 | : _name(Name), _value(std::move(Value)) {
66 | }
67 | OString VObjectProperty::GetName() const {
68 | return _name;
69 | }
70 | std::unique_ptr &VObjectProperty::GetValue() {
71 | return _value;
72 | }
--------------------------------------------------------------------------------
/source/control/button/vAbstractButton.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vAbstractButton.cpp
25 | * \brief The abstract button of the button control in VUILib
26 | */
27 |
28 | #include
29 |
30 | VAbstractButton::VAbstractButton() {
31 | InitAbstractButton(80, 20);
32 | }
33 | VAbstractButton::VAbstractButton(const int &Width, const int &Height) : VObject(nullptr) {
34 | InitAbstractButton(Width, Height);
35 |
36 | SetPropertyValue(PN_UserSpecifiedSize, true);
37 | }
38 | void VAbstractButton::InitAbstractButton(const int &Width, const int &Height) {
39 | Resize(Width, Height);
40 | }
--------------------------------------------------------------------------------
/source/control/button/vPushButton.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vPushButton.cpp
25 | * \brief The push button class in VUILib
26 | */
27 |
28 | #include
29 |
30 | VPushButton::VPushButton(VObject *Parent, const OString &Text) : VAbstractButton() {
31 | InitProperty(Text);
32 |
33 | SetParent(Parent);
34 | }
35 | VPushButton::VPushButton(VObject *Parent, const int &Width, const int &Height, const OString &Text)
36 | : VAbstractButton(Width, Height) {
37 | InitProperty(Text);
38 |
39 | SetParent(Parent);
40 | }
41 | void VPushButton::SetRichText(const OString &Text) {
42 | _text->_value = ostr::format("
", VHTMLLexer::ConvertToPlainText(Text));
66 | _AST = new VHTMLAST(_text->_value);
67 | }
68 | void VPushButton::OnPaint(sk_sp &Surface) {
69 | VRect bound{0, 0, GetWidth(), GetHeight()};
70 |
71 | auto canvas = Surface->getCanvas();
72 | VRichTextRenderer renderer(_AST);
73 |
74 | renderer.Render(canvas, bound);
75 |
76 | canvas->flush();
77 | }
--------------------------------------------------------------------------------
/source/control/shape/vRectangleControl.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRectangle.cpp
25 | * \brief The basic shape control of a rectangle
26 | */
27 |
28 | #include
29 |
30 | VRectangleControl::VRectangleControl(const int &Width, const int &Height, VObject *Parent) : VObject(Parent) {
31 | InitProperty();
32 |
33 | Resize(Width, Height);
34 |
35 | SetPropertyValue(PN_UserSpecifiedSize, true);
36 | }
37 | VRectangleControl::VRectangleControl(VObject *Parent) : VObject(Parent) {
38 | InitProperty();
39 |
40 | Resize(100, 50);
41 | }
42 | void VRectangleControl::SetBorderRadius(const float &Radius) {
43 | _borderRadius->_value = Radius;
44 | }
45 | void VRectangleControl::SetBackgroundColor(const SkColor &Color) {
46 | _backgroundColor->_value = Color;
47 | }
48 | void VRectangleControl::SetBorderColor(const SkColor &Color) {
49 | _borderColor->_value = Color;
50 | }
51 | void VRectangleControl::OnPaint(sk_sp &Surface) {
52 | SkRect bound(0, 0, GetWidth(), GetHeight());
53 |
54 | SkPaint paint;
55 | paint.setStyle(SkPaint::kFill_Style);
56 | paint.setColor(_backgroundColor->_value);
57 | SkPaint strokePaint;
58 | strokePaint.setStyle(SkPaint::kStroke_Style);
59 | strokePaint.setColor(_borderColor->_value);
60 |
61 | auto canvas = Surface->getCanvas();
62 | canvas->drawRoundRect(bound, _borderRadius->_value, _borderRadius->_value, paint);
63 | canvas->drawRoundRect(bound, _borderRadius->_value, _borderRadius->_value, strokePaint);
64 |
65 | canvas->flush();
66 | }
67 | void VRectangleControl::InitProperty() {
68 | auto borderRadius = std::make_unique(0.f);
69 | auto backgroundColor = std::make_unique(SK_ColorWHITE);
70 | auto borderColor = std::make_unique(SK_ColorWHITE);
71 |
72 | RegisterProperty("border.radius", std::move(borderRadius));
73 | RegisterProperty("color.background", std::move(backgroundColor));
74 | RegisterProperty("color.border", std::move(borderColor));
75 |
76 | _borderRadius = GetPropertyValue("border.radius");
77 | _backgroundColor = GetPropertyValue("color.background");
78 | _borderColor = GetPropertyValue("color.border");
79 | }
--------------------------------------------------------------------------------
/source/layout/vPanelLayout.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vPanelLayout.cpp
25 | * \brief The panel layout in VUILib, the basic panel base class
26 | */
27 |
28 | #include
29 |
30 | VPanel::VPanel(VObject *Parent) : VObject(Parent), P_PanelAlign(PN_PanelAlign) {
31 | Resize(Parent->GetWidth(), Parent->GetHeight());
32 | }
33 | VPanel::VPanel(VObject *Parent, const int &Width, const int &Height) : VObject(Parent), P_PanelAlign(PN_PanelAlign) {
34 | Resize(Width, Height);
35 |
36 | _userSpecifiedSize->_value = true;
37 | }
38 | void VPanel::OnLayoutRearrange() {
39 | if (!_userSpecifiedSize->_value && (GetWidth() != _parent->GetWidth() || GetHeight() != _parent->GetHeight())) {
40 | Resize(_parent->GetWidth(), _parent->GetHeight());
41 | }
42 |
43 | Arrange();
44 | }
45 | VRect VPanel::SizeMeasure() {
46 | return {0, 0, GetWidth(), GetHeight()};
47 | }
48 | void VPanel::Arrange() {
49 | for (auto &object : _childList) {
50 | auto width = object->GetWidth();
51 | auto height = object->GetHeight();
52 | auto layoutSizingProperty = object->GetPropertyValue(PN_UserSpecifiedSize);
53 |
54 | if (object->HasProperty("panel.align")) {
55 | auto &value = object->GetProperty("panel.align")._value;
56 | if (value->_type == VPropertyType::String) {
57 | auto align = value->Cast()->GetValue();
58 | if (align == "center") {
59 | width = GetWidth();
60 | height = GetHeight();
61 | if (!layoutSizingProperty->_value) {
62 | object->Resize(width, height);
63 | }
64 |
65 | object->Move(GetWidth() / 2 - object->GetWidth() / 2, GetHeight() / 2 - object->GetHeight() / 2);
66 | }
67 | if (align == "left") {
68 | height = GetHeight();
69 | if (!layoutSizingProperty->_value) {
70 | object->Resize(width, height);
71 | }
72 |
73 | object->Move(0, GetHeight() / 2 - object->GetHeight() / 2);
74 | }
75 | if (align == "right") {
76 | height = GetHeight();
77 | if (!layoutSizingProperty->_value) {
78 | object->Resize(width, height);
79 | }
80 |
81 | object->Move(GetWidth() - object->GetWidth(), GetHeight() / 2 - object->GetHeight() / 2);
82 | }
83 | if (align == "top") {
84 | width = GetWidth();
85 | if (!layoutSizingProperty->_value) {
86 | object->Resize(width, height);
87 | }
88 |
89 | object->Move(GetWidth() / 2 - object->GetWidth() / 2, 0);
90 | }
91 | if (align == "bottom") {
92 | width = GetWidth();
93 | if (!layoutSizingProperty->_value) {
94 | object->Resize(width, height);
95 | }
96 |
97 | object->Move(GetWidth() / 2 - object->GetWidth() / 2, GetHeight() - object->GetHeight());
98 | }
99 | }
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/source/layout/vStackPanelLayout.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vStackPanelLayout.cpp
25 | * \brief The stack panel, every element in stack panel will be arranged from top to bottom
26 | */
27 |
28 | #include
29 |
30 | VStackPanel::VStackPanel(VObject *Parent)
31 | : VObject(Parent), P_StackAlign(PN_StackAlign), P_Margin("stack.margin"), P_MarginTop(PN_MarginTop),
32 | P_MarginBottom(PN_MarginBottom) {
33 | Resize(Parent->GetWidth(), Parent->GetHeight());
34 | }
35 | VStackPanel::VStackPanel(VObject *Parent, const int &Width, const int &Height)
36 | : VObject(Parent), P_StackAlign(PN_StackAlign), P_Margin("stack.margin"), P_MarginTop(PN_MarginTop),
37 | P_MarginBottom(PN_MarginBottom) {
38 | Resize(Width, Height);
39 |
40 | _userSpecifiedSize->_value = true;
41 | }
42 | void VStackPanel::OnLayoutRearrange() {
43 | if (!_userSpecifiedSize->_value && (GetWidth() != _parent->GetWidth() || GetHeight() != _parent->GetHeight())) {
44 | Resize(_parent->GetWidth(), _parent->GetHeight());
45 | }
46 |
47 | Arrange();
48 | }
49 | VRect VStackPanel::SizeMeasure() {
50 | int count = 0;
51 | for (auto &object : _childList) {
52 | count += object->GetHeight();
53 | if (count >= GetHeight()) {
54 | count = GetHeight();
55 |
56 | break;
57 | }
58 | }
59 |
60 | return {0, 0, GetWidth(), count};
61 | }
62 | void VStackPanel::Arrange() {
63 | int count = 0;
64 | for (auto &object : _childList) {
65 | auto width = object->GetWidth();
66 | auto height = object->GetHeight();
67 | auto layoutSizingProperty = object->GetPropertyValue(PN_UserSpecifiedSize);
68 |
69 | bool hasBottomMargin = false;
70 | int bottomMargin = 0;
71 | if (object->HasProperty("stack.margin")) {
72 | auto &value = object->GetProperty("stack.margin")._value;
73 | if (value->_type == VPropertyType::Int) {
74 | auto margin = value->Cast()->GetValue();
75 | count += margin;
76 | bottomMargin = margin;
77 | hasBottomMargin = true;
78 | }
79 | } else {
80 | if (object->HasProperty(PN_MarginTop)) {
81 | auto &value = object->GetProperty(PN_MarginTop)._value;
82 | if (value->_type == VPropertyType::Int) {
83 | auto margin = value->Cast()->GetValue();
84 | count += margin;
85 | }
86 | }
87 | if (object->HasProperty(PN_MarginBottom)) {
88 | auto &value = object->GetProperty(PN_MarginBottom)._value;
89 | if (value->_type == VPropertyType::Int) {
90 | auto margin = value->Cast()->GetValue();
91 | bottomMargin = margin;
92 | hasBottomMargin = true;
93 | }
94 | }
95 | }
96 | if (object->HasProperty(PN_StackAlign)) {
97 | auto &value = object->GetProperty(PN_StackAlign)._value;
98 | if (value->_type == VPropertyType::String) {
99 | auto align = value->Cast()->GetValue();
100 | if (align == PN_StackAlignLeft) {
101 | width = GetWidth();
102 | if (!layoutSizingProperty->_value) {
103 | object->Resize(width, height);
104 | }
105 |
106 | object->Move(0, count);
107 | }
108 | else if (align == PN_StackAlignRight) {
109 | width = GetWidth();
110 | if (!layoutSizingProperty->_value) {
111 | object->Resize(width, height);
112 | }
113 |
114 | object->Move(GetWidth() - object->GetWidth(), count);
115 | } else {
116 | width = GetWidth();
117 | if (!layoutSizingProperty->_value) {
118 | object->Resize(width, height);
119 | }
120 |
121 | object->Move(GetWidth() / 2 - object->GetWidth() / 2, count);
122 | }
123 | }
124 | } else {
125 | width = GetWidth();
126 | if (!layoutSizingProperty->_value) {
127 | object->Resize(width, height);
128 | }
129 |
130 | object->Move(GetWidth() / 2 - object->GetWidth() / 2, count);
131 | }
132 |
133 | count += object->GetHeight();
134 | if (hasBottomMargin) {
135 | count += bottomMargin;
136 | }
137 | }
138 | }
--------------------------------------------------------------------------------
/source/layout/vWrapPanelLayout.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vWrapPanelLayout.cpp
25 | * \brief The wrap panel in VUILib, it arranges elements in the specified direction
26 | */
27 |
28 | #include
29 |
30 | VWrapPanel::VWrapPanel(VObject *Parent) : VObject(Parent) {
31 | Resize(Parent->GetWidth(), Parent->GetHeight());
32 | }
33 | VWrapPanel::VWrapPanel(VObject *Parent, const int &Width, const int &Height) : VObject(Parent) {
34 | Resize(Width, Height);
35 |
36 | _userSpecifiedSize->_value = true;
37 | }
38 | void VWrapPanel::OnLayoutRearrange() {
39 | if (!_userSpecifiedSize->_value && (GetWidth() != _parent->GetWidth() || GetHeight() != _parent->GetHeight())) {
40 | Resize(_parent->GetWidth(), _parent->GetHeight());
41 | }
42 |
43 | Arrange();
44 | }
45 | VRect VWrapPanel::SizeMeasure() {
46 | return {0, 0, GetWidth(), GetHeight()};
47 | }
48 | void VWrapPanel::Arrange() {
49 | int count = 0;
50 | for (auto &object : _childList) {
51 |
52 | }
53 | }
54 | void VWrapPanel::InitProperty() {
55 | auto direction = std::make_unique("horizontal");
56 | RegisterProperty("direction", std::move(direction));
57 | _direction = GetPropertyValue("direction");
58 | }
--------------------------------------------------------------------------------
/source/mvvm/vModelBase.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vModelBase.cpp
25 | * \brief The model class base
26 | */
--------------------------------------------------------------------------------
/source/mvvm/vViewBase.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vViewBase.cpp
25 | * \brief The view layer base class in MVVM
26 | */
--------------------------------------------------------------------------------
/source/mvvm/vViewModelBase.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vViewModelBase.cpp
25 | * \brief The view model layer base class in MVVM
26 | */
27 |
28 | #include
29 |
--------------------------------------------------------------------------------
/source/renderer/vColorFactory.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vColorFactory.cpp
25 | * \brief The color factory class in VUILib renderer
26 | */
--------------------------------------------------------------------------------
/source/renderer/vRenderContext.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRenderContext.cpp
25 | * \brief The render context wrapper of Skia
26 | */
27 |
28 | #include
29 |
30 | VRenderContext::VRenderContext(const sk_sp &Interface) {
31 | _context = GrDirectContext::MakeGL(Interface->GetNativeInterface());
32 | }
--------------------------------------------------------------------------------
/source/renderer/vRenderInterface.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRenderInterface.cpp
25 | * \brief The GLInterface wrapper of Skia
26 | */
27 |
28 | #include
29 |
30 | VRenderInterface::VRenderInterface() {
31 | _interface = GrGLMakeNativeInterface();
32 | }
--------------------------------------------------------------------------------
/source/renderer/vRenderTarget.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRenderTarget.cpp
25 | * \brief A render target wrapper of Skia
26 | */
27 |
28 | #include
29 |
30 | VRenderTarget::VRenderTarget(const VRenderTargetViewport &Viewport)
31 | : _renderTarget(Viewport.Width, Viewport.Height, Viewport.X, Viewport.Y,
32 | GrGLFramebufferInfo{.fFBOID = 0, .fFormat = GL_RGBA8}) {
33 | }
--------------------------------------------------------------------------------
/source/renderer/vSurface.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vSurface.cpp
25 | * \brief The surface class of VRenderer
26 | */
27 |
28 | #include
29 |
30 | VSurface::VSurface(const int &Width, const int &Height) : _surface(SkSurface::MakeRasterN32Premul(Width, Height)) {
31 | }
32 | VSurface::VSurface(sk_sp &&Surface) : _surface(std::move(Surface)) {
33 |
34 | }
35 | VSurface::VSurface(const sk_sp &RenderTarget, const sk_sp &Context) {
36 | // By default, we enable MSAA flag.
37 | SkColorType colorType = kRGBA_8888_SkColorType;
38 | SkSurfaceProps property(SkSurfaceProps::Flags::kDynamicMSAA_Flag, SkPixelGeometry::kUnknown_SkPixelGeometry);
39 |
40 | // In fact, we don't need to proc the render target destroying
41 | _surface =
42 | SkSurface::MakeFromBackendRenderTarget(Context->GetNativeContext().get(), RenderTarget->GetNativeRenderTarget(),
43 | kBottomLeft_GrSurfaceOrigin, colorType, nullptr, &property);
44 | }
--------------------------------------------------------------------------------
/source/style/vRadixStyle.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRadixStyle.cpp
25 | * \brief The default style factory in Radix theme
26 | */
27 |
28 | #include
29 |
--------------------------------------------------------------------------------
/source/style/vStyleCollection.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vStyleCollection.cpp
25 | * \brief The style set collection in VUILib, it collects a set of
26 | * VStyleFunction to meet the requirement
27 | */
28 |
29 | #include
30 |
31 | VStyleCollection::VStyleCollection() {
32 | }
--------------------------------------------------------------------------------
/source/style/vStyleFunction.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vStyleFunction.cpp
25 | * \brief The function method to store the style sheet
26 | */
27 |
28 | #include
29 |
30 | VStyleProperty &VStyleFunction::GetProperty(const OString &Name) {
31 | return _propertyList.find(Name)->second;
32 | }
33 | void VStyleFunction::RegisterProperty(const OString &Name, std::unique_ptr &&Pointer) {
34 | if (_propertyList.find(Name) != _propertyList.end()) {
35 | throw std::logic_error("VProperty should not be redefined");
36 | }
37 |
38 | _propertyList.insert({Name, VObjectProperty(Name, std::move(Pointer))});
39 | }
--------------------------------------------------------------------------------
/source/widget/vGLFWCallback.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vGLFWCallback.cpp
25 | * \brief The callback function wrapper
26 | */
27 |
28 | #include
29 |
30 | #include
31 |
32 | std::unordered_map ObjectMapping;
33 |
34 | void VGLFWRegisterObject(VGLFWWidget *Widget, GLFWwindow *Window) {
35 | ObjectMapping.insert({Window, Widget});
36 | }
37 | void VGLFWLayoutRearrangingCallback(GLFWwindow *Window, int Width, int Height) {
38 | ObjectMapping[Window]->OnGLFWLayoutRearranging(Width, Height);
39 | }
40 | void VGLFWFramebufferSizeCallback(GLFWwindow *Window, int Width, int Height) {
41 | if (Width != 0 && Height != 0) {
42 | ObjectMapping[Window]->OnGLFWRepaint(Width, Height);
43 | }
44 | }
45 | void VGLFWMouseMoveCallback(GLFWwindow *Window, double X, double Y) {
46 | ObjectMapping[Window]->OnGLFWMouseMove(static_cast(X), static_cast(Y));
47 | }
48 | void VGLFWMouseClickCallback(GLFWwindow *Window, int Button, int Action, int Mods) {
49 | int X;
50 | int Y;
51 | glfwGetWindowPos(Window, &X, &Y);
52 | ObjectMapping[Window]->OnGLFWMouseClick(X, Y, Button, Action, Mods);
53 | }
--------------------------------------------------------------------------------
/source/widget/vMainWindow.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vMainWindow.cpp
25 | * \brief The major window in the VUILib, the lifetime of the main window
26 | * is also the lifetime of the program
27 | */
28 |
29 | #include
30 |
31 | VMainWindow::VMainWindow(VApplication *Application, const int &Width, const int &Height, const OString &Title)
32 | : VWidget(Application, Width, Height, Title) {
33 | Application->_mainWindow = _glfwWindow;
34 | }
35 | VMainWindow::VMainWindow(VApplication *Application, const int &Width, const int &Height, const OString &Title,
36 | VMonitor &Monitor)
37 | : VWidget(Application, Width, Height, Title, Monitor) {
38 | Application->_mainWindow = _glfwWindow;
39 | }
--------------------------------------------------------------------------------
/source/widget/vMonitor.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vMonitor.cpp
25 | * \brief The monitor wrapper of GLFW
26 | */
27 |
28 | #include
29 |
30 | #include
31 |
32 | VMonitor::VMonitor(const int &Index) {
33 | glfwSetMonitorCallback(&VMonitor::GLFWMonitorCallback);
34 | _monitorOnEvent.Connect(this, &VMonitor::OnMonitor);
35 |
36 | int monitorCount;
37 | auto monitorList = glfwGetMonitors(&monitorCount);
38 |
39 | if (Index >= monitorCount) {
40 | _glfwMonitor = nullptr;
41 | _glfwVideoMode = nullptr;
42 | _status = VMonitorStatus::Invalid;
43 |
44 | throw std::out_of_range("Monitor count out of range.");
45 | } else {
46 | _glfwMonitor = monitorList[Index];
47 | _glfwVideoMode = glfwGetVideoMode(_glfwMonitor);
48 | _status = VMonitorStatus::Valid;
49 | }
50 | }
51 | VMonitor::VMonitor() {
52 | glfwSetMonitorCallback(&VMonitor::GLFWMonitorCallback);
53 | _monitorOnEvent.Connect(this, &VMonitor::OnMonitor);
54 |
55 | _glfwMonitor = glfwGetPrimaryMonitor();
56 | _glfwVideoMode = glfwGetVideoMode(_glfwMonitor);
57 |
58 | if (!_glfwMonitor) {
59 | _status = VMonitorStatus::Invalid;
60 |
61 | throw VGLFWInstanceCreationFailed("GLFWmonitor");
62 | }
63 | }
64 | void VMonitor::OnMonitor(GLFWmonitor *Monitor, MonitorEventType Event) {
65 | if (Monitor == _glfwMonitor) {
66 | _status = Event == GLFW_CONNECTED ? VMonitorStatus::Valid : VMonitorStatus::Invalid;
67 | }
68 | }
69 | int VMonitor::GetWidth() const {
70 | return _glfwVideoMode->width;
71 | }
72 | int VMonitor::GetHeight() const {
73 | return _glfwVideoMode->height;
74 | }
75 | [[nodiscard]] VMonitorStatus VMonitor::GetStatus() const {
76 | return _status;
77 | }
--------------------------------------------------------------------------------
/source/write/vRichTextRenderer.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file vRichTextRenderer.cpp
25 | * \brief The HTML AST based rich text renderer in VUILib
26 | */
27 |
28 | #include
29 |
30 | VRichTextRenderer::VRichTextRenderer(VHTMLAST *AST) : _ast(AST) {
31 | auto root = _ast->GetRoot();
32 |
33 | _lineSpace = 5;
34 | _wordSpace = 0;
35 |
36 | _color = SK_ColorWHITE;
37 |
38 | InitLabels();
39 | InitFontSet();
40 | }
41 | void VRichTextRenderer::Render(SkCanvas *Canvas, const VRect &Bound) {
42 | VRichTextRendererContext context(_lineWidths, _lineHeights);
43 | context.X = Bound.GetLeft();
44 | context.Y = Bound.GetTop();
45 | context.Bound = Bound;
46 | context.Size = _size;
47 | context.WordSpace = _wordSpace;
48 | context.LineSpace = _lineSpace;
49 | context.EnglishFont = _englishFont;
50 | context.OtherFont = _otherFont;
51 | context.MaxHeight = 0;
52 | context.Color = _color;
53 |
54 | auto root = _ast->GetRoot();
55 | for (auto &node : *root) {
56 | if (_interfaceManager.contains(node->GetId())) {
57 | context = _interfaceManager[node->GetId()]->ContextMeasure(node, context);
58 | auto value = _interfaceManager[node->GetId()]->WidthMeasure(node, context, _interfaceManager);
59 | if (value.has_value()) {
60 | context = value.value();
61 | }
62 | } else {
63 | context = _interfaceManager["$Default"]->ContextMeasure(node, context);
64 | auto value = _interfaceManager["$Default"]->WidthMeasure(node, context, _interfaceManager);
65 | if (value.has_value()) {
66 | context = value.value();
67 | context.WidthCollections.push_back(context.X - context.Bound.GetLeft());
68 | context.HeightCollections.push_back(context.MaxHeight);
69 | }
70 | }
71 | }
72 | context.X = Bound.GetLeft();
73 | context.Y = Bound.GetTop();
74 | context.Size = _size;
75 | context.WordSpace = _wordSpace;
76 | context.LineSpace = _lineSpace;
77 | context.EnglishFont = _englishFont;
78 | context.LineCount = 0;
79 | context.OtherFont = _otherFont;
80 | context.MaxHeight = 0;
81 | context.Color = _color;
82 | for (auto &node : *root) {
83 | if (_interfaceManager.contains(node->GetId())) {
84 | context = _interfaceManager[node->GetId()]->ContextMeasure(node, context);
85 | context = _interfaceManager[node->GetId()]->Render(node, Canvas, context, _interfaceManager);
86 | } else {
87 | context = _interfaceManager["$Default"]->ContextMeasure(node, context);
88 | context = _interfaceManager["$Default"]->Render(node, Canvas, context, _interfaceManager);
89 | }
90 | }
91 | }
92 | void VRichTextRenderer::SetLineSpace(const int &Value) {
93 | _lineSpace = Value;
94 | }
95 | [[nodiscard]] const int VRichTextRenderer::GetLineSpace() const {
96 | return _lineSpace;
97 | }
98 | void VRichTextRenderer::SetWordSpace(const int &Value) {
99 | _wordSpace = Value;
100 | }
101 | [[nodiscard]] const int VRichTextRenderer::GetWordSpace() const {
102 | return _wordSpace;
103 | }
104 | void VRichTextRenderer::InitFontSet() {
105 | _size = 18;
106 |
107 | _otherTypeFace = SkTypeface::MakeFromName("Microsoft YaHei UI", SkFontStyle());
108 | _englishTypeFace = SkTypeface::MakeDefault();
109 |
110 | _englishFont.setTypeface(_englishTypeFace);
111 | _otherFont.setTypeface(_otherTypeFace);
112 |
113 | _englishFont.setSize(_size);
114 | _otherFont.setSize(_size);
115 |
116 | _englishFont.setEdging(SkFont::Edging::kAntiAlias);
117 | _otherFont.setEdging(SkFont::Edging::kAntiAlias);
118 | }
119 | void VRichTextRenderer::InitLabels() {
120 | RegisterLabel();
121 | RegisterLabel();
122 | RegisterLabel();
123 | RegisterLabel();
124 | RegisterLabel();
125 | RegisterLabel();
126 | RegisterLabel();
127 | RegisterLabel();
128 | RegisterLabel();
129 | RegisterLabel();
130 | RegisterLabel();
131 | RegisterLabel();
132 | RegisterLabel();
133 | RegisterLabel();
134 | RegisterLabel();
135 | RegisterLabel();
136 | }
--------------------------------------------------------------------------------
/third/SimpleJson/sJSON.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file sJSON.cpp
25 | * \brief The simple JSON library
26 | */
27 |
28 | #include
29 |
30 | std::map sJSONTokenMap = {{'{', sJSONTokenType::BigLeft}, {'}', sJSONTokenType::BigRight},
31 | {'[', sJSONTokenType::MiddleLeft}, {']', sJSONTokenType::MiddleRight},
32 | {',', sJSONTokenType::Comma}, {':', sJSONTokenType::Colon}};
33 | std::map sJSONTokenStringMap = {
34 | {sJSONTokenType::BigLeft, '{'}, {sJSONTokenType::BigRight, '}'}, {sJSONTokenType::MiddleLeft, '['},
35 | {sJSONTokenType::MiddleRight, ']'}, {sJSONTokenType::Comma, ','}, {sJSONTokenType::Colon, ':'}};
36 | std::map sJSONOppsiteTokenMap = {
37 | {sJSONTokenType::BigLeft, sJSONTokenType::BigRight}, {sJSONTokenType::MiddleLeft, sJSONTokenType::MiddleRight}};
--------------------------------------------------------------------------------
/unitTest/base/base.binding.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.binding.cpp
25 | * \brief The base binding test
26 | */
27 |
28 | #include
29 |
30 | bool VUnitTest(BaseBinding, ValueTest) {
31 | VBindingType testBinding(1);
32 | return (*testBinding) == 1;
33 | }
34 | bool VUnitTest(BaseBinding, BindingValueTest) {
35 | int scopeValue = 1;
36 | VBindingType testBinding(1);
37 | testBinding.Bind(&scopeValue);
38 |
39 | scopeValue = 2;
40 |
41 | return (*testBinding) == 2;
42 | }
43 | bool VUnitTest(BaseBinding, UnbindingValueTest) {
44 | int scopeValue = 1;
45 | VBindingType testBinding(1);
46 | testBinding.Bind(&scopeValue);
47 |
48 | scopeValue = 2;
49 |
50 | testBinding.Unbind();
51 |
52 | return (*testBinding) == 1;
53 | }
54 | bool VUnitTest(BaseBinding, ValueCompareTest) {
55 | VBindingType testBinding(1);
56 |
57 | return testBinding > 0 && testBinding < 2 && testBinding == 1 && testBinding >= 1 && testBinding <= 2;
58 | }
--------------------------------------------------------------------------------
/unitTest/base/base.binding.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.binding.h
25 | * \brief The base binding test
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | bool VUnitTest(BaseBinding, ValueTest);
34 | bool VUnitTest(BaseBinding, BindingValueTest);
35 | bool VUnitTest(BaseBinding, UnbindingValueTest);
36 | bool VUnitTest(BaseBinding, ValueCompareTest);
--------------------------------------------------------------------------------
/unitTest/base/base.command.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.command.h
25 | * \brief The base command test
26 | */
27 |
28 | #include
29 |
30 | bool __VCommandTest_Flag = false;
31 |
32 | void __VTest_Command_Event_Recall() {
33 | __VCommandTest_Flag = true;
34 | }
35 |
36 | bool VUnitTest(BaseCommand, Recall) {
37 | __VCommandTest_Flag = false;
38 |
39 | VCommand recallEvent(__VTest_Command_Event_Recall);
40 | recallEvent.OnCommand();
41 |
42 | return __VCommandTest_Flag;
43 | }
44 | bool VUnitTest(BaseCommand, ClassRecall) {
45 | __VCommandTestClass testClass;
46 |
47 | VCommand<__VCommandTestClass> recallEvent(&testClass, &__VCommandTestClass::RecallFunction);
48 |
49 | return !testClass.Flag;
50 | }
--------------------------------------------------------------------------------
/unitTest/base/base.command.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.command.h
25 | * \brief The base command test
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | class __VCommandTestClass {
34 | public:
35 | __VCommandTestClass() : Flag(false) {
36 |
37 | }
38 |
39 | public:
40 | void RecallFunction() {
41 | Flag = true;
42 | }
43 |
44 | public:
45 | bool Flag;
46 | };
47 |
48 | void __VTest_Command_Event_Recall();
49 |
50 |
51 | bool VUnitTest(BaseCommand, Recall);
52 | bool VUnitTest(BaseCommand, ClassRecall);
--------------------------------------------------------------------------------
/unitTest/base/base.event.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.event.cpp
25 | * \brief The base event test
26 | */
27 |
28 | #include
29 | bool __VTest_Flag = false;
30 |
31 | void __VTest_Base_Event_Recall() {
32 | __VTest_Flag = true;
33 | }
34 |
35 | bool VUnitTest(BaseEvent, Recall) {
36 | __VTest_Flag = false;
37 |
38 | VEvent<> recallEvent;
39 | recallEvent.Connect(__VTest_Base_Event_Recall);
40 | recallEvent.Emit();
41 |
42 | return __VTest_Flag;
43 | }
44 | bool VUnitTest(BaseEvent, Block) {
45 | __VTest_Flag = false;
46 |
47 | VEvent<> recallEvent;
48 | recallEvent.Connect(__VTest_Base_Event_Recall);
49 | recallEvent.Block(__VTest_Base_Event_Recall);
50 | recallEvent.Emit();
51 |
52 | return !__VTest_Flag;
53 | }
54 | bool VUnitTest(BaseEvent, Remove) {
55 | __VTest_Flag = false;
56 |
57 | VEvent<> recallEvent;
58 | recallEvent.Connect(__VTest_Base_Event_Recall);
59 | recallEvent.Disconnect(__VTest_Base_Event_Recall);
60 | recallEvent.Emit();
61 |
62 | return !__VTest_Flag;
63 | }
64 |
65 | bool VUnitTest(BaseEventClass, Recall) {
66 | __VEventTestClass testClass;
67 |
68 | VEvent<> recallEvent;
69 | recallEvent.Connect(&testClass, &__VEventTestClass::RecallFunction);
70 | recallEvent.Emit();
71 |
72 | return testClass.Flag;
73 | }
74 | bool VUnitTest(BaseEventClass, Block) {
75 | __VEventTestClass testClass;
76 |
77 | VEvent<> recallEvent;
78 | recallEvent.Connect(&testClass, &__VEventTestClass::RecallFunction);
79 | recallEvent.Block(&testClass, &__VEventTestClass::RecallFunction);
80 | recallEvent.Emit();
81 |
82 | return !testClass.Flag;
83 | }
84 | bool VUnitTest(BaseEventClass, Remove) {
85 | __VEventTestClass testClass;
86 |
87 | VEvent<> recallEvent;
88 | recallEvent.Connect(&testClass, &__VEventTestClass::RecallFunction);
89 | recallEvent.Disconnect(&testClass, &__VEventTestClass::RecallFunction);
90 | recallEvent.Emit();
91 |
92 | return !testClass.Flag;
93 | }
--------------------------------------------------------------------------------
/unitTest/base/base.event.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.event.h
25 | * \brief The base event test
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 |
33 | class __VEventTestClass {
34 | public:
35 | __VEventTestClass() : Flag(false) {
36 |
37 | }
38 |
39 | public:
40 | void RecallFunction() {
41 | Flag = true;
42 | }
43 |
44 | public:
45 | bool Flag;
46 | };
47 |
48 | void __VTest_Base_Event_Recall();
49 |
50 | bool VUnitTest(BaseEvent, Recall);
51 | bool VUnitTest(BaseEvent, Block);
52 | bool VUnitTest(BaseEvent, Remove);
53 |
54 | bool VUnitTest(BaseEventClass, Recall);
55 | bool VUnitTest(BaseEventClass, Block);
56 | bool VUnitTest(BaseEventClass, Remove);
--------------------------------------------------------------------------------
/unitTest/base/base.geometry.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.point.cpp
25 | * \brief The unit test module for geometry module
26 | */
27 |
28 | #include
29 |
30 | bool VUnitTest(BaseGeometryPoint, Init) {
31 | VPoint defaultConstruction;
32 | VPoint tupleConstruction(VPoint::AxisTuple{10, 10});
33 | VPoint parameterConstruction(12, 12);
34 | VPoint copyConstruction(parameterConstruction);
35 | return defaultConstruction.GetTuple() == VPoint::AxisTuple{0, 0} &&
36 | tupleConstruction.GetTuple() == VPoint::AxisTuple{10, 10} &&
37 | parameterConstruction.GetTuple() == VPoint::AxisTuple{12, 12} &&
38 | parameterConstruction.GetTuple() == VPoint::AxisTuple{12, 12};
39 | }
40 | bool VUnitTest(BaseGeometryPoint, Calculate) {
41 | VPoint point{0, 0};
42 | point = point + 2;
43 | point = point / 2;
44 | point = point + VPoint::AxisTuple{20, 3};
45 | point = point * 3;
46 | point = VPoint::AxisTuple{100, 120} - point;
47 |
48 | return point.GetTuple() == VPoint::AxisTuple{37, 108};
49 | }
50 | bool VUnitTest(BaseGeometryPoint, Compare) {
51 | return !(VPoint(2012, 2013) == VPoint(2014, 2015)) && (VPoint(2016, 2017) == VPoint(2016, 2017));
52 | }
53 |
54 | bool VUnitTest(BaseGeometryRect, Init) {
55 | VRect defaultConstruction;
56 | VRect tupleConstruction(VRect::GeometryTuple{0, 0, 10, 10});
57 | VRect parameterConstruction(0, 0, 12, 12);
58 | VRect copyConstruction(parameterConstruction);
59 | return defaultConstruction.GetGeometryTuple() == VRect::GeometryTuple {0, 0, 0, 0} &&
60 | tupleConstruction.GetGeometryTuple() == VRect::GeometryTuple{0, 0, 10, 10} &&
61 | parameterConstruction.GetGeometryTuple() == VRect::GeometryTuple{0, 0, 12, 12} &&
62 | parameterConstruction.GetGeometryTuple() == VRect::GeometryTuple{0, 0, 12, 12};
63 | }
64 | bool VUnitTest(BaseGeometryRect, Compare) {
65 | return !(VRect (0, 0, 2012, 2013) == VRect(0, 0, 2014, 2015)) && (VRect(0, 0, 2016, 2017) == VRect(0, 0, 2016, 2017));
66 | }
--------------------------------------------------------------------------------
/unitTest/base/base.geometry.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.point.h
25 | * \brief The unit test module for geometry module
26 | */
27 |
28 | #pragma once
29 |
30 | #include
31 | #include
32 | #include
33 |
34 | bool VUnitTest(BaseGeometryPoint, Init);
35 | bool VUnitTest(BaseGeometryPoint, Calculate);
36 | bool VUnitTest(BaseGeometryPoint, Compare);
37 |
38 | bool VUnitTest(BaseGeometryRect, Init);
39 | bool VUnitTest(BaseGeometryRect, Compare);
--------------------------------------------------------------------------------
/unitTest/base/base.object.property.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023~Now Margoo
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a copy
5 | * of this software and associated documentation files (the "Software"), to deal
6 | * in the Software without restriction, including without limitation the rights
7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | * copies of the Software, and to permit persons to whom the Software is
9 | * furnished to do so, subject to the following conditions:
10 | *
11 | * The above copyright notice and this permission notice shall be included in all
12 | * copies or substantial portions of the Software.
13 | *
14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 | * SOFTWARE.
21 | */
22 |
23 | /**
24 | * \file base.object.property.cpp
25 | * \brief The unit test module for object property module
26 | */
27 |
28 | #include
29 |
30 | bool VUnitTest(ObjectProperty, Create) {
31 | auto intDefaultPtr = std::make_unique();
32 | auto intValuePtr = std::make_unique(1);
33 | auto longDefaultPtr = std::make_unique();
34 | auto longValuePtr = std::make_unique(1);
35 | auto floatDefaultPtr = std::make_unique();
36 | auto floatValuePtr = std::make_unique(1);
37 | auto stringDefaultPtr = std::make_unique();
38 | auto stringValuePtr = std::make_unique("Hello, VUILib");
39 | auto rectDefaultPtr = std::make_unique();
40 | auto rectValuePtr = std::make_unique(VRect(0, 0, 100, 100));
41 | auto pointDefaultPtr = std::make_unique();
42 | auto pointValuePtr = std::make_unique(VPoint (0, 0));
43 | VPropertyList list;
44 | std::unique_ptr ptrList[] = {
45 | std::move(intDefaultPtr), std::move(intValuePtr), std::move(longDefaultPtr),
46 | std::move(longValuePtr), std::move(floatDefaultPtr), std::move(floatValuePtr),
47 | std::move(stringDefaultPtr), std::move(stringValuePtr), std::move(rectDefaultPtr),
48 | std::move(rectValuePtr), std::move(pointDefaultPtr), std::move(pointValuePtr)
49 | };
50 | for (auto count : VRange(0, 12)) {
51 | auto name = std::to_string(count);
52 | list.insert({name.data(), VObjectProperty(name.data(), std::move(ptrList[count]))});
53 | }
54 |
55 | return true;
56 | }
57 | bool VUnitTest(ObjectProperty, Read) {
58 | __VObjectTestObject object;
59 | auto& defaultProperty = object.GetProperty("intDefault");
60 | auto& valueProperty = object.GetProperty("intValue");
61 | return defaultProperty.GetValue()->Cast