Skip to content

Commit c981efd

Browse files
committedAug 26, 2020
Merge branch 'develop'
2 parents 1f5ba55 + 899908b commit c981efd

34 files changed

+277
-178
lines changed
 

‎cmake/ElementsConfigCommon.cmake

+7
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ cmake_minimum_required(VERSION 3.9.6...3.15.0)
77

88
project(elements LANGUAGES C CXX)
99

10+
message(STATUS "CMAKE_C_COMPILER ${CMAKE_C_COMPILER}")
11+
message(STATUS "CMAKE_C_COMPILER_ID ${CMAKE_C_COMPILER_ID}")
12+
message(STATUS "CMAKE_C_COMPILER_VERSION ${CMAKE_C_COMPILER_VERSION}")
13+
message(STATUS "CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER}")
14+
message(STATUS "CMAKE_CXX_COMPILER_ID ${CMAKE_CXX_COMPILER_ID}")
15+
message(STATUS "CMAKE_CXX_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION}")
16+
1017
set(DEFAULT_BUILD_TYPE "Release")
1118
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
1219
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")

‎examples/CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,3 @@ add_subdirectory(notebook)
2222
add_subdirectory(doc_aspects)
2323
add_subdirectory(simple_animation)
2424

25-
26-

‎examples/basic_sliders_and_knobs/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ auto make_hslider(int index)
3737
make_markers<false>(),
3838
(index + 1) * 0.25
3939
));
40-
return align_middle(xside_margin({ 20, 20 }, hold(hsliders[index])));
40+
return align_middle(hmargin({ 20, 20 }, hold(hsliders[index])));
4141
}
4242

4343
auto make_hsliders()
@@ -58,7 +58,7 @@ auto make_vslider(int index)
5858
make_markers<true>(),
5959
(index + 1) * 0.25
6060
));
61-
return align_center(yside_margin({ 20, 20 }, hold(vsliders[index])));
61+
return align_center(vmargin({ 20, 20 }, hold(vsliders[index])));
6262
}
6363

6464
auto make_vsliders()
@@ -93,7 +93,7 @@ auto make_dial(int index)
9393

9494
auto make_dials()
9595
{
96-
return xside_margin(20,
96+
return hmargin(20,
9797
vtile(
9898
make_dial(0),
9999
make_dial(1),

‎examples/layout/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ auto make_popup_menu(
285285
auto menu =
286286
layer(
287287
vtile(
288-
link(item1), link(item2),
289-
link(item3), link(item4), link(item5)
288+
item1, item2,
289+
item3, item4, item5
290290
),
291291
panel{}
292292
);

‎examples/sprite_sliders_and_knobs/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ auto make_vslider(int index)
3838
make_markers<true>(),
3939
(index + 1) * 0.25
4040
));
41-
return align_center(yside_margin({ 20, 20 }, hold(vsliders[index])));
41+
return align_center(vmargin({ 20, 20 }, hold(vsliders[index])));
4242
}
4343

4444
auto make_vsliders()
@@ -79,7 +79,7 @@ auto make_dial(int index)
7979

8080
auto make_dials()
8181
{
82-
return xside_margin(20,
82+
return hmargin(20,
8383
vtile(
8484
make_dial(0),
8585
make_dial(1),

‎examples/text_edit/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ set(ELEMENTS_APP_COPYRIGHT "Copyright (c) 2016-2020 Joel de Guzman")
2727
set(ELEMENTS_APP_ID "com.cycfi.text-edit")
2828
set(ELEMENTS_APP_VERSION "1.0")
2929

30-
set(ELEMENTS_APP_RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resources/dark-bkd.jpg)
30+
set(ELEMENTS_APP_RESOURCES
31+
${CMAKE_CURRENT_SOURCE_DIR}/resources/dark-bkd.jpg
32+
${CMAKE_CURRENT_SOURCE_DIR}/resources/WenQuanYiMicroHei.ttf
33+
)
3134

3235
include(ElementsConfigApp)

‎examples/text_edit/main.cpp

+30-21
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,10 @@ auto make_bkd()
1212
{
1313
return port(image{ "dark-bkd.jpg" });
1414
}
15-
16-
std::string const text =
17-
"We are in the midst of an intergalatic condensing of beauty that will "
18-
"clear a path toward the planet itself. The quantum leap of rebirth is "
19-
"now happening worldwide. It is time to take healing to the next level. "
20-
"Soon there will be a deepening of chi the likes of which the infinite "
21-
"has never seen. The universe is approaching a tipping point. This "
22-
"vision quest never ends. Imagine a condensing of what could be. "
23-
"We can no longer afford to live with stagnation. Suffering is born "
24-
"in the gap where stardust has been excluded. You must take a stand "
25-
"against discontinuity.\n\n"
26-
27-
"Without complexity, one cannot dream. Stagnation is the antithesis of "
28-
"life-force. Only a seeker of the galaxy may engender this wellspring of hope."
29-
"Yes, it is possible to eliminate the things that can destroy us, but not "
30-
"without wellbeing on our side. Where there is delusion, faith cannot thrive. "
31-
"You may be ruled by desire without realizing it. Do not let it eliminate "
32-
"the growth of your journey.\n\n"
33-
34-
"--New-Age Bullshit Generator"
15+
std::string const text1 =
16+
"一千条路…\n"
17+
"仁、义、礼、智、信…\n"
18+
"开放包容、视野宽广\n\n"
3519
;
3620

3721
std::string const text2 =
@@ -60,13 +44,38 @@ std::string const text2 =
6044
"reflect, you will enter into infinite freedom that transcends understanding.\n\n"
6145
;
6246

47+
std::string const text3 =
48+
"We are in the midst of an intergalatic condensing of beauty that will "
49+
"clear a path toward the planet itself. The quantum leap of rebirth is "
50+
"now happening worldwide. It is time to take healing to the next level. "
51+
"Soon there will be a deepening of chi the likes of which the infinite "
52+
"has never seen. The universe is approaching a tipping point. This "
53+
"vision quest never ends. Imagine a condensing of what could be. "
54+
"We can no longer afford to live with stagnation. Suffering is born "
55+
"in the gap where stardust has been excluded. You must take a stand "
56+
"against discontinuity.\n\n"
57+
58+
"Without complexity, one cannot dream. Stagnation is the antithesis of "
59+
"life-force. Only a seeker of the galaxy may engender this wellspring of hope."
60+
"Yes, it is possible to eliminate the things that can destroy us, but not "
61+
"without wellbeing on our side. Where there is delusion, faith cannot thrive. "
62+
"You may be ruled by desire without realizing it. Do not let it eliminate "
63+
"the growth of your journey.\n\n"
64+
;
65+
6366
auto make_edit_box()
6467
{
68+
// set the font of text box to 文泉驿 open source font: http://wenq.org/wqy2/index.cgi
69+
char const* font_family = "文泉驿微米黑, \"WenQuanYi Micro Hei\"";
70+
auto text = text1+text2+text3;
71+
6572
return
6673
scroller(
6774
margin(
6875
{ 20, 20, 20, 20 },
69-
align_left_top(hsize(800, basic_text_box(text2+text)))
76+
align_left_top(hsize(800,
77+
basic_text_box(text, font_descr{ font_family }
78+
)))
7079
)
7180
);
7281
}
Binary file not shown.

‎lib/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ endif()
179179

180180
target_compile_options(elements PRIVATE
181181
$<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -Wpedantic -ftemplate-backtrace-limit=0>
182-
$<$<CXX_COMPILER_ID:Clang>:-Wall -Wpedantic -ftemplate-backtrace-limit=0>
182+
$<$<CXX_COMPILER_ID:Clang>:-Werror -Wall -Wpedantic -ftemplate-backtrace-limit=0>
183+
$<$<CXX_COMPILER_ID:AppleClang>:-Werror -Wall -Wpedantic -ftemplate-backtrace-limit=0>
183184
$<$<CXX_COMPILER_ID:MSVC>:/W4 /wd4244 /wd4305 /wd4996 /wd4267 /wd4018 /utf-8>
184185
)
185186

@@ -188,6 +189,11 @@ if (MSVC)
188189
STRING(REGEX REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
189190
endif()
190191

192+
if (APPLE)
193+
# Not sure why APPLE is not picking the target_compile_options above
194+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wpedantic -ftemplate-backtrace-limit=0")
195+
endif()
196+
191197
###############################################################################
192198
# Cairo
193199

‎lib/host/macos/app.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Distributed under the MIT License (https://opensource.org/licenses/MIT)
99
namespace cycfi { namespace elements
1010
{
1111
app::app(
12-
int argc
13-
, char* argv[]
12+
int // argc
13+
, char*[] // argv
1414
, std::string // name Note: Unlike Windows and Linux, MacOS contains
1515
, std::string // id the app name and id in the plist.info file.
1616
// We ignore the ctor params here and use those

‎lib/include/elements/base_view.hpp

+36-24
Original file line numberDiff line numberDiff line change
@@ -294,36 +294,48 @@ namespace cycfi { namespace elements
294294
public:
295295

296296
#if defined(ELEMENTS_HOST_UI_LIBRARY_COCOA) || defined(ELEMENTS_HOST_UI_LIBRARY_GTK)
297-
base_view(host_view_handle h);
297+
base_view(host_view_handle h);
298298
#endif
299-
base_view(extent size_);
300-
base_view(host_window_handle h);
301-
virtual ~base_view();
302-
303-
virtual void draw(cairo_t* /* ctx */, rect /* area */) {};
304-
virtual void click(mouse_button /* btn */) {}
305-
virtual void drag(mouse_button /* btn */) {}
306-
virtual void cursor(point /* p */, cursor_tracking /* status */) {}
307-
virtual void scroll(point /* dir */, point /* p */) {}
308-
virtual void key(key_info const& /* k */) {}
309-
virtual void text(text_info const& /* info */) {}
310-
virtual void begin_focus() {}
311-
virtual void end_focus() {}
312-
virtual void poll() {}
313-
314-
virtual void refresh();
315-
virtual void refresh(rect area);
316-
317-
point cursor_pos() const;
318-
extent size() const;
319-
void size(extent size_);
320-
host_view_handle host() const { return _view; }
299+
base_view(extent size_);
300+
base_view(host_window_handle h);
301+
virtual ~base_view();
302+
303+
virtual void draw(cairo_t* ctx, rect area);
304+
virtual void click(mouse_button btn);
305+
virtual void drag(mouse_button btn);
306+
virtual void cursor(point p, cursor_tracking status);
307+
virtual void scroll(point dir, point p);
308+
virtual void key(key_info const& k);
309+
virtual void text(text_info const& info);
310+
virtual void begin_focus();
311+
virtual void end_focus();
312+
virtual void poll();
313+
314+
virtual void refresh();
315+
virtual void refresh(rect area);
316+
317+
point cursor_pos() const;
318+
extent size() const;
319+
void size(extent size_);
320+
host_view_handle host() const { return _view; }
321321

322322
private:
323323

324-
host_view_handle _view;
324+
host_view_handle _view;
325325
};
326326

327+
////////////////////////////////////////////////////////////////////////////
328+
inline void base_view::draw(cairo_t* /* ctx */, rect /* area */) {}
329+
inline void base_view::click(mouse_button /* btn */) {}
330+
inline void base_view::drag(mouse_button /* btn */) {}
331+
inline void base_view::cursor(point /* p */, cursor_tracking /* status */) {}
332+
inline void base_view::scroll(point /* dir */, point /* p */) {}
333+
inline void base_view::key(key_info const& /* k */) {}
334+
inline void base_view::text(text_info const& /* info */) {}
335+
inline void base_view::begin_focus() {}
336+
inline void base_view::end_focus() {}
337+
inline void base_view::poll() {}
338+
327339
////////////////////////////////////////////////////////////////////////////
328340
// The clipboard
329341
std::string clipboard();

‎lib/include/elements/element/dial.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace cycfi { namespace elements
8888
};
8989

9090
template <std::size_t size>
91-
inline view_limits basic_knob_element<size>::limits(basic_context const& ctx) const
91+
inline view_limits basic_knob_element<size>::limits(basic_context const& /* ctx */) const
9292
{
9393
auto pt = point{ float(size), float(size) };
9494
return view_limits{ pt, pt };

‎lib/include/elements/element/flow.hpp

+14-20
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,27 @@ namespace cycfi { namespace elements
1515
////////////////////////////////////////////////////////////////////////////
1616
// Flow Element
1717
////////////////////////////////////////////////////////////////////////////
18-
class flowable
19-
{
20-
public:
21-
22-
virtual ~flowable() = default;
23-
24-
virtual void break_lines(
25-
std::vector<element_ptr>& rows
26-
, basic_context const& ctx
27-
, float width
28-
) = 0;
29-
};
30-
31-
class flowable_container : public flowable, public container
18+
class flowable_container : public container
3219
{
3320
public:
3421

3522
void break_lines(
3623
std::vector<element_ptr>& rows
3724
, basic_context const& ctx
3825
, float width
39-
) override;
26+
);
4027

4128
virtual float width_of(size_t index, basic_context const& ctx) const;
4229
virtual element_ptr make_row(size_t first, size_t last);
30+
31+
void reflow() { _reflow = true; }
32+
bool needs_reflow() const { return _reflow; }
33+
void reflow_done() { _reflow = false; }
34+
35+
private:
36+
37+
bool _reflow = true;
38+
4339
};
4440

4541
using flow_composite = vector_composite<flowable_container>;
@@ -50,21 +46,19 @@ namespace cycfi { namespace elements
5046

5147
using base_type = vector_composite<vtile_element>;
5248

53-
flow_element(flowable& flowable_)
49+
flow_element(flowable_container& flowable_)
5450
: _flowable(flowable_)
55-
, _laid_out(false)
5651
{}
5752

5853
view_limits limits(basic_context const& ctx) const override;
5954
void layout(context const& ctx) override;
6055

6156
private:
6257

63-
flowable& _flowable;
64-
bool _laid_out;
58+
flowable_container& _flowable;
6559
};
6660

67-
inline auto flow(flowable& flowable_)
61+
inline auto flow(flowable_container& flowable_)
6862
{
6963
return flow_element{ flowable_ };
7064
}

‎lib/include/elements/element/gallery/menu.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace cycfi { namespace elements
5555

5656
inline auto menu_item_text(std::string text)
5757
{
58-
return xside_margin({ 20, 20 }, align_left(label(std::move(text))));
58+
return hmargin({ 20, 20 }, align_left(label(std::move(text))));
5959
}
6060

6161
inline auto menu_item_text(std::string text, shortcut_key shortcut)
@@ -66,7 +66,7 @@ namespace cycfi { namespace elements
6666
#else
6767
auto sk_font = get_theme().label_font;
6868
#endif
69-
return xside_margin({ 20, 10 },
69+
return hmargin({ 20, 10 },
7070
htile(
7171
htile(
7272
align_left(label(std::move(text)))

0 commit comments

Comments
 (0)
Please sign in to comment.