void attach_view_and_controller(popup_t& control, const dictionary_t& parameters, const factory_token_t& token, adobe::name_t, adobe::name_t, adobe::name_t) { sheet_t& layout_sheet(token.client_holder_m.layout_sheet_m); assemblage_t& assemblage(token.client_holder_m.assemblage_m); if (parameters.count(key_bind) != 0) { name_t cell(get_value(parameters, key_bind).cast<name_t>()); attach_view_and_controller_direct(control, parameters, token, cell); } if (parameters.count(key_items) && get_value(parameters, key_items).type_info() == typeid(name_t)) { // dynamically bind to the cell instead of getting a static list of popup items name_t cell(get_value(parameters, key_items).cast<name_t>()); if (layout_sheet.count_interface(cell)) attach_popup_menu_item_set(control, cell, layout_sheet, assemblage, token.client_holder_m); else attach_popup_menu_item_set(control, cell, token.sheet_m, assemblage, token.client_holder_m); } }
void attach_view_and_controller(checkbox_t& control, const dictionary_t& parameters, const factory_token_t& token, adobe::name_t, adobe::name_t, adobe::name_t) { if (parameters.count(key_bind) != 0) { name_t cell(get_value(parameters, key_bind).cast<name_t>()); attach_view_and_controller_direct(control, parameters, token, cell); } any_regular_t checked_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_checked_signal"), checked_binding)) { implementation::cell_and_expression(checked_binding, cell, expression); } control.checked_proc_m = boost::bind(&handle_checked_signal, token.signal_notifier_m, control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _1); #define BIND_COLOR(name) \ adobe::attach_view(control.name##_proxy_m, parameters, token, adobe::static_name_t("bind_" #name)) BIND_COLOR(color); BIND_COLOR(text_color); BIND_COLOR(interior_color); #undef BIND_COLOR }
void create_widget(const dictionary_t& parameters, size_enum_t size, slider_t*& widget) { std::string alt_text; name_t slider_pointing; long num_ticks(0); value_range_format_t format; name_t orientation(key_horizontal); slider_style_t style(slider_points_not_s); if (parameters.count(key_format)) format.set(get_value(parameters, key_format).cast<dictionary_t>()); get_value(parameters, key_alt_text, alt_text); get_value(parameters, key_orientation, orientation); get_value(parameters, key_slider_ticks, num_ticks); get_value(parameters, key_slider_point, slider_pointing); if (slider_pointing == "up"_name) style = slider_points_up_s; else if (slider_pointing == "down"_name) style = slider_points_down_s; else if (slider_pointing == "left"_name) style = slider_points_left_s; else if (slider_pointing == "right"_name) style = slider_points_right_s; widget = new slider_t(alt_text, orientation == key_vertical, style, num_ticks, format, implementation::size_to_theme(size)); }
void create_widget(const dictionary_t& parameters, size_enum_t size, display_number_t*& display_number) { std::string name; std::string alt_text; theme_t theme(implementation::size_to_theme(size)); long characters(5); unit_t default_unit(to_unit(parameters)); std::vector<unit_t> unit_set; get_value(parameters, key_name, name); get_value(parameters, key_alt_text, alt_text); get_value(parameters, key_characters, characters); if (parameters.count(key_units) == 0) { unit_set.push_back(default_unit); } else { array_t unit_array(get_value(parameters, key_units).cast<array_t>()); for (array_t::iterator iter(unit_array.begin()), last(unit_array.end()); iter != last; ++iter) unit_set.push_back(to_unit(iter->cast<dictionary_t>(), default_unit)); } display_number = new display_number_t(name, alt_text, unit_set.begin(), unit_set.end(), theme, characters); }
inline widget_node_t create_and_hookup_widget<control_button_t, poly_placeable_t>(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, bool is_container, const layout_attributes_t& layout_attributes) { size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); std::string name; std::string alt_text; std::string expression_string; get_value(parameters, key_name, name); get_value(parameters, key_alt_text, alt_text); get_value(parameters, static_name_t("expression"), expression_string); control_button_t* widget(NULL); widget = new control_button_t(name, alt_text, boost::bind(&sheet_t::inspect, boost::ref(token.sheet_m), _1), parse_adam_expression(expression_string), implementation::size_to_theme(size)); assemblage_cleanup_ptr(token.client_holder_m.assemblage_m, widget); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, is_container, layout_attributes); attach_view_and_controller(*widget, parameters, token); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, parent.keyboard_token_m); }
widget_node_t make_optional_panel(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory) { size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); optional_panel_t* widget(NULL); create_widget(parameters, size, widget); token.client_holder_m.assemblage_m.cleanup(boost::bind(delete_ptr<optional_panel_t*>(), widget)); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); // // As per SF.net bug 1428833, we want to attach the poly_placeable_t // to Eve before we attach the controller and view to the model // eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, factory.is_container(static_name_t("optional")), factory.layout_attributes(static_name_t("optional"))); widget->set_optional_display_procs(boost::bind(&optional_display_show, boost::ref(token.client_holder_m.visible_change_queue_m), boost::ref(token.client_holder_m.eve_m), eve_token, _1), boost::bind(&optional_display_hide, boost::ref(token.client_holder_m.visible_change_queue_m), boost::ref(token.client_holder_m.eve_m), eve_token, _1)); attach_view_and_controller(*widget, parameters, token); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, parent.keyboard_token_m); }
widget_node_t make_edit_number(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory) { bool is_container(factory.is_container(static_name_t("edit_number"))); const layout_attributes_t& layout_attributes( factory.layout_attributes(static_name_t("edit_number"))); size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); edit_number_t* widget(NULL); create_widget(parameters, size, widget); assemblage_cleanup_ptr(token.client_holder_m.assemblage_m, widget); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); // // As per SF.net bug 1428833, we want to attach the poly_placeable_t // to Eve before we attach the controller and view to the model // eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, is_container, layout_attributes); attach_edit_num_view_and_controller(*widget, parameters, token); keyboard_t::iterator keyboard_token = keyboard_t::get().insert(parent.keyboard_token_m, poly_key_handler_t(boost::ref(*widget))); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, keyboard_token); }
void attach_view_and_controller(slider_t& control, const dictionary_t& parameters, const factory_token_t& token, adobe::name_t, adobe::name_t, adobe::name_t) { sheet_t& layout_sheet(token.client_holder_m.layout_sheet_m); if (parameters.count(key_bind) != 0) { name_t cell(get_value(parameters, key_bind).cast<name_t>()); attach_view_direct(control, parameters, token, cell); // is the cell in the layout sheet or the Adam sheet? if (layout_sheet.count_interface(cell) != 0) couple_controller_to_cell(control, cell, layout_sheet, token, parameters); else couple_controller_to_cell(control, cell, token.sheet_m, token, parameters); } }
widget_node_t make_button(const dictionary_t& parameters, const widget_node_t& parent, const factory_token_t& token, const widget_factory_t& factory) { size_enum_t size(parameters.count(key_size) ? implementation::enumerate_size(get_value(parameters, key_size).cast<name_t>()) : parent.size_m); button_t* widget = implementation::create_button_widget(parameters, token, size); token.client_holder_m.assemblage_m.cleanup(boost::bind(delete_ptr(),widget)); // // Call display_insertion to embed the new widget within the view heirarchy // platform_display_type display_token(insert(get_main_display(), parent.display_token_m, *widget)); // set up key handler code. We do this all the time because we want the button to be updated // when modifier keys are pressed during execution of the dialog. keyboard_t::iterator keyboard_token(keyboard_t::get().insert(parent.keyboard_token_m, poly_key_handler_t(boost::ref(*widget)))); // // As per SF.net bug 1428833, we want to attach the poly_placeable_t // to Eve before we attach the controller and view to the model // eve_t::iterator eve_token; eve_token = attach_placeable<poly_placeable_t>(parent.eve_token_m, *widget, parameters, token, factory.is_container("button"_name), factory.layout_attributes("button"_name)); // // Return the widget_node_t that comprises the tokens created for this widget by the various components // return widget_node_t(size, eve_token, display_token, keyboard_token); }
void apply_layout_parameters( layout_attributes_t& data, const dictionary_t& parameters) { ADOBE_ONCE_INSTANCE(adobe_eve_evaluate); get_value(parameters, key_indent, data.indent_m); if (parameters.count(key_horizontal)) { (*alignment_table_g)( get_value(parameters, key_horizontal).cast<name_t>(), data.slice_m[extents_slices_t::horizontal].alignment_m); } if (parameters.count(key_vertical)) { (*alignment_table_g)( get_value(parameters, key_vertical).cast<name_t>(), data.slice_m[extents_slices_t::vertical].alignment_m); } // REVISIT (sparent) If we had named guides then named guide suppression would go here. if (parameters.count(key_guide_mask)) // an empty array would allow baselines out. { // Turn on all guides - then selectively suppress data.slice_m[extents_slices_t::vertical].suppress_m = false; data.slice_m[extents_slices_t::horizontal].suppress_m = false; array_t guide_mask(get_value(parameters, key_guide_mask).cast<array_t>()); for (array_t::const_iterator iter(guide_mask.begin()), last(guide_mask.end()); iter != last; ++iter) { if (iter->cast<name_t>() == key_guide_baseline) data.slice_m[extents_slices_t::vertical].suppress_m = true; if (iter->cast<name_t>() == key_guide_label) data.slice_m[extents_slices_t::horizontal].suppress_m = true; } } // REVISIT (sparent) : If we had named guides then named guide balancing would go here... /* Balanced guides must be supressed to avoid having them attach to outside guides which could overconstrain the system. */ if (parameters.count(key_guide_balance)) { data.slice_m[extents_slices_t::vertical].balance_m = false; data.slice_m[extents_slices_t::horizontal].balance_m = false; array_t guide_balance(get_value(parameters, key_guide_balance).cast<array_t>()); for (array_t::const_iterator iter(guide_balance.begin()), last(guide_balance.end()); iter != last; ++iter) { if (iter->cast<name_t>() == key_guide_baseline) { data.slice_m[extents_slices_t::vertical].balance_m = true; data.slice_m[extents_slices_t::vertical].suppress_m = true; } if (iter->cast<name_t>() == key_guide_label) { data.slice_m[extents_slices_t::horizontal].balance_m = true; data.slice_m[extents_slices_t::horizontal].suppress_m = true; } } } // REVISIT (sparent) : I'm seeing a pattern here - with three cases this could be factored { dictionary_t::const_iterator iter (parameters.find(key_placement)); if (iter != parameters.end()) { (*placement_table_g)(iter->second.cast<name_t>(), data.placement_m); } // Adjust defaults // Specifying a row from the parameters implies enabling baselines unless otherwise specified. if (iter != parameters.end() && data.placement_m == layout_attributes_placement_t::place_row && !parameters.count(key_guide_mask)) { data.slice_m[extents_slices_t::vertical].suppress_m = false; } } { dictionary_t::const_iterator iter (parameters.find(key_child_horizontal)); if (iter != parameters.end()) { (*alignment_table_g)( iter->second.cast<name_t>(), data.slice_m[extents_slices_t::horizontal].child_alignment_m); } } { dictionary_t::const_iterator iter (parameters.find(key_child_vertical)); if (iter != parameters.end()) { (*alignment_table_g)( iter->second.cast<name_t>(), data.slice_m[extents_slices_t::vertical].child_alignment_m); } } // spacing { dictionary_t::const_iterator iter (parameters.find(key_spacing)); if (iter != parameters.end()) { if (iter->second.type_info() == type_info<array_t>()) { const array_t& spacing_array = iter->second.cast<array_t>(); data.spacing_m.resize(spacing_array.size() + 1); layout_attributes_t::spacing_t::iterator dest_iter(data.spacing_m.begin() + 1); for (array_t::const_iterator iter(spacing_array.begin()); iter != spacing_array.end(); ++iter) { *dest_iter = iter->cast<long>(); ++dest_iter; } } else { double tmp(data.spacing_m[1]); iter->second.cast(tmp); // Try getting as number data.spacing_m[1] = long(tmp); } } } // margin { dictionary_t::const_iterator iter(parameters.find(key_margin)); if (iter != parameters.end()) { if (iter->second.type_info() == type_info<array_t>()) { const array_t& margin_array = iter->second.cast<array_t>(); data.vertical().margin_m.first = margin_array[0].cast<long>(); data.horizontal().margin_m.first = margin_array[1].cast<long>(); data.vertical().margin_m.second = margin_array[2].cast<long>(); data.horizontal().margin_m.second = margin_array[3].cast<long>(); } else { long margin = iter->second.cast<long>(); data.vertical().margin_m.first = margin; data.horizontal().margin_m.first = margin; data.vertical().margin_m.second = margin; data.horizontal().margin_m.second = margin; } } } }
void attach_view_and_controller(listbox_t& control, const dictionary_t& parameters, const factory_token_t& token, adobe::name_t, adobe::name_t, adobe::name_t) { basic_sheet_t& layout_sheet(token.client_holder_m.layout_sheet_m); assemblage_t& assemblage(token.client_holder_m.assemblage_m); if (parameters.count(key_bind) != 0) { name_t cell(get_value(parameters, key_bind).cast<name_t>()); attach_view_and_controller_direct(control, parameters, token, cell); } control.row_factory_m = token.row_factory_m; if (parameters.count(key_items) && get_value(parameters, key_items).type_info() == type_info<name_t>()) { name_t cell(get_value(parameters, key_items).cast<name_t>()); listbox_t::item_set_view_controller_t& tmp = control.item_set_view_controller_m; if (layout_sheet.count_interface(cell)) { attach_view(assemblage, cell, tmp, layout_sheet); attach_controller_direct(tmp, parameters, token, cell); } else { attach_view(assemblage, cell, tmp, token.sheet_m); attach_controller_direct(tmp, parameters, token, cell); } } { any_regular_t selection_changed_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_selection_changed_signal"), selection_changed_binding)) implementation::cell_and_expression(selection_changed_binding, cell, expression); control.selection_changed_proc_m = boost::bind(&handle_selection_changed_signal, _1, token.signal_notifier_m, static_name_t("selection_changed"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2); } { any_regular_t dropped_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_dropped_signal"), dropped_binding)) implementation::cell_and_expression(dropped_binding, cell, expression); control.dropped_proc_m = boost::bind(&handle_row_signal, _1, token.signal_notifier_m, static_name_t("dropped"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2); } { any_regular_t drop_acceptable_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_drop_acceptable_signal"), drop_acceptable_binding)) implementation::cell_and_expression(drop_acceptable_binding, cell, expression); control.drop_acceptable_proc_m = boost::bind(&handle_drop_acceptable_signal, _1, token.signal_notifier_m, static_name_t("drop_acceptable"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2, _3); } { any_regular_t left_clicked_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_left_clicked_signal"), left_clicked_binding)) implementation::cell_and_expression(left_clicked_binding, cell, expression); control.left_clicked_proc_m = boost::bind(&handle_row_click_signal, _1, token.signal_notifier_m, static_name_t("left_clicked"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2, _3); } { any_regular_t right_clicked_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_right_clicked_signal"), right_clicked_binding)) implementation::cell_and_expression(right_clicked_binding, cell, expression); control.right_clicked_proc_m = boost::bind(&handle_row_click_signal, _1, token.signal_notifier_m, static_name_t("right_clicked"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2, _3); } { any_regular_t double_clicked_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_double_clicked_signal"), double_clicked_binding)) implementation::cell_and_expression(double_clicked_binding, cell, expression); control.double_clicked_proc_m = boost::bind(&handle_row_signal, _1, token.signal_notifier_m, static_name_t("double_clicked"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2); } { any_regular_t erased_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_erased_signal"), erased_binding)) implementation::cell_and_expression(erased_binding, cell, expression); control.erased_proc_m = boost::bind(&handle_row_signal, _1, token.signal_notifier_m, static_name_t("erased"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2); } { any_regular_t browsed_binding; name_t cell; array_t expression; if (get_value(parameters, static_name_t("bind_browsed_signal"), browsed_binding)) implementation::cell_and_expression(browsed_binding, cell, expression); control.browsed_proc_m = boost::bind(&handle_row_signal, _1, token.signal_notifier_m, static_name_t("browsed"), control.signal_id_m, boost::ref(token.sheet_m), cell, expression, _2); } adobe::attach_view(control.name_m.color_proxy_m, parameters, token, adobe::static_name_t("bind_label_color")); #define BIND_COLOR(name) \ adobe::attach_view(control.name##_proxy_m, parameters, token, adobe::static_name_t("bind_" #name)) BIND_COLOR(color); BIND_COLOR(interior_color); BIND_COLOR(hilite_color); BIND_COLOR(item_text_color); #undef BIND_COLOR }