2019-10-24 06:36:42 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2019 by its authors. See AUTHORS.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2017-11-22 00:17:04 -08:00
|
|
|
#define EFL_CXXPERIMENTAL
|
2017-11-22 00:14:55 -08:00
|
|
|
|
2019-05-02 11:08:04 -07:00
|
|
|
#include <Efl_Ui.hh>
|
2014-12-16 13:04:43 -08:00
|
|
|
|
2017-11-22 00:14:55 -08:00
|
|
|
using namespace std::placeholders;
|
2017-11-22 00:17:04 -08:00
|
|
|
using efl::eo::add;
|
2017-11-01 06:42:04 -07:00
|
|
|
|
2017-11-22 00:14:55 -08:00
|
|
|
struct appData
|
2014-12-16 13:04:43 -08:00
|
|
|
{
|
2017-11-22 00:14:55 -08:00
|
|
|
appData() : m_win(nullptr) {}
|
2014-12-16 13:04:43 -08:00
|
|
|
|
2017-11-22 00:14:55 -08:00
|
|
|
~appData() {
|
|
|
|
std::cout << "Good bye!" << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
void create() {
|
|
|
|
std::cout << "Hello!" << std::endl;
|
|
|
|
|
2017-11-22 00:17:04 -08:00
|
|
|
add(m_win);
|
2017-11-22 00:14:55 -08:00
|
|
|
m_win.text_set("Calendar Layout Formatting Example");
|
|
|
|
m_win.delete_request_event_cb_add([&](){ destroy(); });
|
2014-12-16 13:04:43 -08:00
|
|
|
|
2017-11-22 00:17:04 -08:00
|
|
|
efl::ui::Calendar cal(add, m_win);
|
2017-11-22 00:14:55 -08:00
|
|
|
m_win.content_set(cal);
|
2014-12-16 13:04:43 -08:00
|
|
|
|
2017-11-22 00:14:55 -08:00
|
|
|
auto wcal(cal._get_wref());
|
2014-12-16 13:04:43 -08:00
|
|
|
|
2017-11-22 00:14:55 -08:00
|
|
|
// FIXME: How does one figure out the argument types for the function?
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
auto cb_a = std::bind([](
|
2017-11-22 00:14:55 -08:00
|
|
|
efl::eina::strbuf_wrapper& sb,
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
efl::eina::value_view const& value) -> bool {
|
2017-11-22 00:14:55 -08:00
|
|
|
try {
|
|
|
|
sb.append_strftime("%b. %y", efl::eina::get<tm>(value));
|
|
|
|
} catch (std::system_error const&) {
|
|
|
|
sb.append(value.to_string());
|
|
|
|
}
|
|
|
|
std::cout << "Month: " << std::string(sb) << std::endl;
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
return true;
|
2017-11-22 00:14:55 -08:00
|
|
|
}, _1, _2);
|
Efl.Ui.Format revamp
This class helps widgets which contain a numerical value and must display it,
like Progressbar (units label), Spin, Spin_Button, Slider (both units and popup
labels, in legacy), Tags (when in shrunk mode) or Calendar (year_month label).
Previously this was a mix of interface and mixin: widgets had to support setting a
formatting func, and the mixin offered support for formatting strings, by setting
an internal formatting func. On top of that, the spinner widget supported "special
values", a list of values that should be shown as certain strings instead.
This has now been simplified and unified:
Widgets including this mixin can use the formatted_value_get() method which accepts
an Eina_Value and returns a string. Thats's it.
The mixin adds three properties to the widget (format_values, format_func and
format_string) which users can use to tailor formatting. The widget does not need
to know which method has been used, it just retrieves the resulting string.
This removes a lot of duplicated widget code, and adds functionality which was
missing before. For example, all widgets support passing a list of values now.
Widgets must implement the apply_formatted_value() method so they are notified
of changes in the format and they can redraw anything they need.
Tests have been added to the Elementary Spec suite for all cases.
Legacy widgets behavior has not been modified, although a few needed some code
changes.
2019-07-02 05:40:06 -07:00
|
|
|
// FIXME XAR: I broke this and I do not know how to fix it
|
|
|
|
// cal.format_func_set(cb_a);
|
2019-07-09 01:13:27 -07:00
|
|
|
(void)cb_a;
|
2017-11-22 00:14:55 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void destroy() {
|
|
|
|
// FIXME: need del() function and no error on unref().
|
2017-11-22 03:25:29 -08:00
|
|
|
::efl_allow_parent_unref_set(m_win, true);
|
2017-11-22 00:14:55 -08:00
|
|
|
m_win = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
efl::ui::Win m_win;
|
|
|
|
};
|
|
|
|
|
|
|
|
static appData app;
|
|
|
|
|
|
|
|
static void
|
|
|
|
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
|
|
|
|
{
|
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
|
|
|
app.create();
|
2014-12-16 13:04:43 -08:00
|
|
|
}
|
2017-11-01 06:42:04 -07:00
|
|
|
EFL_MAIN()
|