From: Foster B. <fos...@us...> - 2006-02-27 20:42:09
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8667/adobe/future/widgets/sources Modified Files: client_assembler.cpp Added Files: image_t.cpp Log Message: image_t (icons and pictures) support for Mac and Win32, along with a GIL image factory and a (sample) Targa file format importing module for that factory. Also added alert.adm/eve as a sample for the icon support. Added the notion of a working directory to the modal dialog interface to reference external resources. Also added an alert API that leverages modal_dialog_interface. Other misc. bug fixes and changes. --- NEW FILE: image_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/image_t.hpp> #include "image_t_impl.hpp" /****************************************************************************************************/ namespace adobe { /****************************************************************************************************/ image_t::image_t(GIL::rgba8_image& image) : object_m(new implementation_t(image)) { } image_t::image_t(const image_t& rhs) : object_m(new implementation_t(*rhs.object_m)) { } image_t& image_t::operator= (const image_t& rhs) { *object_m = *rhs.object_m; return *this; } image_t::~image_t() { delete object_m; } extents_t image_t::measure() { return object_m->measure(); } void image_t::place(const point_2d_t& position, const extents_t& extents) { object_m->place(position, extents); } void image_t::enable(bool make_enabled) { object_m->enable(make_enabled); } void image_t::set(GIL::rgba8_image& image) { object_m->set(image); } bool operator == (const image_t& x, const image_t& y) { return *x.object_m == *y.object_m; } image_t::implementation_t& image_t::implementation() { assert(object_m); return *object_m; } const image_t::implementation_t& image_t::implementation() const { assert(object_m); return *object_m; } /****************************************************************************************************/ } // namespace adobe /****************************************************************************************************/ Index: client_assembler.cpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/future/widgets/sources/client_assembler.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** client_assembler.cpp 23 Feb 2006 23:28:55 -0000 1.10 --- client_assembler.cpp 27 Feb 2006 20:41:59 -0000 1.11 *************** *** 53,56 **** --- 53,61 ---- #include <adobe/future/enum_ops.hpp> + #include <adobe/future/widgets/headers/image_t.hpp> + + #include <adobe/gil/extension/io/io_factory.hpp> + #include <adobe/gil/extension/io/targa.hpp> + #include "ui_core.hpp" #include "display.hpp" *************** *** 59,62 **** --- 64,101 ---- /*************************************************************************************************/ + #if 0 + ADOBE_GIL_NAMESPACE_BEGIN + + /*************************************************************************************************/ + + template <typename ViewType> + struct image_io_dispatch<GIL::targa_t, ViewType> + { + typedef GIL::targa_t value_type; + typedef ViewType view_type; + typedef GIL::image<view_type> image_type; + + inline bool detect(const value_type& value, + std::streambuf& stream_buffer) const + { return value.detect(stream_buffer); } + + inline void read(const value_type& value, + image_type& image, + std::streambuf& stream_buffer, + adobe::dictionary_t parameters = adobe::dictionary_t()) const + { value.read(image, stream_buffer, parameters); } + + inline void write(const value_type& value, + const view_type& image_view, + std::streambuf& stream_buffer, + adobe::dictionary_t parameters = adobe::dictionary_t()) const + { value.write(image_view, stream_buffer, parameters); } + }; + + /*************************************************************************************************/ + + ADOBE_GIL_NAMESPACE_END + #endif + /*************************************************************************************************/ namespace adobe { *************** *** 141,144 **** --- 180,184 ---- const adobe::static_name_t name_button ("button"); const adobe::static_name_t name_checkbox ("checkbox"); + const adobe::static_name_t name_image ("image"); const adobe::static_name_t name_link ("link"); const adobe::static_name_t name_label ("label"); *************** *** 942,945 **** --- 982,1026 ---- /*************************************************************************************************/ + GIL::image_factory_t<GIL::rgba8_view>& gil_image_factory() + { + typedef GIL::rgba8_view view_type; + typedef GIL::image_factory_t<view_type> factory_type; + typedef factory_type::image_format_type format_type; + + static factory_type factory_s; + static bool inited(false); + + if (!inited) + { + inited = true; + + factory_s.register_format(format_type(adobe::static_name_t("targa"), GIL::targa_t<view_type>())); + } + + return factory_s; + } + + /*************************************************************************************************/ + + void load_image_from_name(const boost::filesystem::path& image_path, GIL::rgba8_image& image) + { + if (!boost::filesystem::exists(image_path)) + { + boost::filesystem::path complete_path(boost::filesystem::complete(image_path)); + + throw std::runtime_error(("client_assembler: load_image_from_name: could not locate file \"" + + complete_path.string() + + "\"").c_str()); + } + + boost::filesystem::filebuf filebuf; + + filebuf.open(image_path, std::ios_base::in | std::ios_base::binary); + + gil_image_factory().read(image, filebuf); + } + + /*************************************************************************************************/ + } // namespace *************** *** 3198,3201 **** --- 3279,3326 ---- #endif } + widget_node_t image_factory(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token) + { + std::string image; + + parameters.get<std::string>(key_image, image); + + GIL::rgba8_image actual_image; + + load_image_from_name(boost::filesystem::path(token.working_directory_m / image), actual_image); + + adobe::image_t* control(new adobe::image_t(actual_image)); + + 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_calculate<adobe::image_t>, boost::ref(*control), _1); + + #ifndef NDEBUG + signals.eve_place_proc_m = boost::bind(&generic_widget_place<adobe::image_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::image_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(parent.size_m, eve_token, display_token, overlay_token); + #else + return adobe::widget_node_t(parent.size_m, 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) { *************** *** 3278,3281 **** --- 3403,3407 ---- 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_image) return image_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); *************** *** 3381,3385 **** boost::ref(*this), window, _1, _2), dialog_size, ! widget_factory_m).release(); sheet_m.update(); // Force values to their correct states. --- 3507,3512 ---- boost::ref(*this), window, _1, _2), dialog_size, ! widget_factory_m, ! directory_path_m).release(); sheet_m.update(); // Force values to their correct states. *************** *** 3418,3422 **** boost::ref(*this), window, _1, _2), dialog_size, ! widget_factory_m).release(); sheet_m.update(); // Force values to their correct states. --- 3545,3550 ---- boost::ref(*this), window, _1, _2), dialog_size, ! widget_factory_m, ! directory_path_m).release(); sheet_m.update(); // Force values to their correct states. *************** *** 3528,3538 **** /*************************************************************************************************/ ! adobe::auto_ptr<eve_client_holder> make_view( adobe::name_t file_path, ! const adobe::line_position_t::getline_proc_t& getline_proc, ! std::istream& stream, ! adobe::sheet_t& sheet, ! const button_notifier_t& notifier, ! size_enum_t dialog_size, ! adobe::widget_factory_proc_t factory) { adobe::auto_ptr<eve_client_holder> result(new eve_client_holder()); --- 3656,3667 ---- /*************************************************************************************************/ ! adobe::auto_ptr<eve_client_holder> make_view( adobe::name_t file_path, ! const adobe::line_position_t::getline_proc_t& getline_proc, ! std::istream& stream, ! adobe::sheet_t& sheet, ! const button_notifier_t& notifier, ! size_enum_t dialog_size, ! adobe::widget_factory_proc_t factory, ! const boost::filesystem::path& working_directory) { adobe::auto_ptr<eve_client_holder> result(new eve_client_holder()); *************** *** 3540,3544 **** sheet, *(result.get()), ! notifier ); --- 3669,3674 ---- sheet, *(result.get()), ! notifier, ! working_directory ); |