Skip to content

Commit

Permalink
squashed rebase from master
Browse files Browse the repository at this point in the history
  • Loading branch information
djowel committed Dec 5, 2023
1 parent 2d6f517 commit a4b9cc2
Show file tree
Hide file tree
Showing 135 changed files with 18,682 additions and 16,126 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ xcuserdata/
/cmake-build-release/
/.vs/
/CMakeSettings.json
/lib/artist/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "lib/external/asio"]
path = lib/external/asio
url = https://github.com/chriskohlhoff/asio.git
[submodule "lib/artist"]
path = lib/artist
url = https://github.com/cycfi/artist.git
19 changes: 3 additions & 16 deletions cmake/ElementsConfigApp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ else()
endif()
endif()

###############################################################################
# Linux Open GL

if (UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
find_package(OpenGL REQUIRED COMPONENTS OpenGL)
endif()

###############################################################################
# Sources (and Resources)

Expand Down Expand Up @@ -120,29 +112,25 @@ elseif (WIN32)
)

if (MSVC)

set_property(TARGET ${ELEMENTS_APP_PROJECT} PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded"
)

target_link_options(${ELEMENTS_APP_PROJECT} PRIVATE
/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup shcore.lib
)

add_dependencies(${PROJECT_NAME} windows_dlls)

if (CMAKE_SIZEOF_VOID_P EQUAL 8) # 64 bits?
set(CAIRO_DLL ${ELEMENTS_ROOT}/lib/external/cairo/lib/x64/cairo.dll)
set(FREETYPE_DLL ${ELEMENTS_ROOT}/lib/external/freetype/win64/freetype.dll)
set(FONTCONFIG_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x64/fontconfig.dll)
set(ICONV_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x64/libiconv.dll)
set(XML2 ${ELEMENTS_ROOT}/lib/external/fontconfig/x64/libxml2.dll)
else()
set(CAIRO_DLL ${ELEMENTS_ROOT}/lib/external/cairo/lib/x86/cairo.dll)
set(FREETYPE_DLL ${ELEMENTS_ROOT}/lib/external/freetype/win32/freetype.dll)
set(FONTCONFIG_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x86/fontconfig.dll)
set(ICONV_DLL ${ELEMENTS_ROOT}/lib/external/fontconfig/x86/libiconv.dll)
set(XML2 ${ELEMENTS_ROOT}/lib/external/fontconfig/x86/libxml2.dll)
endif()

file(COPY ${CAIRO_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY ${FREETYPE_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY ${FONTCONFIG_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
file(COPY ${ICONV_DLL} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
Expand Down Expand Up @@ -170,7 +158,6 @@ endif()
target_link_libraries(${ELEMENTS_APP_PROJECT} PRIVATE
${ELEMENTS_APP_DEPENDENCIES}
elements
${OPENGL_LIBRARIES}
)

if (NOT DEFINED ELEMENTS_APP_INCLUDE_DIRECTORIES)
Expand Down
8 changes: 3 additions & 5 deletions examples/CMakeLists.txt
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ add_subdirectory(dialogs)
add_subdirectory(scale)
add_subdirectory(notebook)
add_subdirectory(doc_aspects)
add_subdirectory(rain)
add_subdirectory(simple_animation)
add_subdirectory(thumbwheels)
add_subdirectory(tooltip)
add_subdirectory(list)
add_subdirectory(active_list)
add_subdirectory(list_arranger)
add_subdirectory(dynamic_list)
add_subdirectory(active_dynamic_list)
add_subdirectory(custom_control)
add_subdirectory(child_window)
add_subdirectory(sync_scrollbars)
add_subdirectory(icons_list)
add_subdirectory(table_list)
add_subdirectory(drop_file)
1 change: 0 additions & 1 deletion examples/active_list/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <elements.hpp>

using namespace cycfi::elements;
using cycfi::artist::rgba;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down
5 changes: 2 additions & 3 deletions examples/basic_sliders_and_knobs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <elements.hpp>

using namespace cycfi::elements;
using cycfi::artist::rgba;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down Expand Up @@ -84,8 +83,8 @@ auto make_dial(int index)

auto markers = radial_labels<15>(
hold(dials[index]),
0.7, // Label font size (relative size)
"0", "1", "2", "3", "4", // Labels
0.7, // Label font size (relative size)
"0", "1", "2", "3", "4", // Labels
"5", "6", "7", "8", "9", "10"
);

Expand Down
6 changes: 2 additions & 4 deletions examples/buttons/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include <random>

using namespace cycfi::elements;
using cycfi::artist::rgba;
namespace colors = cycfi::artist::colors;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down Expand Up @@ -43,7 +41,7 @@ view_limits my_custom_button::limits(basic_context const& ctx) const

void my_custom_button::draw(context const& ctx)
{
auto& cnv = ctx.canvas; // The artist canvas
auto& cnv = ctx.canvas; // The canvas
auto bounds = ctx.bounds; // The bounding rectangle

// This is the state of the button. Adjust the rendering based on these if
Expand All @@ -59,7 +57,7 @@ void my_custom_button::draw(context const& ctx)
if (value)
bounds = bounds.move(1, 1); // Simulate click

// Render the button using the artist library
// Render the button using the library
cnv.fill_style(colors::dark_slate_blue);
cnv.fill_round_rect(bounds, 8);
cnv.line_width(1);
Expand Down
2 changes: 0 additions & 2 deletions examples/child_window/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@
#include <elements.hpp>

using namespace cycfi::elements;
using namespace cycfi::artist;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
auto background = box(bkd_color);

auto make_child_window(rect bounds, char const* title)
{
using cycfi::elements::image;
return closable_child_window(
title,
bounds,
Expand Down
2 changes: 0 additions & 2 deletions examples/custom_control/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <infra/support.hpp>

using namespace cycfi::elements;
using namespace cycfi::artist;
using namespace cycfi;

auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down Expand Up @@ -216,7 +215,6 @@ class my_app : public app

auto my_app::make_control()
{
using cycfi::elements::image;
return
layer(
align_center_middle(
Expand Down
1 change: 0 additions & 1 deletion examples/dialogs/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using namespace cycfi::elements;
using namespace std::chrono_literals;
using cycfi::artist::rgba;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down
2 changes: 0 additions & 2 deletions examples/doc_aspects/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <elements.hpp>

using namespace cycfi::elements;
using cycfi::artist::rgba;
namespace colors = cycfi::artist::colors;

#define VARIANT 4

Expand Down
36 changes: 15 additions & 21 deletions examples/drop_file/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

using namespace cycfi::elements;

using cycfi::artist::rgba;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
auto background = box(bkd_color);
Expand All @@ -21,32 +19,28 @@ int main(int argc, char* argv[])

view view_(_win);

auto image_ = share(image{"space.jpg"});
auto drop_box_ = share(drop_box(scroller(hold(image_)), {"text/uri-list"}));
auto image_ = share(image{ "space.jpg" });
auto drop_box_ = share(drop_box(scroller(hold(image_))));

drop_box_->on_drop = [image_ = get(image_), &view_](drop_info const& info)
{
if (contains_filepaths(info.data))
if (info.paths.size() == 1) // We accept only one file
{
auto paths = get_filepaths(info.data);
if (paths.size() == 1) // We accept only one file
auto image_path = info.paths[0];
if (auto p = image_.lock())
{
auto const& image_path = paths[0];
if (auto p = image_.lock())
try
{
auto img = image{image_path};
*p = img;
view_.refresh(*p);
}
catch (std::runtime_error const&)
{
try
{
auto img = image{image_path};
*p = img;
view_.refresh(*p);
}
catch (std::runtime_error const&)
{
// Invalid image
return false;
}
return true;
// Invalid image
return false;
}
return true;
}
}
return false;
Expand Down
1 change: 0 additions & 1 deletion examples/empty/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <elements.hpp>

using namespace cycfi::elements;
using namespace cycfi::artist;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down
21 changes: 10 additions & 11 deletions examples/icons_list/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
#include <elements.hpp>

using namespace cycfi::elements;
using cycfi::artist::rgba;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
auto background = box(bkd_color);

template<size_t Size>
struct fixed_size_base : default_label
class fixed_size_base : public default_label
{
view_limits limits(const basic_context &ctx) const override
{
point size = measure_text(ctx.canvas, "9" ,get_font());
size.x *= Size;
return {{size.x, size.y}, {size.x, size.y}};
}
public:
view_limits limits(const basic_context &ctx) const override
{
point size = measure_text(ctx.canvas, "9", get_font().size(get_font_size()));
size.x *= Size;
return {{size.x, size.y}, {size.x, size.y}};
}
};

template<size_t Size>
Expand All @@ -31,7 +31,8 @@ using fixed_size_label = label_gen<basic_fixed_size<Size>>;

inline auto make_icon_label(std::string name, int i)
{
auto h = htile(fixed_size_label<10>(name), hspace(50), icon_button(i,1));

auto h = htile(fixed_size_label<10>(name), hspacer(50), icon_button(i,1));
return share(h);
}

Expand Down Expand Up @@ -126,8 +127,6 @@ int main(int argc, char* argv[])
comp.push_back(make_icon_label("hand", icons::hand));
comp.push_back(make_icon_label("question", icons::question));
comp.push_back(make_icon_label("menu", icons::menu));
comp.push_back(make_icon_label("link", icons::link));
comp.push_back(make_icon_label("unlink", icons::unlink));
view_.content(
margin({10, 10, 10, 10},
vscroller(margin({40, 20, 40, 20}, comp))),
Expand Down
2 changes: 0 additions & 2 deletions examples/layout/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
#include <elements.hpp>

using namespace cycfi::elements;
namespace colors = cycfi::artist::colors;
using cycfi::artist::rgba;

// Main window background color
auto bkd_color = rgba(62, 62, 62, 255);
Expand Down
5 changes: 2 additions & 3 deletions examples/list/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/*=============================================================================
Copyright (c) 2016-2023 Joel de Guzman
Copyright (c) 2016-2020 Joel de Guzman
Distributed under the MIT License (https://opensource.org/licenses/MIT)
=============================================================================*/
#include <elements.hpp>

using namespace cycfi::elements;
using namespace cycfi::artist;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand All @@ -33,7 +32,7 @@ int main(int argc, char* argv[])
draw_cell // Composer function
);

auto content = share(list{my_composer});
auto content = share(dynamic_list{my_composer});

view_.content(
vscroller(hold(content)),
Expand Down
21 changes: 15 additions & 6 deletions examples/list_arranger/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ std::vector<std::filesystem::path> paths = {

int main(int argc, char* argv[])
{
app _app(argc, argv, "Active Dynamic List", "com.cycfi.list-arranger");
app _app(argc, argv, "Active Dynamic List", "com.cycfi.active-dynamic-list");
window _win(_app.name());
_win.on_close = [&_app]() { _app.stop(); };

Expand All @@ -86,8 +86,8 @@ int main(int argc, char* argv[])
return share(draggable(align_left(label(paths[index].u8string()))));
};

auto cp = basic_vcell_composer(list_size, make_row);
auto list = vlist(cp, false);
auto cp = basic_vertical_cell_composer(list_size, make_row);
auto list = vdynamic_list(cp, false);
auto drop_inserter_ = share(
drop_inserter(
margin({10, 10, 15, 10}, link(list)),
Expand All @@ -112,14 +112,23 @@ int main(int argc, char* argv[])
drop_inserter_->on_move =
[&](std::size_t pos, std::vector<std::size_t> const& indices)
{
move_indices(paths, pos, indices);
std::vector<std::filesystem::path> to_move;
for (auto i = indices.crbegin(); i != indices.crend(); ++i)
{
to_move.push_back(paths[*i]);
paths.erase(paths.begin()+*i);
}
auto pos_i = pos >= paths.size()? paths.end() : paths.begin()+pos;
for (auto const& path : to_move)
paths.insert(pos_i, path);
view_.refresh();
};

drop_inserter_->on_erase =
drop_inserter_->on_delete =
[&](std::vector<std::size_t> const& indices)
{
erase_indices(paths, indices);
for (auto i = indices.crbegin(); i != indices.crend(); ++i)
paths.erase(paths.begin()+*i);
view_.refresh();
};

Expand Down
1 change: 0 additions & 1 deletion examples/menus/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <random>

using namespace cycfi::elements;
using cycfi::artist::rgba;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down
1 change: 0 additions & 1 deletion examples/notebook/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <elements.hpp>

using namespace cycfi::elements;
using namespace cycfi::artist;

// Main window background color
auto constexpr bkd_color = rgba(35, 35, 37, 255);
Expand Down
Loading

0 comments on commit a4b9cc2

Please sign in to comment.