Skip to content

Commit 2d6f517

Browse files
committed
Merge branch 'main'
2 parents f54953d + 7e3178c commit 2d6f517

File tree

235 files changed

+21125
-20846
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+21125
-20846
lines changed

.clang-format

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
AccessModifierOffset: -3
3+
IndentWidth: 3
4+
...

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "lib/external/asio"]
55
path = lib/external/asio
66
url = https://github.com/chriskohlhoff/asio.git
7+
[submodule "lib/artist"]
8+
path = lib/artist
9+
url = https://github.com/cycfi/artist.git

CMakeLists.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2016-2020 Joel de Guzman
2+
# Copyright (c) 2016-2023 Joel de Guzman
33
# Copyright (c) 2020 Michał Urbański
44
#
55
# Distributed under the MIT License (https://opensource.org/licenses/MIT)
@@ -14,6 +14,13 @@ if(CMAKE_CXX_STANDARD LESS 17)
1414
set(CMAKE_CXX_STANDARD 17)
1515
endif()
1616

17+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
18+
include(GitSubmoduleCheck)
19+
git_submodule_check(lib/artist)
20+
git_submodule_check(lib/external/asio)
21+
git_submodule_check(lib/infra)
22+
endif()
23+
1724
include(ElementsConfigCommon)
1825

1926
option(ELEMENTS_BUILD_EXAMPLES "build Elements library examples" ON)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
## Introduction
88

9-
Elements is a lightweight, fine-grained, resolution independent, modular GUI library.
9+
Elements is a lightweight, fine-grained, resolution independent, modular GUI library.
1010
Elements is designed with these requirements in mind:
1111

1212
1. It should be open source with a liberal, non-viral license.
@@ -21,7 +21,7 @@ Elements is designed with these requirements in mind:
2121
tells you *what* rather than *how* (imperative). The GUI should be
2222
declared in C++ code.
2323
7. Keep it simple. Make it easy to use right out of the box, with a lot of examples.
24-
8. Porting to a new host target should be as easy as possible, requiring
24+
8. Porting to a new host target should be as easy as possible, requiring
2525
porting of only a few files.
2626

2727
Elements, is extremely lightweight… and modular. You compose very
@@ -98,5 +98,5 @@ peer-reviewed, Open Source, collaborative development effort.
9898

9999
-------------------------------------------------------------------------------
100100

101-
*Copyright (c) 2014-2022 Joel de Guzman. All rights reserved.*
101+
*Copyright (c) 2014-2023 Joel de Guzman. All rights reserved.*
102102
*Distributed under the [MIT License](https://opensource.org/licenses/MIT)*

cmake/ElementsConfigApp.cmake

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2016-2020 Joel de Guzman
2+
# Copyright (c) 2016-2023 Joel de Guzman
33
#
44
# Distributed under the MIT License (https://opensource.org/licenses/MIT)
55
###############################################################################
@@ -10,6 +10,7 @@ project(${ELEMENTS_APP_PROJECT} LANGUAGES CXX)
1010
# Sanitizers
1111

1212
option(ASAN "Build with address sanitizer" OFF)
13+
option(LSAN "Build with leak sanitizer" OFF)
1314
option(TSAN "Build with thread sanitizer" OFF)
1415
option(UBSAN "Build with undefined Behavior sanitizer" OFF)
1516

@@ -25,6 +26,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
2526
add_sanitizer("address")
2627
endif()
2728

29+
if (LSAN)
30+
add_sanitizer("leak")
31+
endif()
32+
2833
if (TSAN)
2934
add_sanitizer("thread")
3035
endif()
@@ -33,11 +38,19 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU
3338
add_sanitizer("undefined")
3439
endif()
3540
else()
36-
if (ASAN OR TSAN OR UBSAN)
41+
if (ASAN OR LSAN OR TSAN OR UBSAN)
3742
message(FATAL_ERROR "Compiler is not supported.")
3843
endif()
3944
endif()
4045

46+
###############################################################################
47+
# Linux Open GL
48+
49+
if (UNIX AND NOT APPLE)
50+
find_package(PkgConfig REQUIRED)
51+
find_package(OpenGL REQUIRED COMPONENTS OpenGL)
52+
endif()
53+
4154
###############################################################################
4255
# Sources (and Resources)
4356

@@ -107,25 +120,29 @@ elseif (WIN32)
107120
)
108121

109122
if (MSVC)
123+
124+
set_property(TARGET ${ELEMENTS_APP_PROJECT} PROPERTY
125+
MSVC_RUNTIME_LIBRARY "MultiThreaded"
126+
)
127+
110128
target_link_options(${ELEMENTS_APP_PROJECT} PRIVATE
111129
/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup shcore.lib
112130
)
113131

132+
add_dependencies(${PROJECT_NAME} windows_dlls)
133+
114134
if (CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bits?
115-
set(CAIRO_DLL ${ELEMENTS_ROOT}/lib/external/cairo/lib/x64/cairo.dll)
116135
set(FREETYPE_DLL ${ELEMENTS_ROOT}/lib/external/freetype/win64/freetype.dll)
117136
set(FONTCONFIG_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x64/fontconfig.dll)
118137
set(ICONV_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x64/libiconv.dll)
119138
set(XML2 ${ELEMENTS_ROOT}/lib/external/fontconfig/x64/libxml2.dll)
120139
else()
121-
set(CAIRO_DLL ${ELEMENTS_ROOT}/lib/external/cairo/lib/x86/cairo.dll)
122140
set(FREETYPE_DLL ${ELEMENTS_ROOT}/lib/external/freetype/win32/freetype.dll)
123141
set(FONTCONFIG_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x86/fontconfig.dll)
124142
set(ICONV_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x86/libiconv.dll)
125143
set(XML2 ${ELEMENTS_ROOT}/lib/external/fontconfig/x86/libxml2.dll)
126144
endif()
127145

128-
file(COPY ${CAIRO_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
129146
file(COPY ${FREETYPE_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
130147
file(COPY ${FONTCONFIG_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
131148
file(COPY ${ICONV_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
@@ -143,12 +160,17 @@ target_compile_options(${ELEMENTS_APP_PROJECT} PRIVATE
143160
$<$<CXX_COMPILER_ID:MSVC>:/utf-8>
144161
)
145162

163+
if (APPLE)
164+
target_compile_options(${ELEMENTS_APP_PROJECT} PUBLIC "-fobjc-arc")
165+
endif()
166+
146167
###############################################################################
147168
# Libraries and linking
148169

149170
target_link_libraries(${ELEMENTS_APP_PROJECT} PRIVATE
150171
${ELEMENTS_APP_DEPENDENCIES}
151172
elements
173+
${OPENGL_LIBRARIES}
152174
)
153175

154176
if (NOT DEFINED ELEMENTS_APP_INCLUDE_DIRECTORIES)

cmake/ElementsConfigCommon.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###############################################################################
2-
# Copyright (c) 2016-2020 Joel de Guzman
2+
# Copyright (c) 2016-2023 Joel de Guzman
33
#
44
# Distributed under the MIT License (https://opensource.org/licenses/MIT)
55
###############################################################################

cmake/GitSubmoduleCheck.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# https://gist.github.com/scivision/bb1d47a9529e153617414e91ff5390af
2+
find_package(Git REQUIRED)
3+
function(git_submodule_check dir)
4+
if(NOT EXISTS "${dir}/CMakeLists.txt")
5+
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- ${dir}
6+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
7+
COMMAND_ERROR_IS_FATAL ANY)
8+
endif()
9+
endfunction()

examples/CMakeLists.txt

100644100755
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@ add_subdirectory(dialogs)
1212
add_subdirectory(scale)
1313
add_subdirectory(notebook)
1414
add_subdirectory(doc_aspects)
15-
add_subdirectory(simple_animation)
15+
add_subdirectory(rain)
1616
add_subdirectory(thumbwheels)
1717
add_subdirectory(tooltip)
18-
add_subdirectory(dynamic_list)
19-
add_subdirectory(active_dynamic_list)
18+
add_subdirectory(list)
19+
add_subdirectory(active_list)
20+
add_subdirectory(list_arranger)
2021
add_subdirectory(custom_control)
2122
add_subdirectory(child_window)
2223
add_subdirectory(sync_scrollbars)
2324
add_subdirectory(icons_list)
25+
add_subdirectory(table_list)
26+
add_subdirectory(drop_file)

examples/active_dynamic_list/CMakeLists.txt renamed to examples/active_list/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ if (NOT ELEMENTS_BUILD_EXAMPLES)
1616
add_subdirectory(${ELEMENTS_ROOT} elements)
1717
endif()
1818

19-
set(ELEMENTS_APP_PROJECT "ActiveDynamicList")
20-
set(ELEMENTS_APP_TITLE "Active Dynamic List")
19+
set(ELEMENTS_APP_PROJECT "ActiveList")
20+
set(ELEMENTS_APP_TITLE "Active List")
2121
set(ELEMENTS_APP_COPYRIGHT "Copyright (c) 2022 Johann Philippe")
22-
set(ELEMENTS_APP_ID "com.cycfi.active-dynamic-list")
22+
set(ELEMENTS_APP_ID "com.cycfi.active-list")
2323
set(ELEMENTS_APP_VERSION "1.0")
2424

2525
set(ELEMENTS_APP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <elements.hpp>
77

88
using namespace cycfi::elements;
9+
using cycfi::artist::rgba;
910

1011
// Main window background color
1112
auto constexpr bkd_color = rgba(35, 35, 37, 255);
@@ -24,7 +25,7 @@ struct basic_row : htile_composite
2425
{
2526
std::cout << "on text " << std::endl;
2627
};
27-
push_back(share(input.first));
28+
push_back(share(hsize(100, input.first)));
2829
}
2930
}
3031

@@ -33,7 +34,7 @@ struct basic_row : htile_composite
3334

3435
int main(int argc, char* argv[])
3536
{
36-
app _app(argc, argv, "Active Dynamic List", "com.cycfi.active-dynamic-list");
37+
app _app(argc, argv, "Active Dynamic List", "com.cycfi.active-list");
3738
window _win(_app.name());
3839
_win.on_close = [&_app]() { _app.stop(); };
3940

@@ -50,37 +51,38 @@ int main(int argc, char* argv[])
5051
return ptr_list[index];
5152
};
5253

53-
auto cp = basic_vertical_cell_composer(list_size, make_row);
54-
auto content = vdynamic_list(cp);
55-
auto linked = link(content);
54+
auto cp = basic_vcell_composer(list_size, make_row);
55+
auto content = vlist(cp);
5656

5757
auto b1 = icon_button(icons::minus, 1);
5858
auto b2 = icon_button(icons::plus, 1);
5959

60-
b1.on_click = [&](bool)
61-
{
62-
std::cout << "dn " << std::endl;
63-
if (list_size <= 50)
64-
return;
65-
list_size -= 50;
66-
ptr_list.resize(list_size);
67-
content.resize(list_size);
68-
view_.refresh();
69-
};
60+
b1.on_click =
61+
[&](bool)
62+
{
63+
std::cout << "dn " << std::endl;
64+
if (list_size <= 50)
65+
return;
66+
list_size -= 50;
67+
ptr_list.resize(list_size);
68+
content.resize(list_size);
69+
view_.refresh();
70+
};
7071

71-
b2.on_click = [&](bool)
72-
{
73-
std::cout << "up " << std::endl;
74-
list_size +=50;
75-
ptr_list.resize(list_size);
76-
content.resize(list_size);
77-
view_.refresh();
78-
};
72+
b2.on_click =
73+
[&](bool)
74+
{
75+
std::cout << "up " << std::endl;
76+
list_size +=50;
77+
ptr_list.resize(list_size);
78+
content.resize(list_size);
79+
view_.refresh();
80+
};
7981

8082
view_.content(
8183
margin({10, 10, 10, 10},
8284
vtile(
83-
vscroller(hold(share(linked))),
85+
vscroller(link(content)),
8486
htile(b1, b2)
8587
)
8688
),

0 commit comments

Comments
 (0)