From: Foster B. <fos...@us...> - 2006-02-23 23:29:36
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25760/adobe/future/widgets/sources Modified Files: client_assembler.cpp ui_core.cpp Added Files: label_t.cpp Log Message: the state of things. We've been working to isolate static_text_t (now called label_t) but it has been slow going because we're trying to wrestle with perfecting the API and what effect that has on other components that were using label_t in a way that isn't in accordance with the new API we're trying to write. As it stands static_disabled_text_m is broken on both platforms, but everything else should be working better. --- NEW FILE: label_t.cpp --- /* Copyright 2005-2006 Adobe Systems Incorporated Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt or a copy at http://opensource.adobe.com/licenses.html) */ /****************************************************************************************************/ #include <adobe/future/widgets/headers/label_t.hpp> #include "label_t_impl.hpp" /****************************************************************************************************/ namespace adobe { /****************************************************************************************************/ label_t::label_t(const std::string& name, std::size_t characters, theme_t theme) : object_m(new implementation_t(name, characters, theme)) { } label_t::label_t(const label_t& rhs) : object_m(new implementation_t(*rhs.object_m)) { } label_t& label_t::operator= (const label_t& rhs) { *object_m = *rhs.object_m; return *this; } label_t::~label_t() { delete object_m; } extents_t::slice_t label_t::measure_horizontal() { return object_m->measure_horizontal(); } extents_t::slice_t label_t::measure_vertical(const extents_t::slice_t& horizontal) { return object_m->measure_vertical(horizontal); } void label_t::place(const point_2d_t& position, const extents_t& extents) { object_m->place(position, extents); } void label_t::enable(bool make_enabled) { object_m->enable(make_enabled); } bool operator == (const label_t& x, const label_t& y) { return *x.object_m == *y.object_m; } label_t::implementation_t& label_t::implementation() { assert(object_m); return *object_m; } const label_t::implementation_t& label_t::implementation() const { assert(object_m); return *object_m; } /****************************************************************************************************/ } // namespace adobe /****************************************************************************************************/ Index: ui_core.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/ui_core.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ui_core.cpp 3 Feb 2006 18:33:37 -0000 1.7 --- ui_core.cpp 23 Feb 2006 23:28:55 -0000 1.8 *************** *** 38,42 **** ADOBE_UI_CORE_IMPLEMENTATION_SWAP_DEFINITION(progress_bar_t); ADOBE_UI_CORE_IMPLEMENTATION_SWAP_DEFINITION(separator_t); - ADOBE_UI_CORE_IMPLEMENTATION_SWAP_DEFINITION(static_text_t); ADOBE_UI_CORE_IMPLEMENTATION_SWAP_DEFINITION(edit_text_t); ADOBE_UI_CORE_IMPLEMENTATION_SWAP_DEFINITION(popup_t); --- 38,41 ---- *************** *** 553,608 **** /****************************************************************************************************/ - static_text_t::static_text_t() : - object_m(new implementation_t()) - { } - - static_text_t::static_text_t(const static_text_t& rhs) : - object_m(new implementation_t(*rhs.object_m)) - { } - - static_text_t::~static_text_t() - { delete object_m; } - - void static_text_t::initialize(const std::string& name) - { object_m->initialize(initial_bounds_g, name); } - - extents_t static_text_t::best_bounds() - { return object_m->best_bounds(); } - - void static_text_t::set_bounds(const point_2d_t& position, const extents_t& geometry) - { object_m->set_bounds(position, geometry); } - - void static_text_t::set_name(const std::string& name) - { object_m->set_name(name); } - - void static_text_t::set_theme(theme_t theme) - { object_m->set_theme(theme); } - - void static_text_t::adorn_theme(theme_t theme) - { object_m->adorn_theme(theme); } - - void static_text_t::unadorn_theme(theme_t theme) - { object_m->unadorn_theme(theme); } - - void static_text_t::set_active(bool make_active) - { object_m->set_active(make_active); } - - void static_text_t::set_visible(bool make_visible) - { object_m->set_visible(make_visible); } - - long static_text_t::best_height_given_width(long width) - { return object_m->best_height_given_width(width); } - - void static_text_t::signal_hit(implementation::static_text_hit_proc_t proc) - { object_m->signal_hit(proc); } - - /****************************************************************************************************/ - - #if 0 - #pragma mark - - #endif - - /****************************************************************************************************/ - edit_text_t::edit_text_t() : object_m(new implementation_t()) --- 552,555 ---- *************** *** 908,912 **** ADOBE_SERIALIZABLE_EQUALITY_COMPARABLE_BOILERPLATE_DEFINITION(adobe::progress_bar_t); ADOBE_SERIALIZABLE_EQUALITY_COMPARABLE_BOILERPLATE_DEFINITION(adobe::separator_t); - ADOBE_SERIALIZABLE_EQUALITY_COMPARABLE_BOILERPLATE_DEFINITION(adobe::static_text_t); ADOBE_SERIALIZABLE_EQUALITY_COMPARABLE_BOILERPLATE_DEFINITION(adobe::edit_text_t); ADOBE_SERIALIZABLE_EQUALITY_COMPARABLE_BOILERPLATE_DEFINITION(adobe::popup_t); --- 855,858 ---- *************** *** 933,937 **** ADOBE_IMPLEMENTATION_ACCESSOR_FUNCTIONALITY(progress_bar_t); ADOBE_IMPLEMENTATION_ACCESSOR_FUNCTIONALITY(separator_t); - ADOBE_IMPLEMENTATION_ACCESSOR_FUNCTIONALITY(static_text_t); ADOBE_IMPLEMENTATION_ACCESSOR_FUNCTIONALITY(edit_text_t); ADOBE_IMPLEMENTATION_ACCESSOR_FUNCTIONALITY(popup_t); --- 879,882 ---- Index: client_assembler.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/client_assembler.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** client_assembler.cpp 3 Feb 2006 18:33:37 -0000 1.9 --- client_assembler.cpp 23 Feb 2006 23:28:55 -0000 1.10 *************** *** 19,22 **** --- 19,24 ---- #include <boost/bind.hpp> #include <boost/filesystem/path.hpp> + #include <boost/filesystem/operations.hpp> + #include <boost/filesystem/convenience.hpp> #include <boost/filesystem/fstream.hpp> *************** *** 36,39 **** --- 38,49 ---- #include <adobe/static_table.hpp> + #include <adobe/future/widgets/headers/label_t.hpp> + /* + #include <adobe/gil/extension/conceptspace/any_standard_image.hpp> + #include <adobe/gil/extension/io/io_factory.hpp> + #include <adobe/gil/extension/io/targa.hpp> + #include <adobe/gil/core/algorithm.hpp> + */ + #ifdef ADOBE_SERIALIZATION #include <adobe/future/iomanip.hpp> *************** *** 132,135 **** --- 142,146 ---- const adobe::static_name_t name_checkbox ("checkbox"); const adobe::static_name_t name_link ("link"); + const adobe::static_name_t name_label ("label"); const adobe::static_name_t name_separator ("separator"); const adobe::static_name_t name_slider ("slider"); *************** *** 137,141 **** const adobe::static_name_t name_edit_text ("edit_text"); const adobe::static_name_t name_edit_number ("edit_number"); - const adobe::static_name_t name_static_text ("static_text"); const adobe::static_name_t name_popup ("popup"); const adobe::static_name_t name_popup_cluster ("popup_cluster"); --- 148,151 ---- *************** *** 160,163 **** --- 170,174 ---- const adobe::static_name_t key_name ("name"); + const adobe::static_name_t key_image ("image"); const adobe::static_name_t key_value ("value"); const adobe::static_name_t key_tooltip ("tooltip"); *************** *** 638,658 **** /*************************************************************************************************/ - struct static_text_proxy_t : client_proxy_t, adobe::extents_slices_t - { - typedef adobe::static_text_t widget_type_t; - - explicit static_text_proxy_t(const adobe::dictionary_t& parameters, const adobe::factory_token_t&, const adobe::widget_node_t&); - - void calculate(adobe::eve_t::calculate_data_t&); - void calculate_vertical(adobe::eve_t::calculate_data_t& gdata, const adobe::eve_t::place_data_t& pdata); - void place(const adobe::eve_t::calculate_data_t&, const adobe::eve_t::place_data_t& data); - - private: - bool wrap_m; - widget_type_t static_m; - }; - - /*************************************************************************************************/ - struct edit_number_proxy_t : client_proxy_t, adobe::extents_slices_t { --- 649,652 ---- *************** *** 894,902 **** /*************************************************************************************************/ ! void best_bounds_data_convert_slice(const adobe::extents_t& ideal, adobe::eve_t::calculate_data_t& result, adobe::extents_slices_t::slice_select_t slice) { - const adobe::extents_t::slice_t& src_slice(ideal.slice_m[slice]); - adobe::eve_t::calculate_data_t::slice_t& dst_slice(result.slice_m[slice]); - dst_slice.length_m = src_slice.length_m; dst_slice.outset_m = src_slice.outset_m; --- 888,894 ---- /*************************************************************************************************/ ! void to_calculate_data_slice(const adobe::extents_t::slice_t& src_slice, ! adobe::eve_t::calculate_data_t::slice_t& dst_slice) { dst_slice.length_m = src_slice.length_m; dst_slice.outset_m = src_slice.outset_m; *************** *** 909,912 **** --- 901,916 ---- /*************************************************************************************************/ + void to_extents_slice(const adobe::eve_t::calculate_data_t::slice_t& src_slice, adobe::extents_t::slice_t& dst_slice) + { + dst_slice.length_m = src_slice.length_m; + dst_slice.outset_m = src_slice.outset_m; + dst_slice.inset_m = src_slice.inset_m; + dst_slice.frame_m = src_slice.frame_m; + + adobe::copy(src_slice.guide_set_m, std::back_inserter(dst_slice.poi_m)); + } + + /*************************************************************************************************/ + } // namespace implementation *************** *** 927,932 **** adobe::eve_t::calculate_data_t measure_extents_converter(const adobe::extents_t& ideal, adobe::eve_t::calculate_data_t& result) { ! implementation::best_bounds_data_convert_slice(ideal, result, adobe::extents_slices_t::horizontal); ! implementation::best_bounds_data_convert_slice(ideal, result, adobe::extents_slices_t::vertical); return result; --- 931,939 ---- adobe::eve_t::calculate_data_t measure_extents_converter(const adobe::extents_t& ideal, adobe::eve_t::calculate_data_t& result) { ! implementation::to_calculate_data_slice(ideal.slice_m[adobe::extents_slices_t::horizontal], ! result.slice_m[adobe::extents_slices_t::horizontal]); ! ! implementation::to_calculate_data_slice(ideal.slice_m[adobe::extents_slices_t::vertical], ! result.slice_m[adobe::extents_slices_t::vertical]); return result; *************** *** 992,1004 **** /*************************************************************************************************/ - template <> - void calculate_vertical<static_text_proxy_t> - (static_text_proxy_t& t, adobe::eve_t::calculate_data_t& u, const adobe::eve_t::place_data_t& v) - { - t.calculate_vertical(u, v); - } - - /*************************************************************************************************/ - template <class T> void place(T& t, const adobe::eve_t::calculate_data_t& u, const adobe::eve_t::place_data_t& v) --- 999,1002 ---- *************** *** 1247,1314 **** } - /*************************************************************************************************/ - - #if 0 - #pragma mark - - #endif - - /*************************************************************************************************/ - - static_text_proxy_t::static_text_proxy_t( const adobe::dictionary_t& parameters, - const adobe::factory_token_t& token, - const adobe::widget_node_t& parent) : - client_proxy_t(parameters, token), - wrap_m(false) - { - parameters.get<bool>(key_wrap, wrap_m); - - static_m.initialize(name_m); - - set_up_control(*this, static_m, parent, token); - } - - /*************************************************************************************************/ - - enum { static_wrap_width = 100 }; - - void static_text_proxy_t::calculate(adobe::eve_t::calculate_data_t& geometry) - { - adobe::extents_t ideal(static_m.best_bounds()); - - if (wrap_m) - ideal.width() = std::min<long>(static_wrap_width, ideal.width()); - - geometry.slice_m[horizontal].length_m = ideal.width(); - - if (!wrap_m) - { - geometry.slice_m[vertical].length_m = ideal.height(); - - adobe::copy(ideal.slice_m[vertical].poi_m, - std::back_inserter<adobe::guide_set_t>(geometry.slice_m[vertical].guide_set_m)); - } - } - - /*************************************************************************************************/ - - void static_text_proxy_t::calculate_vertical(adobe::eve_t::calculate_data_t& gdata, const adobe::eve_t::place_data_t& pdata) - { - if (!wrap_m) return; - - gdata.slice_m[vertical].length_m = static_m.best_height_given_width(pdata.slice_m[horizontal].length_m); - } - - /*************************************************************************************************/ - - void static_text_proxy_t::place(const adobe::eve_t::calculate_data_t&, const adobe::eve_t::place_data_t& data) - { - place_converter_result_t conv(place_data_converter(data)); - - #ifndef NDEBUG - overlay_m->place(overlay_token_m, conv.first, conv.second); - #endif - - static_m.set_bounds(conv.first, conv.second); - } /*************************************************************************************************/ --- 1245,1248 ---- *************** *** 2562,2565 **** --- 2496,2523 ---- template <typename T> + inline void generic_widget_measure_horizontal(T& widget, adobe::eve_t::calculate_data_t& geometry) + { + adobe::extents_t::slice_t h_slice(widget.measure_horizontal()); + + implementation::to_calculate_data_slice(h_slice, geometry.slice_m[adobe::extents_slices_t::horizontal]); + } + + /*************************************************************************************************/ + + template <typename T> + inline void generic_widget_measure_vertical(T& widget, adobe::eve_t::calculate_data_t& geometry) + { + adobe::extents_t::slice_t h_slice; + + implementation::to_extents_slice(geometry.slice_m[adobe::extents_slices_t::horizontal], h_slice); + + adobe::extents_t::slice_t v_slice(widget.measure_vertical(h_slice)); + + implementation::to_calculate_data_slice(v_slice, geometry.slice_m[adobe::extents_slices_t::vertical]); + } + + /*************************************************************************************************/ + + template <typename T> void generic_widget_place( T& widget, const adobe::eve_t::calculate_data_t&, *************** *** 3126,3130 **** size_enum_t size(parent.size_m); ! if (parameters.count(key_size)) size = enumerate_size(parameters.get<adobe::name_t>(key_size)); adobe::theme_t theme(size_to_theme(size)); --- 3084,3089 ---- size_enum_t size(parent.size_m); ! if (parameters.count(key_size)) ! size = enumerate_size(parameters.get<adobe::name_t>(key_size)); adobe::theme_t theme(size_to_theme(size)); *************** *** 3193,3196 **** --- 3152,3201 ---- #endif } + widget_node_t label_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token) + { + std::string name; + long characters(0); + size_enum_t size(parent.size_m); + + if (parameters.count(key_size)) + size = enumerate_size(parameters.get<adobe::name_t>(key_size)); + + parameters.get<std::string>(key_name, name); + parameters.get<long>(key_characters, characters); + + adobe::label_t* control(new adobe::label_t(name, characters, size_to_theme(size))); + + adobe::display_t::position_t display_token = adobe::insert(adobe::get_main_display(), parent.display_token_m, *control); + + adobe::display_t::position_t overlay_token = token.client_holder_m.overlay_m.insert(parent.overlay_token_m); + + adobe::eve_t::signal_suite_t signals; + + signals.eve_calculate_proc_m = boost::bind(&generic_widget_measure_horizontal<adobe::label_t>, boost::ref(*control), _1); + signals.eve_calculate_vertical_proc_m = boost::bind(&generic_widget_measure_vertical<adobe::label_t>, boost::ref(*control), _1); + + #ifndef NDEBUG + signals.eve_place_proc_m = boost::bind(&generic_widget_place<adobe::label_t>, boost::ref(*control), _1, _2, boost::ref(token.client_holder_m.overlay_m), overlay_token); + #else + signals.eve_place_proc_m = boost::bind(&generic_widget_place<adobe::label_t>, boost::ref(*control), _1, _2); + #endif + + adobe::eve_t::iterator eve_token = + token.client_holder_m.eve_m.add_view_element(parent.eve_token_m, + adobe::eve_t::insert_element_t( + adobe::eve_t::calculate_data_t(), + false, + parameters, + signals) + ); + + token.client_holder_m.assemblage_m.delete_on_destruction(control); + + #ifndef NDEBUG + return adobe::widget_node_t(size, eve_token, display_token, overlay_token); + #else + return adobe::widget_node_t(size, eve_token, display_token); + #endif + } widget_node_t edit_text_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token) { *************** *** 3201,3208 **** return wire_to_eve<edit_number_proxy_t>(token, parent, parameters); } - widget_node_t static_text_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token) - { - return wire_to_eve<static_text_proxy_t>(token, parent, parameters); - } widget_node_t popup_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token) { --- 3206,3209 ---- *************** *** 3269,3273 **** else if (name == name_edit_text) return edit_text_factory(parameters, parent, token); else if (name == name_edit_number) return edit_number_factory(parameters, parent, token); - else if (name == name_static_text) return static_text_factory(parameters, parent, token); else if (name == name_popup) return popup_factory(parameters, parent, token); else if (name == name_group) return group_factory(parameters, parent, token); --- 3270,3273 ---- *************** *** 3276,3279 **** --- 3276,3281 ---- else if (name == name_separator) return separator_factory(parameters, parent, token); else if (name == name_link) return link_factory(parameters, parent, token); + else if (name == name_label) return label_factory(parameters, parent, token); + else if (name == adobe::static_name_t("static_text")) return label_factory(parameters, parent, token); else if (name == name_progress_bar) return progress_bar_factory(parameters, parent, token); else if (name == name_tab_group) return tab_group_factory(parameters, parent, token); *************** *** 3345,3351 **** /*************************************************************************************************/ ! window_server_t::window_server_t(const char* directory_path, adobe::sheet_t& sheet) : sheet_m(sheet), ! directory_path_m(directory_path), widget_factory_m(adobe::default_factory) { } --- 3347,3353 ---- /*************************************************************************************************/ ! window_server_t::window_server_t(const boost::filesystem::path& working_directory, adobe::sheet_t& sheet) : sheet_m(sheet), ! directory_path_m(working_directory), widget_factory_m(adobe::default_factory) { } *************** *** 3362,3367 **** void window_server_t::push_back(const char* name, size_enum_t dialog_size) { ! iterator window(window_list_m.insert(window_list_m.end(), NULL)); ! boost::filesystem::path file_name(directory_path_m + "/" + name, boost::filesystem::native); boost::filesystem::ifstream stream(file_name); --- 3364,3369 ---- void window_server_t::push_back(const char* name, size_enum_t dialog_size) { ! iterator window(window_list_m.insert(window_list_m.end(), NULL)); ! boost::filesystem::path file_name(directory_path_m / name); boost::filesystem::ifstream stream(file_name); *************** *** 3388,3391 **** --- 3390,3394 ---- /*************************************************************************************************/ + void window_server_t::push_back(std::istream& data, adobe::name_t file_path, |