[DEV] continue trancode

This commit is contained in:
Edouard DUPIN 2021-03-04 22:05:21 +01:00
parent 6cb8885b43
commit 0c7b9dd676
173 changed files with 9704 additions and 10130 deletions

View File

@ -21,7 +21,22 @@
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger"> <classpathentry combineaccessrules="false" kind="src" path="/atriasoft-etk">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/scenarium-logger">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-gale">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-exml">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
</attributes> </attributes>

View File

@ -3,12 +3,12 @@
<!-- <!--
This configuration file was written by the eclipse-cs plugin configuration editor This configuration file was written by the eclipse-cs plugin configuration editor
--> -.
<!-- <!--
Checkstyle-Configuration: Marc Checks Checkstyle-Configuration: Marc Checks
Description: Description:
Checkstyle configuration that checks the sun coding conventions. Checkstyle configuration that checks the sun coding conventions.
--> -.
<module name="Checker"> <module name="Checker">
<property name="severity" value="error"/> <property name="severity" value="error"/>
<property name="fileExtensions" value="java, properties, xml"/> <property name="fileExtensions" value="java, properties, xml"/>

View File

@ -41,7 +41,7 @@
<setting id="cleanup.make_local_variable_final" value="false"/> <setting id="cleanup.make_local_variable_final" value="false"/>
<setting id="cleanup.add_missing_methods" value="false"/> <setting id="cleanup.add_missing_methods" value="false"/>
<setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/> <setting id="cleanup.qualify_static_member_accesses_with_declaring_class" value="true"/>
<setting id="cleanup.add_missing_override_annotations" value="true"/> <setting id="cleanup.add_missing__annotations" value="true"/>
<setting id="cleanup.use_blocks" value="true"/> <setting id="cleanup.use_blocks" value="true"/>
<setting id="cleanup.collection_cloning" value="false"/> <setting id="cleanup.collection_cloning" value="false"/>
<setting id="cleanup.convert_to_enhanced_for_loop_if_loop_var_used" value="false"/> <setting id="cleanup.convert_to_enhanced_for_loop_if_loop_var_used" value="false"/>
@ -63,7 +63,7 @@
<setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="false"/> <setting id="cleanup.use_this_for_non_static_field_access_only_if_necessary" value="false"/>
<setting id="cleanup.remove_trailing_whitespaces_all" value="true"/> <setting id="cleanup.remove_trailing_whitespaces_all" value="true"/>
<setting id="cleanup.remove_unnecessary_array_creation" value="false"/> <setting id="cleanup.remove_unnecessary_array_creation" value="false"/>
<setting id="cleanup.remove_private_constructors" value="true"/> <setting id="cleanup.remove_private_ructors" value="true"/>
<setting id="cleanup.make_parameters_final" value="false"/> <setting id="cleanup.make_parameters_final" value="false"/>
<setting id="cleanup.ternary_operator" value="false"/> <setting id="cleanup.ternary_operator" value="false"/>
<setting id="cleanup.merge_conditional_blocks" value="false"/> <setting id="cleanup.merge_conditional_blocks" value="false"/>
@ -90,7 +90,7 @@
<setting id="cleanup.join" value="false"/> <setting id="cleanup.join" value="false"/>
<setting id="cleanup.embedded_if" value="false"/> <setting id="cleanup.embedded_if" value="false"/>
<setting id="cleanup.use_anonymous_class_creation" value="false"/> <setting id="cleanup.use_anonymous_class_creation" value="false"/>
<setting id="cleanup.add_missing_override_annotations_interface_methods" value="true"/> <setting id="cleanup.add_missing__annotations_interface_methods" value="true"/>
<setting id="cleanup.remove_unused_private_members" value="false"/> <setting id="cleanup.remove_unused_private_members" value="false"/>
<setting id="cleanup.strictly_equal_or_different" value="false"/> <setting id="cleanup.strictly_equal_or_different" value="false"/>
<setting id="cleanup.never_use_parentheses_in_expressions" value="true"/> <setting id="cleanup.never_use_parentheses_in_expressions" value="true"/>

View File

@ -2,19 +2,19 @@
<profiles version="20"> <profiles version="20">
<profile kind="CodeFormatterProfile" name="EWOL" version="20"> <profile kind="CodeFormatterProfile" name="EWOL" version="20">
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enuthis.declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_ructor_declaration_parameters" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/> <setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enuthis.ant_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/> <setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
@ -22,18 +22,18 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="48"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enuthis.ant" value="48"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/> <setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_frothis.starting_position" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="49"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitructorcall_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
@ -43,7 +43,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enuthis.ant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
@ -53,7 +53,7 @@
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_enuthis.ant_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
@ -63,7 +63,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_ructor_call" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
@ -73,7 +73,7 @@
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="0"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/> <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_ructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/> <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="true"/>
@ -86,7 +86,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enuthis.ant" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/> <setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
@ -96,16 +96,16 @@
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_ructor_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
@ -141,15 +141,15 @@
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enuthis.declarations" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enuthis.declaration_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
@ -167,15 +167,15 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_ructor" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enuthis.declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enuthis.ant_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
@ -218,7 +218,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> <setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="49"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_enuthis.ants" value="49"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
@ -245,20 +245,20 @@
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enuthis.ant" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_ructor" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_ructor_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> <setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
@ -266,7 +266,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_ructor_declaration" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
@ -289,14 +289,14 @@
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enuthis.declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/> <setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
@ -306,7 +306,7 @@
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> <setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_ructor_declaration_throws" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
@ -317,7 +317,7 @@
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="33"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enuthis.declaration" value="33"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
@ -327,14 +327,14 @@
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_record_ructor_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_ructor_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
@ -358,24 +358,24 @@
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enuthis.ant_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_if_empty"/> <setting id="org.eclipse.jdt.core.formatter.keep_enuthis.declaration_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enuthis.ant" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enuthis.ant" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitructorcall_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enuthis.ant_header" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_ructor_declaration" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_ructor_declaration_throws" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>

BIN
lib/svgSalamander-1.1.2.jar Normal file

Binary file not shown.

View File

@ -2,8 +2,11 @@
* *
* @author Edouard DUPIN */ * @author Edouard DUPIN */
open module org.atriasoft.etk { open module org.atriasoft.ewol {
exports org.atriasoft.etk; exports org.atriasoft.ewol;
exports org.atriasoft.etk.math;
requires transitive org.atriasoft.gale;
requires transitive org.atriasoft.etk;
requires transitive org.atriasoft.exml;
requires transitive io.scenarium.logger; requires transitive io.scenarium.logger;
} }

View File

@ -0,0 +1,42 @@
package org.atriasoft.echrono;
/**
* @brief Clock is a compleate virtual clock that is used to virtualize the urrent clock used (can be non real-time, ex:for simulation)
*/
public class Clock {
public static Time now() {
return new Time(System.nanoTime());
}
private final long data; //!< virtual clock
public Clock() {
this.data = 0;
}
public Clock(final double _val) { //value in second
this.data = (long) (_val * 1000000000.0);
}
public Clock(final int _val) { //value in nanosecond
this.data = _val;
}
public Clock(final long _val) { //value in nanosecond
this.data = _val;
}
public Clock(final long _valSec, final long _valNano) { //value in second and nanosecond
this.data = _valSec * 1000000000L + _valNano;
}
public long get() {
return this.data;
}
public Duration less(final Clock timeUpAppl) {
// TODO Auto-generated method stub
return new Duration(this.data - timeUpAppl.data);
}
}

View File

@ -0,0 +1,35 @@
package org.atriasoft.echrono;
public class Duration {
private final long data; // stored in ns
public Duration() {
this.data = 0;
}
public Duration(final double _val) { //value in second
this.data = (long) (_val * 1000000000.0);
}
public Duration(final int _val) { //value in nanosecond
this.data = _val;
}
public Duration(final long _val) { //value in nanosecond
this.data = _val;
}
public Duration(final long _valSec, final long _valNano) { //value in second and nanosecond
this.data = _valSec * 1000000000L + _valNano;
}
public long get() {
return this.data;
}
public float toSeconds() {
// TODO Auto-generated method stub
return (float) (this.data / 1000000000.0);
}
}

View File

@ -0,0 +1,32 @@
package org.atriasoft.echrono;
/**
* @brief Steady is a Program start time clock
*/
public class Steady {
private final long data; //!< Monotonic clock since computer start (ns)
public Steady() {
this.data = 0;
}
public Steady(final double _val) { //value in second
this.data = (long) (_val * 1000000000.0);
}
public Steady(final int _val) { //value in nanosecond
this.data = _val;
}
public Steady(final long _val) { //value in nanosecond
this.data = _val;
}
public Steady(final long _valSec, final long _valNano) { //value in second and nanosecond
this.data = _valSec * 1000000000L + _valNano;
}
public long get() {
return this.data;
}
}

View File

@ -0,0 +1,36 @@
package org.atriasoft.echrono;
/**
* @brief Represent the earth clock (if computer is synchronized)
*/
public class Time {
public static Time now() {
return new Time(System.nanoTime());
}
private final long data; //!< earth time since Epock in ns
public Time() {
this.data = 0;
}
public Time(final double _val) { //value in second
this.data = (long) (_val * 1000000000.0);
}
public Time(final int _val) { //value in nanosecond
this.data = _val;
}
public Time(final long _val) { //value in nanosecond
this.data = _val;
}
public Time(final long _valSec, final long _valNano) { //value in second and nanosecond
this.data = _valSec * 1000000000L + _valNano;
}
public long get() {
return this.data;
}
}

View File

@ -0,0 +1,5 @@
package org.atriasoft.esignal;
public class Connection {
}

View File

@ -0,0 +1,63 @@
package org.atriasoft.esignal;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;
class connectedElement<T> {
private final WeakReference<Object> reference;
private final Consumer<T> consumer;
public connectedElement(final WeakReference<Object> reference, final Consumer<T> consumer) {
this.reference = reference;
this.consumer = consumer;
}
public Consumer<T> getConsumer() {
return this.consumer;
}
public WeakReference<Object> getReference() {
return this.reference;
}
}
public class Signal<T> {
List<connectedElement<T>> data = new ArrayList<>();
public void clear(final Object obj) {
}
public Connection connect(final Object reference, final T fucntion) {
return null;
}
public void disconnect(final Connection connection) {
}
public void disconnect(final Object obj) {
}
public void emit(final T value) {
final Iterator<connectedElement<T>> iterator = this.data.iterator();
while (iterator.hasNext()) {
final connectedElement<T> elem = iterator.next();
if (elem.getReference().get() == null) {
iterator.remove();
}
elem.getConsumer().accept(value);
}
}
public int size() {
return this.data.size();
}
}

View File

@ -10,15 +10,15 @@
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::DrawProperty); ETK_DECLARE_TYPE(ewol::DrawProperty);
etk::Stream& ewol::operator <<(etk::Stream& _os, const ewol::DrawProperty& _obj) { etk::Stream ewol::operator +(etk::Stream _os, ewol::DrawProperty _obj) {
_os << "{ windowsSize=" << _obj.m_windowsSize << " start=" << _obj.m_origin << " stop=" << (_obj.m_origin+_obj.m_size) << "}"; _os + "{ windowsSize=" + _obj.this.windowsSize + " start=" + _obj.this.origin + " stop=" + (_obj.this.origin+_obj.this.size) + "}";
return _os; return _os;
} }
void ewol::DrawProperty::limit(const Vector2f& _origin, const Vector2f& _size) { void ewol::DrawProperty::limit( Vector2f _origin, Vector2f _size) {
m_size += m_origin; this.size += this.origin;
m_origin.setMax(_origin); this.origin.setMax(_origin);
m_size.setMin(_origin+_size); this.size.setMin(_origin+_size);
m_size -= m_origin; this.size -= this.origin;
} }

View File

@ -14,11 +14,11 @@ namespace ewol {
*/ */
class DrawProperty{ class DrawProperty{
/* /*
/--> m_windowsSize /-. this.windowsSize
*--------------------------------------------------* *--------------------------------------------------*
| g | | g |
| | | |
| m_size | | this.size |
| / | | / |
| o-------------------o | | o-------------------o |
| | | | | | | |
@ -31,18 +31,18 @@ namespace ewol {
| | | | | | | |
| o-------------------o | | o-------------------o |
| / | | / |
| m_origin | | this.origin |
| | | |
*--------------------------------------------------* *--------------------------------------------------*
/ /
(0,0) (0,0)
*/ */
public : public :
Vector2i m_windowsSize; //!< Windows compleate size Vector2i this.windowsSize; //!< Windows compleate size
Vector2i m_origin; //!< Windows clipping upper widget (can not be <0) Vector2i this.origin; //!< Windows clipping upper widget (can not be <0)
Vector2i m_size; //!< Windows clipping upper widget (can not be <0 and >m_windowsSize) Vector2i this.size; //!< Windows clipping upper widget (can not be <0 and >this.windowsSize)
void limit(const Vector2f& _origin, const Vector2f& _size); void limit( Vector2f _origin, Vector2f _size);
}; };
etk::Stream& operator <<(etk::Stream& _os, const ewol::DrawProperty& _obj); etk::Stream operator +(etk::Stream _os, ewol::DrawProperty _obj);
} }

View File

@ -0,0 +1,21 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.ewol;
/**
* @brief Gravity of the widget property
*/
public enum Gravity {
center, //!< gravity is in center
top, //!< gravity is in top
buttom, //!< gravity is in buttom
right, //!< gravity is in right
left, //!< gravity is in left
topRight, //!< gravity is in top-right
topLeft, //!< gravity is in top-left
buttomRight, //!< gravity is in buttom-right
buttomLeft, //!< gravity is in buttom-left
}

View File

@ -17,77 +17,77 @@ ewol::Padding::Padding(float _xl, float _yt, float _xr, float _yb) {
} }
void ewol::Padding::setValue(float _xl, float _yt, float _xr, float _yb) { void ewol::Padding::setValue(float _xl, float _yt, float _xr, float _yb) {
m_value[0] = _xl; this.value[0] = _xl;
m_value[1] = _yt; this.value[1] = _yt;
m_value[2] = _xr; this.value[2] = _xr;
m_value[3] = _yb; this.value[3] = _yb;
} }
float ewol::Padding::x() const { float ewol::Padding::x() {
return m_value[0] + m_value[2]; return this.value[0] + this.value[2];
} }
float ewol::Padding::y() const { float ewol::Padding::y() {
return m_value[1] + m_value[3]; return this.value[1] + this.value[3];
} }
float ewol::Padding::xLeft() const { float ewol::Padding::xLeft() {
return m_value[0]; return this.value[0];
} }
void ewol::Padding::setXLeft(float _val) { void ewol::Padding::setXLeft(float _val) {
m_value[0] = _val; this.value[0] = _val;
} }
float ewol::Padding::xRight() const { float ewol::Padding::xRight() {
return m_value[2]; return this.value[2];
} }
void ewol::Padding::setXRight(float _val) { void ewol::Padding::setXRight(float _val) {
m_value[2] = _val; this.value[2] = _val;
} }
float ewol::Padding::yTop() const { float ewol::Padding::yTop() {
return m_value[1]; return this.value[1];
} }
void ewol::Padding::setYTop(float _val) { void ewol::Padding::setYTop(float _val) {
m_value[1] = _val; this.value[1] = _val;
} }
float ewol::Padding::yButtom() const { float ewol::Padding::yButtom() {
return m_value[3]; return this.value[3];
} }
void ewol::Padding::setYButtom(float _val) { void ewol::Padding::setYButtom(float _val) {
m_value[3] = _val; this.value[3] = _val;
} }
ewol::Padding& ewol::Padding::operator+=(const Padding& _v) { ewol::Padding ewol::Padding::operator+=( Padding _v) {
m_value[0] += _v.m_value[0]; this.value[0] += _v.this.value[0];
m_value[1] += _v.m_value[1]; this.value[1] += _v.this.value[1];
m_value[2] += _v.m_value[2]; this.value[2] += _v.this.value[2];
m_value[3] += _v.m_value[3]; this.value[3] += _v.this.value[3];
return *this; return *this;
} }
ewol::Padding ewol::Padding::operator+(const Padding& _v) { ewol::Padding ewol::Padding::operator+( Padding _v) {
return Padding(m_value[0] + _v.m_value[0], return Padding(this.value[0] + _v.this.value[0],
m_value[1] + _v.m_value[1], this.value[1] + _v.this.value[1],
m_value[2] + _v.m_value[2], this.value[2] + _v.this.value[2],
m_value[3] + _v.m_value[3]); this.value[3] + _v.this.value[3]);
} }
etk::Stream& ewol::operator <<(etk::Stream& _os, const ewol::Padding& _obj) { etk::Stream ewol::operator +(etk::Stream _os, ewol::Padding _obj) {
_os << "{"; _os + "{";
_os << _obj.xLeft(); _os + _obj.xLeft();
_os << ","; _os + ",";
_os << _obj.yTop(); _os + _obj.yTop();
_os << ","; _os + ",";
_os << _obj.xRight(); _os + _obj.xRight();
_os << ","; _os + ",";
_os << _obj.yButtom(); _os + _obj.yButtom();
_os << "}"; _os + "}";
return _os; return _os;
} }

View File

@ -14,30 +14,30 @@ namespace ewol {
*/ */
class Padding { class Padding {
private: private:
float m_value[4]; //!< this represent the 4 padding value Left top right buttom (like css) float this.value[4]; //!< this represent the 4 padding value Left top right buttom (like css)
public: public:
Padding(); Padding();
Padding(float _xl, float _yt=0.0f, float _xr=0.0f, float _yb=0.0f); Padding(float _xl, float _yt=0.0f, float _xr=0.0f, float _yb=0.0f);
void setValue(float _xl, float _yt=0.0f, float _xr=0.0f, float _yb=0.0f); void setValue(float _xl, float _yt=0.0f, float _xr=0.0f, float _yb=0.0f);
float x() const; float x() ;
float y() const; float y() ;
float xLeft() const; float xLeft() ;
void setXLeft(float _val); void setXLeft(float _val);
float xRight() const; float xRight() ;
void setXRight(float _val); void setXRight(float _val);
float yTop() const; float yTop() ;
void setYTop(float _val); void setYTop(float _val);
float yButtom() const; float yButtom() ;
void setYButtom(float _val); void setYButtom(float _val);
/** /**
* @brief Add a vector to this one * @brief Add a vector to this one
* @param _v The vector to add to this one * @param _v The vector to add to this one
*/ */
Padding& operator+=(const Padding& _v); Padding operator+=( Padding _v);
//! @previous //! @previous
Padding operator+(const Padding& _v); Padding operator+( Padding _v);
}; };
etk::Stream& operator <<(etk::Stream& _os, const ewol::Padding& _obj); etk::Stream operator +(etk::Stream _os, ewol::Padding _obj);
}; };

View File

@ -0,0 +1,20 @@
package org.atriasoft.ewol.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Meta-annotation (annotations used on other annotations)
* used for marking all annotations that are
* part of Exml package. Can be used for recognizing all
* Exml annotations generically, and in future also for
* passing other generic annotation configuration.
*/
@Target({ ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface EwolAnnotation {
// for now, a pure tag annotation, no parameters
}

View File

@ -0,0 +1,13 @@
package org.atriasoft.ewol.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ ElementType.FIELD, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@EwolAnnotation
public @interface EwolDescription {
String[] value();
}

View File

@ -0,0 +1,6 @@
package org.atriasoft.ewol.annotation;
public @interface EwolSignal {
String[] name();
}

View File

@ -10,32 +10,32 @@
ETK_DECLARE_TYPE(ewol::compositing::Area); ETK_DECLARE_TYPE(ewol::compositing::Area);
// VBO table property: // VBO table property:
const int32_t ewol::compositing::Area::m_vboIdCoord(0); int ewol::compositing::Area::this.vboIdCoord(0);
const int32_t ewol::compositing::Area::m_vboIdCoordText(1); int ewol::compositing::Area::this.vboIdCoordText(1);
const int32_t ewol::compositing::Area::m_vboIdColor(2); int ewol::compositing::Area::this.vboIdColor(2);
#define NB_VBO (3) #define NB_VBO (3)
ewol::compositing::Area::Area(const Vector2i& _size) : ewol::compositing::Area::Area( Vector2i _size) :
m_position(0.0, 0.0, 0.0), this.position(0.0, 0.0, 0.0),
m_color(etk::color::white), this.color(etk::color::white),
m_GLprogram(null), this.GLprogram(null),
m_GLPosition(-1), this.GLPosition(-1),
m_GLMatrix(-1), this.GLMatrix(-1),
m_GLColor(-1), this.GLColor(-1),
m_GLtexture(-1), this.GLtexture(-1),
m_GLtexID(-1), this.GLtexID(-1),
m_resource(null) { this.resource(null) {
m_resource = ewol::resource::Texture::create(); this.resource = ewol::resource::Texture::create();
m_resource->setImageSize(_size); this.resource.setImageSize(_size);
m_resource->flush(); this.resource.flush();
// Create the VBO: // Create the VBO:
m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); this.VBO = gale::resource::VirtualBufferObject::create(NB_VBO);
if (m_VBO == null) { if (this.VBO == null) {
Log.error("can not instanciate VBO ..."); Log.error("can not instanciate VBO ...");
return; return;
} }
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
m_VBO->setName("[VBO] of ewol::compositing::Area"); this.VBO.setName("[VBO] of ewol::compositing::Area");
loadProgram(); loadProgram();
} }
@ -45,98 +45,98 @@ ewol::compositing::Area::~Area() {
void ewol::compositing::Area::loadProgram() { void ewol::compositing::Area::loadProgram() {
// get the shader resource : // get the shader resource :
m_GLPosition = 0; this.GLPosition = 0;
m_GLprogram = gale::resource::Program::create(etk::String("DATA:///textured3D.prog?lib=ewol")); this.GLprogram = gale::resource::Program::create(String("DATA:///textured3D.prog?lib=ewol"));
if (m_GLprogram != null) { if (this.GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); this.GLPosition = this.GLprogram.getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color"); this.GLColor = this.GLprogram.getAttribute("EW_color");
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); this.GLtexture = this.GLprogram.getAttribute("EW_texture2d");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation");
m_GLtexID = m_GLprogram->getUniform("EW_texID"); this.GLtexID = this.GLprogram.getUniform("EW_texID");
} }
} }
void ewol::compositing::Area::draw(bool _disableDepthTest) { void ewol::compositing::Area::draw(boolean _disableDepthTest) {
if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
//EWOL_WARNING("Nothink to draw..."); //Log.warning("Nothink to draw...");
return; return;
} }
if (m_resource == null) { if (this.resource == null) {
// this is a normale case ... the user can choice to have no image ... // this is a normale case ... the user can choice to have no image ...
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply;
m_GLprogram->use(); this.GLprogram.use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// TextureID // TextureID
m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.resource.getRendererId());
// position: // position:
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// Texture: // Texture:
m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdColor); this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdColor);
// color: // color:
m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdCoordText); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdCoordText);
// Request the draw od the elements : // Request the draw od the elements :
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
m_GLprogram->unUse(); this.GLprogram.unUse();
} }
void ewol::compositing::Area::clear() { void ewol::compositing::Area::clear() {
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset all VBOs: // reset all VBOs:
m_VBO->clear(); this.VBO.clear();
// reset temporal variables : // reset temporal variables :
m_position = Vector3f(0.0, 0.0, 0.0); this.position = Vector3f(0.0, 0.0, 0.0);
} }
void ewol::compositing::Area::print(const Vector2i& _size) { void ewol::compositing::Area::print( Vector2i _size) {
Vector3f point(0,0,0); Vector3f point(0,0,0);
Vector2f tex(0,1); Vector2f tex(0,1);
point.setX(m_position.x()); point.setX(this.position.x());
point.setY(m_position.y()); point.setY(this.position.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoordText, tex); this.VBO.pushOnBuffer(this.vboIdCoordText, tex);
tex.setValue(1,1); tex.setValue(1,1);
point.setX(m_position.x() + _size.x()); point.setX(this.position.x() + _size.x());
point.setY(m_position.y()); point.setY(this.position.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoordText, tex); this.VBO.pushOnBuffer(this.vboIdCoordText, tex);
tex.setValue(1,0); tex.setValue(1,0);
point.setX(m_position.x() + _size.x()); point.setX(this.position.x() + _size.x());
point.setY(m_position.y() + _size.y()); point.setY(this.position.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoordText, tex); this.VBO.pushOnBuffer(this.vboIdCoordText, tex);
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoordText, tex); this.VBO.pushOnBuffer(this.vboIdCoordText, tex);
tex.setValue(0,0); tex.setValue(0,0);
point.setX(m_position.x()); point.setX(this.position.x());
point.setY(m_position.y() + _size.y()); point.setY(this.position.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoordText, tex); this.VBO.pushOnBuffer(this.vboIdCoordText, tex);
tex.setValue(0,1); tex.setValue(0,1);
point.setX(m_position.x()); point.setX(this.position.x());
point.setY(m_position.y()); point.setY(this.position.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoordText, tex); this.VBO.pushOnBuffer(this.vboIdCoordText, tex);
m_VBO->flush(); this.VBO.flush();
} }

View File

@ -17,22 +17,22 @@ namespace ewol {
namespace compositing { namespace compositing {
class Area : public ewol::Compositing { class Area : public ewol::Compositing {
private: private:
Vector3f m_position; //!< The current position to draw Vector3f this.position; //!< The current position to draw
etk::Color<float,4> m_color; //!< The text foreground color etk::Color<float,4> this.color; //!< The text foreground color
private: private:
ememory::SharedPtr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program ememory::Ptr<gale::resource::Program> this.GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int this.GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int this.GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLColor; //!< openGL id on the element (color buffer) int this.GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position) int this.GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID) int this.GLtexID; //!< openGL id on the element (texture ID)
private: private:
ememory::SharedPtr<ewol::resource::Texture> m_resource; //!< texture resources ememory::Ptr<ewol::resource::Texture> this.resource; //!< texture resources
protected: protected:
static const int32_t m_vboIdCoord; static int this.vboIdCoord;
static const int32_t m_vboIdCoordText; static int this.vboIdCoordText;
static const int32_t m_vboIdColor; static int this.vboIdColor;
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_VBO; ememory::Ptr<gale::resource::VirtualBufferObject> this.VBO;
private: private:
/** /**
* @brief load the openGL program and get all the ID needed * @brief load the openGL program and get all the ID needed
@ -40,19 +40,19 @@ namespace ewol {
void loadProgram(); void loadProgram();
public: public:
/** /**
* @brief generic constructor * @brief generic ructor
* @param[in] _size Basic size of the area. * @param[in] _size Basic size of the area.
*/ */
Area(const Vector2i& _size); Area( Vector2i _size);
/** /**
* @brief generic destructor * @brief generic destructor
*/ */
virtual ~Area(); ~Area();
public: public:
/** /**
* @brief draw All the refistered text in the current element on openGL * @brief draw All the refistered text in the current element on openGL
*/ */
void draw(bool _disableDepthTest=true); void draw(boolean _disableDepthTest=true);
/** /**
* @brief clear alll the registered element in the current element * @brief clear alll the registered element in the current element
*/ */
@ -61,40 +61,40 @@ namespace ewol {
* @brief get the current display position (sometime needed in the gui control) * @brief get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
*/ */
const Vector3f& getPos() { Vector3f getPos() {
return m_position; return this.position;
}; };
/** /**
* @brief set position for the next text writen * @brief set position for the next text writen
* @param[in] _pos Position of the text (in 3D) * @param[in] _pos Position of the text (in 3D)
*/ */
void setPos(const Vector3f& _pos) { void setPos( Vector3f _pos) {
m_position = _pos; this.position = _pos;
}; };
inline void setPos(const Vector2f& _pos) { void setPos( Vector2f _pos) {
setPos(Vector3f(_pos.x(),_pos.y(),0)); setPos(Vector3f(_pos.x(),_pos.y(),0));
}; };
/** /**
* @brief set relative position for the next text writen * @brief set relative position for the next text writen
* @param[in] _pos ofset apply of the text (in 3D) * @param[in] _pos ofset apply of the text (in 3D)
*/ */
void setRelPos(const Vector3f& _pos) { void setRelPos( Vector3f _pos) {
m_position += _pos; this.position += _pos;
}; };
inline void setRelPos(const Vector2f& _pos) { void setRelPos( Vector2f _pos) {
setRelPos(Vector3f(_pos.x(),_pos.y(),0)); setRelPos(Vector3f(_pos.x(),_pos.y(),0));
}; };
/** /**
* @brief add a compleate of the image to display with the requested size * @brief add a compleate of the image to display with the requested size
* @param[in] _size size of the output image * @param[in] _size size of the output image
*/ */
void print(const Vector2i& _size); void print( Vector2i _size);
egami::Image& get() { egami::Image get() {
return m_resource->get(); return this.resource.get();
}; };
void flush() { void flush() {
m_resource->flush(); this.resource.flush();
}; };
}; };
}; };

View File

@ -18,30 +18,30 @@ ewol::Compositing::Compositing() {
void ewol::Compositing::resetMatrix() { void ewol::Compositing::resetMatrix() {
m_matrixApply.identity(); this.matrixApply.identity();
} }
void ewol::Compositing::translate(const Vector3f& _vect) { void ewol::Compositing::translate( Vector3f _vect) {
m_matrixApply *= etk::matTranslate(_vect); this.matrixApply *= etk::matTranslate(_vect);
} }
void ewol::Compositing::rotate(const Vector3f& _vect, float _angle) { void ewol::Compositing::rotate( Vector3f _vect, float _angle) {
m_matrixApply *= etk::matRotate(_vect, _angle); this.matrixApply *= etk::matRotate(_vect, _angle);
} }
void ewol::Compositing::scale(const Vector3f& _vect) { void ewol::Compositing::scale( Vector3f _vect) {
m_matrixApply *= etk::matScale(_vect); this.matrixApply *= etk::matScale(_vect);
} }
void ewol::Compositing::clear() { void ewol::Compositing::clear() {
m_matrixApply.identity(); this.matrixApply.identity();
} }
void ewol::Compositing::setMatrix(const mat4& _mat) { void ewol::Compositing::setMatrix( mat4 _mat) {
m_matrixApply = _mat; this.matrixApply = _mat;
} }

View File

@ -12,47 +12,47 @@
namespace ewol { namespace ewol {
class Compositing { class Compositing {
protected: protected:
mat4 m_matrixApply; mat4 this.matrixApply;
public: public:
/** /**
* @brief generic constructor * @brief generic ructor
*/ */
Compositing(); Compositing();
/** /**
* @brief Generic destructor * @brief Generic destructor
*/ */
virtual ~Compositing() = default; ~Compositing() = default;
/** /**
* @brief Virtal pure function that request the draw of all openGl elements * @brief Virtal pure function that request the draw of all openGl elements
*/ */
virtual void draw(bool _disableDepthTest = true) = 0; void draw(boolean _disableDepthTest = true) = 0;
/** /**
* @brief clear alll tre registered element in the current element * @brief clear alll tre registered element in the current element
*/ */
virtual void clear(); void clear();
/** /**
* @brief reset to the eye matrix the openGL mouving system * @brief reset to the eye matrix the openGL mouving system
*/ */
virtual void resetMatrix(); void resetMatrix();
/** /**
* @brief translate the current display of this element * @brief translate the current display of this element
* @param[in] _vect The translation vector to apply at the transformation matrix * @param[in] _vect The translation vector to apply at the transformation matrix
*/ */
virtual void translate(const Vector3f& _vect); void translate( Vector3f _vect);
/** /**
* @brief rotate the curent display of this element * @brief rotate the curent display of this element
* @param[in] _vect The rotation vector to apply at the transformation matrix * @param[in] _vect The rotation vector to apply at the transformation matrix
*/ */
virtual void rotate(const Vector3f& _vect, float _angle); void rotate( Vector3f _vect, float _angle);
/** /**
* @brief scale the current diaplsy of this element * @brief scale the current diaplsy of this element
* @param[in] _vect The scaling vector to apply at the transformation matrix * @param[in] _vect The scaling vector to apply at the transformation matrix
*/ */
virtual void scale(const Vector3f& _vect); void scale( Vector3f _vect);
/** /**
* @brief set the transformation matrix * @brief set the transformation matrix
* @param[in] _mat The new matrix. * @param[in] _mat The new matrix.
*/ */
virtual void setMatrix(const mat4& _mat); void setMatrix( mat4 _mat);
}; };
}; };

View File

@ -11,42 +11,42 @@
ETK_DECLARE_TYPE(ewol::compositing::Drawing); ETK_DECLARE_TYPE(ewol::compositing::Drawing);
// VBO table property: // VBO table property:
const int32_t ewol::compositing::Drawing::m_vboIdCoord(0); int ewol::compositing::Drawing::this.vboIdCoord(0);
const int32_t ewol::compositing::Drawing::m_vboIdColor(1); int ewol::compositing::Drawing::this.vboIdColor(1);
#define NB_VBO (2) #define NB_VBO (2)
#if 0 #if 0
static void generatePolyGone(List<Vector2f > & input, List<Vector2f > & output ) static void generatePolyGone(List<Vector2f > input, List<Vector2f > output )
{ {
if (input.size()<3) { if (input.size()<3) {
return; return;
} }
// TODO : Regenerate a linear poligone generation // TODO : Regenerate a linear poligone generation
for (int32_t iii=1; iii<input.size()-1; iii++) { for (int iii=1; iii<input.size()-1; iii++) {
output.pushBack(input[0]); output.pushBack(input[0]);
output.pushBack(input[iii]); output.pushBack(input[iii]);
output.pushBack(input[iii+1]); output.pushBack(input[iii+1]);
} }
//Log.debug("generate Plygone : " << input.size() << " == > " << output.size() ); //Log.debug("generate Plygone : " + input.size() + " == > " + output.size() );
} }
static void SutherlandHodgman(List<Vector2f > & input, List<Vector2f > & output, float sx, float sy, float ex, float ey) static void SutherlandHodgman(List<Vector2f > input, List<Vector2f > output, float sx, float sy, float ex, float ey)
{ {
// with Sutherland-Hodgman-Algorithm // with Sutherland-Hodgman-Algorithm
if (input.size() <0) { if (input.size() <0) {
return; return;
} }
//int32_t sizeInit=input.size(); //int sizeInit=input.size();
// last element : // last element :
Vector2f destPoint; Vector2f destPoint;
Vector2f lastElement = input[input.size()-1]; Vector2f lastElement = input[input.size()-1];
bool inside = true; boolean inside = true;
if (lastElement.x < sx) { if (lastElement.x < sx) {
inside = false; inside = false;
} }
//Log.debug("generate an crop : "); //Log.debug("generate an crop : ");
for(int32_t iii=0; iii<input.size(); iii++) { for(int iii=0; iii<input.size(); iii++) {
if(input[iii].x < sx) { if(input[iii].x < sx) {
if(true == inside) { if(true == inside) {
//Log.debug("element IN == > OUT "); //Log.debug("element IN == > OUT ");
@ -83,7 +83,7 @@ static void SutherlandHodgman(List<Vector2f > & input, List<Vector2f > & output,
lastElement.y = input[iii].y; lastElement.y = input[iii].y;
} }
//Log.debug("generate an crop on element : " << sizeInit << " == > " << output.size() << "intermediate (1)"); //Log.debug("generate an crop on element : " + sizeInit + " == > " + output.size() + "intermediate (1)");
input = output; input = output;
output.clear(); output.clear();
lastElement = input[input.size()-1]; lastElement = input[input.size()-1];
@ -91,7 +91,7 @@ static void SutherlandHodgman(List<Vector2f > & input, List<Vector2f > & output,
if (lastElement.y < sy) { if (lastElement.y < sy) {
inside = false; inside = false;
} }
for(int32_t iii=0; iii<input.size(); iii++) { for(int iii=0; iii<input.size(); iii++) {
if(input[iii].y < sy) { if(input[iii].y < sy) {
if(true == inside) { if(true == inside) {
//Log.debug("element IN == > OUT "); //Log.debug("element IN == > OUT ");
@ -136,7 +136,7 @@ static void SutherlandHodgman(List<Vector2f > & input, List<Vector2f > & output,
inside = false; inside = false;
} }
//Log.debug("generate an crop : "); //Log.debug("generate an crop : ");
for(int32_t iii=0; iii<input.size(); iii++) { for(int iii=0; iii<input.size(); iii++) {
if(input[iii].x > ex) { if(input[iii].x > ex) {
if(true == inside) { if(true == inside) {
//Log.debug("element IN == > OUT "); //Log.debug("element IN == > OUT ");
@ -180,7 +180,7 @@ static void SutherlandHodgman(List<Vector2f > & input, List<Vector2f > & output,
if (lastElement.y > ey) { if (lastElement.y > ey) {
inside = false; inside = false;
} }
for(int32_t iii=0; iii<input.size(); iii++) { for(int iii=0; iii<input.size(); iii++) {
if(input[iii].y > ey) { if(input[iii].y > ey) {
if(true == inside) { if(true == inside) {
//Log.debug("element IN == > OUT "); //Log.debug("element IN == > OUT ");
@ -218,37 +218,37 @@ static void SutherlandHodgman(List<Vector2f > & input, List<Vector2f > & output,
} }
//Log.debug("generate an crop on element : " << sizeInit << " == > " << output.size() ); //Log.debug("generate an crop on element : " + sizeInit + " == > " + output.size() );
} }
#endif #endif
ewol::compositing::Drawing::Drawing() : ewol::compositing::Drawing::Drawing() :
m_position(0.0, 0.0, 0.0), this.position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), this.clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), this.clippingPosStop(0.0, 0.0, 0.0),
m_clippingEnable(false), this.clippingEnable(false),
m_color(etk::color::black), this.color(etk::color::black),
m_colorBg(etk::color::none), this.colorBg(etk::color::none),
m_GLprogram(null), this.GLprogram(null),
m_GLPosition(-1), this.GLPosition(-1),
m_GLMatrix(-1), this.GLMatrix(-1),
m_GLMatrixPosition(-1), this.GLMatrixPosition(-1),
m_GLColor(-1), this.GLColor(-1),
m_thickness(0.0), this.thickness(0.0),
m_triElement(0) { this.triElement(0) {
loadProgram(); loadProgram();
for (int32_t iii=0; iii<3; iii++) { for (int iii=0; iii<3; iii++) {
m_triangle[iii] = m_position; this.triangle[iii] = this.position;
m_tricolor[iii] = m_color; this.tricolor[iii] = this.color;
} }
// Create the VBO: // Create the VBO:
m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); this.VBO = gale::resource::VirtualBufferObject::create(NB_VBO);
if (m_VBO == null) { if (this.VBO == null) {
Log.error("can not instanciate VBO ..."); Log.error("can not instanciate VBO ...");
return; return;
} }
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
m_VBO->setName("[VBO] of ewol::compositing::Area"); this.VBO.setName("[VBO] of ewol::compositing::Area");
} }
ewol::compositing::Drawing::~Drawing() { ewol::compositing::Drawing::~Drawing() {
@ -256,181 +256,181 @@ ewol::compositing::Drawing::~Drawing() {
} }
void ewol::compositing::Drawing::generateTriangle() { void ewol::compositing::Drawing::generateTriangle() {
m_triElement = 0; this.triElement = 0;
m_VBO->pushOnBuffer(m_vboIdCoord, m_triangle[0]); this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[0]);
m_VBO->pushOnBuffer(m_vboIdColor, m_tricolor[0]); this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[0]);
m_VBO->pushOnBuffer(m_vboIdCoord, m_triangle[1]); this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[1]);
m_VBO->pushOnBuffer(m_vboIdColor, m_tricolor[1]); this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[1]);
m_VBO->pushOnBuffer(m_vboIdCoord, m_triangle[2]); this.VBO.pushOnBuffer(this.vboIdCoord, this.triangle[2]);
m_VBO->pushOnBuffer(m_vboIdColor, m_tricolor[2]); this.VBO.pushOnBuffer(this.vboIdColor, this.tricolor[2]);
} }
void ewol::compositing::Drawing::internalSetColor(const etk::Color<>& _color) { void ewol::compositing::Drawing::internalSetColor( etk::Color<> _color) {
if (m_triElement < 1) { if (this.triElement < 1) {
m_tricolor[0] = _color; this.tricolor[0] = _color;
} }
if (m_triElement < 2) { if (this.triElement < 2) {
m_tricolor[1] = _color; this.tricolor[1] = _color;
} }
if (m_triElement < 3) { if (this.triElement < 3) {
m_tricolor[2] = _color; this.tricolor[2] = _color;
} }
} }
void ewol::compositing::Drawing::setPoint(const Vector3f& _point) { void ewol::compositing::Drawing::setPoint( Vector3f _point) {
m_triangle[m_triElement] = _point; this.triangle[this.triElement] = _point;
m_triElement++; this.triElement++;
if (m_triElement >= 3) { if (this.triElement >= 3) {
generateTriangle(); generateTriangle();
} }
m_VBO->flush(); this.VBO.flush();
} }
void ewol::compositing::Drawing::resetCount() { void ewol::compositing::Drawing::resetCount() {
m_triElement = 0; this.triElement = 0;
} }
void ewol::compositing::Drawing::unLoadProgram() { void ewol::compositing::Drawing::unLoadProgram() {
m_GLprogram.reset(); this.GLprogram.reset();
} }
void ewol::compositing::Drawing::loadProgram() { void ewol::compositing::Drawing::loadProgram() {
// remove previous loading ... in case // remove previous loading ... in case
unLoadProgram(); unLoadProgram();
// oad the new ... // oad the new ...
m_GLprogram = gale::resource::Program::create("DATA:///color3.prog?lib=ewol"); this.GLprogram = gale::resource::Program::create("DATA:///color3.prog?lib=ewol");
// get the shader resource : // get the shader resource :
if (m_GLprogram != null) { if (this.GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); this.GLPosition = this.GLprogram.getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color"); this.GLColor = this.GLprogram.getAttribute("EW_color");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation");
m_GLMatrixPosition = m_GLprogram->getUniform("EW_MatrixPosition"); this.GLMatrixPosition = this.GLprogram.getUniform("EW_MatrixPosition");
} }
} }
void ewol::compositing::Drawing::draw(bool _disableDepthTest) { void ewol::compositing::Drawing::draw(boolean _disableDepthTest) {
if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
// TODO : set it back ... // TODO : set it back ...
//EWOL_WARNING("Nothink to draw..."); //Log.warning("Nothink to draw...");
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply;
m_GLprogram->use(); this.GLprogram.use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
mat4 tmpMatrix2; mat4 tmpMatrix2;
m_GLprogram->uniformMatrix(m_GLMatrixPosition, tmpMatrix2); this.GLprogram.uniformMatrix(this.GLMatrixPosition, tmpMatrix2);
// position: // position:
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// color: // color:
m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor);
// Request the draw od the elements : // Request the draw od the elements :
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
m_GLprogram->unUse(); this.GLprogram.unUse();
} }
void ewol::compositing::Drawing::clear() { void ewol::compositing::Drawing::clear() {
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset Buffer : // reset Buffer :
m_VBO->clear(); this.VBO.clear();
// reset temporal variables : // reset temporal variables :
m_position = Vector3f(0.0, 0.0, 0.0); this.position = Vector3f(0.0, 0.0, 0.0);
m_clippingPosStart = Vector3f(0.0, 0.0, 0.0); this.clippingPosStart = Vector3f(0.0, 0.0, 0.0);
m_clippingPosStop = Vector3f(0.0, 0.0, 0.0); this.clippingPosStop = Vector3f(0.0, 0.0, 0.0);
m_clippingEnable = false; this.clippingEnable = false;
m_color = etk::color::black; this.color = etk::color::black;
m_colorBg = etk::color::none; this.colorBg = etk::color::none;
for (int32_t iii=0; iii<3; iii++) { for (int iii=0; iii<3; iii++) {
m_triangle[iii] = m_position; this.triangle[iii] = this.position;
m_tricolor[iii] = m_color; this.tricolor[iii] = this.color;
} }
} }
void ewol::compositing::Drawing::setClipping(const Vector3f& _pos, const Vector3f& _posEnd) { void ewol::compositing::Drawing::setClipping( Vector3f _pos, Vector3f _posEnd) {
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); this.clippingPosStart.setX(_pos.x());
m_clippingPosStop.setX(_posEnd.x()); this.clippingPosStop.setX(_posEnd.x());
} else { } else {
m_clippingPosStart.setX(_posEnd.x()); this.clippingPosStart.setX(_posEnd.x());
m_clippingPosStop.setX(_pos.x()); this.clippingPosStop.setX(_pos.x());
} }
if (_pos.y() <= _posEnd.y()) { if (_pos.y() <= _posEnd.y()) {
m_clippingPosStart.setY(_pos.y()); this.clippingPosStart.setY(_pos.y());
m_clippingPosStop.setY(_posEnd.y()); this.clippingPosStop.setY(_posEnd.y());
} else { } else {
m_clippingPosStart.setY(_posEnd.y()); this.clippingPosStart.setY(_posEnd.y());
m_clippingPosStop.setY(_pos.y()); this.clippingPosStop.setY(_pos.y());
} }
if (_pos.z() <= _posEnd.z()) { if (_pos.z() <= _posEnd.z()) {
m_clippingPosStart.setZ(_pos.z()); this.clippingPosStart.setZ(_pos.z());
m_clippingPosStop.setZ(_posEnd.z()); this.clippingPosStop.setZ(_posEnd.z());
} else { } else {
m_clippingPosStart.setZ(_posEnd.z()); this.clippingPosStart.setZ(_posEnd.z());
m_clippingPosStop.setZ(_pos.z()); this.clippingPosStop.setZ(_pos.z());
} }
m_clippingEnable = true; this.clippingEnable = true;
} }
void ewol::compositing::Drawing::setThickness(float _thickness) { void ewol::compositing::Drawing::setThickness(float _thickness) {
m_thickness = _thickness; this.thickness = _thickness;
// thickness must be positive // thickness must be positive
if (m_thickness < 0) { if (this.thickness < 0) {
m_thickness *= -1; this.thickness *= -1;
} }
} }
void ewol::compositing::Drawing::addVertex() { void ewol::compositing::Drawing::addVertex() {
internalSetColor(m_color); internalSetColor(this.color);
setPoint(m_position); setPoint(this.position);
} }
void ewol::compositing::Drawing::lineTo(const Vector3f& _dest) { void ewol::compositing::Drawing::lineTo( Vector3f _dest) {
resetCount(); resetCount();
internalSetColor(m_color); internalSetColor(this.color);
//Log.verbose("DrawLine : " << m_position << " to " << _dest); //Log.verbose("DrawLine : " + this.position + " to " + _dest);
if (m_position.x() == _dest.x() && m_position.y() == _dest.y() && m_position.z() == _dest.z()) { if (this.position.x() == _dest.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.position.y() == _dest.y() LOMLOMLOMLOMLOM this.position.z() == _dest.z()) {
//EWOL_WARNING("Try to draw a line width 0"); //Log.warning("Try to draw a line width 0");
return; return;
} }
//teta = tan-1(oposer/adjacent) //teta = tan-1(oposer/adjacent)
float teta = 0; float teta = 0;
if (m_position.x() <= _dest.x()) { if (this.position.x() <= _dest.x()) {
teta = atan((_dest.y()-m_position.y())/(_dest.x()-m_position.x())); teta = atan((_dest.y()-this.position.y())/(_dest.x()-this.position.x()));
} else { } else {
teta = M_PI + atan((_dest.y()-m_position.y())/(_dest.x()-m_position.x())); teta = M_PI + atan((_dest.y()-this.position.y())/(_dest.x()-this.position.x()));
} }
if (teta < 0) { if (teta < 0) {
teta += 2*M_PI; teta += 2*M_PI;
} else if (teta > 2*M_PI) { } else if (teta > 2*M_PI) {
teta -= 2*M_PI; teta -= 2*M_PI;
} }
//Log.debug("teta = " << (teta*180/(M_PI)) << " deg." ); //Log.debug("teta = " + (teta*180/(M_PI)) + " deg." );
float offsety = sin(teta-M_PI/2) * (m_thickness/2); float offsety = sin(teta-M_PI/2) * (this.thickness/2);
float offsetx = cos(teta-M_PI/2) * (m_thickness/2); float offsetx = cos(teta-M_PI/2) * (this.thickness/2);
setPoint(Vector3f(m_position.x() - offsetx, m_position.y() - offsety, m_position.z()) ); setPoint(Vector3f(this.position.x() - offsetx, this.position.y() - offsety, this.position.z()) );
setPoint(Vector3f(m_position.x() + offsetx, m_position.y() + offsety, m_position.z()) ); setPoint(Vector3f(this.position.x() + offsetx, this.position.y() + offsety, this.position.z()) );
setPoint(Vector3f(_dest.x() + offsetx, _dest.y() + offsety, m_position.z()) ); setPoint(Vector3f(_dest.x() + offsetx, _dest.y() + offsety, this.position.z()) );
setPoint(Vector3f(_dest.x() + offsetx, _dest.y() + offsety, _dest.z()) ); setPoint(Vector3f(_dest.x() + offsetx, _dest.y() + offsety, _dest.z()) );
setPoint(Vector3f(_dest.x() - offsetx, _dest.y() - offsety, _dest.z()) ); setPoint(Vector3f(_dest.x() - offsetx, _dest.y() - offsety, _dest.z()) );
setPoint(Vector3f(m_position.x() - offsetx, m_position.y() - offsety, _dest.z()) ); setPoint(Vector3f(this.position.x() - offsetx, this.position.y() - offsety, _dest.z()) );
// update the system position : // update the system position :
m_position = _dest; this.position = _dest;
} }
void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) { void ewol::compositing::Drawing::rectangle( Vector3f _dest) {
resetCount(); resetCount();
internalSetColor(m_color); internalSetColor(this.color);
/* Bitmap position /* Bitmap position
* xA xB * xA xB
* yC *------* * yC *------*
@ -438,7 +438,7 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) {
* | | * | |
* yD *------* * yD *------*
*/ */
float dxA = m_position.x(); float dxA = this.position.x();
float dxB = _dest.x(); float dxB = _dest.x();
if (dxA > dxB) { if (dxA > dxB) {
// inverse order : // inverse order :
@ -446,7 +446,7 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) {
dxA = dxB; dxA = dxB;
dxB = tmp; dxB = tmp;
} }
float dyC = m_position.y(); float dyC = this.position.y();
float dyD = _dest.y(); float dyD = _dest.y();
if (dyC > dyD) { if (dyC > dyD) {
// inverse order : // inverse order :
@ -454,18 +454,18 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) {
dyC = dyD; dyC = dyD;
dyD = tmp; dyD = tmp;
} }
if (true == m_clippingEnable) { if (true == this.clippingEnable) {
if (dxA < m_clippingPosStart.x()) { if (dxA < this.clippingPosStart.x()) {
dxA = m_clippingPosStart.x(); dxA = this.clippingPosStart.x();
} }
if (dxB > m_clippingPosStop.x()) { if (dxB > this.clippingPosStop.x()) {
dxB = m_clippingPosStop.x(); dxB = this.clippingPosStop.x();
} }
if (dyC < m_clippingPosStart.y()) { if (dyC < this.clippingPosStart.y()) {
dyC = m_clippingPosStart.y(); dyC = this.clippingPosStart.y();
} }
if (dyD > m_clippingPosStop.y()) { if (dyD > this.clippingPosStop.y()) {
dyD = m_clippingPosStop.y(); dyD = this.clippingPosStop.y();
} }
} }
if( dyC >= dyD if( dyC >= dyD
@ -481,7 +481,7 @@ void ewol::compositing::Drawing::rectangle(const Vector3f& _dest) {
setPoint(Vector3f(dxA, dyD, 0) ); setPoint(Vector3f(dxA, dyD, 0) );
} }
void ewol::compositing::Drawing::cube(const Vector3f& _dest) { void ewol::compositing::Drawing::cube( Vector3f _dest) {
} }
@ -494,65 +494,65 @@ void ewol::compositing::Drawing::circle(float _radius, float _angleStart, float
_angleStop = _angleStop-_angleStart; _angleStop = _angleStop-_angleStart;
int32_t nbOcurence = _radius; int nbOcurence = _radius;
if (nbOcurence < 10) if (nbOcurence < 10)
{ {
nbOcurence = 10; nbOcurence = 10;
} }
// display background : // display background :
if (m_colorBg.a()!=0) { if (this.colorBg.a()!=0) {
internalSetColor(m_colorBg); internalSetColor(this.colorBg);
for (int32_t iii=0; iii<nbOcurence; iii++) { for (int iii=0; iii<nbOcurence; iii++) {
setPoint(Vector3f(m_position.x(), setPoint(Vector3f(this.position.x(),
m_position.y(), this.position.y(),
0) ); 0) );
float angleOne = _angleStart + (_angleStop* iii / nbOcurence) ; float angleOne = _angleStart + (_angleStop* iii / nbOcurence) ;
float offsety = sin(angleOne) * _radius; float offsety = sin(angleOne) * _radius;
float offsetx = cos(angleOne) * _radius; float offsetx = cos(angleOne) * _radius;
setPoint(Vector3f(m_position.x() + offsetx, setPoint(Vector3f(this.position.x() + offsetx,
m_position.y() + offsety, this.position.y() + offsety,
0) ); 0) );
float angleTwo = _angleStart + (_angleStop* (iii+1) / nbOcurence) ; float angleTwo = _angleStart + (_angleStop* (iii+1) / nbOcurence) ;
offsety = sin(angleTwo) * _radius; offsety = sin(angleTwo) * _radius;
offsetx = cos(angleTwo) * _radius; offsetx = cos(angleTwo) * _radius;
setPoint(Vector3f(m_position.x() + offsetx, setPoint(Vector3f(this.position.x() + offsetx,
m_position.y() + offsety, this.position.y() + offsety,
0) ); 0) );
} }
} }
// show if we have a border : // show if we have a border :
if( m_thickness == 0 if( this.thickness == 0
|| m_color.a() == 0) { || this.color.a() == 0) {
return; return;
} }
internalSetColor(m_color); internalSetColor(this.color);
for (int32_t iii=0; iii<nbOcurence; iii++) { for (int iii=0; iii<nbOcurence; iii++) {
float angleOne = _angleStart + (_angleStop* iii / nbOcurence) ; float angleOne = _angleStart + (_angleStop* iii / nbOcurence) ;
float offsetExty = sin(angleOne) * (_radius+m_thickness/2); float offsetExty = sin(angleOne) * (_radius+this.thickness/2);
float offsetExtx = cos(angleOne) * (_radius+m_thickness/2); float offsetExtx = cos(angleOne) * (_radius+this.thickness/2);
float offsetInty = sin(angleOne) * (_radius-m_thickness/2); float offsetInty = sin(angleOne) * (_radius-this.thickness/2);
float offsetIntx = cos(angleOne) * (_radius-m_thickness/2); float offsetIntx = cos(angleOne) * (_radius-this.thickness/2);
float angleTwo = _angleStart + (_angleStop* (iii+1) / nbOcurence ); float angleTwo = _angleStart + (_angleStop* (iii+1) / nbOcurence );
float offsetExt2y = sin(angleTwo) * (_radius+m_thickness/2); float offsetExt2y = sin(angleTwo) * (_radius+this.thickness/2);
float offsetExt2x = cos(angleTwo) * (_radius+m_thickness/2); float offsetExt2x = cos(angleTwo) * (_radius+this.thickness/2);
float offsetInt2y = sin(angleTwo) * (_radius-m_thickness/2); float offsetInt2y = sin(angleTwo) * (_radius-this.thickness/2);
float offsetInt2x = cos(angleTwo) * (_radius-m_thickness/2); float offsetInt2x = cos(angleTwo) * (_radius-this.thickness/2);
setPoint(Vector3f(m_position.x() + offsetIntx, m_position.y() + offsetInty, 0)); setPoint(Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
setPoint(Vector3f(m_position.x() + offsetExtx, m_position.y() + offsetExty, 0)); setPoint(Vector3f(this.position.x() + offsetExtx, this.position.y() + offsetExty, 0));
setPoint(Vector3f(m_position.x() + offsetExt2x, m_position.y() + offsetExt2y, 0)); setPoint(Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
setPoint(Vector3f(m_position.x() + offsetExt2x, m_position.y() + offsetExt2y, 0)); setPoint(Vector3f(this.position.x() + offsetExt2x, this.position.y() + offsetExt2y, 0));
setPoint(Vector3f(m_position.x() + offsetInt2x, m_position.y() + offsetInt2y, 0)); setPoint(Vector3f(this.position.x() + offsetInt2x, this.position.y() + offsetInt2y, 0));
setPoint(Vector3f(m_position.x() + offsetIntx, m_position.y() + offsetInty, 0)); setPoint(Vector3f(this.position.x() + offsetIntx, this.position.y() + offsetInty, 0));
} }
} }

View File

@ -16,32 +16,32 @@ namespace ewol {
namespace compositing { namespace compositing {
class Drawing : public ewol::Compositing { class Drawing : public ewol::Compositing {
private: private:
Vector3f m_position; //!< The current position to draw Vector3f this.position; //!< The current position to draw
Vector3f m_clippingPosStart; //!< Clipping start position Vector3f this.clippingPosStart; //!< Clipping start position
Vector3f m_clippingPosStop; //!< Clipping stop position Vector3f this.clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated boolean this.clippingEnable; //!< true if the clipping must be activated
private: private:
etk::Color<> m_color; //!< The text foreground color etk::Color<> this.color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color etk::Color<> this.colorBg; //!< The text background color
private: private:
ememory::SharedPtr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program ememory::Ptr<gale::resource::Program> this.GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int this.GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int this.GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLMatrixPosition; //!< position matrix int this.GLMatrixPosition; //!< position matrix
int32_t m_GLColor; //!< openGL id on the element (color buffer) int this.GLColor; //!< openGL id on the element (color buffer)
protected: protected:
static const int32_t m_vboIdCoord; static int this.vboIdCoord;
static const int32_t m_vboIdColor; static int this.vboIdColor;
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_VBO; ememory::Ptr<gale::resource::VirtualBufferObject> this.VBO;
public: public:
/** /**
* @brief Basic constructor * @brief Basic ructor
*/ */
Drawing(); Drawing();
/** /**
* @brief Basic destructor * @brief Basic destructor
*/ */
virtual ~Drawing(); ~Drawing();
private: private:
/** /**
* @brief load the openGL program and get all the ID needed * @brief load the openGL program and get all the ID needed
@ -51,10 +51,10 @@ namespace ewol {
* @brief Un-Load the openGL program and get all the ID needed * @brief Un-Load the openGL program and get all the ID needed
*/ */
void unLoadProgram(); void unLoadProgram();
float m_thickness; //!< when drawing line and other things float this.thickness; //!< when drawing line and other things
int32_t m_triElement; //!< special counter of the single dot generated int this.triElement; //!< special counter of the single dot generated
Vector3f m_triangle[3]; //!< Register every system with a combinaison of tiangle Vector3f this.triangle[3]; //!< Register every system with a combinaison of tiangle
etk::Color<float,4> m_tricolor[3]; //!< Register every the associated color foreground etk::Color<float,4> this.tricolor[3]; //!< Register every the associated color foreground
// internal API for the generation abstraction of triangles // internal API for the generation abstraction of triangles
/** /**
* @brief Lunch the generation of triangle * @brief Lunch the generation of triangle
@ -68,18 +68,18 @@ namespace ewol {
* @brief set the Color of the current triangle drawing * @brief set the Color of the current triangle drawing
* @param[in] _color Color to current dots generated * @param[in] _color Color to current dots generated
*/ */
void internalSetColor(const etk::Color<>& _color); void internalSetColor( etk::Color<> _color);
/** /**
* @brief internal add of the specific point * @brief internal add of the specific point
* @param[in] _point The requeste dpoint to add * @param[in] _point The requeste dpoint to add
*/ */
void setPoint(const Vector3f& point); void setPoint( Vector3f point);
public: public:
/** /**
* @brief draw All the refistered text in the current element on openGL * @brief draw All the refistered text in the current element on openGL
*/ */
void draw(bool _disableDepthTest=true); void draw(boolean _disableDepthTest=true);
/** /**
* @brief clear alll tre registered element in the current element * @brief clear alll tre registered element in the current element
*/ */
@ -88,66 +88,66 @@ namespace ewol {
* @brief get the current display position (sometime needed in the gui control) * @brief get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
*/ */
const Vector3f& getPos() { Vector3f getPos() {
return m_position; return this.position;
}; };
/** /**
* @brief set position for the next text writen * @brief set position for the next text writen
* @param[in] _pos Position of the text (in 3D) * @param[in] _pos Position of the text (in 3D)
*/ */
void setPos(const Vector3f& _pos) { void setPos( Vector3f _pos) {
m_position = _pos; this.position = _pos;
}; };
inline void setPos(const Vector2f& _pos) { void setPos( Vector2f _pos) {
setPos(Vector3f(_pos.x(), _pos.y(), 0)); setPos(Vector3f(_pos.x(), _pos.y(), 0));
}; };
/** /**
* @brief set relative position for the next text writen * @brief set relative position for the next text writen
* @param[in] _pos ofset apply of the text (in 3D) * @param[in] _pos ofset apply of the text (in 3D)
*/ */
void setRelPos(const Vector3f& _pos) { void setRelPos( Vector3f _pos) {
m_position += _pos; this.position += _pos;
}; };
inline void setRelPos(const Vector2f& _pos) { void setRelPos( Vector2f _pos) {
setRelPos(Vector3f(_pos.x(), _pos.y(), 0)); setRelPos(Vector3f(_pos.x(), _pos.y(), 0));
}; };
/** /**
* @brief set the Color of the current foreground font * @brief set the Color of the current foreground font
* @param[in] _color Color to set on foreground (for next print) * @param[in] _color Color to set on foreground (for next print)
*/ */
void setColor(const etk::Color<>& _color) { void setColor( etk::Color<> _color) {
m_color = _color; this.color = _color;
}; };
/** /**
* @brief Get the foreground color of the font. * @brief Get the foreground color of the font.
* @return Foreground color. * @return Foreground color.
*/ */
const etk::Color<>& getColor() { etk::Color<> getColor() {
return m_color; return this.color;
}; };
/** /**
* @brief set the background color of the font (for selected Text (not the global BG)) * @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _color Color to set on background (for next print) * @param[in] _color Color to set on background (for next print)
*/ */
void setColorBg(const etk::Color<>& _color) { void setColorBg( etk::Color<> _color) {
m_colorBg = _color; this.colorBg = _color;
}; };
/** /**
* @brief Get the background color of the font. * @brief Get the background color of the font.
* @return Background color. * @return Background color.
*/ */
const etk::Color<>& getColorBg() { etk::Color<> getColorBg() {
return m_colorBg; return this.colorBg;
}; };
/** /**
* @brief Request a clipping area for the text (next draw only) * @brief Request a clipping area for the text (next draw only)
* @param[in]_ pos Start position of the clipping * @param[in]_ pos Start position of the clipping
* @param[in] _width Width size of the clipping * @param[in] _width Width size of the clipping
*/ */
void setClippingWidth(const Vector3f& _pos, const Vector3f& _width) { void setClippingWidth( Vector3f _pos, Vector3f _width) {
setClipping(_pos, _pos+_width); setClipping(_pos, _pos+_width);
}; };
inline void setClippingWidth(const Vector2f& _pos, const Vector2f& _width) { void setClippingWidth( Vector2f _pos, Vector2f _width) {
setClippingWidth(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_width.x(),_width.y(), 2)); setClippingWidth(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_width.x(),_width.y(), 2));
}; };
/** /**
@ -155,16 +155,16 @@ namespace ewol {
* @param[in] _pos Start position of the clipping * @param[in] _pos Start position of the clipping
* @param[in] _posEnd End position of the clipping * @param[in] _posEnd End position of the clipping
*/ */
void setClipping(const Vector3f& _pos, const Vector3f& _posEnd); void setClipping( Vector3f _pos, Vector3f _posEnd);
inline void setClipping(const Vector2f& _pos, const Vector2f& _posEnd) { void setClipping( Vector2f _pos, Vector2f _posEnd) {
setClipping(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_posEnd.x(),_posEnd.y(), 1)); setClipping(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_posEnd.x(),_posEnd.y(), 1));
}; };
/** /**
* @brief enable/Disable the clipping (without lose the current clipping position) * @brief enable/Disable the clipping (without lose the current clipping position)
* @brief _newMode The new status of the clipping * @brief _newMode The new status of the clipping
*/ */
void setClippingMode(bool _newMode) { void setClippingMode(boolean _newMode) {
m_clippingEnable = _newMode; this.clippingEnable = _newMode;
}; };
/** /**
* @brief Specify the line thickness for the next elements * @brief Specify the line thickness for the next elements
@ -179,43 +179,43 @@ namespace ewol {
* @brief draw a line to a specific position * @brief draw a line to a specific position
* @param[in] _dest Position of the end of the line. * @param[in] _dest Position of the end of the line.
*/ */
void lineTo(const Vector3f& _dest); void lineTo( Vector3f _dest);
inline void lineTo(const Vector2f& _dest) { void lineTo( Vector2f _dest) {
lineTo(Vector3f(_dest.x(), _dest.y(), 0)); lineTo(Vector3f(_dest.x(), _dest.y(), 0));
}; };
/** /**
* @brief Relative drawing a line (spacial vector) * @brief Relative drawing a line (spacial vector)
* @param[in] _vect Vector of the curent line. * @param[in] _vect Vector of the curent line.
*/ */
void lineRel(const Vector3f& _vect) { void lineRel( Vector3f _vect) {
lineTo(m_position+_vect); lineTo(this.position+_vect);
}; };
inline void lineRel(const Vector2f& _vect) { void lineRel( Vector2f _vect) {
lineRel(Vector3f(_vect.x(), _vect.y(), 0)); lineRel(Vector3f(_vect.x(), _vect.y(), 0));
}; };
/** /**
* @brief draw a 2D rectangle to the position requested. * @brief draw a 2D rectangle to the position requested.
* @param[in] _dest Position the the end of the rectangle * @param[in] _dest Position the the end of the rectangle
*/ */
void rectangle(const Vector3f& _dest); void rectangle( Vector3f _dest);
inline void rectangle(const Vector2f& _dest) { void rectangle( Vector2f _dest) {
rectangle(Vector3f(_dest.x(), _dest.y(), 0)); rectangle(Vector3f(_dest.x(), _dest.y(), 0));
}; };
/** /**
* @brief draw a 2D rectangle to the requested size. * @brief draw a 2D rectangle to the requested size.
* @param[in] _size size of the rectangle * @param[in] _size size of the rectangle
*/ */
void rectangleWidth(const Vector3f& _size) { void rectangleWidth( Vector3f _size) {
rectangle(m_position+_size); rectangle(this.position+_size);
}; };
inline void rectangleWidth(const Vector2f& _size) { void rectangleWidth( Vector2f _size) {
rectangleWidth(Vector3f(_size.x(), _size.y(), 0)); rectangleWidth(Vector3f(_size.x(), _size.y(), 0));
}; };
/** /**
* @brief draw a 3D rectangle to the position requested. * @brief draw a 3D rectangle to the position requested.
* @param[in] _dest Position the the end of the rectangle * @param[in] _dest Position the the end of the rectangle
*/ */
void cube(const Vector3f& _dest); void cube( Vector3f _dest);
/** /**
* @brief draw a 2D circle with the specify rafdius parameter. * @brief draw a 2D circle with the specify rafdius parameter.
* @param[in] _radius Distence to the dorder * @param[in] _radius Distence to the dorder

View File

@ -9,42 +9,42 @@
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::compositing::Image); ETK_DECLARE_TYPE(ewol::compositing::Image);
const int32_t ewol::compositing::Image::sizeAuto(0); int ewol::compositing::Image::sizeAuto(0);
// VBO table property: // VBO table property:
const int32_t ewol::compositing::Image::m_vboIdCoord(0); int ewol::compositing::Image::this.vboIdCoord(0);
const int32_t ewol::compositing::Image::m_vboIdCoordTex(1); int ewol::compositing::Image::this.vboIdCoordTex(1);
const int32_t ewol::compositing::Image::m_vboIdColor(2); int ewol::compositing::Image::this.vboIdColor(2);
#define NB_VBO (3) #define NB_VBO (3)
ewol::compositing::Image::Image(const etk::Uri& _imageName, ewol::compositing::Image::Image( etk::Uri _imageName,
bool _df, boolean _df,
int32_t _size) : int _size) :
m_filename(_imageName), this.filename(_imageName),
m_requestSize(2,2), this.requestSize(2,2),
m_position(0.0, 0.0, 0.0), this.position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), this.clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), this.clippingPosStop(0.0, 0.0, 0.0),
m_clippingEnable(false), this.clippingEnable(false),
m_color(etk::color::white), this.color(etk::color::white),
m_angle(0.0), this.angle(0.0),
m_GLprogram(null), this.GLprogram(null),
m_GLPosition(-1), this.GLPosition(-1),
m_GLMatrix(-1), this.GLMatrix(-1),
m_GLColor(-1), this.GLColor(-1),
m_GLtexture(-1), this.GLtexture(-1),
m_GLtexID(-1), this.GLtexID(-1),
m_distanceFieldMode(_df), this.distanceFieldMode(_df),
m_resource(null), this.resource(null),
m_resourceDF(null) { this.resourceDF(null) {
// Create the VBO: // Create the VBO:
m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); this.VBO = gale::resource::VirtualBufferObject::create(NB_VBO);
if (m_VBO == null) { if (this.VBO == null) {
Log.error("can not instanciate VBO ..."); Log.error("can not instanciate VBO ...");
return; return;
} }
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
m_VBO->setName("[VBO] of ewol::compositing::Image"); this.VBO.setName("[VBO] of ewol::compositing::Image");
setSource(_imageName, _size); setSource(_imageName, _size);
loadProgram(); loadProgram();
} }
@ -55,310 +55,310 @@ ewol::compositing::Image::~Image() {
void ewol::compositing::Image::loadProgram() { void ewol::compositing::Image::loadProgram() {
// get the shader resource: // get the shader resource:
m_GLPosition = 0; this.GLPosition = 0;
m_GLprogram.reset(); this.GLprogram.reset();
if (m_distanceFieldMode == true) { if (this.distanceFieldMode == true) {
m_GLprogram = gale::resource::Program::create("DATA:///texturedDF.prog?lib=ewol"); this.GLprogram = gale::resource::Program::create("DATA:///texturedDF.prog?lib=ewol");
} else { } else {
m_GLprogram = gale::resource::Program::create("DATA:///textured3D.prog?lib=ewol"); this.GLprogram = gale::resource::Program::create("DATA:///textured3D.prog?lib=ewol");
} }
if (m_GLprogram != null) { if (this.GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); this.GLPosition = this.GLprogram.getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color"); this.GLColor = this.GLprogram.getAttribute("EW_color");
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d"); this.GLtexture = this.GLprogram.getAttribute("EW_texture2d");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation");
m_GLtexID = m_GLprogram->getUniform("EW_texID"); this.GLtexID = this.GLprogram.getUniform("EW_texID");
} }
} }
void ewol::compositing::Image::draw(bool _disableDepthTest) { void ewol::compositing::Image::draw(boolean _disableDepthTest) {
if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
//EWOL_WARNING("Nothink to draw..."); //Log.warning("Nothink to draw...");
return; return;
} }
if ( m_resource == null if ( this.resource == null
&& m_resourceDF == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceDF == null
&& m_resourceImage == null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceImage == null) {
// this is a normale case ... the user can choice to have no image ... // this is a normale case ... the user can choice to have no image ...
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
//EWOL_WARNING("Display image : " << m_VBO->bufferSize(m_vboIdCoord)); //Log.warning("Display image : " + this.VBO.bufferSize(this.vboIdCoord));
if (_disableDepthTest == true) { if (_disableDepthTest == true) {
gale::openGL::disable(gale::openGL::flag_depthTest); gale::openGL::disable(gale::openGL::flag_depthTest);
} else { } else {
gale::openGL::enable(gale::openGL::flag_depthTest); gale::openGL::enable(gale::openGL::flag_depthTest);
} }
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply;
m_GLprogram->use(); this.GLprogram.use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// TextureID // TextureID
if (m_resourceImage != null) { if (this.resourceImage != null) {
m_GLprogram->setTexture0(m_GLtexID, m_resourceImage->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.resourceImage.getRendererId());
} else if (m_resource != null) { } else if (this.resource != null) {
if (m_distanceFieldMode == true) { if (this.distanceFieldMode == true) {
Log.error("FONT type error Request distance field and display normal ..."); Log.error("FONT type error Request distance field and display normal ...");
} }
m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.resource.getRendererId());
} else { } else {
if (m_distanceFieldMode == false) { if (this.distanceFieldMode == false) {
Log.error("FONT type error Request normal and display distance field ..."); Log.error("FONT type error Request normal and display distance field ...");
} }
m_GLprogram->setTexture0(m_GLtexID, m_resourceDF->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.resourceDF.getRendererId());
} }
// position: // position:
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// Texture: // Texture:
m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordTex); this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordTex);
// color: // color:
m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor);
// Request the draw of the elements: // Request the draw of the elements:
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
m_GLprogram->unUse(); this.GLprogram.unUse();
} }
void ewol::compositing::Image::clear() { void ewol::compositing::Image::clear() {
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset Buffer : // reset Buffer :
m_VBO->clear(); this.VBO.clear();
// reset temporal variables : // reset temporal variables :
m_position = Vector3f(0.0, 0.0, 0.0); this.position = Vector3f(0.0, 0.0, 0.0);
m_clippingPosStart = Vector3f(0.0, 0.0, 0.0); this.clippingPosStart = Vector3f(0.0, 0.0, 0.0);
m_clippingPosStop = Vector3f(0.0, 0.0, 0.0); this.clippingPosStop = Vector3f(0.0, 0.0, 0.0);
m_clippingEnable = false; this.clippingEnable = false;
m_color = etk::color::white; this.color = etk::color::white;
m_angle = 0.0; this.angle = 0.0;
} }
void ewol::compositing::Image::setClipping(const Vector3f& _pos, Vector3f _posEnd) { void ewol::compositing::Image::setClipping( Vector3f _pos, Vector3f _posEnd) {
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); this.clippingPosStart.setX(_pos.x());
m_clippingPosStop.setX(_posEnd.x()); this.clippingPosStop.setX(_posEnd.x());
} else { } else {
m_clippingPosStart.setX(_posEnd.x()); this.clippingPosStart.setX(_posEnd.x());
m_clippingPosStop.setX(_pos.x()); this.clippingPosStop.setX(_pos.x());
} }
if (_pos.y() <= _posEnd.y()) { if (_pos.y() <= _posEnd.y()) {
m_clippingPosStart.setY(_pos.y()); this.clippingPosStart.setY(_pos.y());
m_clippingPosStop.setY(_posEnd.y()); this.clippingPosStop.setY(_posEnd.y());
} else { } else {
m_clippingPosStart.setY(_posEnd.y()); this.clippingPosStart.setY(_posEnd.y());
m_clippingPosStop.setY(_pos.y()); this.clippingPosStop.setY(_pos.y());
} }
if (_pos.z() <= _posEnd.z()) { if (_pos.z() <= _posEnd.z()) {
m_clippingPosStart.setZ(_pos.z()); this.clippingPosStart.setZ(_pos.z());
m_clippingPosStop.setZ(_posEnd.z()); this.clippingPosStop.setZ(_posEnd.z());
} else { } else {
m_clippingPosStart.setZ(_posEnd.z()); this.clippingPosStart.setZ(_posEnd.z());
m_clippingPosStop.setZ(_pos.z()); this.clippingPosStop.setZ(_pos.z());
} }
m_clippingEnable = true; this.clippingEnable = true;
} }
void ewol::compositing::Image::setAngle(float _angle) { void ewol::compositing::Image::setAngle(float _angle) {
m_angle = _angle; this.angle = _angle;
} }
void ewol::compositing::Image::print(const Vector2f& _size) { void ewol::compositing::Image::print( Vector2f _size) {
printPart(_size, Vector2f(0,0), Vector2f(1.0,1.0)); printPart(_size, Vector2f(0,0), Vector2f(1.0,1.0));
} }
void ewol::compositing::Image::printPart(const Vector2f& _size, void ewol::compositing::Image::printPart( Vector2f _size,
Vector2f _sourcePosStart, Vector2f _sourcePosStart,
Vector2f _sourcePosStop) { Vector2f _sourcePosStop) {
if (m_resource == null) { if (this.resource == null) {
return; return;
} }
Vector2f openGLSize = Vector2f(m_resource->getOpenGlSize().x(), m_resource->getOpenGlSize().y()); Vector2f openGLSize = Vector2f(this.resource.getOpenGlSize().x(), this.resource.getOpenGlSize().y());
Vector2f usefullSize = m_resource->getUsableSize(); Vector2f usefullSize = this.resource.getUsableSize();
Vector2f ratio = usefullSize/openGLSize; Vector2f ratio = usefullSize/openGLSize;
_sourcePosStart *= ratio; _sourcePosStart *= ratio;
_sourcePosStop *= ratio; _sourcePosStop *= ratio;
Log.verbose(" openGLSize=" << openGLSize << " usableSize=" << usefullSize << " start=" << _sourcePosStart << " stop=" << _sourcePosStop); Log.verbose(" openGLSize=" + openGLSize + " usableSize=" + usefullSize + " start=" + _sourcePosStart + " stop=" + _sourcePosStop);
//Log.error("Debug image " << m_filename << " ==> " << m_position << " " << _size << " " << _sourcePosStart << " " << _sourcePosStop); //Log.error("Debug image " + this.filename + " ==> " + this.position + " " + _size + " " + _sourcePosStart + " " << _sourcePosStop);
if (m_angle == 0.0f) { if (this.angle == 0.0f) {
Vector3f point = m_position; Vector3f point = this.position;
Vector2f tex(_sourcePosStart.x(),_sourcePosStop.y()); Vector2f tex(_sourcePosStart.x(),_sourcePosStop.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStop.x(),_sourcePosStop.y()); tex.setValue(_sourcePosStop.x(),_sourcePosStop.y());
point.setX(m_position.x() + _size.x()); point.setX(this.position.x() + _size.x());
point.setY(m_position.y()); point.setY(this.position.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStop.x(),_sourcePosStart.y()); tex.setValue(_sourcePosStop.x(),_sourcePosStart.y());
point.setX(m_position.x() + _size.x()); point.setX(this.position.x() + _size.x());
point.setY(m_position.y() + _size.y()); point.setY(this.position.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStart.x(),_sourcePosStart.y()); tex.setValue(_sourcePosStart.x(),_sourcePosStart.y());
point.setX(m_position.x()); point.setX(this.position.x());
point.setY(m_position.y() + _size.y()); point.setY(this.position.y() + _size.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStart.x(),_sourcePosStop.y()); tex.setValue(_sourcePosStart.x(),_sourcePosStop.y());
point.setX(m_position.x()); point.setX(this.position.x());
point.setY(m_position.y()); point.setY(this.position.y());
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->flush(); this.VBO.flush();
return; return;
} }
Vector3f center = m_position + Vector3f(_size.x(),_size.y(),0)/2.0f; Vector3f center = this.position + Vector3f(_size.x(),_size.y(),0)/2.0f;
Vector3f limitedSize(_size.x()*0.5f, _size.y()*0.5f, 0.0f); Vector3f limitedSize(_size.x()*0.5f, _size.y()*0.5f, 0.0f);
Vector3f point(0,0,0); Vector3f point(0,0,0);
Vector2f tex(_sourcePosStart.x(),_sourcePosStop.y()); Vector2f tex(_sourcePosStart.x(),_sourcePosStop.y());
point.setValue(-limitedSize.x(), -limitedSize.y(), 0); point.setValue(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotate(Vector3f(0,0,1), m_angle) + center; point = point.rotate(Vector3f(0,0,1), this.angle) + center;
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStop.x(),_sourcePosStop.y()); tex.setValue(_sourcePosStop.x(),_sourcePosStop.y());
point.setValue(limitedSize.x(), -limitedSize.y(), 0); point.setValue(limitedSize.x(), -limitedSize.y(), 0);
point = point.rotate(Vector3f(0,0,1), m_angle) + center; point = point.rotate(Vector3f(0,0,1), this.angle) + center;
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStop.x(),_sourcePosStart.y()); tex.setValue(_sourcePosStop.x(),_sourcePosStart.y());
point.setValue(limitedSize.x(), limitedSize.y(), 0); point.setValue(limitedSize.x(), limitedSize.y(), 0);
point = point.rotate(Vector3f(0,0,1), m_angle) + center; point = point.rotate(Vector3f(0,0,1), this.angle) + center;
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStart.x(),_sourcePosStart.y()); tex.setValue(_sourcePosStart.x(),_sourcePosStart.y());
point.setValue(-limitedSize.x(), limitedSize.y(), 0); point.setValue(-limitedSize.x(), limitedSize.y(), 0);
point = point.rotate(Vector3f(0,0,1), m_angle) + center; point = point.rotate(Vector3f(0,0,1), this.angle) + center;
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
tex.setValue(_sourcePosStart.x(),_sourcePosStop.y()); tex.setValue(_sourcePosStart.x(),_sourcePosStop.y());
point.setValue(-limitedSize.x(), -limitedSize.y(), 0); point.setValue(-limitedSize.x(), -limitedSize.y(), 0);
point = point.rotate(Vector3f(0,0,1), m_angle) + center; point = point.rotate(Vector3f(0,0,1), this.angle) + center;
m_VBO->pushOnBuffer(m_vboIdCoord, point); this.VBO.pushOnBuffer(this.vboIdCoord, point);
m_VBO->pushOnBuffer(m_vboIdCoordTex, tex); this.VBO.pushOnBuffer(this.vboIdCoordTex, tex);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->flush(); this.VBO.flush();
} }
void ewol::compositing::Image::setSource(const etk::Uri& _uri, const Vector2f& _size) { void ewol::compositing::Image::setSource( etk::Uri _uri, Vector2f _size) {
clear(); clear();
if ( m_filename == _uri if ( this.filename == _uri
&& m_requestSize == _size) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.requestSize == _size) {
// Nothing to do ... // Nothing to do ...
return; return;
} }
ememory::SharedPtr<ewol::resource::TextureFile> resource = m_resource; ememory::Ptr<ewol::resource::TextureFile> resource = this.resource;
ememory::SharedPtr<ewol::resource::ImageDF> resourceDF = m_resourceDF; ememory::Ptr<ewol::resource::ImageDF> resourceDF = this.resourceDF;
ememory::SharedPtr<ewol::resource::Texture> resourceTex = m_resourceImage; ememory::Ptr<ewol::resource::Texture> resourceTex = this.resourceImage;
m_filename = _uri; this.filename = _uri;
m_requestSize = _size; this.requestSize = _size;
m_resource.reset(); this.resource.reset();
m_resourceDF.reset(); this.resourceDF.reset();
m_resourceImage.reset(); this.resourceImage.reset();
Vector2i tmpSize(_size.x(),_size.y()); Vector2i tmpSize(_size.x(),_size.y());
// note that no image can be loaded... // note that no image can be loaded...
if (_uri.isEmpty() == false) { if (_uri.isEmpty() == false) {
// link to new one // link to new one
if (m_distanceFieldMode == false) { if (this.distanceFieldMode == false) {
m_resource = ewol::resource::TextureFile::create(m_filename, tmpSize); this.resource = ewol::resource::TextureFile::create(this.filename, tmpSize);
if (m_resource == null) { if (this.resource == null) {
Log.error("Can not get Image resource"); Log.error("Can not get Image resource");
} }
} else { } else {
m_resourceDF = ewol::resource::ImageDF::create(m_filename, tmpSize); this.resourceDF = ewol::resource::ImageDF::create(this.filename, tmpSize);
if (m_resourceDF == null) { if (this.resourceDF == null) {
Log.error("Can not get Image resource DF"); Log.error("Can not get Image resource DF");
} }
} }
} }
if ( m_resource == null if ( this.resource == null
&& m_resourceDF == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceDF == null
&& m_resourceImage == null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceImage == null) {
if (resource != null) { if (resource != null) {
EWOL_WARNING("Retrive previous resource"); Log.warning("Retrive previous resource");
m_resource = resource; this.resource = resource;
} }
if (resourceDF != null) { if (resourceDF != null) {
EWOL_WARNING("Retrive previous resource (DF)"); Log.warning("Retrive previous resource (DF)");
m_resourceDF = resourceDF; this.resourceDF = resourceDF;
} }
if (resourceTex != null) { if (resourceTex != null) {
EWOL_WARNING("Retrive previous resource (image)"); Log.warning("Retrive previous resource (image)");
m_resourceImage = resourceTex; this.resourceImage = resourceTex;
} }
} }
} }
void ewol::compositing::Image::setSource(egami::Image _image) { void ewol::compositing::Image::setSource(egami::Image _image) {
clear(); clear();
m_filename = "direct image BUFFER"; this.filename = "direct image BUFFER";
m_requestSize = _image.getSize(); this.requestSize = _image.getSize();
m_resourceImage = ewol::resource::Texture::create(); this.resourceImage = ewol::resource::Texture::create();
m_resourceImage->set(etk::move(_image)); this.resourceImage.set(etk::move(_image));
} }
bool ewol::compositing::Image::hasSources() { boolean ewol::compositing::Image::hasSources() {
return m_resource != null return this.resource != null
|| m_resourceDF != null; || this.resourceDF != null;
} }
Vector2f ewol::compositing::Image::getRealSize() { Vector2f ewol::compositing::Image::getRealSize() {
if ( m_resource == null if ( this.resource == null
&& m_resourceDF == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceDF == null
&& m_resourceImage == null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.resourceImage == null) {
return Vector2f(0,0); return Vector2f(0,0);
} }
if (m_resource != null) { if (this.resource != null) {
return m_resource->getRealSize(); return this.resource.getRealSize();
} }
if (m_resourceDF != null) { if (this.resourceDF != null) {
return m_resourceDF->getRealSize(); return this.resourceDF.getRealSize();
} }
if (m_resourceImage != null) { if (this.resourceImage != null) {
return m_resourceImage->getUsableSize(); return this.resourceImage.getUsableSize();
} }
return Vector2f(0,0); return Vector2f(0,0);
} }
void ewol::compositing::Image::setDistanceFieldMode(bool _mode) { void ewol::compositing::Image::setDistanceFieldMode(boolean _mode) {
if (m_distanceFieldMode == _mode) { if (this.distanceFieldMode == _mode) {
return; return;
} }
m_distanceFieldMode = _mode; this.distanceFieldMode = _mode;
// Force reload input // Force reload input
setSource(m_filename, m_requestSize); setSource(this.filename, this.requestSize);
loadProgram(); loadProgram();
} }

View File

@ -15,33 +15,33 @@ namespace ewol {
namespace compositing { namespace compositing {
class Image : public ewol::Compositing { class Image : public ewol::Compositing {
public: public:
static const int32_t sizeAuto; static int sizeAuto;
private: private:
etk::Uri m_filename; etk::Uri this.filename;
Vector2i m_requestSize; Vector2i this.requestSize;
Vector3f m_position; //!< The current position to draw Vector3f this.position; //!< The current position to draw
Vector3f m_clippingPosStart; //!< Clipping start position Vector3f this.clippingPosStart; //!< Clipping start position
Vector3f m_clippingPosStop; //!< Clipping stop position Vector3f this.clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated boolean this.clippingEnable; //!< true if the clipping must be activated
private: private:
etk::Color<float,4> m_color; //!< The text foreground color etk::Color<float,4> this.color; //!< The text foreground color
float m_angle; //!< Angle to set at the axes float this.angle; //!< Angle to set at the axes
private: private:
ememory::SharedPtr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program ememory::Ptr<gale::resource::Program> this.GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int this.GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int this.GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLColor; //!< openGL id on the element (color buffer) int this.GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position) int this.GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID) int this.GLtexID; //!< openGL id on the element (texture ID)
private: private:
bool m_distanceFieldMode; //!< select distance field mode boolean this.distanceFieldMode; //!< select distance field mode
ememory::SharedPtr<ewol::resource::TextureFile> m_resource; //!< texture resources ememory::Ptr<ewol::resource::TextureFile> this.resource; //!< texture resources
ememory::SharedPtr<ewol::resource::Texture> m_resourceImage; //!< texture resources ememory::Ptr<ewol::resource::Texture> this.resourceImage; //!< texture resources
ememory::SharedPtr<ewol::resource::ImageDF> m_resourceDF; //!< texture resources ememory::Ptr<ewol::resource::ImageDF> this.resourceDF; //!< texture resources
static const int32_t m_vboIdCoord; static int this.vboIdCoord;
static const int32_t m_vboIdCoordTex; static int this.vboIdCoordTex;
static const int32_t m_vboIdColor; static int this.vboIdColor;
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_VBO; ememory::Ptr<gale::resource::VirtualBufferObject> this.VBO;
private: private:
/** /**
* @brief load the openGL program and get all the ID needed * @brief load the openGL program and get all the ID needed
@ -49,24 +49,24 @@ namespace ewol {
void loadProgram(); void loadProgram();
public: public:
/** /**
* @brief generic constructor * @brief generic ructor
* @param[in] _uri URI of the file that might be loaded * @param[in] _uri URI of the file that might be loaded
* @param[in] _df enable distance field mode * @param[in] _df enable distance field mode
* @param[in] _size for the image when Verctorial image loading is requested * @param[in] _size for the image when Verctorial image loading is requested
*/ */
Image(const etk::Uri& _uri="", Image( etk::Uri _uri="",
bool _df=false, boolean _df=false,
int32_t _size=ewol::compositing::Image::sizeAuto); int _size=ewol::compositing::Image::sizeAuto);
/** /**
* @brief generic destructor * @brief generic destructor
*/ */
virtual ~Image(); ~Image();
public: public:
/** /**
* @brief draw All the refistered text in the current element on openGL * @brief draw All the refistered text in the current element on openGL
* @param[in] _disableDepthTest disable the Depth test for display * @param[in] _disableDepthTest disable the Depth test for display
*/ */
void draw(bool _disableDepthTest=true); void draw(boolean _disableDepthTest=true);
/** /**
* @brief clear alll tre registered element in the current element * @brief clear alll tre registered element in the current element
*/ */
@ -75,45 +75,45 @@ namespace ewol {
* @brief get the current display position (sometime needed in the gui control) * @brief get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
*/ */
const Vector3f& getPos() { Vector3f getPos() {
return m_position; return this.position;
}; };
/** /**
* @brief set position for the next text writen * @brief set position for the next text writen
* @param[in] _pos Position of the text (in 3D) * @param[in] _pos Position of the text (in 3D)
*/ */
void setPos(const Vector3f& _pos) { void setPos( Vector3f _pos) {
m_position = _pos; this.position = _pos;
}; };
inline void setPos(const Vector2f& _pos) { void setPos( Vector2f _pos) {
setPos(Vector3f(_pos.x(),_pos.y(),0)); setPos(Vector3f(_pos.x(),_pos.y(),0));
}; };
/** /**
* @brief set relative position for the next text writen * @brief set relative position for the next text writen
* @param[in] _pos ofset apply of the text (in 3D) * @param[in] _pos ofset apply of the text (in 3D)
*/ */
void setRelPos(const Vector3f& _pos) { void setRelPos( Vector3f _pos) {
m_position += _pos; this.position += _pos;
}; };
inline void setRelPos(const Vector2f& _pos) { void setRelPos( Vector2f _pos) {
setRelPos(Vector3f(_pos.x(),_pos.y(),0)); setRelPos(Vector3f(_pos.x(),_pos.y(),0));
}; };
/** /**
* @brief set the Color of the current foreground font * @brief set the Color of the current foreground font
* @param[in] _color Color to set on foreground (for next print) * @param[in] _color Color to set on foreground (for next print)
*/ */
void setColor(const etk::Color<>& _color) { void setColor( etk::Color<> _color) {
m_color = _color; this.color = _color;
}; };
/** /**
* @brief Request a clipping area for the text (next draw only) * @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping * @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping * @param[in] _width Width size of the clipping
*/ */
void setClippingWidth(const Vector3f& _pos, Vector3f _width) { void setClippingWidth( Vector3f _pos, Vector3f _width) {
setClipping(_pos, _pos+_width); setClipping(_pos, _pos+_width);
}; };
inline void setClippingWidth(const Vector2f& _pos, const Vector2f& _width) { void setClippingWidth( Vector2f _pos, Vector2f _width) {
setClippingWidth(Vector3f(_pos.x(),_pos.y(),0), Vector3f(_width.x(),_width.y(),0)); setClippingWidth(Vector3f(_pos.x(),_pos.y(),0), Vector3f(_width.x(),_width.y(),0));
}; };
/** /**
@ -121,16 +121,16 @@ namespace ewol {
* @param[in] _pos Start position of the clipping * @param[in] _pos Start position of the clipping
* @param[in] _posEnd End position of the clipping * @param[in] _posEnd End position of the clipping
*/ */
void setClipping(const Vector3f& _pos, Vector3f _posEnd); void setClipping( Vector3f _pos, Vector3f _posEnd);
inline void setClipping(const Vector2f& _pos, const Vector2f& _posEnd) { void setClipping( Vector2f _pos, Vector2f _posEnd) {
setClipping(Vector3f(_pos.x(),_pos.y(),0), Vector3f(_posEnd.x(),_posEnd.y(),0)); setClipping(Vector3f(_pos.x(),_pos.y(),0), Vector3f(_posEnd.x(),_posEnd.y(),0));
}; };
/** /**
* @brief enable/Disable the clipping (without lose the current clipping position) * @brief enable/Disable the clipping (without lose the current clipping position)
* @brief _newMode The new status of the clipping * @brief _newMode The new status of the clipping
*/ */
void setClippingMode(bool _newMode) { void setClippingMode(boolean _newMode) {
m_clippingEnable = _newMode; this.clippingEnable = _newMode;
}; };
/** /**
* @brief set a unique rotation of this element (not set in the rotate Generic system) * @brief set a unique rotation of this element (not set in the rotate Generic system)
@ -141,17 +141,17 @@ namespace ewol {
* @brief add a compleate of the image to display with the requested size * @brief add a compleate of the image to display with the requested size
* @param[in] _size size of the output image * @param[in] _size size of the output image
*/ */
void print(const Vector2i& _size) { void print( Vector2i _size) {
print(Vector2f(_size.x(),_size.y())); print(Vector2f(_size.x(),_size.y()));
}; };
void print(const Vector2f& _size); void print( Vector2f _size);
/** /**
* @brief add a part of the image to display with the requested size * @brief add a part of the image to display with the requested size
* @param[in] _size size of the output image * @param[in] _size size of the output image
* @param[in] _sourcePosStart Start position in the image [0..1] (can be bigger but this repeate the image). * @param[in] _sourcePosStart Start position in the image [0..1] (can be bigger but this repeate the image).
* @param[in] _sourcePosStop Stop position in the image [0..1] (can be bigger but this repeate the image). * @param[in] _sourcePosStop Stop position in the image [0..1] (can be bigger but this repeate the image).
*/ */
void printPart(const Vector2f& _size, void printPart( Vector2f _size,
Vector2f _sourcePosStart, Vector2f _sourcePosStart,
Vector2f _sourcePosStop); Vector2f _sourcePosStop);
/** /**
@ -159,16 +159,16 @@ namespace ewol {
* @param[in] _uri New file of the Image * @param[in] _uri New file of the Image
* @param[in] _size for the image when Verctorial image loading is requested * @param[in] _size for the image when Verctorial image loading is requested
*/ */
void setSource(const etk::Uri& _uri, int32_t _size=32) { void setSource( etk::Uri _uri, int _size=32) {
setSource(_uri, Vector2f(_size,_size)); setSource(_uri, Vector2f(_size,_size));
}; };
void setSource(const etk::Uri& _uri, const Vector2f& _size); void setSource( etk::Uri _uri, Vector2f _size);
void setSource(egami::Image _image); void setSource(egami::Image _image);
/** /**
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. * @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources. * @return the validity od the resources.
*/ */
bool hasSources(); boolean hasSources();
/** /**
* @brief get the source image registered size in the file (<0 when multiple size image) * @brief get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size * @return tre image registered size
@ -179,13 +179,13 @@ namespace ewol {
* @brief Set render mode of the image * @brief Set render mode of the image
* @param[in] _mode Activation of distance field mode * @param[in] _mode Activation of distance field mode
*/ */
void setDistanceFieldMode(bool _mode); void setDistanceFieldMode(boolean _mode);
/** /**
* @brief Get the render methode. * @brief Get the render methode.
* @return The render mode of the image. * @return The render mode of the image.
*/ */
bool getDistanceFieldMode() const { boolean getDistanceFieldMode() {
return m_distanceFieldMode; return this.distanceFieldMode;
} }
}; };
}; };

View File

@ -11,50 +11,50 @@
ETK_DECLARE_TYPE(ewol::compositing::Shaper); ETK_DECLARE_TYPE(ewol::compositing::Shaper);
// VBO table property: // VBO table property:
const int32_t ewol::compositing::Shaper::m_vboIdCoord(0); int ewol::compositing::Shaper::this.vboIdCoord(0);
const int32_t ewol::compositing::Shaper::m_vboIdPos(1); int ewol::compositing::Shaper::this.vboIdPos(1);
#define NB_VBO (2) #define NB_VBO (2)
ewol::compositing::Shaper::Shaper(const etk::Uri& _uri) : ewol::compositing::Shaper::Shaper( etk::Uri _uri) :
m_uri(_uri), this.uri(_uri),
m_config(null), this.config(null),
m_confIdMode(-1), this.confIdMode(-1),
m_confIdDisplayOutside(-1), this.confIdDisplayOutside(-1),
m_confIdChangeTime(-1), this.confIdChangeTime(-1),
m_confProgramFile(-1), this.confProgramFile(-1),
m_confColorFile(-1), this.confColorFile(-1),
m_confImageFile(-1), this.confImageFile(-1),
m_GLprogram(null), this.GLprogram(null),
m_GLPosition(-1), this.GLPosition(-1),
m_GLMatrix(-1), this.GLMatrix(-1),
m_GLStateActivate(-1), this.GLStateActivate(-1),
m_GLStateOld(-1), this.GLStateOld(-1),
m_GLStateNew(-1), this.GLStateNew(-1),
m_GLStateTransition(-1), this.GLStateTransition(-1),
m_resourceTexture(null), this.resourceTexture(null),
m_nextStatusRequested(-1), this.nextStatusRequested(-1),
m_propertyOrigin(0,0), this.propertyOrigin(0,0),
m_propertySize(0,0), this.propertySize(0,0),
m_propertyInsidePosition(0,0), this.propertyInsidePosition(0,0),
m_propertyInsideSize(0,0), this.propertyInsideSize(0,0),
m_stateActivate(0), this.stateActivate(0),
m_stateOld(0), this.stateOld(0),
m_stateNew(0), this.stateNew(0),
m_stateTransition(1.0), this.stateTransition(1.0),
m_nbVertexToDisplay(0) { this.nbVertexToDisplay(0) {
for (size_t iii=0; iii<shaperPosCount; ++iii) { for (int iii=0; iii<shaperPosCount; ++iii) {
m_confIdPaddingOut[iii] = -1; this.confIdPaddingOut[iii] = -1;
m_confIdBorder[iii] = -1; this.confIdBorder[iii] = -1;
m_confIdPaddingIn[iii] = -1; this.confIdPaddingIn[iii] = -1;
} }
// Create the VBO: // Create the VBO:
m_VBO = gale::resource::VirtualBufferObject::create(NB_VBO); this.VBO = gale::resource::VirtualBufferObject::create(NB_VBO);
if (m_VBO == null) { if (this.VBO == null) {
Log.error("can not instanciate VBO ..."); Log.error("can not instanciate VBO ...");
return; return;
} }
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
m_VBO->setName("[VBO] of ewol::compositing::Shaper"); this.VBO.setName("[VBO] of ewol::compositing::Shaper");
loadProgram(); loadProgram();
} }
@ -63,225 +63,225 @@ ewol::compositing::Shaper::~Shaper() {
} }
void ewol::compositing::Shaper::unLoadProgram() { void ewol::compositing::Shaper::unLoadProgram() {
m_GLprogram.reset(); this.GLprogram.reset();
m_resourceTexture.reset(); this.resourceTexture.reset();
m_config.reset(); this.config.reset();
m_colorProperty.reset(); this.colorProperty.reset();
for (size_t iii=0; iii<shaperPosCount; ++iii) { for (int iii=0; iii<shaperPosCount; ++iii) {
m_confIdPaddingOut[iii] = -1; this.confIdPaddingOut[iii] = -1;
m_confIdBorder[iii] = -1; this.confIdBorder[iii] = -1;
m_confIdPaddingIn[iii] = -1; this.confIdPaddingIn[iii] = -1;
} }
m_VBO->clear(); this.VBO.clear();
m_confIdMode = -1; this.confIdMode = -1;
m_confIdDisplayOutside = -1; this.confIdDisplayOutside = -1;
m_nbVertexToDisplay = 0; this.nbVertexToDisplay = 0;
m_confIdChangeTime = -1; this.confIdChangeTime = -1;
m_confProgramFile = -1; this.confProgramFile = -1;
m_confImageFile = -1; this.confImageFile = -1;
m_listAssiciatedId.clear(); this.listAssiciatedId.clear();
} }
void ewol::compositing::Shaper::loadProgram() { void ewol::compositing::Shaper::loadProgram() {
if (m_uri.isEmpty() == true) { if (this.uri.isEmpty() == true) {
Log.debug("no Shaper set for loading resources ..."); Log.debug("no Shaper set for loading resources ...");
return; return;
} }
m_config = ewol::resource::ConfigFile::create(m_uri.get()); this.config = ewol::resource::ConfigFile::create(this.uri.get());
if (m_config != null) { if (this.config != null) {
m_confIdMode = m_config->request("mode"); this.confIdMode = this.config.request("mode");
m_confIdDisplayOutside = m_config->request("display-outside"); this.confIdDisplayOutside = this.config.request("display-outside");
m_confIdPaddingOut[shaperPosLeft] = m_config->request("padding-out-left"); this.confIdPaddingOut[shaperPosLeft] = this.config.request("padding-out-left");
m_confIdPaddingOut[shaperPosRight] = m_config->request("padding-out-right"); this.confIdPaddingOut[shaperPosRight] = this.config.request("padding-out-right");
m_confIdPaddingOut[shaperPosTop] = m_config->request("padding-out-top"); this.confIdPaddingOut[shaperPosTop] = this.config.request("padding-out-top");
m_confIdPaddingOut[shaperPosButtom] = m_config->request("padding-out-buttom"); this.confIdPaddingOut[shaperPosButtom] = this.config.request("padding-out-buttom");
m_confIdBorder[shaperPosLeft] = m_config->request("border-left"); this.confIdBorder[shaperPosLeft] = this.config.request("border-left");
m_confIdBorder[shaperPosRight] = m_config->request("border-right"); this.confIdBorder[shaperPosRight] = this.config.request("border-right");
m_confIdBorder[shaperPosTop] = m_config->request("border-top"); this.confIdBorder[shaperPosTop] = this.config.request("border-top");
m_confIdBorder[shaperPosButtom] = m_config->request("border-buttom"); this.confIdBorder[shaperPosButtom] = this.config.request("border-buttom");
m_confIdPaddingIn[shaperPosLeft] = m_config->request("padding-in-left"); this.confIdPaddingIn[shaperPosLeft] = this.config.request("padding-in-left");
m_confIdPaddingIn[shaperPosRight] = m_config->request("padding-in-right"); this.confIdPaddingIn[shaperPosRight] = this.config.request("padding-in-right");
m_confIdPaddingIn[shaperPosTop] = m_config->request("padding-in-top"); this.confIdPaddingIn[shaperPosTop] = this.config.request("padding-in-top");
m_confIdPaddingIn[shaperPosButtom] = m_config->request("padding-in-buttom"); this.confIdPaddingIn[shaperPosButtom] = this.config.request("padding-in-buttom");
m_confIdChangeTime = m_config->request("change-time"); this.confIdChangeTime = this.config.request("change-time");
m_confProgramFile = m_config->request("program"); this.confProgramFile = this.config.request("program");
m_confImageFile = m_config->request("image"); this.confImageFile = this.config.request("image");
m_confColorFile = m_config->request("color"); this.confColorFile = this.config.request("color");
} }
etk::String basicShaderFile = m_config->getString(m_confProgramFile); String basicShaderFile = this.config.getString(this.confProgramFile);
if (basicShaderFile != "") { if (basicShaderFile != "") {
etk::String tmpFilename(basicShaderFile); String tmpFilename(basicShaderFile);
if (tmpFilename.find(':') == etk::String::npos) { if (tmpFilename.find(':') == String::npos) {
// get the relative position of the current file ... // get the relative position of the current file ...
etk::Uri tmpUri = m_uri; etk::Uri tmpUri = this.uri;
tmpUri.setPath(m_uri.getPath().getParent() / basicShaderFile); tmpUri.setPath(this.uri.getPath().getParent() / basicShaderFile);
tmpFilename = tmpUri.get(); tmpFilename = tmpUri.get();
Log.debug("Shaper try load shader : '" << tmpFilename << "' with base : '" << basicShaderFile << "'"); Log.debug("Shaper try load shader : '" + tmpFilename + "' with base : '" + basicShaderFile + "'");
} else { } else {
Log.debug("Shaper try load shader : '" << tmpFilename << "'"); Log.debug("Shaper try load shader : '" + tmpFilename + "'");
} }
// get the shader resource : // get the shader resource :
m_GLPosition = 0; this.GLPosition = 0;
m_GLprogram = gale::resource::Program::create(tmpFilename); this.GLprogram = gale::resource::Program::create(tmpFilename);
if (m_GLprogram != null) { if (this.GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord2d"); this.GLPosition = this.GLprogram.getAttribute("EW_coord2d");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation");
// Widget property == > for the Vertex shader // Widget property == > for the Vertex shader
m_GLPropertyPos = m_GLprogram->getAttribute("EW_widgetPropertyPos"); this.GLPropertyPos = this.GLprogram.getAttribute("EW_widgetPropertyPos");
// status property == > for the fragment shader // status property == > for the fragment shader
m_GLStateActivate = m_GLprogram->getUniform("EW_status.activate"); this.GLStateActivate = this.GLprogram.getUniform("EW_status.activate");
m_GLStateOld = m_GLprogram->getUniform("EW_status.stateOld"); this.GLStateOld = this.GLprogram.getUniform("EW_status.stateOld");
m_GLStateNew = m_GLprogram->getUniform("EW_status.stateNew"); this.GLStateNew = this.GLprogram.getUniform("EW_status.stateNew");
m_GLStateTransition = m_GLprogram->getUniform("EW_status.transition"); this.GLStateTransition = this.GLprogram.getUniform("EW_status.transition");
// for the texture ID : // for the texture ID :
m_GLtexID = m_GLprogram->getUniform("EW_texID"); this.GLtexID = this.GLprogram.getUniform("EW_texID");
} }
etk::String basicImageFile = m_config->getString(m_confImageFile); String basicImageFile = this.config.getString(this.confImageFile);
if (basicImageFile != "") { if (basicImageFile != "") {
etk::String tmpFilename(basicImageFile); String tmpFilename(basicImageFile);
if (tmpFilename.find(':') == etk::String::npos) { if (tmpFilename.find(':') == String::npos) {
// get the relative position of the current file ... // get the relative position of the current file ...
etk::Uri tmpUri = m_uri; etk::Uri tmpUri = this.uri;
tmpUri.setPath(m_uri.getPath().getParent() / basicImageFile); tmpUri.setPath(this.uri.getPath().getParent() / basicImageFile);
tmpFilename = tmpUri.get(); tmpFilename = tmpUri.get();
Log.debug("Shaper try load shaper image : '" << tmpFilename << "' with base : '" << basicImageFile << "'"); Log.debug("Shaper try load shaper image : '" + tmpFilename + "' with base : '" + basicImageFile + "'");
} else { } else {
Log.debug("Shaper try load shaper image : '" << tmpFilename << "'"); Log.debug("Shaper try load shaper image : '" + tmpFilename + "'");
} }
Vector2i size(64,64); Vector2i size(64,64);
m_resourceTexture = ewol::resource::TextureFile::create(tmpFilename, size); this.resourceTexture = ewol::resource::TextureFile::create(tmpFilename, size);
} }
} }
etk::String basicColorFile = m_config->getString(m_confColorFile); String basicColorFile = this.config.getString(this.confColorFile);
if (basicColorFile != "") { if (basicColorFile != "") {
etk::String tmpFilename(basicColorFile); String tmpFilename(basicColorFile);
if (tmpFilename.find(':') == etk::String::npos) { if (tmpFilename.find(':') == String::npos) {
// get the relative position of the current file ... // get the relative position of the current file ...
etk::Uri tmpUri = m_uri; etk::Uri tmpUri = this.uri;
tmpUri.setPath(m_uri.getPath().getParent() / basicColorFile); tmpUri.setPath(this.uri.getPath().getParent() / basicColorFile);
tmpFilename = tmpUri.get(); tmpFilename = tmpUri.get();
Log.debug("Shaper try load colorFile : '" << tmpFilename << "' with base : '" << basicColorFile << "'"); Log.debug("Shaper try load colorFile : '" + tmpFilename + "' with base : '" + basicColorFile + "'");
} else { } else {
Log.debug("Shaper try load colorFile : '" << tmpFilename << "'"); Log.debug("Shaper try load colorFile : '" + tmpFilename + "'");
} }
m_colorProperty = ewol::resource::ColorFile::create(tmpFilename); this.colorProperty = ewol::resource::ColorFile::create(tmpFilename);
if ( m_GLprogram != null if ( this.GLprogram != null
&& m_colorProperty != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.colorProperty != null) {
List<etk::String> listColor = m_colorProperty->getColors(); List<String> listColor = this.colorProperty.getColors();
for (auto tmpColor : listColor) { for (auto tmpColor : listColor) {
int32_t glId = m_GLprogram->getUniform(tmpColor); int glId = this.GLprogram.getUniform(tmpColor);
int32_t colorID = m_colorProperty->request(tmpColor); int colorID = this.colorProperty.request(tmpColor);
m_listAssiciatedId.pushBack(Vector2i(glId, colorID)); this.listAssiciatedId.pushBack(Vector2i(glId, colorID));
} }
} }
} }
} }
void ewol::compositing::Shaper::draw(bool _disableDepthTest) { void ewol::compositing::Shaper::draw(boolean _disableDepthTest) {
if (m_config == null) { if (this.config == null) {
// this is a normale case ... the user can choice to have no config basic file ... // this is a normale case ... the user can choice to have no config basic file ...
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
if (m_VBO->bufferSize(m_vboIdCoord) <= 0) { if (this.VBO.bufferSize(this.vboIdCoord) <= 0) {
return; return;
} }
//glScalef(m_scaling.x, m_scaling.y, 1.0); //glScalef(this.scaling.x, this.scaling.y, 1.0);
m_GLprogram->use(); this.GLprogram.use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 tmpMatrix = gale::openGL::getMatrix(); mat4 tmpMatrix = gale::openGL::getMatrix();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position: // position:
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// property // property
m_GLprogram->sendAttributePointer(m_GLPropertyPos, m_VBO, m_vboIdPos); this.GLprogram.sendAttributePointer(this.GLPropertyPos, this.VBO, this.vboIdPos);
// all entry parameters : // all entry parameters :
m_GLprogram->uniform1i(m_GLStateActivate, m_stateActivate); this.GLprogram.uniform1i(this.GLStateActivate, this.stateActivate);
m_GLprogram->uniform1i(m_GLStateOld, m_stateOld); this.GLprogram.uniform1i(this.GLStateOld, this.stateOld);
m_GLprogram->uniform1i(m_GLStateNew, m_stateNew); this.GLprogram.uniform1i(this.GLStateNew, this.stateNew);
m_GLprogram->uniform1f(m_GLStateTransition, m_stateTransition); this.GLprogram.uniform1f(this.GLStateTransition, this.stateTransition);
for (auto element : m_listAssiciatedId) { for (auto element : this.listAssiciatedId) {
m_GLprogram->uniform(element.x(), m_colorProperty->get(element.y())); this.GLprogram.uniform(element.x(), this.colorProperty.get(element.y()));
} }
if (m_resourceTexture != null) { if (this.resourceTexture != null) {
// TextureID // TextureID
m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.resourceTexture.getRendererId());
} }
// Request the draw of the elements : // Request the draw of the elements :
//gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, SHAPER_NB_MAX_VERTEX); //gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, SHAPER_NB_MAX_VERTEX);
gale::openGL::drawArrays(gale::openGL::renderMode::triangleStrip, 0, m_nbVertexToDisplay); gale::openGL::drawArrays(gale::openGL::renderMode::triangleStrip, 0, this.nbVertexToDisplay);
m_GLprogram->unUse(); this.GLprogram.unUse();
} }
void ewol::compositing::Shaper::clear() { void ewol::compositing::Shaper::clear() {
// nothing to do ... // nothing to do ...
m_propertySize = Vector2f(0,0); this.propertySize = Vector2f(0,0);
m_propertyOrigin = Vector2f(0,0); this.propertyOrigin = Vector2f(0,0);
m_propertyInsidePosition = Vector2f(0,0); this.propertyInsidePosition = Vector2f(0,0);
m_propertyInsideSize = Vector2f(0,0); this.propertyInsideSize = Vector2f(0,0);
m_VBO->clear(); this.VBO.clear();
} }
bool ewol::compositing::Shaper::setState(int32_t _newState) { boolean ewol::compositing::Shaper::setState(int _newState) {
if (m_stateActivate == _newState) { if (this.stateActivate == _newState) {
return false; return false;
} }
m_stateActivate = _newState; this.stateActivate = _newState;
return true; return true;
} }
bool ewol::compositing::Shaper::changeStatusIn(int32_t _newStatusId) { boolean ewol::compositing::Shaper::changeStatusIn(int _newStatusId) {
if (_newStatusId != m_stateNew) { if (_newStatusId != this.stateNew) {
m_nextStatusRequested = _newStatusId; this.nextStatusRequested = _newStatusId;
return true; return true;
} }
if( m_nextStatusRequested != -1 if( this.nextStatusRequested != -1
|| m_stateNew != m_stateOld) { || this.stateNew != this.stateOld) {
return true; return true;
} }
return false; return false;
} }
bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) { boolean ewol::compositing::Shaper::periodicCall( ewol::event::Time _event) {
Log.verbose("call=" << _event << "state transition=" << m_stateTransition << " speedTime=" << m_config->getNumber(m_confIdChangeTime)); Log.verbose("call=" + _event + "state transition=" + this.stateTransition + " speedTime=" + this.config.getNumber(this.confIdChangeTime));
// start : // start :
if (m_stateTransition >= 1.0) { if (this.stateTransition >= 1.0) {
m_stateOld = m_stateNew; this.stateOld = this.stateNew;
if( m_nextStatusRequested != -1 if( this.nextStatusRequested != -1
&& m_nextStatusRequested != m_stateOld) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.nextStatusRequested != this.stateOld) {
m_stateNew = m_nextStatusRequested; this.stateNew = this.nextStatusRequested;
m_nextStatusRequested = -1; this.nextStatusRequested = -1;
m_stateTransition = 0.0; this.stateTransition = 0.0;
Log.verbose(" ##### START ##### "); Log.verbose(" ##### START ##### ");
} else { } else {
m_nextStatusRequested = -1; this.nextStatusRequested = -1;
// disable periodic call ... // disable periodic call ...
return false; return false;
} }
} }
if (m_stateTransition<1.0) { if (this.stateTransition<1.0) {
// check if no new state requested: // check if no new state requested:
if (m_nextStatusRequested != -1 && m_stateTransition<0.5) { if (this.nextStatusRequested != -1 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.stateTransition<0.5) {
// invert sources with destination // invert sources with destination
int32_t tmppp = m_stateOld; int tmppp = this.stateOld;
m_stateOld = m_stateNew; this.stateOld = this.stateNew;
m_stateNew = tmppp; this.stateNew = tmppp;
m_stateTransition = 1.0 - m_stateTransition; this.stateTransition = 1.0 - this.stateTransition;
if (m_nextStatusRequested == m_stateNew) { if (this.nextStatusRequested == this.stateNew) {
m_nextStatusRequested = -1; this.nextStatusRequested = -1;
} }
} }
float timeRelativity = 0.0f; float timeRelativity = 0.0f;
if (m_config != null) { if (this.config != null) {
timeRelativity = m_config->getNumber(m_confIdChangeTime) / 1000.0; timeRelativity = this.config.getNumber(this.confIdChangeTime) / 1000.0;
} }
m_stateTransition += _event.getDeltaCall() / timeRelativity; this.stateTransition += _event.getDeltaCall() / timeRelativity;
//m_stateTransition += _event.getDeltaCall(); //this.stateTransition += _event.getDeltaCall();
m_stateTransition = etk::avg(0.0f, m_stateTransition, 1.0f); this.stateTransition = etk::avg(0.0f, this.stateTransition, 1.0f);
Log.verbose("relative=" << timeRelativity << " Transition : " << m_stateTransition); Log.verbose("relative=" + timeRelativity + " Transition : " + this.stateTransition);
} }
return true; return true;
} }
@ -299,112 +299,112 @@ void ewol::compositing::Shaper::addVertexLine(float _yTop,
float _x8, float _x8,
float _yValTop, float _yValTop,
float _yValButtom, float _yValButtom,
const float* _table, float* _table,
bool _displayOutside) { boolean _displayOutside) {
if (m_nbVertexToDisplay != 0) { if (this.nbVertexToDisplay != 0) {
// change line ... // change line ...
m_VBO->pushOnBuffer(m_vboIdCoord, this.VBO.pushOnBuffer(this.vboIdCoord,
m_VBO->getOnBufferVec2(m_vboIdCoord, m_nbVertexToDisplay-1)); this.VBO.getOnBufferVec2(this.vboIdCoord, this.nbVertexToDisplay-1));
m_VBO->pushOnBuffer(m_vboIdPos, this.VBO.pushOnBuffer(this.vboIdPos,
m_VBO->getOnBufferVec2(m_vboIdPos, m_nbVertexToDisplay-1)); this.VBO.getOnBufferVec2(this.vboIdPos, this.nbVertexToDisplay-1));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
if (_displayOutside == true) { if (_displayOutside == true) {
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x1, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x1, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[0],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[0],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
} else { } else {
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
} }
} }
if (_displayOutside == true) { if (_displayOutside == true) {
// A // A
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x1, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x1, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[0],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[0],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x1, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x1, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[0],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[0],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// B // B
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// C // C
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x3, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[2],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
} else { } else {
// C // C
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x2, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x2, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[1],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[1],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x3, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[2],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
} }
// D // D
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x3, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x3, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[2],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[2],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// E // E
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x4, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x4, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[3],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[3],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// F // F
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x4, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x4, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[3],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[3],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// G // G
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x5, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x5, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[4],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[4],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// H // H
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x5, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x5, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[4],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[4],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// I // I
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x6, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x6, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[5],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[5],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// J // J
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x6, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x6, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[5],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[5],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// K // K
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x7, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x7, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[6],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[6],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// L // L
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x7, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x7, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[6],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[6],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
if (_displayOutside == true) { if (_displayOutside == true) {
// M // M
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x8, _yButtom)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x8, _yButtom));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[7],_yValButtom)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[7],_yValButtom));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
// N // N
m_VBO->pushOnBuffer(m_vboIdCoord, Vector2f(_x8, _yTop)); this.VBO.pushOnBuffer(this.vboIdCoord, Vector2f(_x8, _yTop));
m_VBO->pushOnBuffer(m_vboIdPos, Vector2f(_table[7],_yValTop)); this.VBO.pushOnBuffer(this.vboIdPos, Vector2f(_table[7],_yValTop));
m_nbVertexToDisplay++; this.nbVertexToDisplay++;
} }
} }
const float modeDisplay[][8] = { float modeDisplay[][8] = {
/* !! 0 !! /* !! 0 !!
* / ******* * / *******
* / ****** / * / ****** /
@ -451,8 +451,8 @@ const float modeDisplay[][8] = {
{ 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f } { 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f }
}; };
void ewol::compositing::Shaper::setShape(const Vector2f& _origin, const Vector2f& _size, const Vector2f& _insidePos, const Vector2f& _insideSize) { void ewol::compositing::Shaper::setShape( Vector2f _origin, Vector2f _size, Vector2f _insidePos, Vector2f _insideSize) {
m_VBO->clear(); this.VBO.clear();
ewol::Padding borderTmp = getBorder(); ewol::Padding borderTmp = getBorder();
ewol::Padding paddingIn = getPaddingIn(); ewol::Padding paddingIn = getPaddingIn();
ewol::Padding paddingOut = getPaddingOut(); ewol::Padding paddingOut = getPaddingOut();
@ -490,17 +490,17 @@ void ewol::compositing::Shaper::setShape(const Vector2f& _origin, const Vector2f
#endif #endif
/* /*
Log.error(" enveloppe = " << enveloppe); Log.error(" enveloppe = " + enveloppe);
Log.error(" border = " << border); Log.error(" border = " + border);
Log.error(" inside = " << inside); Log.error(" inside = " + inside);
*/ */
int32_t mode = 0; int mode = 0;
bool displayOutside = false; boolean displayOutside = false;
if (m_config != null) { if (this.config != null) {
mode = m_config->getNumber(m_confIdMode); mode = this.config.getNumber(this.confIdMode);
displayOutside = m_config->getBoolean(m_confIdDisplayOutside); displayOutside = this.config.getBoolean(this.confIdDisplayOutside);
} }
m_nbVertexToDisplay = 0; this.nbVertexToDisplay = 0;
if (displayOutside == true) { if (displayOutside == true) {
addVertexLine(enveloppe.yTop(), border.yTop(), addVertexLine(enveloppe.yTop(), border.yTop(),
enveloppe.xLeft(), enveloppe.xLeft(),
@ -589,7 +589,7 @@ void ewol::compositing::Shaper::setShape(const Vector2f& _origin, const Vector2f
modeDisplay[mode], modeDisplay[mode],
displayOutside); displayOutside);
} }
m_VBO->flush(); this.VBO.flush();
} }
ewol::Padding ewol::compositing::Shaper::getPadding() { ewol::Padding ewol::compositing::Shaper::getPadding() {
@ -598,96 +598,96 @@ ewol::Padding ewol::compositing::Shaper::getPadding() {
ewol::Padding ewol::compositing::Shaper::getPaddingIn() { ewol::Padding ewol::compositing::Shaper::getPaddingIn() {
ewol::Padding padding(0,0,0,0); ewol::Padding padding(0,0,0,0);
if (m_config != null) { if (this.config != null) {
padding.setValue(m_config->getNumber(m_confIdPaddingIn[shaperPosLeft]), padding.setValue(this.config.getNumber(this.confIdPaddingIn[shaperPosLeft]),
m_config->getNumber(m_confIdPaddingIn[shaperPosTop]), this.config.getNumber(this.confIdPaddingIn[shaperPosTop]),
m_config->getNumber(m_confIdPaddingIn[shaperPosRight]), this.config.getNumber(this.confIdPaddingIn[shaperPosRight]),
m_config->getNumber(m_confIdPaddingIn[shaperPosButtom])); this.config.getNumber(this.confIdPaddingIn[shaperPosButtom]));
} }
return padding; return padding;
} }
ewol::Padding ewol::compositing::Shaper::getPaddingOut() { ewol::Padding ewol::compositing::Shaper::getPaddingOut() {
ewol::Padding padding(0,0,0,0); ewol::Padding padding(0,0,0,0);
if (m_config != null) { if (this.config != null) {
padding.setValue(m_config->getNumber(m_confIdPaddingOut[shaperPosLeft]), padding.setValue(this.config.getNumber(this.confIdPaddingOut[shaperPosLeft]),
m_config->getNumber(m_confIdPaddingOut[shaperPosTop]), this.config.getNumber(this.confIdPaddingOut[shaperPosTop]),
m_config->getNumber(m_confIdPaddingOut[shaperPosRight]), this.config.getNumber(this.confIdPaddingOut[shaperPosRight]),
m_config->getNumber(m_confIdPaddingOut[shaperPosButtom])); this.config.getNumber(this.confIdPaddingOut[shaperPosButtom]));
} }
return padding; return padding;
} }
ewol::Padding ewol::compositing::Shaper::getBorder() { ewol::Padding ewol::compositing::Shaper::getBorder() {
ewol::Padding padding(0,0,0,0); ewol::Padding padding(0,0,0,0);
if (m_config != null) { if (this.config != null) {
padding.setValue(m_config->getNumber(m_confIdBorder[shaperPosLeft]), padding.setValue(this.config.getNumber(this.confIdBorder[shaperPosLeft]),
m_config->getNumber(m_confIdBorder[shaperPosTop]), this.config.getNumber(this.confIdBorder[shaperPosTop]),
m_config->getNumber(m_confIdBorder[shaperPosRight]), this.config.getNumber(this.confIdBorder[shaperPosRight]),
m_config->getNumber(m_confIdBorder[shaperPosButtom])); this.config.getNumber(this.confIdBorder[shaperPosButtom]));
} }
return padding; return padding;
} }
void ewol::compositing::Shaper::setSource(const etk::Uri& _uri) { void ewol::compositing::Shaper::setSource( etk::Uri _uri) {
clear(); clear();
unLoadProgram(); unLoadProgram();
m_uri = _uri; this.uri = _uri;
loadProgram(); loadProgram();
} }
bool ewol::compositing::Shaper::hasSources() { boolean ewol::compositing::Shaper::hasSources() {
return m_GLprogram != null; return this.GLprogram != null;
} }
const etk::Color<float>& ewol::compositing::Shaper::getColor(int32_t _id) { etk::Color<float> ewol::compositing::Shaper::getColor(int _id) {
static const etk::Color<float> errorValue(0,0,0,0); static etk::Color<float> errorValue(0,0,0,0);
if (m_colorProperty == null) { if (this.colorProperty == null) {
EWOL_WARNING("null of m_colorProperty ==> return #0000 for id " << _id); Log.warning("null of this.colorProperty ==> return #0000 for id " + _id);
return errorValue; return errorValue;
} }
return m_colorProperty->get(_id); return this.colorProperty.get(_id);
} }
int32_t ewol::compositing::Shaper::requestColor(const etk::String& _name) { int ewol::compositing::Shaper::requestColor( String _name) {
if (m_colorProperty == null) { if (this.colorProperty == null) {
EWOL_WARNING("null of m_colorProperty ==> return -1 for name " << _name); Log.warning("null of this.colorProperty ==> return -1 for name " + _name);
return -1; return -1;
} }
return m_colorProperty->request(_name); return this.colorProperty.request(_name);
} }
int32_t ewol::compositing::Shaper::requestConfig(const etk::String& _name) { int ewol::compositing::Shaper::requestConfig( String _name) {
if (m_config == null) { if (this.config == null) {
EWOL_WARNING("null of m_config ==> return -1 for name " << _name); Log.warning("null of this.config ==> return -1 for name " + _name);
return -1; return -1;
} }
return m_config->request(_name); return this.config.request(_name);
} }
double ewol::compositing::Shaper::getConfigNumber(int32_t _id) { double ewol::compositing::Shaper::getConfigNumber(int _id) {
if ( _id == -1 if ( _id == -1
|| m_config == null) { || this.config == null) {
EWOL_WARNING("null of m_config ==> return 0.0 for id " << _id); Log.warning("null of this.config ==> return 0.0 for id " + _id);
return 0.0; return 0.0;
} }
return m_config->getNumber(_id); return this.config.getNumber(_id);
} }
namespace etk { namespace etk {
template<> etk::String toString<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) { template<> String toString<ewol::compositing::Shaper>( ewol::compositing::Shaper _obj) {
return _obj.getSource().get(); return _obj.getSource().get();
} }
template<> etk::UString toUString<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) { template<> etk::UString toUString<ewol::compositing::Shaper>( ewol::compositing::Shaper _obj) {
return etk::toUString(etk::toString(_obj)); return etk::toUString(etk::toString(_obj));
} }
template<> bool from_string<ewol::compositing::Shaper>(ewol::compositing::Shaper& _variableRet, const etk::String& _value) { template<> boolean frothis.string<ewol::compositing::Shaper>(ewol::compositing::Shaper _variableRet, String _value) {
_variableRet.setSource(_value); _variableRet.setSource(_value);
return true; return true;
} }
template<> bool from_string<ewol::compositing::Shaper>(ewol::compositing::Shaper& _variableRet, const etk::UString& _value) { template<> boolean frothis.string<ewol::compositing::Shaper>(ewol::compositing::Shaper _variableRet, etk::UString _value) {
return from_string(_variableRet, etk::toString(_value)); return frothis.string(_variableRet, etk::toString(_value));
} }
}; };

View File

@ -38,48 +38,48 @@ namespace ewol {
// TODO : Abstaraction between states (call by name and the system greate IDs // TODO : Abstaraction between states (call by name and the system greate IDs
class Shaper : public ewol::Compositing { class Shaper : public ewol::Compositing {
private: private:
etk::Uri m_uri; //!< Name of the configuration of the shaper. etk::Uri this.uri; //!< Name of the configuration of the shaper.
// External theme config: // External theme config:
ememory::SharedPtr<ewol::resource::ConfigFile> m_config; //!< pointer on the config file resources ememory::Ptr<ewol::resource::ConfigFile> this.config; //!< pointer on the config file resources
int32_t m_confIdPaddingOut[shaperPosCount]; //!< Padding out property : X-left X-right Y-top Y-buttom int this.confIdPaddingOut[shaperPosCount]; //!< Padding out property : X-left X-right Y-top Y-buttom
int32_t m_confIdBorder[shaperPosCount]; //!< border property : X-left X-right Y-top Y-buttom int this.confIdBorder[shaperPosCount]; //!< border property : X-left X-right Y-top Y-buttom
int32_t m_confIdPaddingIn[shaperPosCount]; //!< Padding in property : X-left X-right Y-top Y-buttom int this.confIdPaddingIn[shaperPosCount]; //!< Padding in property : X-left X-right Y-top Y-buttom
int32_t m_confIdMode; //!< Display mode int this.confIdMode; //!< Display mode
int32_t m_confIdDisplayOutside; //!< Display outside of the shape... int this.confIdDisplayOutside; //!< Display outside of the shape...
int32_t m_confIdChangeTime; //!< ConfigFile padding transition time property int this.confIdChangeTime; //!< ConfigFile padding transition time property
int32_t m_confProgramFile; //!< ConfigFile opengGl program Name int this.confProgramFile; //!< ConfigFile opengGl program Name
int32_t m_confColorFile; //!< ConfigFile opengGl color file Name int this.confColorFile; //!< ConfigFile opengGl color file Name
int32_t m_confImageFile; //!< ConfigFile opengGl program Name int this.confImageFile; //!< ConfigFile opengGl program Name
// openGL shaders programs: // openGL shaders programs:
ememory::SharedPtr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program ememory::Ptr<gale::resource::Program> this.GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int this.GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int this.GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on Vector2f(X,Y)) int this.GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on Vector2f(X,Y))
int32_t m_GLStateActivate; //!< openGL id on the element (activate state displayed) int this.GLStateActivate; //!< openGL id on the element (activate state displayed)
int32_t m_GLStateOld; //!< openGL id on the element (old state displayed) int this.GLStateOld; //!< openGL id on the element (old state displayed)
int32_t m_GLStateNew; //!< openGL id on the element (new state displayed) int this.GLStateNew; //!< openGL id on the element (new state displayed)
int32_t m_GLStateTransition; //!< openGL id on the element (transition ofset [0.0..1.0] ) int this.GLStateTransition; //!< openGL id on the element (transition ofset [0.0..1.0] )
int32_t m_GLtexID; //!< openGL id on the element (texture image) int this.GLtexID; //!< openGL id on the element (texture image)
// For the Image : // For the Image :
ememory::SharedPtr<ewol::resource::TextureFile> m_resourceTexture; //!< texture resources (for the image) ememory::Ptr<ewol::resource::TextureFile> this.resourceTexture; //!< texture resources (for the image)
// internal needed data : // internal needed data :
int32_t m_nextStatusRequested; //!< when status is changing, this represent the next step of it int this.nextStatusRequested; //!< when status is changing, this represent the next step of it
Vector2f m_propertyOrigin; //!< widget origin Vector2f this.propertyOrigin; //!< widget origin
Vector2f m_propertySize; //!< widget size Vector2f this.propertySize; //!< widget size
Vector2f m_propertyInsidePosition; //!< internal subwidget position Vector2f this.propertyInsidePosition; //!< internal subwidget position
Vector2f m_propertyInsideSize; //!< internal subwidget size Vector2f this.propertyInsideSize; //!< internal subwidget size
int32_t m_stateActivate; //!< Activate state of the element int this.stateActivate; //!< Activate state of the element
int32_t m_stateOld; //!< previous state int this.stateOld; //!< previous state
int32_t m_stateNew; //!< destination state int this.stateNew; //!< destination state
float m_stateTransition; //!< working state between 2 states float this.stateTransition; //!< working state between 2 states
int32_t m_nbVertexToDisplay; int this.nbVertexToDisplay;
// color management theme: // color management theme:
ememory::SharedPtr<ewol::resource::ColorFile> m_colorProperty; //!< input resource for color management ememory::Ptr<ewol::resource::ColorFile> this.colorProperty; //!< input resource for color management
List<Vector2i> m_listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X) List<Vector2i> this.listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X)
protected: protected:
static const int32_t m_vboIdCoord; static int this.vboIdCoord;
static const int32_t m_vboIdPos; static int this.vboIdPos;
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_VBO; ememory::Ptr<gale::resource::VirtualBufferObject> this.VBO;
private: private:
/** /**
* @brief load the openGL program and get all the ID needed * @brief load the openGL program and get all the ID needed
@ -91,19 +91,19 @@ namespace ewol {
void unLoadProgram(); void unLoadProgram();
public: public:
/** /**
* @brief generic constructor * @brief generic ructor
* @param[in] _uri URI of the file that might be loaded * @param[in] _uri URI of the file that might be loaded
*/ */
Shaper(const etk::Uri& _uri=""); Shaper( etk::Uri _uri="");
/** /**
* @brief generic destructor * @brief generic destructor
*/ */
virtual ~Shaper(); ~Shaper();
public: public:
/** /**
* @brief draw All the refistered text in the current element on openGL * @brief draw All the refistered text in the current element on openGL
*/ */
void draw(bool _disableDepthTest=true); void draw(boolean _disableDepthTest=true);
/** /**
* @brief clear alll tre registered element in the current element * @brief clear alll tre registered element in the current element
*/ */
@ -114,34 +114,34 @@ namespace ewol {
* @return true Need redraw. * @return true Need redraw.
* @return false No need redraw. * @return false No need redraw.
*/ */
bool setState(int32_t _newState); boolean setState(int _newState);
/** /**
* @brief change the current status in an other * @brief change the current status in an other
* @param[in] _newStatusId the next new status requested * @param[in] _newStatusId the next new status requested
* @return true The widget must call this fuction periodicly (and redraw itself) * @return true The widget must call this fuction periodicly (and redraw itself)
* @return false No need to request the periodic call. * @return false No need to request the periodic call.
*/ */
bool changeStatusIn(int32_t _newStatusId); boolean changeStatusIn(int _newStatusId);
/** /**
* @brief get the current displayed status of the shaper * @brief get the current displayed status of the shaper
* @return The Status Id * @return The Status Id
*/ */
int32_t getCurrentDisplayedStatus() { int getCurrentDisplayedStatus() {
return m_stateNew; return this.stateNew;
}; };
/** /**
* @brief get the next displayed status of the shaper * @brief get the next displayed status of the shaper
* @return The next status Id (-1 if no status in next) * @return The next status Id (-1 if no status in next)
*/ */
int32_t getNextDisplayedStatus() { int getNextDisplayedStatus() {
return m_nextStatusRequested; return this.nextStatusRequested;
}; };
/** /**
* @brief get the current trasion status * @brief get the current trasion status
* @return value of the transition status (0.0f when no activity) * @return value of the transition status (0.0f when no activity)
*/ */
float getTransitionStatus() { float getTransitionStatus() {
return m_stateTransition; return this.stateTransition;
}; };
/** /**
* @brief Same as the widfget periodic call (this is for change display) * @brief Same as the widfget periodic call (this is for change display)
@ -149,7 +149,7 @@ namespace ewol {
* @return true The widget must call this fuction periodicly (and redraw itself) * @return true The widget must call this fuction periodicly (and redraw itself)
* @return false No need to request the periodic call. * @return false No need to request the periodic call.
*/ */
bool periodicCall(const ewol::event::Time& _event); boolean periodicCall( ewol::event::Time _event);
/** /**
* @brief get the padding declared by the user in the config file * @brief get the padding declared by the user in the config file
* @return the padding property * @return the padding property
@ -166,19 +166,19 @@ namespace ewol {
* @brief change the shaper Source * @brief change the shaper Source
* @param[in] _uri New file of the shaper * @param[in] _uri New file of the shaper
*/ */
void setSource(const etk::Uri& _uri); void setSource( etk::Uri _uri);
/** /**
* @brief get the shaper file Source * @brief get the shaper file Source
* @return the shapper file name * @return the shapper file name
*/ */
const etk::Uri& getSource() const { etk::Uri getSource() {
return m_uri; return this.uri;
}; };
/** /**
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. * @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources. * @return the validity od the resources.
*/ */
bool hasSources(); boolean hasSources();
public: public:
/** /**
* @brief set the shape property: * @brief set the shape property:
@ -224,9 +224,9 @@ namespace ewol {
* @param[in] _insidePos Positin of the internal data * @param[in] _insidePos Positin of the internal data
* @param[in] _insideSize Size of the internal data * @param[in] _insideSize Size of the internal data
*/ */
void setShape(const Vector2f& _origin, const Vector2f& _size, const Vector2f& _insidePos, const Vector2f& _insideSize); void setShape( Vector2f _origin, Vector2f _size, Vector2f _insidePos, Vector2f _insideSize);
// @previous // @previous
void setShape(const Vector2f& _origin, const Vector2f& _size) { void setShape( Vector2f _origin, Vector2f _size) {
ewol::Padding tmp = getPadding(); ewol::Padding tmp = getPadding();
setShape(_origin, _size, _origin+Vector2f(tmp.xLeft(), tmp.yButtom()), _size - Vector2f(tmp.x(), tmp.y())); setShape(_origin, _size, _origin+Vector2f(tmp.xLeft(), tmp.yButtom()), _size - Vector2f(tmp.x(), tmp.y()));
} }
@ -236,33 +236,33 @@ namespace ewol {
* @param[in] _name Name of the element requested * @param[in] _name Name of the element requested
* @return The Id of the color * @return The Id of the color
*/ */
int32_t requestColor(const etk::String& _name); int requestColor( String _name);
/** /**
* @brief Get The color associated at an ID. * @brief Get The color associated at an ID.
* @param[in] _id Id of the color * @param[in] _id Id of the color
* @return the reference on the color * @return the reference on the color
*/ */
const etk::Color<float>& getColor(int32_t _id); etk::Color<float> getColor(int _id);
public: public:
/** /**
* @brief Get an ID on the configuration instance element * @brief Get an ID on the configuration instance element
* @param[in] _name Name of the element requested * @param[in] _name Name of the element requested
* @return The Id of the element * @return The Id of the element
*/ */
int32_t requestConfig(const etk::String& _name); int requestConfig( String _name);
/** /**
* @brief Get The number associated at an ID. * @brief Get The number associated at an ID.
* @param[in] _id Id of the parameter * @param[in] _id Id of the parameter
* @return the requested number. * @return the requested number.
*/ */
double getConfigNumber(int32_t _id); double getConfigNumber(int _id);
public: public:
/** /**
* @brief Set activate state of the element * @brief Set activate state of the element
* @param[in] _status New activate status * @param[in] _status New activate status
*/ */
void setActivateState(int32_t _status) { void setActivateState(int _status) {
m_stateActivate = _status; this.stateActivate = _status;
} }
private: private:
void addVertexLine(float _yTop, void addVertexLine(float _yTop,
@ -277,17 +277,17 @@ namespace ewol {
float _x8, float _x8,
float _yValTop, float _yValTop,
float _yValButtom, float _yValButtom,
const float* _table, float* _table,
bool _displayOutside); boolean _displayOutside);
public: public:
/* **************************************************** /* ****************************************************
* == operator * == operator
*****************************************************/ *****************************************************/
bool operator== (const Shaper& _obj) const { boolean operator== ( Shaper _obj) {
return _obj.m_uri == m_uri; return _obj.this.uri == this.uri;
} }
bool operator!= (const Shaper& _obj) const { boolean operator!= ( Shaper _obj) {
return _obj.m_uri != m_uri; return _obj.this.uri != this.uri;
} }
}; };
} }

View File

@ -10,30 +10,30 @@
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::compositing::Sprite); ETK_DECLARE_TYPE(ewol::compositing::Sprite);
ewol::compositing::Sprite::Sprite(const etk::String& _imageName, const Vector2i& _nbSprite, int32_t _size) : ewol::compositing::Sprite::Sprite( String _imageName, Vector2i _nbSprite, int _size) :
ewol::compositing::Image(_imageName, false, _size), ewol::compositing::Image(_imageName, false, _size),
m_nbSprite(_nbSprite), this.nbSprite(_nbSprite),
m_unitarySpriteSize(0,0) { this.unitarySpriteSize(0,0) {
/* /*
Vector2f imageSize = getRealSize(); Vector2f imageSize = getRealSize();
m_unitarySpriteSize.setValue(imageSize.x()/(float)m_nbSprite.x(), this.unitarySpriteSize.setValue(imageSize.x()/(float)this.nbSprite.x(),
imageSize.y()/(float)m_nbSprite.y()); imageSize.y()/(float)this.nbSprite.y());
*/ */
m_unitarySpriteSize.setValue(1.0/(float)m_nbSprite.x(), this.unitarySpriteSize.setValue(1.0/(float)this.nbSprite.x(),
1.0/(float)m_nbSprite.y()); 1.0/(float)this.nbSprite.y());
} }
void ewol::compositing::Sprite::printSprite(const Vector2i& _spriteID, const Vector3f& _size) { void ewol::compositing::Sprite::printSprite( Vector2i _spriteID, Vector3f _size) {
if( _spriteID.x()<0 if( _spriteID.x()<0
|| _spriteID.y()<0 || _spriteID.y()<0
|| _spriteID.x() >= m_nbSprite.x() || _spriteID.x() >= this.nbSprite.x()
|| _spriteID.y() >= m_nbSprite.y()) { || _spriteID.y() >= this.nbSprite.y()) {
return; return;
} }
printPart(Vector2f(_size.x(),_size.y()), printPart(Vector2f(_size.x(),_size.y()),
Vector2f((float)(_spriteID.x() )*m_unitarySpriteSize.x(), (float)(_spriteID.y() )*m_unitarySpriteSize.y()), Vector2f((float)(_spriteID.x() )*this.unitarySpriteSize.x(), (float)(_spriteID.y() )*this.unitarySpriteSize.y()),
Vector2f((float)(_spriteID.x()+1)*m_unitarySpriteSize.x(), (float)(_spriteID.y()+1)*m_unitarySpriteSize.y())); Vector2f((float)(_spriteID.x()+1)*this.unitarySpriteSize.x(), (float)(_spriteID.y()+1)*this.unitarySpriteSize.y()));
} }

View File

@ -12,17 +12,17 @@ namespace ewol {
namespace compositing { namespace compositing {
class Sprite : public ewol::compositing::Image { class Sprite : public ewol::compositing::Image {
protected: protected:
Vector2i m_nbSprite; //!< number of sprite in vertical and horizontal Vector2i this.nbSprite; //!< number of sprite in vertical and horizontal
Vector2f m_unitarySpriteSize; //!< size of a unique sprite Vector2f this.unitarySpriteSize; //!< size of a unique sprite
public: public:
Sprite(const etk::String& _imageName, Sprite( String _imageName,
const Vector2i& _nbSprite, Vector2i _nbSprite,
int32_t _size=ewol::compositing::Image::sizeAuto); int _size=ewol::compositing::Image::sizeAuto);
virtual ~Sprite() {}; ~Sprite() {};
void printSprite(const Vector2i& _spriteID, const Vector2f& _size) { void printSprite( Vector2i _spriteID, Vector2f _size) {
printSprite(_spriteID, Vector3f(_size.x(), _size.y(),0)); printSprite(_spriteID, Vector3f(_size.x(), _size.y(),0));
}; };
void printSprite(const Vector2i& _spriteID, const Vector3f& _size); void printSprite( Vector2i _spriteID, Vector3f _size);
}; };
} }
} }

View File

@ -12,8 +12,8 @@
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::compositing::Text); ETK_DECLARE_TYPE(ewol::compositing::Text);
ewol::compositing::Text::Text(const etk::String& _fontName, int32_t _fontSize) : ewol::compositing::Text::Text( String _fontName, int _fontSize) :
m_font(null) { this.font(null) {
setFont(_fontName, _fontSize); setFont(_fontName, _fontSize);
} }
@ -21,22 +21,22 @@ ewol::compositing::Text::~Text() {
} }
void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) { void ewol::compositing::Text::drawMT( mat4 _transformationMatrix, boolean _enableDepthTest) {
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(); this.vectorialDraw.draw();
if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 if ( this.VBO.bufferSize(this.vboIdCoord) <= 0
|| m_font == null) { || this.font == null) {
// TODO : set it back ... // TODO : set it back ...
//EWOL_WARNING("Nothink to draw..."); //Log.warning("Nothink to draw...");
return; return;
} }
if (m_font == null) { if (this.font == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
@ -47,109 +47,109 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en
mat4 projMatrix = gale::openGL::getMatrix(); mat4 projMatrix = gale::openGL::getMatrix();
mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix();
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
m_GLprogram->use(); this.GLprogram.use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// Texture: // Texture:
m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.font.getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextWidth, this.font.getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextHeight, this.font.getOpenGlSize().x());
// position: // position:
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// Texture: // Texture:
m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText);
// color: // color:
m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor);
// Request the draw od the elements: // Request the draw od the elements:
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
m_GLprogram->unUse(); this.GLprogram.unUse();
if (_enableDepthTest == true) { if (_enableDepthTest == true) {
gale::openGL::disable(gale::openGL::flag_depthTest); gale::openGL::disable(gale::openGL::flag_depthTest);
} }
} }
void ewol::compositing::Text::drawD(bool _disableDepthTest) { void ewol::compositing::Text::drawD(boolean _disableDepthTest) {
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(_disableDepthTest); this.vectorialDraw.draw(_disableDepthTest);
if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 if ( this.VBO.bufferSize(this.vboIdCoord) <= 0
|| m_font == null) { || this.font == null) {
//EWOL_WARNING("Nothink to draw..."); //Log.warning("Nothink to draw...");
return; return;
} }
if (m_font == null) { if (this.font == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply;
m_GLprogram->use(); this.GLprogram.use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// Texture : // Texture :
m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.font.getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextWidth, this.font.getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextHeight, this.font.getOpenGlSize().x());
// position: // position:
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
// Texture: // Texture:
m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText);
// color: // color:
m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor);
// Request the draw od the elements : // Request the draw od the elements :
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
m_GLprogram->unUse(); this.GLprogram.unUse();
} }
float ewol::compositing::Text::getSize() { float ewol::compositing::Text::getSize() {
if (m_font == null) { if (this.font == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return 1.0f; return 1.0f;
} }
return m_font->getFontSize(); return this.font.getFontSize();
} }
float ewol::compositing::Text::getHeight() { float ewol::compositing::Text::getHeight() {
if (m_font == null) { if (this.font == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return 10.0f; return 10.0f;
} }
return m_font->getHeight(m_mode); return this.font.getHeight(this.mode);
} }
ewol::GlyphProperty * ewol::compositing::Text::getGlyphPointer(char32_t _charcode) { ewol::GlyphProperty * ewol::compositing::Text::getGlyphPointer(Character _charcode) {
if (m_font == null) { if (this.font == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return null; return null;
} }
return m_font->getGlyphPointer(_charcode, m_mode); return this.font.getGlyphPointer(_charcode, this.mode);
} }
void ewol::compositing::Text::setFontSize(int32_t _fontSize) { void ewol::compositing::Text::setFontSize(int _fontSize) {
// get old size // get old size
etk::String fontName = ""; String fontName = "";
if (m_font != null) { if (this.font != null) {
fontName = m_font->getName(); fontName = this.font.getName();
// Remove the :XX for the size ... // Remove the :XX for the size ...
size_t pos = fontName.rfind(':'); int pos = fontName.rfind(':');
fontName.erase(pos, fontName.size()-pos); fontName.erase(pos, fontName.size()-pos);
} }
setFont(fontName, _fontSize); setFont(fontName, _fontSize);
} }
void ewol::compositing::Text::setFontName(const etk::String& _fontName) { void ewol::compositing::Text::setFontName( String _fontName) {
// get old size // get old size
int32_t fontSize = -1; int fontSize = -1;
if (m_font != null) { if (this.font != null) {
fontSize = m_font->getFontSize(); fontSize = this.font.getFontSize();
} }
setFont(_fontName, fontSize); setFont(_fontName, fontSize);
} }
void ewol::compositing::Text::setFont(etk::String _fontName, int32_t _fontSize) { void ewol::compositing::Text::setFont(String _fontName, int _fontSize) {
clear(); clear();
// remove old one // remove old one
ememory::SharedPtr<ewol::resource::TexturedFont> previousFont = m_font; ememory::Ptr<ewol::resource::TexturedFont> previousFont = this.font;
if (_fontSize <= 0) { if (_fontSize <= 0) {
_fontSize = ewol::getContext().getFontDefault().getSize(); _fontSize = ewol::getContext().getFontDefault().getSize();
} }
@ -158,37 +158,37 @@ void ewol::compositing::Text::setFont(etk::String _fontName, int32_t _fontSize)
} }
_fontName += ":"; _fontName += ":";
_fontName += etk::toString(_fontSize); _fontName += etk::toString(_fontSize);
Log.verbose("plop : " << _fontName << " size=" << _fontSize << " result :" << _fontName); Log.verbose("plop : " + _fontName + " size=" + _fontSize + " result :" + _fontName);
// link to new one // link to new one
m_font = ewol::resource::TexturedFont::create(_fontName); this.font = ewol::resource::TexturedFont::create(_fontName);
if (m_font == null) { if (this.font == null) {
Log.error("Can not get font resource"); Log.error("Can not get font resource");
m_font = previousFont; this.font = previousFont;
} }
} }
void ewol::compositing::Text::setFontMode(enum ewol::font::mode _mode) { void ewol::compositing::Text::setFontMode(enum ewol::font::mode _mode) {
if (m_font != null) { if (this.font != null) {
m_mode = m_font->getWrappingMode(_mode); this.mode = this.font.getWrappingMode(_mode);
} }
} }
void ewol::compositing::Text::printChar(const char32_t& _charcode) { void ewol::compositing::Text::printChar( Character _charcode) {
// get a pointer on the glyph property : // get a pointer on the glyph property :
ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode); ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode);
if (null == myGlyph) { if (null == myGlyph) {
Log.error(" font does not really existed ..."); Log.error(" font does not really existed ...");
return; return;
} }
int32_t fontSize = getSize(); int fontSize = getSize();
int32_t fontHeigh = getHeight(); int fontHeigh = getHeight();
// get the kerning ofset : // get the kerning ofset :
float kerningOffset = 0; float kerningOffset = 0;
if (m_kerning == true) { if (this.kerning == true) {
kerningOffset = myGlyph->kerningGet(m_previousCharcode); kerningOffset = myGlyph.kerningGet(this.previousCharcode);
if (kerningOffset != 0) { if (kerningOffset != 0) {
//Log.debug("Kerning between : '" << m_previousCharcode << "'&'" << myGlyph->m_UVal << "' value : " << kerningOffset); //Log.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.this.UVal + "' value : " + kerningOffset);
} }
} }
// 0x01 == 0x20 == ' '; // 0x01 == 0x20 == ' ';
@ -200,62 +200,62 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) {
* | | * | |
* yD *------* * yD *------*
*/ */
float dxA = m_position.x() + myGlyph->m_bearing.x() + kerningOffset; float dxA = this.position.x() + myGlyph.this.bearing.x() + kerningOffset;
float dxB = dxA + myGlyph->m_sizeTexture.x(); float dxB = dxA + myGlyph.this.sizeTexture.x();
float dyC = m_position.y() + myGlyph->m_bearing.y() + fontHeigh - fontSize; float dyC = this.position.y() + myGlyph.this.bearing.y() + fontHeigh - fontSize;
float dyD = dyC - myGlyph->m_sizeTexture.y(); float dyD = dyC - myGlyph.this.sizeTexture.y();
float tuA = myGlyph->m_texturePosStart.x(); float tuA = myGlyph.this.texturePosStart.x();
float tuB = tuA + myGlyph->m_texturePosSize.x(); float tuB = tuA + myGlyph.this.texturePosSize.x();
float tvC = myGlyph->m_texturePosStart.y(); float tvC = myGlyph.this.texturePosStart.y();
float tvD = tvC + myGlyph->m_texturePosSize.y(); float tvD = tvC + myGlyph.this.texturePosSize.y();
// Clipping and drawing area // Clipping and drawing area
if( m_clippingEnable == true if( this.clippingEnable == true
&& ( dxB < m_clippingPosStart.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( dxB < this.clippingPosStart.x()
|| dxA > m_clippingPosStop.x() || dxA > this.clippingPosStop.x()
|| dyC < m_clippingPosStart.y() || dyC < this.clippingPosStart.y()
|| dyD > m_clippingPosStop.y() ) ) { || dyD > this.clippingPosStop.y() ) ) {
// Nothing to diplay ... // Nothing to diplay ...
} else { } else {
if (m_clippingEnable == true) { if (this.clippingEnable == true) {
// generata positions... // generata positions...
float TexSizeX = tuB - tuA; float TexSizeX = tuB - tuA;
if (dxA < m_clippingPosStart.x()) { if (dxA < this.clippingPosStart.x()) {
// clip display // clip display
float drawSize = m_clippingPosStart.x() - dxA; float drawSize = this.clippingPosStart.x() - dxA;
// update element start display // update element start display
dxA = m_clippingPosStart.x(); dxA = this.clippingPosStart.x();
float addElement = TexSizeX * drawSize / (float)myGlyph->m_sizeTexture.x(); float addElement = TexSizeX * drawSize / (float)myGlyph.this.sizeTexture.x();
// update texture start X Pos // update texture start X Pos
tuA += addElement; tuA += addElement;
} }
if (dxB > m_clippingPosStop.x()) { if (dxB > this.clippingPosStop.x()) {
// clip display // clip display
float drawSize = dxB - m_clippingPosStop.x(); float drawSize = dxB - this.clippingPosStop.x();
// update element start display // update element start display
dxB = m_clippingPosStop.x(); dxB = this.clippingPosStop.x();
float addElement = TexSizeX * drawSize / (float)myGlyph->m_sizeTexture.x(); float addElement = TexSizeX * drawSize / (float)myGlyph.this.sizeTexture.x();
// update texture start X Pos // update texture start X Pos
tuB -= addElement; tuB -= addElement;
} }
float TexSizeY = tvC - tvD; float TexSizeY = tvC - tvD;
if (dyC > m_clippingPosStop.y()) { if (dyC > this.clippingPosStop.y()) {
// clip display // clip display
float drawSize = dyC - m_clippingPosStop.y(); float drawSize = dyC - this.clippingPosStop.y();
// update element start display // update element start display
dyC = m_clippingPosStop.y(); dyC = this.clippingPosStop.y();
float addElement = TexSizeY * drawSize / (float)myGlyph->m_sizeTexture.y(); float addElement = TexSizeY * drawSize / (float)myGlyph.this.sizeTexture.y();
// update texture start X Pos // update texture start X Pos
tvC -= addElement; tvC -= addElement;
} }
if (dyD < m_clippingPosStart.y()) { if (dyD < this.clippingPosStart.y()) {
// clip display // clip display
float drawSize = m_clippingPosStart.y() - dyD; float drawSize = this.clippingPosStart.y() - dyD;
// update element start display // update element start display
dyD = m_clippingPosStart.y(); dyD = this.clippingPosStart.y();
float addElement = TexSizeY * drawSize / (float)myGlyph->m_sizeTexture.y(); float addElement = TexSizeY * drawSize / (float)myGlyph.this.sizeTexture.y();
// update texture start X Pos // update texture start X Pos
tvD += addElement; tvD += addElement;
} }
@ -270,12 +270,12 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) {
* | | * | |
* 3------2 * 3------2
*/ */
if (m_needDisplay == true) { if (this.needDisplay == true) {
Vector3f bitmapDrawPos[4]; Vector3f bitmapDrawPos[4];
bitmapDrawPos[0].setValue((int32_t)dxA, (int32_t)dyC, 0); bitmapDrawPos[0].setValue((int)dxA, (int)dyC, 0);
bitmapDrawPos[1].setValue((int32_t)dxB, (int32_t)dyC, 0); bitmapDrawPos[1].setValue((int)dxB, (int)dyC, 0);
bitmapDrawPos[2].setValue((int32_t)dxB, (int32_t)dyD, 0); bitmapDrawPos[2].setValue((int)dxB, (int)dyD, 0);
bitmapDrawPos[3].setValue((int32_t)dxA, (int32_t)dyD, 0); bitmapDrawPos[3].setValue((int)dxA, (int)dyD, 0);
/* texture Position : /* texture Position :
* 0------1 * 0------1
* | | * | |
@ -283,10 +283,10 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) {
* 3------2 * 3------2
*/ */
Vector2f texturePos[4]; Vector2f texturePos[4];
texturePos[0].setValue(tuA+m_mode, tvC); texturePos[0].setValue(tuA+this.mode, tvC);
texturePos[1].setValue(tuB+m_mode, tvC); texturePos[1].setValue(tuB+this.mode, tvC);
texturePos[2].setValue(tuB+m_mode, tvD); texturePos[2].setValue(tuB+this.mode, tvD);
texturePos[3].setValue(tuA+m_mode, tvD); texturePos[3].setValue(tuA+this.mode, tvD);
// NOTE : Android does not support the Quads elements ... // NOTE : Android does not support the Quads elements ...
/* Step 1 : /* Step 1 :
@ -297,17 +297,17 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) {
* *
*/ */
// set texture coordonates : // set texture coordonates :
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[1]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[1]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]);
// set display positions : // set display positions :
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[1]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[1]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]);
// set the color // set the color
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
/* Step 2 : /* Step 2 :
* *
* ** * **
@ -316,41 +316,41 @@ void ewol::compositing::Text::printChar(const char32_t& _charcode) {
* ******** * ********
*/ */
// set texture coordonates : // set texture coordonates :
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[3]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[3]);
// set display positions : // set display positions :
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[3]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[3]);
// set the color // set the color
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
} }
} }
} }
} }
// move the position : // move the position :
//Log.debug(" 5 pos=" << m_position << " advance=" << myGlyph->m_advance.x() << " kerningOffset=" << kerningOffset); //Log.debug(" 5 pos=" + this.position + " advance=" + myGlyph.this.advance.x() + " kerningOffset=" + kerningOffset);
m_position.setX(m_position.x() + myGlyph->m_advance.x() + kerningOffset); this.position.setX(this.position.x() + myGlyph.this.advance.x() + kerningOffset);
//Log.debug(" 6 print '" << charcode << "' : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); //Log.debug(" 6 print '" + charcode + "' : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position);
// Register the previous character // Register the previous character
m_previousCharcode = _charcode; this.previousCharcode = _charcode;
m_VBO->flush(); this.VBO.flush();
return; return;
} }
Vector3f ewol::compositing::Text::calculateSizeChar(const char32_t& _charcode) { Vector3f ewol::compositing::Text::calculateSizeChar( Character _charcode) {
// get a pointer on the glyph property : // get a pointer on the glyph property :
ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode); ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode);
int32_t fontHeigh = getHeight(); int fontHeigh = getHeight();
if (myGlyph == null) { if (myGlyph == null) {
if (m_font == null) { if (this.font == null) {
EWOL_WARNING("no Glyph... in no font"); Log.warning("no Glyph... in no font");
} else { } else {
EWOL_WARNING("no Glyph... in font : " << m_font->getName()); Log.warning("no Glyph... in font : " + this.font.getName());
} }
return Vector3f((float)(0.2), return Vector3f((float)(0.2),
(float)(fontHeigh), (float)(fontHeigh),
@ -358,15 +358,15 @@ Vector3f ewol::compositing::Text::calculateSizeChar(const char32_t& _charcode) {
} }
// get the kerning ofset : // get the kerning ofset :
float kerningOffset = 0.0; float kerningOffset = 0.0;
if (m_kerning == true) { if (this.kerning == true) {
kerningOffset = myGlyph->kerningGet(m_previousCharcode); kerningOffset = myGlyph.kerningGet(this.previousCharcode);
} }
Vector3f outputSize((float)(myGlyph->m_advance.x() + kerningOffset), Vector3f outputSize((float)(myGlyph.this.advance.x() + kerningOffset),
(float)(fontHeigh), (float)(fontHeigh),
(float)(0.0)); (float)(0.0));
// Register the previous character // Register the previous character
m_previousCharcode = _charcode; this.previousCharcode = _charcode;
return outputSize; return outputSize;
} }

View File

@ -21,35 +21,35 @@ namespace ewol {
namespace compositing { namespace compositing {
class Text : public ewol::compositing::TextBase { class Text : public ewol::compositing::TextBase {
protected: protected:
ememory::SharedPtr<ewol::resource::TexturedFont> m_font; //!< Font resources ememory::Ptr<ewol::resource::TexturedFont> this.font; //!< Font resources
public: public:
/** /**
* @brief generic constructor * @brief generic ructor
* @param[in] _fontName Name of the font that might be loaded * @param[in] _fontName Name of the font that might be loaded
* @param[in] _fontSize size of the font that might be loaded * @param[in] _fontSize size of the font that might be loaded
*/ */
Text(const etk::String& _fontName="", int32_t _fontSize=-1); Text( String _fontName="", int _fontSize=-1);
/** /**
* @brief generic destructor * @brief generic destructor
*/ */
virtual ~Text(); ~Text();
public: public:
virtual void drawD(bool _disableDepthTest); void drawD(boolean _disableDepthTest);
virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest); void drawMT( mat4 _transformationMatrix, boolean _enableDepthTest);
protected: protected:
float m_size; float this.size;
public: public:
virtual float getHeight(); float getHeight();
virtual float getSize(); float getSize();
virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode); ewol::GlyphProperty * getGlyphPointer(Character _charcode);
public: public:
virtual void setFontSize(int32_t _fontSize); void setFontSize(int _fontSize);
virtual void setFontName(const etk::String& _fontName); void setFontName( String _fontName);
virtual void setFont(etk::String _fontName, int32_t _fontSize); void setFont(String _fontName, int _fontSize);
virtual void setFontMode(enum ewol::font::mode _mode); void setFontMode(enum ewol::font::mode _mode);
virtual void printChar(const char32_t& _charcode); void printChar( Character _charcode);
virtual Vector3f calculateSizeChar(const char32_t& _charcode); Vector3f calculateSizeChar( Character _charcode);
}; };
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -22,13 +22,13 @@ namespace ewol {
*/ */
class TextDecoration { class TextDecoration {
public: public:
etk::Color<float,4> m_colorBg; //!< display background color etk::Color<float,4> this.colorBg; //!< display background color
etk::Color<float,4> m_colorFg; //!< display foreground color etk::Color<float,4> this.colorFg; //!< display foreground color
enum ewol::font::mode m_mode; //!< display mode Regular/Bold/Italic/BoldItalic enum ewol::font::mode this.mode; //!< display mode Regular/Bold/Italic/BoldItalic
TextDecoration() { TextDecoration() {
m_colorBg = etk::color::blue; this.colorBg = etk::color::blue;
m_colorBg = etk::color::green; this.colorBg = etk::color::green;
m_mode = ewol::font::Regular; this.mode = ewol::font::Regular;
} }
}; };
@ -42,158 +42,158 @@ namespace ewol {
class TextBase : public ewol::Compositing { class TextBase : public ewol::Compositing {
protected: protected:
ewol::compositing::Drawing m_vectorialDraw; //!< This is used to draw background selection and other things ... ewol::compositing::Drawing this.vectorialDraw; //!< This is used to draw background selection and other things ...
public: public:
virtual ewol::compositing::Drawing& getDrawing() { ewol::compositing::Drawing getDrawing() {
return m_vectorialDraw; return this.vectorialDraw;
}; };
protected: protected:
int32_t m_nbCharDisplayed; //!< prevent some error in calculation size. int this.nbCharDisplayed; //!< prevent some error in calculation size.
Vector3f m_sizeDisplayStart; //!< The start windows of the display. Vector3f this.sizeDisplayStart; //!< The start windows of the display.
Vector3f m_sizeDisplayStop; //!< The end windows of the display. Vector3f this.sizeDisplayStop; //!< The end windows of the display.
bool m_needDisplay; //!< This just need the display and not the size rendering. boolean this.needDisplay; //!< This just need the display and not the size rendering.
Vector3f m_position; //!< The current position to draw Vector3f this.position; //!< The current position to draw
Vector3f m_clippingPosStart; //!< Clipping start position Vector3f this.clippingPosStart; //!< Clipping start position
Vector3f m_clippingPosStop; //!< Clipping stop position Vector3f this.clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated boolean this.clippingEnable; //!< true if the clipping must be activated
protected: protected:
etk::Color<float,4> m_defaultColorFg; //!< The text foreground color etk::Color<float,4> this.defaultColorFg; //!< The text foreground color
etk::Color<float,4> m_defaultColorBg; //!< The text background color etk::Color<float,4> this.defaultColorBg; //!< The text background color
protected: protected:
etk::Color<float,4> m_color; //!< The text foreground color etk::Color<float,4> this.color; //!< The text foreground color
etk::Color<float,4> m_colorBg; //!< The text background color etk::Color<float,4> this.colorBg; //!< The text background color
etk::Color<float,4> m_colorCursor; //!< The text cursor color etk::Color<float,4> this.colorCursor; //!< The text cursor color
etk::Color<float,4> m_colorSelection; //!< The text Selection color etk::Color<float,4> this.colorSelection; //!< The text Selection color
protected: protected:
enum ewol::font::mode m_mode; //!< font display property : Regular/Bold/Italic/BoldItalic enum ewol::font::mode this.mode; //!< font display property : Regular/Bold/Italic/BoldItalic
bool m_kerning; //!< Kerning enable or disable on the next elements displayed boolean this.kerning; //!< Kerning enable or disable on the next elements displayed
char32_t m_previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning Character this.previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning
protected: protected:
float m_startTextpos; //!< start position of the Alignement (when \n the text return at this position) float this.startTextpos; //!< start position of the Alignement (when \n the text return at this position)
float m_stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this virtual line and the center is perform with this one) float this.stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this line and the center is perform with this one)
enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...) enum aligneMode this.alignement; //!< Current Alignement mode (justify/left/right ...)
protected: protected:
ememory::SharedPtr<gale::resource::Program> m_GLprogram; //!< pointer on the opengl display program ememory::Ptr<gale::resource::Program> this.GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int this.GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int this.GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLColor; //!< openGL id on the element (color buffer) int this.GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position) int this.GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID) int this.GLtexID; //!< openGL id on the element (texture ID)
int32_t m_GLtextWidth; //!< openGL Id on the texture width int this.GLtextWidth; //!< openGL Id on the texture width
int32_t m_GLtextHeight; //!< openGL Id on the texture height int this.GLtextHeight; //!< openGL Id on the texture height
protected: protected:
int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection) int this.selectionStartPos; //!< start position of the Selection (if == this.cursorPos ==> no selection)
int32_t m_cursorPos; //!< Cursor position (default no cursor == > -100) int this.cursorPos; //!< Cursor position (default no cursor == > -100)
protected: // Text protected: // Text
static const int32_t m_vboIdCoord; static int this.vboIdCoord;
static const int32_t m_vboIdCoordText; static int this.vboIdCoordText;
static const int32_t m_vboIdColor; static int this.vboIdColor;
static const int32_t m_vboIdGlyphLevel; static int this.vboIdGlyphLevel;
ememory::SharedPtr<gale::resource::VirtualBufferObject> m_VBO; ememory::Ptr<gale::resource::VirtualBufferObject> this.VBO;
public: public:
/** /**
* @brief load the openGL program and get all the ID needed * @brief load the openGL program and get all the ID needed
*/ */
virtual void loadProgram(const etk::String& _shaderName); void loadProgram( String _shaderName);
public: public:
/** /**
* @brief generic constructor * @brief generic ructor
*/ */
TextBase(const etk::String& _shaderName = "DATA:///text.prog?lib=ewol", bool _loadProgram = true); TextBase( String _shaderName = "DATA:///text.prog?lib=ewol", boolean _loadProgram = true);
/** /**
* @brief generic destructor * @brief generic destructor
*/ */
virtual ~TextBase(); ~TextBase();
public: // Derived function public: // Derived function
void translate(const Vector3f& _vect); void translate( Vector3f _vect);
void rotate(const Vector3f& _vect, float _angle); void rotate( Vector3f _vect, float _angle);
void scale(const Vector3f& _vect); void scale( Vector3f _vect);
public: public:
/** /**
* @brief draw All the refistered text in the current element on openGL * @brief draw All the refistered text in the current element on openGL
*/ */
void draw(bool _disableDepthTest=true) { void draw(boolean _disableDepthTest=true) {
drawD(_disableDepthTest); drawD(_disableDepthTest);
} }
//! @previous //! @previous
void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false) { void draw( mat4 _transformationMatrix, boolean _enableDepthTest=false) {
drawMT(_transformationMatrix, _enableDepthTest); drawMT(_transformationMatrix, _enableDepthTest);
} }
/** /**
* @brief draw All the refistered text in the current element on openGL * @brief draw All the refistered text in the current element on openGL
*/ */
virtual void drawD(bool _disableDepthTest) = 0; void drawD(boolean _disableDepthTest) = 0;
//! @previous //! @previous
virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) = 0; void drawMT( mat4 _transformationMatrix, boolean _enableDepthTest) = 0;
/** /**
* @brief clear all the registered element in the current element * @brief clear all the registered element in the current element
*/ */
virtual void clear(); void clear();
/** /**
* @brief clear all the intermediate result detween 2 prints * @brief clear all the intermediate result detween 2 prints
*/ */
virtual void reset(); void reset();
/** /**
* @brief get the current display position (sometime needed in the gui control) * @brief get the current display position (sometime needed in the gui control)
* @return the current position. * @return the current position.
*/ */
const Vector3f& getPos() { Vector3f getPos() {
return m_position; return this.position;
}; };
/** /**
* @brief set position for the next text writen * @brief set position for the next text writen
* @param[in] _pos Position of the text (in 3D) * @param[in] _pos Position of the text (in 3D)
*/ */
void setPos(const Vector3f& _pos); void setPos( Vector3f _pos);
//! @previous //! @previous
inline void setPos(const Vector2f& _pos) { void setPos( Vector2f _pos) {
setPos(Vector3f(_pos.x(),_pos.y(),0)); setPos(Vector3f(_pos.x(),_pos.y(),0));
}; };
/** /**
* @brief set relative position for the next text writen * @brief set relative position for the next text writen
* @param[in] _pos ofset apply of the text (in 3D) * @param[in] _pos ofset apply of the text (in 3D)
*/ */
void setRelPos(const Vector3f& _pos); void setRelPos( Vector3f _pos);
//! @previous //! @previous
inline void setRelPos(const Vector2f& _pos) { void setRelPos( Vector2f _pos) {
setRelPos(Vector3f(_pos.x(),_pos.y(),0)); setRelPos(Vector3f(_pos.x(),_pos.y(),0));
}; };
/** /**
* @brief set the default background color of the font (when reset, set this value ...) * @brief set the default background color of the font (when reset, set this value ...)
* @param[in] _color Color to set on background * @param[in] _color Color to set on background
*/ */
void setDefaultColorBg(const etk::Color<>& _color) { void setDefaultColorBg( etk::Color<> _color) {
m_defaultColorBg = _color; this.defaultColorBg = _color;
} }
/** /**
* @brief set the default Foreground color of the font (when reset, set this value ...) * @brief set the default Foreground color of the font (when reset, set this value ...)
* @param[in] _color Color to set on foreground * @param[in] _color Color to set on foreground
*/ */
void setDefaultColorFg(const etk::Color<>& _color) { void setDefaultColorFg( etk::Color<> _color) {
m_defaultColorFg = _color; this.defaultColorFg = _color;
} }
/** /**
* @brief set the Color of the current foreground font * @brief set the Color of the current foreground font
* @param[in] _color Color to set on foreground (for next print) * @param[in] _color Color to set on foreground (for next print)
*/ */
void setColor(const etk::Color<>& _color) { void setColor( etk::Color<> _color) {
m_color = _color; this.color = _color;
}; };
/** /**
* @brief set the background color of the font (for selected Text (not the global BG)) * @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _color Color to set on background (for next print) * @param[in] _color Color to set on background (for next print)
*/ */
void setColorBg(const etk::Color<>& _color); void setColorBg( etk::Color<> _color);
/** /**
* @brief Request a clipping area for the text (next draw only) * @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping * @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping * @param[in] _width Width size of the clipping
*/ */
void setClippingWidth(const Vector3f& _pos, const Vector3f& _width) { void setClippingWidth( Vector3f _pos, Vector3f _width) {
setClipping(_pos, _pos+_width); setClipping(_pos, _pos+_width);
} }
//! @previous //! @previous
void setClippingWidth(const Vector2f& _pos, const Vector2f& _width) { void setClippingWidth( Vector2f _pos, Vector2f _width) {
setClipping(_pos, _pos+_width); setClipping(_pos, _pos+_width);
}; };
/** /**
@ -201,9 +201,9 @@ namespace ewol {
* @param[in] _pos Start position of the clipping * @param[in] _pos Start position of the clipping
* @param[in] _posEnd End position of the clipping * @param[in] _posEnd End position of the clipping
*/ */
void setClipping(const Vector3f& _pos, const Vector3f& _posEnd); void setClipping( Vector3f _pos, Vector3f _posEnd);
//! @previous //! @previous
void setClipping(const Vector2f& _pos, const Vector2f& _posEnd) { void setClipping( Vector2f _pos, Vector2f _posEnd) {
setClipping(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_posEnd.x(),_posEnd.y(),1) ); setClipping(Vector3f(_pos.x(),_pos.y(),-1), Vector3f(_posEnd.x(),_posEnd.y(),1) );
}; };
/** /**
@ -211,60 +211,60 @@ namespace ewol {
* @brief _newMode The new status of the clipping * @brief _newMode The new status of the clipping
*/ */
// TODO : Rename setClippingActivity // TODO : Rename setClippingActivity
void setClippingMode(bool _newMode); void setClippingMode(boolean _newMode);
/** /**
* @brief Specify the font size (this reset the internal element of the current text (system requirement) * @brief Specify the font size (this reset the internal element of the current text (system requirement)
* @param[in] _fontSize New font size * @param[in] _fontSize New font size
*/ */
virtual void setFontSize(int32_t _fontSize) = 0; void setFontSize(int _fontSize) = 0;
/** /**
* @brief Specify the font name (this reset the internal element of the current text (system requirement) * @brief Specify the font name (this reset the internal element of the current text (system requirement)
* @param[in] _fontName Current name of the selected font * @param[in] _fontName Current name of the selected font
*/ */
virtual void setFontName(const etk::String& _fontName) = 0; void setFontName( String _fontName) = 0;
/** /**
* @brief Specify the font property (this reset the internal element of the current text (system requirement) * @brief Specify the font property (this reset the internal element of the current text (system requirement)
* @param[in] fontName Current name of the selected font * @param[in] fontName Current name of the selected font
* @param[in] fontSize New font size * @param[in] fontSize New font size
*/ */
virtual void setFont(etk::String _fontName, int32_t _fontSize) = 0; void setFont(String _fontName, int _fontSize) = 0;
/** /**
* @brief Specify the font mode for the next @ref print * @brief Specify the font mode for the next @ref print
* @param[in] mode The font mode requested * @param[in] mode The font mode requested
*/ */
virtual void setFontMode(enum ewol::font::mode _mode) = 0; void setFontMode(enum ewol::font::mode _mode) = 0;
/** /**
* @brief get the current font mode * @brief get the current font mode
* @return The font mode applied * @return The font mode applied
*/ */
enum ewol::font::mode getFontMode() { enum ewol::font::mode getFontMode() {
return m_mode; return this.mode;
}; };
virtual float getHeight() = 0; float getHeight() = 0;
virtual float getSize() = 0; float getSize() = 0;
virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode) = 0; ewol::GlyphProperty * getGlyphPointer(Character _charcode) = 0;
/** /**
* @brief enable or disable the bold mode * @brief enable or disable the bold mode
* @param[in] _status The new status for this display property * @param[in] _status The new status for this display property
*/ */
void setFontBold(bool _status); void setFontBold(boolean _status);
/** /**
* @brief enable or disable the italic mode * @brief enable or disable the italic mode
* @param[in] _status The new status for this display property * @param[in] _status The new status for this display property
*/ */
void setFontItalic(bool _status); void setFontItalic(boolean _status);
/** /**
* @brief set the activation of the Kerning for the display (if it existed) * @brief set the activation of the Kerning for the display (if it existed)
* @param[in] _newMode enable/Diasable the kerning on this font. * @param[in] _newMode enable/Diasable the kerning on this font.
*/ */
void setKerningMode(bool _newMode); void setKerningMode(boolean _newMode);
/** /**
* @brief display a compleat string in the current element. * @brief display a compleat string in the current element.
* @param[in] _text The string to display. * @param[in] _text The string to display.
*/ */
void print(const etk::String& _text); void print( String _text);
//! @previous //! @previous
void print(const etk::UString& _text); void print( etk::UString _text);
/** /**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
* *
@ -294,9 +294,9 @@ namespace ewol {
* @param[in] _text The string to display. * @param[in] _text The string to display.
* @TODO : implementation not done .... * @TODO : implementation not done ....
*/ */
void printDecorated(const etk::String& _text); void printDecorated( String _text);
//! @previous //! @previous
void printDecorated(const etk::UString& _text); void printDecorated( etk::UString _text);
/** /**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
* *
@ -330,22 +330,22 @@ namespace ewol {
* @param[in] _text The string to display. * @param[in] _text The string to display.
* @TODO : implementation not done .... * @TODO : implementation not done ....
*/ */
void printHTML(const etk::String& _text); void printHTML( String _text);
//! @previous //! @previous
void printHTML(const etk::UString& _text); void printHTML( etk::UString _text);
/** /**
* @brief display a compleat string in the current element whith specific decorations (advence mode). * @brief display a compleat string in the current element whith specific decorations (advence mode).
* @param[in] _text The string to display. * @param[in] _text The string to display.
* @param[in] _decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get) * @param[in] _decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get)
*/ */
void print(const etk::String& _text, const List<TextDecoration>& _decoration); void print( String _text, List<TextDecoration> _decoration);
//! @previous //! @previous
void print(const etk::UString& _text, const List<TextDecoration>& _decoration); void print( etk::UString _text, List<TextDecoration> _decoration);
/** /**
* @brief display the current char in the current element (note that the kerning is availlable if the position is not changed) * @brief display the current char in the current element (note that the kerning is availlable if the position is not changed)
* @param[in] _charcode Char that might be dispalyed * @param[in] _charcode Char that might be dispalyed
*/ */
virtual void printChar(const char32_t& _charcode) = 0; void printChar( Character _charcode) = 0;
/** /**
* @brief This generate the line return == > it return to the alignement position start and at the correct line position ==> it might be use to not know the line height * @brief This generate the line return == > it return to the alignement position start and at the correct line position ==> it might be use to not know the line height
*/ */
@ -355,7 +355,7 @@ namespace ewol {
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include). * @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
* @param[in] _element the exml element. * @param[in] _element the exml element.
*/ */
void parseHtmlNode(const exml::Element& _element); void parseHtmlNode( exml::Element _element);
public: public:
/** /**
* @brief This generate the possibility to generate the big text property * @brief This generate the possibility to generate the big text property
@ -379,43 +379,43 @@ namespace ewol {
* @param[in] _text The string to calculate dimention. * @param[in] _text The string to calculate dimention.
* @return The theoric size used. * @return The theoric size used.
*/ */
Vector3f calculateSizeHTML(const etk::String& _text); Vector3f calculateSizeHTML( String _text);
//! @previous //! @previous
Vector3f calculateSizeHTML(const etk::UString& _text); Vector3f calculateSizeHTML( etk::UString _text);
/** /**
* @brief calculate a theoric text size * @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention. * @param[in] _text The string to calculate dimention.
* @return The theoric size used. * @return The theoric size used.
*/ */
Vector3f calculateSizeDecorated(const etk::String& _text); Vector3f calculateSizeDecorated( String _text);
//! @previous //! @previous
Vector3f calculateSizeDecorated(const etk::UString& _text); Vector3f calculateSizeDecorated( etk::UString _text);
/** /**
* @brief calculate a theoric text size * @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention. * @param[in] _text The string to calculate dimention.
* @return The theoric size used. * @return The theoric size used.
*/ */
Vector3f calculateSize(const etk::String& _text); Vector3f calculateSize( String _text);
//! @previous //! @previous
Vector3f calculateSize(const etk::UString& _text); Vector3f calculateSize( etk::UString _text);
/** /**
* @brief calculate a theoric charcode size * @brief calculate a theoric charcode size
* @param[in] _charcode The Unicode value to calculate dimention. * @param[in] _charcode The Unicode value to calculate dimention.
* @return The theoric size used. * @return The theoric size used.
*/ */
inline Vector3f calculateSize(const char32_t& _charcode) { Vector3f calculateSize( Character _charcode) {
return calculateSizeChar(_charcode); return calculateSizeChar(_charcode);
}; };
protected: protected:
//! @previous //! @previous
virtual Vector3f calculateSizeChar(const char32_t& _charcode) = 0; Vector3f calculateSizeChar( Character _charcode) = 0;
public: public:
/** /**
* @brief draw a cursor at the specify position * @brief draw a cursor at the specify position
* @param[in] _isInsertMode True if the insert mode is activated * @param[in] _isInsertMode True if the insert mode is activated
* @param[in] _cursorSize The sizae of the cursor that might be set when insert mode is set [default 20] * @param[in] _cursorSize The sizae of the cursor that might be set when insert mode is set [default 20]
*/ */
void printCursor(bool _isInsertMode, float _cursorSize = 20.0f); void printCursor(boolean _isInsertMode, float _cursorSize = 20.0f);
protected: protected:
/** /**
* @brief calculate the element number that is the first out the alignement range * @brief calculate the element number that is the first out the alignement range
@ -428,19 +428,19 @@ namespace ewol {
* @return true if the rifht has free space that can be use for jystify. * @return true if the rifht has free space that can be use for jystify.
* @return false if we find '\n' * @return false if we find '\n'
*/ */
bool extrapolateLastId(const etk::String& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); boolean extrapolateLastId( String _text, int _start, int _stop, int _space, int _freeSpace);
//! @previous //! @previous
bool extrapolateLastId(const etk::UString& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); boolean extrapolateLastId( etk::UString _text, int _start, int _stop, int _space, int _freeSpace);
protected: protected:
// this section is reserved for HTML parsing and display: // this section is reserved for HTML parsing and display:
etk::UString m_htmlCurrrentLine; //!< current line for HTML display etk::UString this.htmlCurrrentLine; //!< current line for HTML display
List<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display List<TextDecoration> this.htmlDecoration; //!< current decoration for the HTML display
TextDecoration m_htmlDecoTmp; //!< current decoration TextDecoration this.htmlDecoTmp; //!< current decoration
/** /**
* @brief add a line with the current m_htmlDecoTmp decoration * @brief add a line with the current this.htmlDecoTmp decoration
* @param[in] _data The cuurent data to add. * @param[in] _data The cuurent data to add.
*/ */
void htmlAddData(const etk::UString& _data); void htmlAddData( etk::UString _data);
/** /**
* @brief draw the current line * @brief draw the current line
*/ */
@ -454,23 +454,23 @@ namespace ewol {
* @brief set a cursor at a specific position: * @brief set a cursor at a specific position:
* @param[in] _cursorPos id of the cursor position * @param[in] _cursorPos id of the cursor position
*/ */
void setCursorPos(int32_t _cursorPos); void setCursorPos(int _cursorPos);
/** /**
* @brief set a cursor at a specific position with his associated selection: * @brief set a cursor at a specific position with his associated selection:
* @param[in] _cursorPos id of the cursor position * @param[in] _cursorPos id of the cursor position
* @param[in] _selectionStartPos id of the starting of the selection * @param[in] _selectionStartPos id of the starting of the selection
*/ */
void setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos); void setCursorSelection(int _cursorPos, int _selectionStartPos);
/** /**
* @brief change the selection color * @brief change the selection color
* @param[in] _color New color for the Selection * @param[in] _color New color for the Selection
*/ */
void setSelectionColor(const etk::Color<>& _color); void setSelectionColor( etk::Color<> _color);
/** /**
* @brief change the cursor color * @brief change the cursor color
* @param[in] _color New color for the Selection * @param[in] _color New color for the Selection
*/ */
void setCursorColor(const etk::Color<>& _color); void setCursorColor( etk::Color<> _color);
}; };
} }
} }

View File

@ -11,11 +11,11 @@
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::compositing::TextDF); ETK_DECLARE_TYPE(ewol::compositing::TextDF);
ewol::compositing::TextDF::TextDF(const etk::String& _fontName, int32_t _fontSize) : ewol::compositing::TextDF::TextDF( String _fontName, int _fontSize) :
ewol::compositing::TextBase("", false), ewol::compositing::TextBase("", false),
m_fontDF(null), this.fontDF(null),
m_GLglyphLevel(-1), this.GLglyphLevel(-1),
m_size(12.0) { this.size(12.0) {
setFont(_fontName, _fontSize); setFont(_fontName, _fontSize);
loadProgram("DATA:///fontDistanceField/font1.prog?lib=ewol"); loadProgram("DATA:///fontDistanceField/font1.prog?lib=ewol");
} }
@ -24,26 +24,26 @@ ewol::compositing::TextDF::~TextDF() {
} }
void ewol::compositing::TextDF::updateSizeToRender(const Vector2f& _size) { void ewol::compositing::TextDF::updateSizeToRender( Vector2f _size) {
float minSize = etk::min(_size.x(), _size.y()); float minSize = etk::min(_size.x(), _size.y());
if (m_fontDF != null) { if (this.fontDF != null) {
setFontSize(m_fontDF->getSize(minSize)); setFontSize(this.fontDF.getSize(minSize));
} }
} }
void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) { void ewol::compositing::TextDF::drawMT( mat4 _transformationMatrix, boolean _enableDepthTest) {
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(); this.vectorialDraw.draw();
if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 if ( this.VBO.bufferSize(this.vboIdCoord) <= 0
|| m_fontDF == null) { || this.fontDF == null) {
//EWOL_WARNING("Nothink to draw..."); //Log.warning("Nothink to draw...");
return; return;
} }
if (m_fontDF == null) { if (this.fontDF == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
@ -54,127 +54,127 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
mat4 projMatrix = gale::openGL::getMatrix(); mat4 projMatrix = gale::openGL::getMatrix();
mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix();
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
m_GLprogram->use(); this.GLprogram.use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// Texture: // Texture:
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.fontDF.getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextWidth, this.fontDF.getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextHeight, this.fontDF.getOpenGlSize().x());
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText);
m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor);
m_GLprogram->sendAttributePointer(m_GLglyphLevel, m_VBO, m_vboIdGlyphLevel); this.GLprogram.sendAttributePointer(this.GLglyphLevel, this.VBO, this.vboIdGlyphLevel);
// Request the draw od the elements: // Request the draw od the elements:
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
m_GLprogram->unUse(); this.GLprogram.unUse();
if (_enableDepthTest == true) { if (_enableDepthTest == true) {
gale::openGL::disable(gale::openGL::flag_depthTest); gale::openGL::disable(gale::openGL::flag_depthTest);
} }
} }
void ewol::compositing::TextDF::drawD(bool _disableDepthTest) { void ewol::compositing::TextDF::drawD(boolean _disableDepthTest) {
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(); this.vectorialDraw.draw();
if ( m_VBO->bufferSize(m_vboIdCoord) <= 0 if ( this.VBO.bufferSize(this.vboIdCoord) <= 0
|| m_fontDF == null) { || this.fontDF == null) {
// TODO : Set it back // TODO : Set it back
//EWOL_WARNING("Nothink to draw..."); //Log.warning("Nothink to draw...");
return; return;
} }
if (m_fontDF == null) { if (this.fontDF == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; mat4 tmpMatrix = gale::openGL::getMatrix()*this.matrixApply;
m_GLprogram->use(); this.GLprogram.use();
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// Texture: // Texture:
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getRendererId()); this.GLprogram.setTexture0(this.GLtexID, this.fontDF.getRendererId());
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextWidth, this.fontDF.getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x()); this.GLprogram.uniform1i(this.GLtextHeight, this.fontDF.getOpenGlSize().x());
m_GLprogram->sendAttributePointer(m_GLPosition, m_VBO, m_vboIdCoord); this.GLprogram.sendAttributePointer(this.GLPosition, this.VBO, this.vboIdCoord);
m_GLprogram->sendAttributePointer(m_GLtexture, m_VBO, m_vboIdCoordText); this.GLprogram.sendAttributePointer(this.GLtexture, this.VBO, this.vboIdCoordText);
m_GLprogram->sendAttributePointer(m_GLColor, m_VBO, m_vboIdColor); this.GLprogram.sendAttributePointer(this.GLColor, this.VBO, this.vboIdColor);
m_GLprogram->sendAttributePointer(m_GLglyphLevel, m_VBO, m_vboIdGlyphLevel); this.GLprogram.sendAttributePointer(this.GLglyphLevel, this.VBO, this.vboIdGlyphLevel);
// Request the draw od the elements: // Request the draw od the elements:
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_VBO->bufferSize(m_vboIdCoord)); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, this.VBO.bufferSize(this.vboIdCoord));
m_GLprogram->unUse(); this.GLprogram.unUse();
} }
void ewol::compositing::TextDF::loadProgram(const etk::String& _shaderName) { void ewol::compositing::TextDF::loadProgram( String _shaderName) {
ewol::compositing::TextBase::loadProgram(_shaderName); ewol::compositing::TextBase::loadProgram(_shaderName);
if (m_GLprogram != null) { if (this.GLprogram != null) {
m_GLglyphLevel = m_GLprogram->getAttribute("EW_glyphLevel"); this.GLglyphLevel = this.GLprogram.getAttribute("EW_glyphLevel");
} }
} }
float ewol::compositing::TextDF::getHeight() { float ewol::compositing::TextDF::getHeight() {
if (m_fontDF == null) { if (this.fontDF == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return 1; return 1;
} }
return m_fontDF->getHeight(m_size); return this.fontDF.getHeight(this.size);
} }
ewol::GlyphProperty * ewol::compositing::TextDF::getGlyphPointer(char32_t _charcode) { ewol::GlyphProperty * ewol::compositing::TextDF::getGlyphPointer(Character _charcode) {
if (m_fontDF == null) { if (this.fontDF == null) {
EWOL_WARNING("no font..."); Log.warning("no font...");
return null; return null;
} }
return m_fontDF->getGlyphPointer(_charcode); return this.fontDF.getGlyphPointer(_charcode);
} }
void ewol::compositing::TextDF::setFontSize(int32_t _fontSize) { void ewol::compositing::TextDF::setFontSize(int _fontSize) {
clear(); clear();
Log.verbose("Set font Size: " << _fontSize); Log.verbose("Set font Size: " + _fontSize);
if (_fontSize <= 1) { if (_fontSize <= 1) {
m_size = ewol::getContext().getFontDefault().getSize(); this.size = ewol::getContext().getFontDefault().getSize();
} else { } else {
m_size = _fontSize; this.size = _fontSize;
} }
} }
void ewol::compositing::TextDF::setFontName(const etk::String& _fontName) { void ewol::compositing::TextDF::setFontName( String _fontName) {
clear(); clear();
// remove old one // remove old one
ememory::SharedPtr<ewol::resource::DistanceFieldFont> previousFont = m_fontDF; ememory::Ptr<ewol::resource::DistanceFieldFont> previousFont = this.fontDF;
etk::String fontName; String fontName;
if (_fontName == "") { if (_fontName == "") {
fontName = ewol::getContext().getFontDefault().getName(); fontName = ewol::getContext().getFontDefault().getName();
} else { } else {
fontName = _fontName; fontName = _fontName;
} }
Log.verbose("Set font name: '" << fontName << "'"); Log.verbose("Set font name: '" + fontName + "'");
// link to new one // link to new one
m_fontDF = ewol::resource::DistanceFieldFont::create(fontName); this.fontDF = ewol::resource::DistanceFieldFont::create(fontName);
if (m_fontDF == null) { if (this.fontDF == null) {
Log.error("Can not get find resource"); Log.error("Can not get find resource");
m_fontDF = previousFont; this.fontDF = previousFont;
} }
} }
void ewol::compositing::TextDF::setFont(etk::String _fontName, int32_t _fontSize) { void ewol::compositing::TextDF::setFont(String _fontName, int _fontSize) {
setFontSize(_fontSize); setFontSize(_fontSize);
setFontName(_fontName); setFontName(_fontName);
} }
void ewol::compositing::TextDF::setFontMode(enum ewol::font::mode _mode) { void ewol::compositing::TextDF::setFontMode(enum ewol::font::mode _mode) {
m_mode = _mode; this.mode = _mode;
} }
//#define ANGLE_OF_ITALIC (tan(0.4)) //#define ANGLE_OF_ITALIC (tan(0.4))
#define ANGLE_OF_ITALIC (0.00698143f) #define ANGLE_OF_ITALIC (0.00698143f)
void ewol::compositing::TextDF::printChar(const char32_t& _charcode) { void ewol::compositing::TextDF::printChar( Character _charcode) {
// get a pointer on the glyph property : // get a pointer on the glyph property :
ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode); ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode);
if (null == myGlyph) { if (null == myGlyph) {
@ -184,29 +184,29 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
float fontSize = getSize(); float fontSize = getSize();
float fontHeigh = getHeight(); float fontHeigh = getHeight();
float factorDisplay = m_fontDF->getDisplayRatio(fontSize); float factorDisplay = this.fontDF.getDisplayRatio(fontSize);
// get the kerning ofset : // get the kerning ofset :
float kerningOffset = 0; float kerningOffset = 0;
if (true == m_kerning) { if (true == this.kerning) {
kerningOffset = myGlyph->kerningGet(m_previousCharcode); kerningOffset = myGlyph.kerningGet(this.previousCharcode);
if (kerningOffset != 0) { if (kerningOffset != 0) {
//Log.debug("Kerning between : '" << m_previousCharcode << "'&'" << myGlyph->m_UVal << "' value : " << kerningOffset); //Log.debug("Kerning between : '" + this.previousCharcode + "''" + myGlyph.this.UVal + "' value : " + kerningOffset);
} }
} }
// 0x01 == 0x20 == ' '; // 0x01 == 0x20 == ' ';
if ( _charcode != 0x01 if ( _charcode != 0x01
&& _charcode != 0x20) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _charcode != 0x20) {
float glyphLevel = 0.5f; float glyphLevel = 0.5f;
if ( m_mode == ewol::font::BoldItalic if ( this.mode == ewol::font::BoldItalic
|| m_mode == ewol::font::Bold) { || this.mode == ewol::font::Bold) {
glyphLevel = 0.41f; glyphLevel = 0.41f;
} }
float italicMove = 0.0f; float italicMove = 0.0f;
if ( m_mode == ewol::font::BoldItalic if ( this.mode == ewol::font::BoldItalic
|| m_mode == ewol::font::Italic) { || this.mode == ewol::font::Italic) {
// This is a simple version of Italic mode, in theory we need to move the up and the down... // This is a simple version of Italic mode, in theory we need to move the up and the down...
italicMove = (float)myGlyph->m_sizeTexture.y() * factorDisplay * ANGLE_OF_ITALIC; italicMove = (float)myGlyph.this.sizeTexture.y() * factorDisplay * ANGLE_OF_ITALIC;
// TODO : pb on the clipper... // TODO : pb on the clipper...
} }
@ -218,79 +218,79 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
* yD *------* * yD *------*
*/ */
#if 0 #if 0
float dxA = m_position.x() + (myGlyph->m_bearing.x() + kerningOffset) * factorDisplay; float dxA = this.position.x() + (myGlyph.this.bearing.x() + kerningOffset) * factorDisplay;
float dxB = dxA + myGlyph->m_sizeTexture.x() * factorDisplay; float dxB = dxA + myGlyph.this.sizeTexture.x() * factorDisplay;
float dyC = m_position.y() + (myGlyph->m_bearing.y() + fontHeigh - fontSize) * factorDisplay; float dyC = this.position.y() + (myGlyph.this.bearing.y() + fontHeigh - fontSize) * factorDisplay;
float dyD = dyC - myGlyph->m_sizeTexture.y() * factorDisplay; float dyD = dyC - myGlyph.this.sizeTexture.y() * factorDisplay;
#else #else
//Log.debug(" plop : fontHeigh" << fontHeigh << " fontSize=" << fontSize); //Log.debug(" plop : fontHeigh" + fontHeigh + " fontSize=" + fontSize);
float dxA = m_position.x() + ((float)myGlyph->m_bearing.x() + kerningOffset - (float)m_fontDF->getPixelBorderSize()*0.5f) * factorDisplay; float dxA = this.position.x() + ((float)myGlyph.this.bearing.x() + kerningOffset - (float)this.fontDF.getPixelBorderSize()*0.5f) * factorDisplay;
float dxB = dxA + ((float)myGlyph->m_sizeTexture.x() + (float)m_fontDF->getPixelBorderSize()) * factorDisplay; float dxB = dxA + ((float)myGlyph.this.sizeTexture.x() + (float)this.fontDF.getPixelBorderSize()) * factorDisplay;
float dyC = m_position.y() + (fontHeigh - fontSize + ((float)myGlyph->m_bearing.y() + (float)m_fontDF->getPixelBorderSize()*0.5f) * factorDisplay); float dyC = this.position.y() + (fontHeigh - fontSize + ((float)myGlyph.this.bearing.y() + (float)this.fontDF.getPixelBorderSize()*0.5f) * factorDisplay);
float dyD = dyC - ((float)myGlyph->m_sizeTexture.y() + (float)m_fontDF->getPixelBorderSize()) * factorDisplay; float dyD = dyC - ((float)myGlyph.this.sizeTexture.y() + (float)this.fontDF.getPixelBorderSize()) * factorDisplay;
#endif #endif
float tuA = myGlyph->m_texturePosStart.x(); float tuA = myGlyph.this.texturePosStart.x();
float tuB = tuA + myGlyph->m_texturePosSize.x(); float tuB = tuA + myGlyph.this.texturePosSize.x();
float tvC = myGlyph->m_texturePosStart.y(); float tvC = myGlyph.this.texturePosStart.y();
float tvD = tvC + myGlyph->m_texturePosSize.y(); float tvD = tvC + myGlyph.this.texturePosSize.y();
/* /*
Vector3f drawingPos = m_vectorialDraw.getPos(); Vector3f drawingPos = this.vectorialDraw.getPos();
etk::Color<> backColor = m_vectorialDraw.getColor(); etk::Color<> backColor = this.vectorialDraw.getColor();
m_vectorialDraw.setPos(Vector2f(dxA, dyC)); this.vectorialDraw.setPos(Vector2f(dxA, dyC));
m_vectorialDraw.setColor(etk::Color<>(0.0,1.0,0.0,1.0)); this.vectorialDraw.setColor(etk::Color<>(0.0,1.0,0.0,1.0));
m_vectorialDraw.rectangle(Vector2f(dxB, dyD)); this.vectorialDraw.rectangle(Vector2f(dxB, dyD));
m_vectorialDraw.setPos(drawingPos); this.vectorialDraw.setPos(drawingPos);
m_vectorialDraw.setColor(backColor); this.vectorialDraw.setColor(backColor);
*/ */
// Clipping and drawing area // Clipping and drawing area
if( m_clippingEnable == true if( this.clippingEnable == true
&& ( dxB < m_clippingPosStart.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( dxB < this.clippingPosStart.x()
|| dxA > m_clippingPosStop.x() || dxA > this.clippingPosStop.x()
|| dyC < m_clippingPosStart.y() || dyC < this.clippingPosStart.y()
|| dyD > m_clippingPosStop.y() ) ) { || dyD > this.clippingPosStop.y() ) ) {
// Nothing to diplay ... // Nothing to diplay ...
} else { } else {
if (m_clippingEnable == true) { if (this.clippingEnable == true) {
// generata positions... // generata positions...
float TexSizeX = tuB - tuA; float TexSizeX = tuB - tuA;
if (dxA < m_clippingPosStart.x()) { if (dxA < this.clippingPosStart.x()) {
// clip display // clip display
float drawSize = m_clippingPosStart.x() - dxA; float drawSize = this.clippingPosStart.x() - dxA;
// update element start display // update element start display
dxA = m_clippingPosStart.x(); dxA = this.clippingPosStart.x();
float addElement = TexSizeX * drawSize / ((float)myGlyph->m_sizeTexture.x() * factorDisplay); float addElement = TexSizeX * drawSize / ((float)myGlyph.this.sizeTexture.x() * factorDisplay);
// update texture start X Pos // update texture start X Pos
tuA += addElement; tuA += addElement;
} }
if (dxB > m_clippingPosStop.x()) { if (dxB > this.clippingPosStop.x()) {
// clip display // clip display
float drawSize = dxB - m_clippingPosStop.x(); float drawSize = dxB - this.clippingPosStop.x();
// update element start display // update element start display
dxB = m_clippingPosStop.x(); dxB = this.clippingPosStop.x();
float addElement = TexSizeX * drawSize / ((float)myGlyph->m_sizeTexture.x() * factorDisplay); float addElement = TexSizeX * drawSize / ((float)myGlyph.this.sizeTexture.x() * factorDisplay);
// update texture start X Pos // update texture start X Pos
tuB -= addElement; tuB -= addElement;
} }
float TexSizeY = tvC - tvD; float TexSizeY = tvC - tvD;
if (dyC > m_clippingPosStop.y()) { if (dyC > this.clippingPosStop.y()) {
// clip display // clip display
float drawSize = dyC - m_clippingPosStop.y(); float drawSize = dyC - this.clippingPosStop.y();
// update element start display // update element start display
dyC = m_clippingPosStop.y(); dyC = this.clippingPosStop.y();
float addElement = TexSizeY * drawSize / ((float)myGlyph->m_sizeTexture.y() * factorDisplay); float addElement = TexSizeY * drawSize / ((float)myGlyph.this.sizeTexture.y() * factorDisplay);
// update texture start X Pos // update texture start X Pos
tvC -= addElement; tvC -= addElement;
} }
if (dyD < m_clippingPosStart.y()) { if (dyD < this.clippingPosStart.y()) {
// clip display // clip display
float drawSize = m_clippingPosStart.y() - dyD; float drawSize = this.clippingPosStart.y() - dyD;
// update element start display // update element start display
dyD = m_clippingPosStart.y(); dyD = this.clippingPosStart.y();
float addElement = TexSizeY * drawSize / ((float)myGlyph->m_sizeTexture.y() * factorDisplay); float addElement = TexSizeY * drawSize / ((float)myGlyph.this.sizeTexture.y() * factorDisplay);
// update texture start X Pos // update texture start X Pos
tvD += addElement; tvD += addElement;
} }
@ -305,7 +305,7 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
* | | * | |
* 3------2 * 3------2
*/ */
if (m_needDisplay == true) { if (this.needDisplay == true) {
Vector3f bitmapDrawPos[4]; Vector3f bitmapDrawPos[4];
bitmapDrawPos[0].setValue(dxA+italicMove, dyC, 0); bitmapDrawPos[0].setValue(dxA+italicMove, dyC, 0);
bitmapDrawPos[1].setValue(dxB+italicMove, dyC, 0); bitmapDrawPos[1].setValue(dxB+italicMove, dyC, 0);
@ -318,10 +318,10 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
* 3------2 * 3------2
*/ */
Vector2f texturePos[4]; Vector2f texturePos[4];
texturePos[0].setValue(tuA+m_mode, tvC); texturePos[0].setValue(tuA+this.mode, tvC);
texturePos[1].setValue(tuB+m_mode, tvC); texturePos[1].setValue(tuB+this.mode, tvC);
texturePos[2].setValue(tuB+m_mode, tvD); texturePos[2].setValue(tuB+this.mode, tvD);
texturePos[3].setValue(tuA+m_mode, tvD); texturePos[3].setValue(tuA+this.mode, tvD);
// NOTE : Android does not support the Quads elements ... // NOTE : Android does not support the Quads elements ...
/* Step 1 : /* Step 1 :
@ -332,21 +332,21 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
* *
*/ */
// set texture coordonates : // set texture coordonates :
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[1]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[1]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]);
// set display positions : // set display positions :
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[1]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[1]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]);
// set the color // set the color
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
// set the bliph level // set the bliph level
m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel);
m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel);
m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel);
/* Step 2 : /* Step 2 :
* *
* ** * **
@ -355,52 +355,52 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
* ******** * ********
*/ */
// set texture coordonates : // set texture coordonates :
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[0]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[0]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[2]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[2]);
m_VBO->pushOnBuffer(m_vboIdCoordText, texturePos[3]); this.VBO.pushOnBuffer(this.vboIdCoordText, texturePos[3]);
// set display positions : // set display positions :
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[0]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[0]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[2]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[2]);
m_VBO->pushOnBuffer(m_vboIdCoord, bitmapDrawPos[3]); this.VBO.pushOnBuffer(this.vboIdCoord, bitmapDrawPos[3]);
// set the color // set the color
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
m_VBO->pushOnBuffer(m_vboIdColor, m_color); this.VBO.pushOnBuffer(this.vboIdColor, this.color);
// set the bliph level // set the bliph level
m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel);
m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel);
m_VBO->pushOnBuffer(m_vboIdGlyphLevel, glyphLevel); this.VBO.pushOnBuffer(this.vboIdGlyphLevel, glyphLevel);
} }
} }
} }
} }
// move the position : // move the position :
//Log.debug(" 5 pos=" << m_position << " advance=" << myGlyph->m_advance.x() << " kerningOffset=" << kerningOffset); //Log.debug(" 5 pos=" + this.position + " advance=" + myGlyph.this.advance.x() + " kerningOffset=" + kerningOffset);
m_position.setX(m_position.x() + (myGlyph->m_advance.x() + kerningOffset) * factorDisplay); this.position.setX(this.position.x() + (myGlyph.this.advance.x() + kerningOffset) * factorDisplay);
//Log.debug(" 6 print '" << charcode << "' : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); //Log.debug(" 6 print '" + charcode + "' : start=" + this.sizeDisplayStart + " stop=" + this.sizeDisplayStop + " pos=" + this.position);
// Register the previous character // Register the previous character
m_previousCharcode = _charcode; this.previousCharcode = _charcode;
m_VBO->flush(); this.VBO.flush();
return; return;
} }
Vector3f ewol::compositing::TextDF::calculateSizeChar(const char32_t& _charcode) { Vector3f ewol::compositing::TextDF::calculateSizeChar( Character _charcode) {
// get a pointer on the glyph property : // get a pointer on the glyph property :
ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode); ewol::GlyphProperty * myGlyph = getGlyphPointer(_charcode);
int32_t fontHeigh = getHeight(); int fontHeigh = getHeight();
// get the kerning ofset : // get the kerning ofset :
float kerningOffset = 0.0; float kerningOffset = 0.0;
if (true == m_kerning) { if (true == this.kerning) {
kerningOffset = myGlyph->kerningGet(m_previousCharcode); kerningOffset = myGlyph.kerningGet(this.previousCharcode);
} }
Vector3f outputSize((float)(myGlyph->m_advance.x() + kerningOffset)*m_fontDF->getDisplayRatio(getSize()), Vector3f outputSize((float)(myGlyph.this.advance.x() + kerningOffset)*this.fontDF.getDisplayRatio(getSize()),
(float)(fontHeigh), (float)(fontHeigh),
(float)(0.0)); (float)(0.0));
// Register the previous character // Register the previous character
m_previousCharcode = _charcode; this.previousCharcode = _charcode;
return outputSize; return outputSize;
} }

View File

@ -19,50 +19,50 @@ namespace ewol {
namespace compositing { namespace compositing {
class TextDF : public ewol::compositing::TextBase { class TextDF : public ewol::compositing::TextBase {
protected: protected:
ememory::SharedPtr<ewol::resource::DistanceFieldFont> m_fontDF; //!< Font resources ememory::Ptr<ewol::resource::DistanceFieldFont> this.fontDF; //!< Font resources
protected: protected:
int32_t m_GLglyphLevel; //!< openGL Id on the glyph level display int this.GLglyphLevel; //!< openGL Id on the glyph level display
public: public:
/** /**
* @brief generic constructor * @brief generic ructor
* @param[in] _fontName Name of the font that might be loaded * @param[in] _fontName Name of the font that might be loaded
* @param[in] _fontSize size of the font that might be loaded * @param[in] _fontSize size of the font that might be loaded
*/ */
TextDF(const etk::String& _fontName="", int32_t _fontSize=-1); TextDF( String _fontName="", int _fontSize=-1);
/** /**
* @brief generic destructor * @brief generic destructor
*/ */
virtual ~TextDF(); ~TextDF();
public: public:
/** /**
* @brief Calculate size to be at the best size for a render in this special size. * @brief Calculate size to be at the best size for a render in this special size.
* @note special for Distance field mode. * @note special for Distance field mode.
* @param[in] _size request dimention. * @param[in] _size request dimention.
*/ */
void updateSizeToRender(const Vector2f& _size); void updateSizeToRender( Vector2f _size);
public: public:
virtual void drawD(bool _disableDepthTest); void drawD(boolean _disableDepthTest);
virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest); void drawMT( mat4 _transformationMatrix, boolean _enableDepthTest);
protected: protected:
float m_size; float this.size;
public: public:
virtual float getHeight(); float getHeight();
virtual float getSize() { float getSize() {
return m_size; return this.size;
} }
virtual void setSize(float _size) { void setSize(float _size) {
m_size = _size; this.size = _size;
} }
virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode); ewol::GlyphProperty * getGlyphPointer(Character _charcode);
public: public:
virtual void loadProgram(const etk::String& _shaderName); void loadProgram( String _shaderName);
virtual void setFontSize(int32_t _fontSize); void setFontSize(int _fontSize);
virtual void setFontName(const etk::String& _fontName); void setFontName( String _fontName);
virtual void setFont(etk::String _fontName, int32_t _fontSize); void setFont(String _fontName, int _fontSize);
virtual void setFontMode(enum ewol::font::mode _mode); void setFontMode(enum ewol::font::mode _mode);
virtual void printChar(const char32_t& _charcode); void printChar( Character _charcode);
virtual Vector3f calculateSizeChar(const char32_t& _charcode); Vector3f calculateSizeChar( Character _charcode);
}; };
} }
} }

View File

@ -9,41 +9,41 @@
#include <ewol/context/Context.hpp> #include <ewol/context/Context.hpp>
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::context::Application); ETK_DECLARE_TYPE(EwolApplication);
ewol::context::Application::Application() { EwolApplication::Application() {
} }
ewol::context::Application::~Application() { EwolApplication::~Application() {
} }
void ewol::context::Application::onCreate(ewol::Context& _context) { void EwolApplication::onCreate(EwolContext _context) {
} }
void ewol::context::Application::onStart(ewol::Context& _context) { void EwolApplication::onStart(EwolContext _context) {
} }
void ewol::context::Application::onResume(ewol::Context& _context) { void EwolApplication::onResume(EwolContext _context) {
} }
void ewol::context::Application::onPause(ewol::Context& _context) { void EwolApplication::onPause(EwolContext _context) {
} }
void ewol::context::Application::onStop(ewol::Context& _context) { void EwolApplication::onStop(EwolContext _context) {
} }
void ewol::context::Application::onDestroy(ewol::Context& _context) { void EwolApplication::onDestroy(EwolContext _context) {
} }
void ewol::context::Application::onKillDemand(ewol::Context& _context) { void EwolApplication::onKillDemand(EwolContext _context) {
_context.exit(0); _context.exit(0);
} }

View File

@ -1,54 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
namespace ewol {
class Context;
namespace context {
class Application {
public:
Application();
virtual ~Application();
public:
/**
* @brief The application is created.
* @param[in] _context Current ewol context.
*/
virtual void onCreate(ewol::Context& _context);
/**
* @brief The application is started.
* @param[in] _context Current ewol context.
*/
virtual void onStart(ewol::Context& _context);
/**
* @brief The application is resumed (now visible).
* @param[in] _context Current ewol context.
*/
virtual void onResume(ewol::Context& _context);
/**
* @brief The application is Hide / not visible.
* @param[in] _context Current ewol context.
*/
virtual void onPause(ewol::Context& _context);
/**
* @brief The application is stopped.
* @param[in] _context Current ewol context.
*/
virtual void onStop(ewol::Context& _context);
/**
* @brief The application is removed (call destructor just adter it.).
* @param[in] _context Current ewol context.
*/
virtual void onDestroy(ewol::Context& _context);
/**
* @brief The user request application removing.
* @param[in] _context Current ewol context.
*/
virtual void onKillDemand(ewol::Context& _context);
};
};
};

View File

@ -7,37 +7,37 @@
#include <ewol/context/ConfigFont.hpp> #include <ewol/context/ConfigFont.hpp>
#include <ewol/resource/FontFreeType.hpp> #include <ewol/resource/FontFreeType.hpp>
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::context::ConfigFont); ETK_DECLARE_TYPE(ConfigFont);
ewol::context::ConfigFont::ConfigFont() : ConfigFont::ConfigFont() :
m_folder("DATA:///fonts?lib=ewol"), this.folder("DATA:///fonts?lib=ewol"),
m_name("Arial;Helvetica"), this.name("Arial;Helvetica"),
m_size(10), this.size(10),
m_useExternal(false) { this.useExternal(false) {
#ifdef __TARGET_OS__Android #ifdef __TARGET_OS__Android
m_name = "Roboto;DroidSans"; this.name = "Roboto;DroidSans";
#endif #endif
ewol::resource::freeTypeInit(); ewol::resource::freeTypeInit();
} }
ewol::context::ConfigFont::~ConfigFont() { ConfigFont::~ConfigFont() {
// UnInit FreeTypes // UnInit FreeTypes
ewol::resource::freeTypeUnInit(); ewol::resource::freeTypeUnInit();
} }
void ewol::context::ConfigFont::set(const etk::String& _fontName, int32_t _size) { void ConfigFont::set( String _fontName, int _size) {
m_name = _fontName; this.name = _fontName;
m_size = _size; this.size = _size;
Log.debug("Set default Font : '" << m_name << "' size=" << m_size); Log.debug("Set default Font : '" + this.name + "' size=" + this.size);
} }
void ewol::context::ConfigFont::setSize(int32_t _size) { void ConfigFont::setSize(int _size) {
m_size = _size; this.size = _size;
Log.debug("Set default Font : '" << m_name << "' size=" << m_size << " (change size only)"); Log.debug("Set default Font : '" + this.name + "' size=" + this.size + " (change size only)");
} }
void ewol::context::ConfigFont::setName(const etk::String& _fontName) { void ConfigFont::setName( String _fontName) {
m_name = _fontName; this.name = _fontName;
Log.debug("Set default Font : '" << m_name << "' size=" << m_size << " (change name only)"); Log.debug("Set default Font : '" + this.name + "' size=" + this.size + " (change name only)");
} }

View File

@ -16,74 +16,74 @@ namespace ewol {
* Constructor / destructor * Constructor / destructor
*/ */
ConfigFont(); ConfigFont();
virtual ~ConfigFont(); ~ConfigFont();
private: private:
etk::Uri m_folder; etk::Uri this.folder;
public: public:
/** /**
* @brief Specify the default font folder for the Ewol search system (only needed when embended font) * @brief Specify the default font folder for the Ewol search system (only needed when embended font)
* @param[in] _folder basic folder of the font (ex: DATA:fonts) * @param[in] _folder basic folder of the font (ex: DATA:fonts)
*/ */
void setFolder(const etk::Uri& _folder) { void setFolder( etk::Uri _folder) {
m_folder = _folder; this.folder = _folder;
}; };
/** /**
* @brief get the default font folder. * @brief get the default font folder.
* @return The default font folder. * @return The default font folder.
*/ */
const etk::Uri& getFolder() { etk::Uri getFolder() {
return m_folder; return this.folder;
}; };
private: private:
etk::String m_name; String this.name;
int32_t m_size; int this.size;
public: public:
/** /**
* @brief set the defaut font for all the widgets and basics display. * @brief set the defaut font for all the widgets and basics display.
* @param[in] _fontName The font name requested (not case sensitive) ex "Arial" or multiple separate by ';' ex : "Arial;Helvetica". * @param[in] _fontName The font name requested (not case sensitive) ex "Arial" or multiple separate by ';' ex : "Arial;Helvetica".
* @param[in] _size The default size of the font default=10. * @param[in] _size The default size of the font default=10.
*/ */
void set(const etk::String& _fontName, int32_t _size); void set( String _fontName, int _size);
/** /**
* @brief get the current default font name * @brief get the current default font name
* @raturn a reference on the font name string * @raturn a reference on the font name string
*/ */
const etk::String& getName() { String getName() {
return m_name; return this.name;
}; };
/** /**
* @brief Set the current default font name * @brief Set the current default font name
* @param[in] _fontName The font name requested (not case sensitive) ex "Arial" or multiple separate by ';' ex : "Arial;Helvetica". * @param[in] _fontName The font name requested (not case sensitive) ex "Arial" or multiple separate by ';' ex : "Arial;Helvetica".
*/ */
void setName(const etk::String& _fontName); void setName( String _fontName);
/** /**
* @brief get the default font size. * @brief get the default font size.
* @return the font size. * @return the font size.
*/ */
int32_t getSize() { int getSize() {
return m_size; return this.size;
}; };
/** /**
* @brief Set the default font size. * @brief Set the default font size.
* @param[in] _size new font size. * @param[in] _size new font size.
*/ */
void setSize(int32_t _size); void setSize(int _size);
private: private:
bool m_useExternal; boolean this.useExternal;
public: public:
/** /**
* @brief set use of internal/external Font * @brief set use of internal/external Font
* @param[in] _val true to enable search of internal data. * @param[in] _val true to enable search of internal data.
*/ */
void setUseExternal(bool _val) { void setUseExternal(boolean _val) {
m_useExternal=_val; this.useExternal=_val;
}; };
/** /**
* @brief get the use of internal/external Font * @brief get the use of internal/external Font
* @return true to enable search of internal data. * @return true to enable search of internal data.
*/ */
bool getUseExternal() { boolean getUseExternal() {
return m_useExternal; return this.useExternal;
}; };
}; };
}; };

View File

@ -1,382 +1,57 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <etk/types.hpp> void EwolContext::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId)
#include <etk/etk.hpp>
#include <etk/tool.hpp>
#include <etk/theme/theme.hpp>
#include <ethread/tools.hpp> EwolContext::Context(EwolApplication* _application) :
#include <ethread/Mutex.hpp> EwolContext::~Context() {
#include <ewol/ewol.hpp>
#include <ewol/debug.hpp>
#include <gale/renderer/openGL/openGL.hpp>
#include <gale/Dimension.hpp>
#include <etranslate/etranslate.hpp>
#include <ewol/object/Object.hpp>
#include <ewol/object/Manager.hpp>
#include <ewol/widget/Widget.hpp>
#include <ewol/widget/Windows.hpp>
#include <ewol/widget/Manager.hpp>
#include <ewol/context/Context.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::Context);
static ewol::Context* l_curentInterface=null;
ewol::Context& ewol::getContext() {
gale::Context& context = gale::getContext();
ememory::SharedPtr<gale::Application> appl = context.getApplication();
if (appl == null) {
Log.critical("[CRITICAL] try acces at an empty GALE application (can not get Context)");
// ???
}
return *(ememory::staticPointerCast<ewol::Context>(appl));
}
void ewol::Context::setInitImage(const etk::Uri& _fileName) {
//m_initDisplayImageName = _fileName;
}
void ewol::Context::inputEventTransfertWidget(ewol::WidgetShared _source,
ewol::WidgetShared _destination) {
m_input.transfertEvent(_source, _destination);
}
void ewol::Context::inputEventGrabPointer(ewol::WidgetShared _widget) {
m_input.grabPointer(_widget);
}
void ewol::Context::inputEventUnGrabPointer() {
m_input.unGrabPointer();
}
void ewol::Context::onCreate(gale::Context& _context) {
Log.info(" == > Ewol system create (BEGIN)");
// Add basic ewol translation:
etranslate::addPath("ewol", "DATA:///translate/ewol/?lib=ewol");
etranslate::autoDetectLanguage();
// By default we set 2 themes (1 color and 1 shape ...) :
etk::theme::setNameDefault("GUI", "shape/square/");
etk::theme::setNameDefault("COLOR", "color/black/");
// parse for help:
for(int32_t iii = 0; iii < _context.getCmd().size() ; ++iii) {
if ( _context.getCmd().get(iii) == "-h"
|| _context.getCmd().get(iii) == "--help") {
Log.print("ewol - help : ");
Log.print(" " << etk::getApplicationName() << " [options]");
Log.print(" -h/--help: Display this help");
Log.print(" example:");
Log.print(" " << etk::getApplicationName() << " --help");
// this is a global help system does not remove it
continue;
} else {
continue;
}
_context.getCmd().remove(iii);
--iii;
}
Log.info("EWOL v:" << ewol::getVersion());
// force a recalculation
/*
requestUpdateSize();
#if defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__)
forceOrientation(ewol::screenLandscape);
#elif defined(__EWOL_ANDROID_ORIENTATION_PORTRAIT__)
forceOrientation(ewol::screenPortrait);
#else
forceOrientation(ewol::screenAuto);
#endif
*/
ememory::SharedPtr<ewol::context::Application> appl = m_application;
if (appl == null) {
Log.error(" == > Create without application");
return;
}
appl->onCreate(*this);
Log.info(" == > Ewol system create (END)");
}
void ewol::Context::onStart(gale::Context& _context) {
Log.info(" == > Ewol system start (BEGIN)");
ememory::SharedPtr<ewol::context::Application> appl = m_application;
if (appl == null) {
// TODO : Request exit of the application .... with error ...
return;
}
appl->onStart(*this);
Log.info(" == > Ewol system start (END)");
}
void ewol::Context::onResume(gale::Context& _context) {
Log.info(" == > Ewol system resume (BEGIN)");
ememory::SharedPtr<ewol::context::Application> appl = m_application;
if (appl == null) {
return;
}
appl->onResume(*this);
Log.info(" == > Ewol system resume (END)");
}
void ewol::Context::onRegenerateDisplay(gale::Context& _context) {
//Log.info("REGENERATE_DISPLAY");
// check if the user selected a windows
ewol::widget::WindowsShared window = m_windowsCurrent;
if (window == null) {
Log.debug("No windows ...");
return;
}
// Redraw all needed elements
window->onRegenerateDisplay();
if (m_widgetManager.isDrawingNeeded() == true) {
markDrawingIsNeeded();
}
//markDrawingIsNeeded();
}
void ewol::Context::onDraw(gale::Context& _context) {
//Log.info("DRAW");
// clean internal data...
m_objectManager.cleanInternalRemoved();
// real draw...
ewol::widget::WindowsShared window = m_windowsCurrent;
if (window == null) {
return;
}
window->sysDraw();
}
void ewol::Context::onPause(gale::Context& _context) {
Log.info(" == > Ewol system pause (BEGIN)");
ememory::SharedPtr<ewol::context::Application> appl = m_application;
if (appl == null) {
return;
}
appl->onPause(*this);
Log.info(" == > Ewol system pause (END)");
}
void ewol::Context::onStop(gale::Context& _context) {
Log.info(" == > Ewol system stop (BEGIN)");
ememory::SharedPtr<ewol::context::Application> appl = m_application;
if (appl == null) {
return;
}
appl->onStop(*this);
Log.info(" == > Ewol system stop (END)");
}
void ewol::Context::onDestroy(gale::Context& _context) {
Log.info(" == > Ewol system destroy (BEGIN)");
// Remove current windows
m_windowsCurrent.reset();
// clean all widget and sub widget with their resources:
m_objectManager.cleanInternalRemoved();
ememory::SharedPtr<ewol::context::Application> appl = m_application;
if (appl != null) {
// call application to uninit
appl->onDestroy(*this);
m_application.reset();
}
// internal clean elements
m_objectManager.cleanInternalRemoved();
Log.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
m_objectManager.displayListObject();
// now All must be removed !!!
m_objectManager.unInit();
Log.info(" == > Ewol system destroy (END)");
}
void ewol::Context::onKillDemand(gale::Context& _context) {
Log.info(" == > User demand a destroy (BEGIN)");
ememory::SharedPtr<ewol::context::Application> appl = m_application;
if (appl == null) {
exit(0);
return;
}
appl->onKillDemand(*this);
Log.info(" == > User demand a destroy (END)");
}
void ewol::Context::onPointer(enum gale::key::type _type,
int32_t _pointerID,
const Vector2f& _pos,
gale::key::status _state) {
switch (_state) {
case gale::key::status::move:
//Log.debug("Receive MSG : THREAD_INPUT_MOTION");
m_input.motion(_type, _pointerID, _pos);
break;
case gale::key::status::down:
case gale::key::status::downRepeate:
//Log.debug("Receive MSG : THREAD_INPUT_STATE");
m_input.state(_type, _pointerID, true, _pos);
break;
case gale::key::status::up:
//Log.debug("Receive MSG : THREAD_INPUT_STATE");
m_input.state(_type, _pointerID, false, _pos);
break;
default:
Log.debug("Unknow state : " << _state);
break;
}
}
void ewol::Context::onKeyboard(const gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state) {
Log.verbose("event {" << _special << "} " << _type << " " << _value << " " << _state);
// store the keyboard special key status for mouse event...
m_input.setLastKeyboardSpecial(_special);
if (m_windowsCurrent == null) {
// No windows ...
return;
}
bool repeate = (_state == gale::key::status::downRepeate);
bool isDown = (_state == gale::key::status::downRepeate)
|| (_state == gale::key::status::down);
if (m_windowsCurrent->onEventShortCut(_special,
_value,
_type,
isDown) == true) {
// Keep a shortcut ...
return;
}
// get the current focused Widget :
ewol::WidgetShared tmpWidget = m_widgetManager.focusGet();
if (tmpWidget == null) {
// no Widget ...
return;
}
// check if the widget allow repeating key events.
//Log.info("repeating test :" << repeate << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << isDown);
if( repeate == false
|| ( repeate == true
&& tmpWidget->getKeyboardRepeat() == true) ) {
// check Widget shortcut
if (tmpWidget->onEventShortCut(_special,
_value,
_type,
isDown) == false) {
// generate the direct event ...
if (_type == gale::key::keyboard::character) {
ewol::event::EntrySystem tmpEntryEvent(gale::key::keyboard::character,
gale::key::status::up,
_special,
_value);
if(isDown == true) {
tmpEntryEvent.m_event.setStatus(gale::key::status::down);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE
ewol::event::EntrySystem tmpEntryEvent(_type,
gale::key::status::up,
_special,
0);
if(isDown == true) {
tmpEntryEvent.m_event.setStatus(gale::key::status::down);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
}
} else {
Log.debug("remove Repeate key ...");
}
}
}
/*
void ewol::Context::processEvents() {
case eSystemMessage::msgResize:
//Log.debug("Receive MSG : THREAD_RESIZE");
m_windowsSize = data->dimention;
ewol::Dimension::setPixelWindowsSize(m_windowsSize);
forceRedrawAll();
break;
*/
void ewol::Context::onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) {
ewol::WidgetShared tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != null) {
tmpWidget->onEventClipboard(_clipboardId);
}
}
ewol::Context::Context(ewol::context::Application* _application) :
//m_application(ememory::makeShared<ewol::context::Application>(_application)),
m_application(_application),
m_objectManager(*this),
m_input(*this),
m_windowsCurrent(null),
m_initStepId(0) {
if (m_application == null) {
Log.critical("Can not start context with no Application ==> rtfm ...");
}
}
ewol::Context::~Context() {
// nothing to do ... // nothing to do ...
} }
void ewol::Context::requestUpdateSize() { void EwolContext::requestUpdateSize() {
gale::Context& context = gale::getContext(); Context context = gale::getContext();
context.requestUpdateSize(); context.requestUpdateSize();
} }
void ewol::Context::onPeriod(const echrono::Clock& _time) { void EwolContext::onPeriod( echrono::Clock _time) {
m_objectManager.timeCall(_time); this.objectManager.timeCall(_time);
} }
void ewol::Context::resetIOEvent() { void EwolContext::resetIOEvent() {
m_input.newLayerSet(); this.input.newLayerSet();
} }
void ewol::Context::setWindows(const ewol::widget::WindowsShared& _windows) { void EwolContext::setWindows( ewol::widget::WindowsShared _windows) {
Log.info("set New windows"); Log.info("set New windows");
// remove current focus : // remove current focus :
m_widgetManager.focusSetDefault(null); this.widgetManager.focusSetDefault(null);
m_widgetManager.focusRelease(); this.widgetManager.focusRelease();
// set the new pointer as windows system // set the new pointer as windows system
m_windowsCurrent = _windows; this.windowsCurrent = _windows;
// set the new default focus: // set the new default focus:
m_widgetManager.focusSetDefault(_windows); this.widgetManager.focusSetDefault(_windows);
// display the title of the Windows: // display the title of the Windows:
if (m_windowsCurrent != null) { if (this.windowsCurrent != null) {
setTitle(m_windowsCurrent->propertyTitle.get()); setTitle(this.windowsCurrent.propertyTitle.get());
} }
// request all the widget redrawing // request all the widget redrawing
forceRedrawAll(); forceRedrawAll();
} }
ewol::widget::WindowsShared ewol::Context::getWindows() { ewol::widget::WindowsShared EwolContext::getWindows() {
return m_windowsCurrent; return this.windowsCurrent;
}; };
void ewol::Context::onResize(const Vector2i& _size) { void EwolContext::onResize( Vector2i _size) {
Log.verbose("Resize: " << _size); Log.verbose("Resize: " + _size);
forceRedrawAll(); forceRedrawAll();
} }
void ewol::Context::forceRedrawAll() { void EwolContext::forceRedrawAll() {
if (m_windowsCurrent == null) { if (this.windowsCurrent == null) {
return; return;
} }
Vector2i size = getSize(); Vector2i size = getSize();
m_windowsCurrent->setSize(Vector2f(size.x(), size.y())); this.windowsCurrent.setSize(Vector2f(size.x(), size.y()));
m_windowsCurrent->onChangeSize(); this.windowsCurrent.onChangeSize();
} }

View File

@ -1,159 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <gale/key/key.hpp>
#include <gale/Application.hpp>
#include <gale/context/Context.hpp>
#include <gale/context/clipBoard.hpp>
#include <gale/context/commandLine.hpp>
#include <ewol/debug.hpp>
#include <ewol/ewol.hpp>
#include <ewol/object/Manager.hpp>
#include <ewol/widget/Manager.hpp>
#include <ewol/widget/Windows.hpp>
#include <ewol/context/Application.hpp>
#include <ewol/context/ConfigFont.hpp>
#include <ewol/context/InputManager.hpp>
#include <ememory/memory.hpp>
namespace ewol {
// Here we hereted from the gale application to be agnostic of the OW where we work ...
class Context : public gale::Application {
private:
ememory::SharedPtr<ewol::context::Application> m_application; //!< Application handle
public:
ememory::SharedPtr<ewol::context::Application> getApplication() {
return m_application;
}
public:
gale::context::CommandLine& getCmd() {
return gale::getContext().getCmd();
};
private:
ewol::context::ConfigFont m_configFont; //!< global font configuration
public:
ewol::context::ConfigFont& getFontDefault() {
return m_configFont;
};
private:
ewol::object::Manager m_objectManager; //!< Object Manager main instance
public:
ewol::object::Manager& getEObjectManager() {
return m_objectManager;
};
private:
ewol::widget::Manager m_widgetManager; //!< global widget manager
public:
ewol::widget::Manager& getWidgetManager() {
return m_widgetManager;
};
public:
gale::resource::Manager& getResourcesManager() {
return gale::getContext().getResourcesManager();
};
public:
Context(ewol::context::Application* _application);
virtual ~Context();
private:
ewol::context::InputManager m_input;
public: // herited function:
void onCreate(gale::Context& _context) override;
void onStart(gale::Context& _context) override;
void onResume(gale::Context& _context) override;
void onRegenerateDisplay(gale::Context& _context) override;
void onDraw(gale::Context& _context) override;
void onPause(gale::Context& _context) override;
void onStop(gale::Context& _context) override;
void onDestroy(gale::Context& _context) override;
void onKillDemand(gale::Context& _context) override;
void onPointer(enum gale::key::type _type,
int32_t _pointerID,
const Vector2f& _pos,
gale::key::status _state) override;
void onKeyboard(const gale::key::Special& _special,
enum gale::key::keyboard _type,
char32_t _value,
gale::key::status _state) override;
void onClipboardEvent(enum gale::context::clipBoard::clipboardListe _clipboardId) override;
public:
/**
* @brief reset event management for the IO like Input ou Mouse or keyborad
*/
void resetIOEvent();
private:
ewol::widget::WindowsShared m_windowsCurrent; //!< curent displayed windows
public:
/**
* @brief set the current windows to display :
* @param _windows Windows that might be displayed
*/
void setWindows(const ewol::widget::WindowsShared& _windows);
/**
* @brief get the current windows that is displayed
* @return the current handle on the windows (can be null)
*/
ewol::widget::WindowsShared getWindows();
/**
* @brief Redraw all the windows
*/
void forceRedrawAll();
/**
* @brief This is to transfert the event from one widget to another one
* @param source the widget where the event came from
* @param destination the widget where the event mitgh be generated now
*/
void inputEventTransfertWidget(ewol::WidgetShared _source, ewol::WidgetShared _destination);
/**
* @brief This fonction lock the pointer properties to move in relative instead of absolute
* @param[in] widget The widget that lock the pointer events
*/
void inputEventGrabPointer(ewol::WidgetShared _widget);
/**
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/
void inputEventUnGrabPointer();
void onResize(const Vector2i& _size) override;
public:
/**
* @brief This is the only one things the User might done in his main();
* @note : must be implemented in all system OPS implementation
* @note To answare you before you ask the question, this is really simple:
* Due to the fect that the current system is multiple-platform, you "main"
* Does not exist in the android platform, then ewol call other start
* and stop function, to permit to have only one code
* @note The main can not be in the ewol, due to the fact thet is an librairy
* @param[in] _argc Standard argc
* @param[in] _argv Standard argv
* @return normal error int for the application error management
*/
static int main(int _argc, const char *_argv[]);
private:
size_t m_initStepId;
size_t m_initTotalStep;
public:
/**
* @brief Special for init (main) set the start image when loading data
* @param[in] _fileName Name of the image to load
*/
void setInitImage(const etk::Uri& _fileName);
public:
/**
* @brief Request a display after call a resize
*/
void requestUpdateSize();
void onPeriod(const echrono::Clock& _time) override;
};
/**
* @brief From everyware in the program, we can get the context inteface.
* @return current reference on the instance.
*/
Context& getContext();
};

View File

@ -0,0 +1,53 @@
package org.atriasoft.ewol.context;
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
public interface EwolApplication {
/**
* @brief The application is created.
* @param[in] _context Current ewol context.
*/
void onCreate(EwolContext _context);
/**
* @brief The application is removed (call destructor just adter it.).
* @param[in] _context Current ewol context.
*/
void onDestroy(EwolContext _context);
/**
* @brief The user request application removing.
* @param[in] _context Current ewol context.
*/
default void onKillDemand(final EwolContext _context) {
_context.exit(0);
}
/**
* @brief The application is Hide / not visible.
* @param[in] _context Current ewol context.
*/
void onPause(EwolContext _context);
/**
* @brief The application is resumed (now visible).
* @param[in] _context Current ewol context.
*/
void onResume(EwolContext _context);
/**
* @brief The application is started.
* @param[in] _context Current ewol context.
*/
void onStart(EwolContext _context);
/**
* @brief The application is stopped.
* @param[in] _context Current ewol context.
*/
void onStop(EwolContext _context);
}

View File

@ -0,0 +1,430 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.ewol.context;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.ewol.object.ObjectManager;
import org.atriasoft.ewol.widget.WidgetManager;
import org.atriasoft.gale.Application;
import org.atriasoft.gale.Gale;
import org.atriasoft.gale.context.ClipboardList;
import org.atriasoft.gale.context.CommandLine;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import org.atriasoft.gale.resource.ResourceManager;
// Here we hereted from the gale application to be agnostic of the OW where we work ...
public abstract class EwolContext extends Application {
private static EwolContext curentInterface = null;
/**
* @brief From everyware in the program, we can get the context inteface.
* @return current reference on the instance.
*/
static EwolContext getContext() {
return curentInterface;
}
private final EwolApplication application; //!< Application handle
public EwolApplication getApplication() {
return this.application;
}
public CommandLine getCmd() {
return Gale.getContext().getCmd();
}
private ConfigFont configFont; //!< global font configuration
public ConfigFont getFontDefault() {
return this.configFont;
}
private final ObjectManager objectManager; //!< Object Manager main instance
public ObjectManager getEObjectManager() {
return this.objectManager;
}
private WidgetManager widgetManager; //!< global widget manager
public WidgetManager getWidgetManager() {
return this.widgetManager;
}
public ResourceManager getResourcesManager() {
return Gale.getContext().getResourcesManager();
}
public EwolContext(final EwolApplication _application) {
this.application = _application;
this.objectManager = new ObjectManager(this);
this.input = new InputManager(this);
if (this.application == null) {
Log.critical("Can not start context with no Application ==> rtfm ...");
}
}
private final InputManager input;
public void onCreate(final Context _context) {
Log.info(" == > Ewol system create (BEGIN)");
// Add basic ewol translation:
etranslate::addPath("ewol", "DATA:///translate/ewol/?lib=ewol");
etranslate::autoDetectLanguage();
// By default we set 2 themes (1 color and 1 shape ...) :
etk::theme::setNameDefault("GUI", "shape/square/");
etk::theme::setNameDefault("COLOR", "color/black/");
// parse for help:
for(int iii = 0; iii < _context.getCmd().size() ; ++iii) {
if ( _context.getCmd().get(iii) == "-h"
|| _context.getCmd().get(iii) == "--help") {
Log.print("ewol - help : ");
Log.print(" " + etk::getApplicationName() + " [options]");
Log.print(" -h/--help: Display this help");
Log.print(" example:");
Log.print(" " + etk::getApplicationName() + " --help");
// this is a global help system does not remove it
continue;
} else {
continue;
}
_context.getCmd().remove(iii);
--iii;
}
Log.info("EWOL v:" + ewol::getVersion());
// force a recalculation
/*
requestUpdateSize();
#if defined(__EWOL_ANDROID_ORIENTATION_LANDSCAPE__)
forceOrientation(ewol::screenLandscape);
#elif defined(__EWOL_ANDROID_ORIENTATION_PORTRAIT__)
forceOrientation(ewol::screenPortrait);
#else
forceOrientation(ewol::screenAuto);
#endif
*/
EwolApplication appl = this.application;
if (appl == null) {
Log.error(" == > Create without application");
return;
}
appl.onCreate(*this);
Log.info(" == > Ewol system create (END)");
}
public abstract void onStart(final Context _context) {
Log.info(" == > Ewol system start (BEGIN)");
EwolApplication appl = this.application;
if (appl == null) {
// TODO : Request exit of the application .... with error ...
return;
}
appl.onStart(*this);
Log.info(" == > Ewol system start (END)");
}
public abstract void onResume(final Context _context){
Log.info(" == > Ewol system resume (BEGIN)");
EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onResume(*this);
Log.info(" == > Ewol system resume (END)");
}
public abstract void onRegenerateDisplay(final Context _context) {
//Log.info("REGENERATE_DISPLAY");
// check if the user selected a windows
ewol::widget::WindowsShared window = this.windowsCurrent;
if (window == null) {
Log.debug("No windows ...");
return;
}
// Redraw all needed elements
window.onRegenerateDisplay();
if (this.widgetManager.isDrawingNeeded() == true) {
markDrawingIsNeeded();
}
//markDrawingIsNeeded();
}
public abstract void onDraw(final Context _context) {
//Log.info("DRAW");
// clean internal data...
this.objectManager.cleanInternalRemoved();
// real draw...
ewol::widget::WindowsShared window = this.windowsCurrent;
if (window == null) {
return;
}
window.sysDraw();
}
public abstract void onPause(final Context _context){
Log.info(" == > Ewol system pause (BEGIN)");
EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onPause(*this);
Log.info(" == > Ewol system pause (END)");
}
public abstract void onStop(final Context _context){
Log.info(" == > Ewol system stop (BEGIN)");
EwolApplication appl = this.application;
if (appl == null) {
return;
}
appl.onStop(*this);
Log.info(" == > Ewol system stop (END)");
}
public abstract void onDestroy(final Context _context){
Log.info(" == > Ewol system destroy (BEGIN)");
// Remove current windows
this.windowsCurrent.reset();
// clean all widget and sub widget with their resources:
this.objectManager.cleanInternalRemoved();
EwolApplication appl = this.application;
if (appl != null) {
// call application to uninit
appl.onDestroy(*this);
this.application.reset();
}
// internal clean elements
this.objectManager.cleanInternalRemoved();
Log.info("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
this.objectManager.displayListObject();
// now All must be removed !!!
this.objectManager.unInit();
Log.info(" == > Ewol system destroy (END)");
}
public abstract void onKillDemand(final Context _context){
Log.info(" == > User demand a destroy (BEGIN)");
EwolApplication appl = this.application;
if (appl == null) {
exit(0);
return;
}
appl.onKillDemand(*this);
Log.info(" == > User demand a destroy (END)");
}
public abstract void onPointer(final KeyType _type, final int _pointerID, final Vector2f _pos, final KeyStatus _state) {
switch (_state) {
case KeyStatus::move:
//Log.debug("Receive MSG : THREAD_INPUT_MOTION");
this.input.motion(_type, _pointerID, _pos);
break;
case KeyStatus::down:
case KeyStatus::downRepeate:
//Log.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(_type, _pointerID, true, _pos);
break;
case KeyStatus::up:
//Log.debug("Receive MSG : THREAD_INPUT_STATE");
this.input.state(_type, _pointerID, false, _pos);
break;
default:
Log.debug("Unknow state : " + _state);
break;
}
}
@Override
public abstract void onKeyboard(final KeySpecial _special, final KeyKeyboard _type, final Character _value, final KeyStatus _state) {
Log.verbose("event {" + _special + "} " + _type + " " + _value + " " + _state);
// store the keyboard special key status for mouse event...
this.input.setLastKeyboardSpecial(_special);
if (this.windowsCurrent == null) {
// No windows ...
return;
}
boolean repeate = (_state == KeyStatus::downRepeate);
boolean isDown = (_state == KeyStatus::downRepeate)
|| (_state == KeyStatus::down);
if (this.windowsCurrent.onEventShortCut(_special,
_value,
_type,
isDown) == true) {
// Keep a shortcut ...
return;
}
// get the current focused Widget :
Widget tmpWidget = this.widgetManager.focusGet();
if (tmpWidget == null) {
// no Widget ...
return;
}
// check if the widget allow repeating key events.
//Log.info("repeating test :" + repeate + " widget=" + tmpWidget.getKeyboardRepeate() + " state=" + isDown);
if( repeate == false
|| ( repeate == true
LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM tmpWidget.getKeyboardRepeat() == true) ) {
// check Widget shortcut
if (tmpWidget.onEventShortCut(_special,
_value,
_type,
isDown) == false) {
// generate the direct event ...
if (_type == KeyKeyboard::character) {
ewol::event::EntrySystem tmpEntryEvent(KeyKeyboard::character,
KeyStatus::up,
_special,
_value);
if(isDown == true) {
tmpEntryEvent.this.event.setStatus(KeyStatus::down);
}
tmpWidget.systemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE
ewol::event::EntrySystem tmpEntryEvent(_type,
KeyStatus::up,
_special,
0);
if(isDown == true) {
tmpEntryEvent.this.event.setStatus(KeyStatus::down);
}
tmpWidget.systemEventEntry(tmpEntryEvent);
}
} else {
Log.debug("remove Repeate key ...");
}
}
}
@Override
public void onClipboardEvent(final ClipboardList _clipboardId) {
final Widget tmpWidget = this.widgetManager.focusGet();
if (tmpWidget != null) {
tmpWidget.onEventClipboard(_clipboardId);
}
}
/**
* @brief reset event management for the IO like Input ou Mouse or keyborad
*/
public void resetIOEvent() {
this.input.newLayerSet();
}
private final Windows windowsCurrent = null; //!< current displayed windows
/**
* @brief set the current windows to display :
* @param _windows Windows that might be displayed
*/
public void setWindows(final Windows _windows) {
Log.info("set New windows");
// remove current focus :
this.widgetManager.focusSetDefault(null);
this.widgetManager.focusRelease();
// set the new pointer as windows system
this.windowsCurrent = _windows;
// set the new default focus:
this.widgetManager.focusSetDefault(_windows);
// display the title of the Windows:
if (this.windowsCurrent != null) {
setTitle(this.windowsCurrent.propertyTitle.get());
}
// request all the widget redrawing
forceRedrawAll();
}
/**
* @brief get the current windows that is displayed
* @return the current handle on the windows (can be null)
*/
public Windows getWindows() {
return this.windowsCurrent;
};
/**
* @brief Redraw all the windows
*/
public void forceRedrawAll() {
if (this.windowsCurrent == null) {
return;
}
final Vector2i size = getSize();
this.windowsCurrent.setSize(Vector2f(size.x(), size.y()));
this.windowsCurrent.onChangeSize();
}
/**
* @brief This is to transfert the event from one widget to another one
* @param source the widget where the event came from
* @param destination the widget where the event mitgh be generated now
*/
public void inputEventTransfertWidget(final Widget _source, final Widget _destination) {
this.input.transfertEvent(_source, _destination);
}
/**
* @brief This fonction lock the pointer properties to move in relative instead of absolute
* @param[in] widget The widget that lock the pointer events
*/
public void inputEventGrabPointer(final Widget _widget) {
this.input.grabPointer(_widget);
}
/**
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/
public void inputEventUnGrabPointer() {
this.input.unGrabPointer();
}
public void onResize(final Vector2i _size) {
Log.verbose("Resize: " + _size);
forceRedrawAll();
}
/**
* @brief This is the only one things the User might done in his main();
* @note : must be implemented in all system OPS implementation
* @note To answare you before you ask the question, this is really simple:
* Due to the fect that the current system is multiple-platform, you "main"
* Does not exist in the android platform, then ewol call other start
* and stop function, to permit to have only one code
* @note The main can not be in the ewol, due to the fact thet is an librairy
* @param[in] _argc Standard argc
* @param[in] _argv Standard argv
* @return normal error int for the application error management
*/
public static int main(String[] _args);
private final int initStepId = 0;
private final int initTotalStep = 0;
/**
* @brief Special for init (main) set the start image when loading data
* @param[in] _fileName Name of the image to load
*/
public void setInitImage(final Uri _fileName) {
//this.initDisplayImageName = _fileName;
}
/**
* @brief Request a display after call a resize
*/
public void requestUpdateSize() {
final Context context = gale::getContext();
context.requestUpdateSize();
}
public void onPeriod(final Clock _time) {
this.objectManager.timeCall(_time);
}
}

View File

@ -23,30 +23,30 @@ ETK_DECLARE_TYPE(ewol::context::InputManager);
//#define EVENT_DEBUG EWOL_DEBUG //#define EVENT_DEBUG EWOL_DEBUG
void ewol::context::InputManager::calculateLimit() { void ewol::context::InputManager::calculateLimit() {
m_eventInputLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300)); this.eventInputLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300));
m_eventInputLimit.DpiOffset = m_dpi*100; this.eventInputLimit.DpiOffset = this.dpi*100;
m_eventMouseLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300)); this.eventMouseLimit.sepatateTime = echrono::Duration(echrono::milliseconds(300));
m_eventMouseLimit.DpiOffset = float(m_dpi)*0.1f; this.eventMouseLimit.DpiOffset = float(this.dpi)*0.1f;
} }
void ewol::context::InputManager::setDpi(int32_t newDPI) { void ewol::context::InputManager::setDpi(int newDPI) {
m_dpi = newDPI; this.dpi = newDPI;
// recalculate the DPI system ... // recalculate the DPI system ...
calculateLimit(); calculateLimit();
} }
bool ewol::context::InputManager::localEventInput(enum gale::key::type _type, boolean ewol::context::InputManager::localEventInput(KeyType _type,
ewol::WidgetShared _destWidget, Widget _destWidget,
int32_t _IdInput, int _IdInput,
enum gale::key::status _status, KeyStatus _status,
Vector2f _pos) { Vector2f _pos) {
if (_destWidget != null) { if (_destWidget != null) {
if ( _type == gale::key::type::mouse if ( _type == KeyType::mouse
|| _type == gale::key::type::finger) { || _type == KeyType::finger) {
// create the system Event : // create the system Event :
ewol::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0, m_specialKey); // TODO : set the real ID ... ewol::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0, this.specialKey); // TODO : set the real ID ...
// generate the event : // generate the event :
return _destWidget->systemEventInput(tmpEventSystem); return _destWidget.systemEventInput(tmpEventSystem);
} else { } else {
return false; return false;
} }
@ -55,8 +55,8 @@ bool ewol::context::InputManager::localEventInput(enum gale::key::type _type,
} }
void ewol::context::InputManager::abortElement(InputPoperty *_eventTable, void ewol::context::InputManager::abortElement(InputPoperty *_eventTable,
int32_t _idInput, int _idInput,
enum gale::key::type _type) { KeyType _type) {
if (_eventTable == null) { if (_eventTable == null) {
return; return;
} }
@ -64,17 +64,17 @@ void ewol::context::InputManager::abortElement(InputPoperty *_eventTable,
localEventInput(_type, localEventInput(_type,
_eventTable[_idInput].curentWidgetEvent.lock(), _eventTable[_idInput].curentWidgetEvent.lock(),
_eventTable[_idInput].destinationInputId, _eventTable[_idInput].destinationInputId,
gale::key::status::abort, KeyStatus::abort,
_eventTable[_idInput].posEvent); _eventTable[_idInput].posEvent);
} }
} }
void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable, void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable,
int32_t _idInput) { int _idInput) {
if (_eventTable == null) { if (_eventTable == null) {
return; return;
} }
//Log.info("CleanElement[" << idInput << "] = @" << (int64_t)eventTable); //Log.info("CleanElement[" + idInput + "] = @" + (long)eventTable);
_eventTable[_idInput].isUsed = false; _eventTable[_idInput].isUsed = false;
_eventTable[_idInput].destinationInputId = 0; _eventTable[_idInput].destinationInputId = 0;
_eventTable[_idInput].lastTimeEvent.reset(); _eventTable[_idInput].lastTimeEvent.reset();
@ -88,74 +88,74 @@ void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable,
_eventTable[_idInput].posEvent.setValue(0,0); _eventTable[_idInput].posEvent.setValue(0,0);
} }
void ewol::context::InputManager::transfertEvent(ewol::WidgetShared _source, ewol::WidgetShared _destination) { void ewol::context::InputManager::transfertEvent(Widget _source, Widget _destination) {
if( _source == null if( _source == null
|| _destination == null) { || _destination == null) {
// prevent errors ... // prevent errors ...
return; return;
} }
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
ewol::WidgetShared tmpWidget = m_eventInputSaved[iii].curentWidgetEvent.lock(); Widget tmpWidget = this.eventInputSaved[iii].curentWidgetEvent.lock();
if (tmpWidget == _source) { if (tmpWidget == _source) {
// inform the widget that it does not receive the event now // inform the widget that it does not receive the event now
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventInputSaved[iii].posEvent); EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_ABORT] " + this.eventInputSaved[iii].posEvent);
localEventInput(gale::key::type::finger, tmpWidget, m_eventInputSaved[iii].destinationInputId, gale::key::status::abort, m_eventInputSaved[iii].posEvent); localEventInput(KeyType::finger, tmpWidget, this.eventInputSaved[iii].destinationInputId, KeyStatus::abort, this.eventInputSaved[iii].posEvent);
// set the new widget ... // set the new widget ...
m_eventInputSaved[iii].curentWidgetEvent = _destination; this.eventInputSaved[iii].curentWidgetEvent = _destination;
// inform the widget that he receive the event property now... // inform the widget that he receive the event property now...
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventInputSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventInputSaved[iii].posEvent); EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventInputSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_TRANSFERT] " + this.eventInputSaved[iii].posEvent);
localEventInput(gale::key::type::finger, _destination, m_eventInputSaved[iii].destinationInputId, gale::key::status::transfert, m_eventInputSaved[iii].posEvent); localEventInput(KeyType::finger, _destination, this.eventInputSaved[iii].destinationInputId, KeyStatus::transfert, this.eventInputSaved[iii].posEvent);
} }
tmpWidget = m_eventMouseSaved[iii].curentWidgetEvent.lock(); tmpWidget = this.eventMouseSaved[iii].curentWidgetEvent.lock();
if (tmpWidget == _source) { if (tmpWidget == _source) {
// inform the widget that it does not receive the event now // inform the widget that it does not receive the event now
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_ABORT] " << m_eventMouseSaved[iii].posEvent); EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_ABORT] " + this.eventMouseSaved[iii].posEvent);
localEventInput(gale::key::type::mouse, tmpWidget, m_eventMouseSaved[iii].destinationInputId, gale::key::status::abort, m_eventMouseSaved[iii].posEvent); localEventInput(KeyType::mouse, tmpWidget, this.eventMouseSaved[iii].destinationInputId, KeyStatus::abort, this.eventMouseSaved[iii].posEvent);
// set the new widget ... // set the new widget ...
m_eventMouseSaved[iii].curentWidgetEvent = _destination; this.eventMouseSaved[iii].curentWidgetEvent = _destination;
// inform the widget that he receive the event property now... // inform the widget that he receive the event property now...
EVENT_DEBUG("GUI : Input ID=" << iii << " == >" << m_eventMouseSaved[iii].destinationInputId << " [EVENT_INPUT_TYPE_TRANSFERT] " << m_eventMouseSaved[iii].posEvent); EVENT_DEBUG("GUI : Input ID=" + iii + " == >" + this.eventMouseSaved[iii].destinationInputId + " [EVENT_INPUT_TYPE_TRANSFERT] " + this.eventMouseSaved[iii].posEvent);
localEventInput(gale::key::type::mouse, _destination, m_eventMouseSaved[iii].destinationInputId, gale::key::status::transfert, m_eventMouseSaved[iii].posEvent); localEventInput(KeyType::mouse, _destination, this.eventMouseSaved[iii].destinationInputId, KeyStatus::transfert, this.eventMouseSaved[iii].posEvent);
} }
} }
} }
void ewol::context::InputManager::grabPointer(ewol::WidgetShared _widget) { void ewol::context::InputManager::grabPointer(Widget _widget) {
if(_widget == null) { if(_widget == null) {
return; return;
} }
m_grabWidget = _widget; this.grabWidget = _widget;
/* TODO : /* TODO :
m_context.grabPointerEvents(true, _widget->getOrigin() this.context.grabPointerEvents(true, _widget.getOrigin()
+ Vector2i(_widget->getSize().x()/2.0f, + Vector2i(_widget.getSize().x()/2.0f,
_widget->getSize().y()/2.0f) ); _widget.getSize().y()/2.0f) );
*/ */
} }
void ewol::context::InputManager::unGrabPointer() { void ewol::context::InputManager::unGrabPointer() {
m_grabWidget.reset(); this.grabWidget.reset();
// TODO: m_context.grabPointerEvents(false, Vector2f(0,0)); // TODO: this.context.grabPointerEvents(false, Vector2f(0,0));
} }
void ewol::context::InputManager::newLayerSet() { void ewol::context::InputManager::newLayerSet() {
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ... // remove the property of this input ...
abortElement(m_eventInputSaved, iii, gale::key::type::finger); abortElement(this.eventInputSaved, iii, KeyType::finger);
cleanElement(m_eventInputSaved, iii); cleanElement(this.eventInputSaved, iii);
abortElement(m_eventMouseSaved, iii, gale::key::type::mouse); abortElement(this.eventMouseSaved, iii, KeyType::mouse);
cleanElement(m_eventMouseSaved, iii); cleanElement(this.eventMouseSaved, iii);
} }
} }
ewol::context::InputManager::InputManager(ewol::Context& _context) : ewol::context::InputManager::InputManager(EwolContext _context) :
m_grabWidget(), this.grabWidget(),
m_context(_context) { this.context(_context) {
setDpi(200); setDpi(200);
Log.info("Init (start)"); Log.info("Init (start)");
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
// remove the property of this input ... // remove the property of this input ...
cleanElement(m_eventInputSaved, iii); cleanElement(this.eventInputSaved, iii);
cleanElement(m_eventMouseSaved, iii); cleanElement(this.eventMouseSaved, iii);
} }
Log.info("Init (end)"); Log.info("Init (end)");
} }
@ -165,17 +165,17 @@ ewol::context::InputManager::~InputManager() {
Log.info("Un-Init (end)"); Log.info("Un-Init (end)");
} }
int32_t ewol::context::InputManager::localGetDestinationId(enum gale::key::type _type, int ewol::context::InputManager::localGetDestinationId(KeyType _type,
ewol::WidgetShared _destWidget, Widget _destWidget,
int32_t _realInputId) { int _realInputId) {
if (_type == gale::key::type::finger) { if (_type == KeyType::finger) {
int32_t lastMinimum = 0; int lastMinimum = 0;
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) { for(int iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (true == m_eventInputSaved[iii].isUsed) { if (true == this.eventInputSaved[iii].isUsed) {
ewol::WidgetShared tmpWidget = m_eventInputSaved[iii].curentWidgetEvent.lock(); Widget tmpWidget = this.eventInputSaved[iii].curentWidgetEvent.lock();
if (tmpWidget == _destWidget) { if (tmpWidget == _destWidget) {
if (iii != _realInputId) { if (iii != _realInputId) {
lastMinimum = etk::max(lastMinimum, m_eventInputSaved[iii].destinationInputId); lastMinimum = etk::max(lastMinimum, this.eventInputSaved[iii].destinationInputId);
} }
} }
} }
@ -186,19 +186,19 @@ int32_t ewol::context::InputManager::localGetDestinationId(enum gale::key::type
} }
// note if id<0 == > the it was finger event ... // note if id<0 == > the it was finger event ...
void ewol::context::InputManager::motion(enum gale::key::type _type, void ewol::context::InputManager::motion(KeyType _type,
int _pointerID, int _pointerID,
Vector2f _pos) { Vector2f _pos) {
EVENT_DEBUG("motion event : " << _type << " " << _pointerID << " " << _pos); EVENT_DEBUG("motion event : " + _type + " " + _pointerID + " " + _pos);
if (MAX_MANAGE_INPUT <= _pointerID) { if (MAX_MANAGE_INPUT <= _pointerID) {
// reject pointer == > out of IDs... // reject pointer == > out of IDs...
return; return;
} }
InputPoperty *eventTable = null; InputPoperty *eventTable = null;
if (_type == gale::key::type::mouse) { if (_type == KeyType::mouse) {
eventTable = m_eventMouseSaved; eventTable = this.eventMouseSaved;
} else if (_type == gale::key::type::finger) { } else if (_type == KeyType::finger) {
eventTable = m_eventInputSaved; eventTable = this.eventInputSaved;
} else { } else {
Log.error("Unknown type of event"); Log.error("Unknown type of event");
return; return;
@ -208,34 +208,34 @@ void ewol::context::InputManager::motion(enum gale::key::type _type,
// not manage input // not manage input
return; return;
} }
ewol::widget::WindowsShared tmpWindows = m_context.getWindows(); ewol::widget::Windows tmpWindows = this.context.getWindows();
// special case for the mouse event 0 that represent the hover event of the system : // special case for the mouse event 0 that represent the hover event of the system :
if ( _type == gale::key::type::mouse if ( _type == KeyType::mouse
&& _pointerID == 0) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _pointerID == 0) {
// this event is all time on the good widget ... and manage the enter and leave ... // this event is all time on the good widget ... and manage the enter and leave ...
// NOTE : the "layer widget" force us to get the widget at the specific position all the time : // NOTE : the "layer widget" force us to get the widget at the specific position all the time :
ewol::WidgetShared tmpWidget; Widget tmpWidget;
if (m_grabWidget.lock() != null) { if (this.grabWidget.lock() != null) {
// grab all events ... // grab all events ...
tmpWidget = m_grabWidget.lock(); tmpWidget = this.grabWidget.lock();
} else { } else {
if (tmpWindows != null) { if (tmpWindows != null) {
tmpWidget = tmpWindows->getWidgetAtPos(_pos); tmpWidget = tmpWindows.getWidgetAtPos(_pos);
} }
} }
if( tmpWidget != eventTable[_pointerID].curentWidgetEvent.lock() if( tmpWidget != eventTable[_pointerID].curentWidgetEvent.lock()
|| ( eventTable[_pointerID].isInside == true || ( eventTable[_pointerID].isInside == true
&& ( eventTable[_pointerID].origin.x() > _pos.x() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( eventTable[_pointerID].origin.x() > _pos.x()
|| eventTable[_pointerID].origin.y() > _pos.y() || eventTable[_pointerID].origin.y() > _pos.y()
|| (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x() || (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x()
|| (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) ) ) { || (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) ) ) {
eventTable[_pointerID].isInside = false; eventTable[_pointerID].isInside = false;
EVENT_DEBUG("GUI : Input ID=" << _pointerID << " == >" << eventTable[_pointerID].destinationInputId << " [LEAVE] " << _pos); EVENT_DEBUG("GUI : Input ID=" + _pointerID + " == >" + eventTable[_pointerID].destinationInputId + " [LEAVE] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::leave, KeyStatus::leave,
_pos); _pos);
} }
if (eventTable[_pointerID].isInside == false) { if (eventTable[_pointerID].isInside == false) {
@ -246,28 +246,28 @@ void ewol::context::InputManager::motion(enum gale::key::type _type,
if (tmpWidget == null) { if (tmpWidget == null) {
eventTable[_pointerID].isInside = false; eventTable[_pointerID].isInside = false;
} else { } else {
eventTable[_pointerID].origin = tmpWidget->getOrigin(); eventTable[_pointerID].origin = tmpWidget.getOrigin();
eventTable[_pointerID].size = tmpWidget->getSize(); eventTable[_pointerID].size = tmpWidget.getSize();
} }
eventTable[_pointerID].destinationInputId = 0; eventTable[_pointerID].destinationInputId = 0;
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [ENTER] " << _pos); + " [ENTER] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
tmpWidget, tmpWidget,
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::enter, KeyStatus::enter,
_pos); _pos);
} }
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [MOVE] " << _pos); + " [MOVE] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
tmpWidget, tmpWidget,
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::move, KeyStatus::move,
_pos); _pos);
} else if (eventTable[_pointerID].isUsed == true) { } else if (eventTable[_pointerID].isUsed == true) {
if (eventTable[_pointerID].isInside == true) { if (eventTable[_pointerID].isInside == true) {
@ -276,63 +276,63 @@ void ewol::context::InputManager::motion(enum gale::key::type _type,
|| (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x() || (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) < _pos.x()
|| (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) { || (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) < _pos.y()) {
eventTable[_pointerID].isInside = false; eventTable[_pointerID].isInside = false;
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [LEAVE] " << _pos); + " [LEAVE] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::leave, KeyStatus::leave,
_pos); _pos);
} }
} else { } else {
if( ( eventTable[_pointerID].origin.x() <= _pos.x() if( ( eventTable[_pointerID].origin.x() <= _pos.x()
&& (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) >= _pos.x() ) LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (eventTable[_pointerID].origin.x() + eventTable[_pointerID].size.x()) >= _pos.x() )
&& ( eventTable[_pointerID].origin.y() <= _pos.y() LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM ( eventTable[_pointerID].origin.y() <= _pos.y()
&& (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) >= _pos.y() ) ) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM (eventTable[_pointerID].origin.y() + eventTable[_pointerID].size.y()) >= _pos.y() ) ) {
eventTable[_pointerID].isInside = true; eventTable[_pointerID].isInside = true;
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [ENTER] " << _pos); + " [ENTER] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::enter, KeyStatus::enter,
_pos); _pos);
} }
} }
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [MOVE] " << _pos); + " [MOVE] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::move, KeyStatus::move,
_pos); _pos);
} }
} }
void ewol::context::InputManager::state(enum gale::key::type _type, void ewol::context::InputManager::state(KeyType _type,
int _pointerID, int _pointerID,
bool _isDown, boolean _isDown,
Vector2f _pos) { Vector2f _pos) {
if (_pointerID >= MAX_MANAGE_INPUT) { if (_pointerID >= MAX_MANAGE_INPUT) {
// reject pointer == > out of IDs... // reject pointer == > out of IDs...
return; return;
} }
EVENT_DEBUG("event pointerId=" << _pointerID); EVENT_DEBUG("event pointerId=" + _pointerID);
// convert position in open-GL coordonates ... // convert position in open-GL coordonates ...
InputPoperty *eventTable = null; InputPoperty *eventTable = null;
InputLimit localLimit; InputLimit localLimit;
if (_type == gale::key::type::mouse) { if (_type == KeyType::mouse) {
eventTable = m_eventMouseSaved; eventTable = this.eventMouseSaved;
localLimit = m_eventMouseLimit; localLimit = this.eventMouseLimit;
} else if (_type == gale::key::type::finger) { } else if (_type == KeyType::finger) {
eventTable = m_eventInputSaved; eventTable = this.eventInputSaved;
localLimit = m_eventInputLimit; localLimit = this.eventInputLimit;
} else { } else {
Log.error("Unknown type of event"); Log.error("Unknown type of event");
return; return;
@ -344,12 +344,12 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
} }
// get the curent time ... // get the curent time ...
echrono::Clock currentTime = echrono::Clock::now(); echrono::Clock currentTime = echrono::Clock::now();
ewol::widget::WindowsShared tmpWindows = m_context.getWindows(); ewol::widget::Windows tmpWindows = this.context.getWindows();
if (_isDown == true) { if (_isDown == true) {
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [DOWN] " << _pos); + " [DOWN] " + _pos);
if(eventTable[_pointerID].isUsed == true) { if(eventTable[_pointerID].isUsed == true) {
// we have an event previously ... check delay between click and offset position // we have an event previously ... check delay between click and offset position
if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) { if (currentTime - eventTable[_pointerID].lastTimeEvent > localLimit.sepatateTime) {
@ -363,14 +363,14 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
// save start time // save start time
eventTable[_pointerID].lastTimeEvent = currentTime; eventTable[_pointerID].lastTimeEvent = currentTime;
// generate DOWN Event // generate DOWN Event
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [DOWN] " << _pos); + " [DOWN] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
eventTable[_pointerID].curentWidgetEvent.lock(), eventTable[_pointerID].curentWidgetEvent.lock(),
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::down, KeyStatus::down,
_pos); _pos);
} else { } else {
// Mark it used : // Mark it used :
@ -381,19 +381,19 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
eventTable[_pointerID].lastTimeEvent = currentTime; eventTable[_pointerID].lastTimeEvent = currentTime;
// set the element inside ... // set the element inside ...
eventTable[_pointerID].isInside = true; eventTable[_pointerID].isInside = true;
ewol::WidgetShared tmpWidget = m_grabWidget.lock(); Widget tmpWidget = this.grabWidget.lock();
// get destination widget : // get destination widget :
if(tmpWindows != null) { if(tmpWindows != null) {
if ( tmpWidget != null if ( tmpWidget != null
&& _type == gale::key::type::mouse) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _type == KeyType::mouse) {
eventTable[_pointerID].curentWidgetEvent = tmpWidget; eventTable[_pointerID].curentWidgetEvent = tmpWidget;
} else { } else {
tmpWidget = tmpWindows->getWidgetAtPos(_pos); tmpWidget = tmpWindows.getWidgetAtPos(_pos);
eventTable[_pointerID].curentWidgetEvent = tmpWidget; eventTable[_pointerID].curentWidgetEvent = tmpWidget;
if (tmpWidget != null) { if (tmpWidget != null) {
EVENT_DEBUG("Get widget at pos=" << _pos << " type: " << tmpWidget->getObjectType()); EVENT_DEBUG("Get widget at pos=" + _pos + " type: " + tmpWidget.getObjectType());
} else { } else {
EVENT_DEBUG("Get widget at pos=" << _pos << " NO WIDGET"); EVENT_DEBUG("Get widget at pos=" + _pos + " NO WIDGET");
} }
} }
} else { } else {
@ -401,28 +401,28 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
} }
tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock(); tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock();
if (tmpWidget != null) { if (tmpWidget != null) {
eventTable[_pointerID].origin = tmpWidget->getOrigin(); eventTable[_pointerID].origin = tmpWidget.getOrigin();
eventTable[_pointerID].size = tmpWidget->getSize(); eventTable[_pointerID].size = tmpWidget.getSize();
eventTable[_pointerID].destinationInputId = localGetDestinationId(_type, tmpWidget, _pointerID); eventTable[_pointerID].destinationInputId = localGetDestinationId(_type, tmpWidget, _pointerID);
} else { } else {
eventTable[_pointerID].destinationInputId = -1; eventTable[_pointerID].destinationInputId = -1;
} }
// generate DOWN Event // generate DOWN Event
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [DOWN] " << _pos); + " [DOWN] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
tmpWidget, tmpWidget,
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
gale::key::status::down, KeyStatus::down,
_pos); _pos);
} }
} else { } else {
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [UP] " << _pos); + " [UP] " + _pos);
ewol::WidgetShared tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock(); Widget tmpWidget = eventTable[_pointerID].curentWidgetEvent.lock();
if(eventTable[_pointerID].isUsed == false) { if(eventTable[_pointerID].isUsed == false) {
// bad case ... ??? // bad case ... ???
Log.debug("Up event without previous down ... "); Log.debug("Up event without previous down ... ");
@ -439,44 +439,44 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
eventTable[_pointerID].curentWidgetEvent.reset(); eventTable[_pointerID].curentWidgetEvent.reset();
} else { } else {
// generate UP Event // generate UP Event
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [UP] " << _pos); + " [UP] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
// send up event after the single event to prevent multiple widget getting elements // send up event after the single event to prevent multiple widget getting elements
localEventInput(_type, localEventInput(_type,
tmpWidget, tmpWidget,
_pointerID, _pointerID,
gale::key::status::up, KeyStatus::up,
_pos); _pos);
// generate event (single) // generate event (single)
if( etk::abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset if( etk::abs(eventTable[_pointerID].downStart.x() - _pos.x()) < localLimit.DpiOffset
&& etk::abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){ LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM etk::abs(eventTable[_pointerID].downStart.y() - _pos.y()) < localLimit.DpiOffset ){
// Save current position : // Save current position :
eventTable[_pointerID].downStart = _pos; eventTable[_pointerID].downStart = _pos;
// save start time // save start time
eventTable[_pointerID].lastTimeEvent = currentTime; eventTable[_pointerID].lastTimeEvent = currentTime;
int32_t nbClickMax = 0; int nbClickMax = 0;
if(tmpWidget != null) { if(tmpWidget != null) {
nbClickMax = tmpWidget->getMouseLimit(); nbClickMax = tmpWidget.getMouseLimit();
if (nbClickMax>5) { if (nbClickMax>5) {
nbClickMax = 5; nbClickMax = 5;
} }
} }
// in grab mode the single to quinte event are not generated .... // in grab mode the single to quinte event are not generated ....
if( ( m_grabWidget.lock() == null if( ( this.grabWidget.lock() == null
|| _type != gale::key::type::mouse ) || _type != KeyType::mouse )
&& eventTable[_pointerID].nbClickEvent < nbClickMax) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM eventTable[_pointerID].nbClickEvent < nbClickMax) {
// generate event SINGLE : // generate event SINGLE :
eventTable[_pointerID].nbClickEvent++; eventTable[_pointerID].nbClickEvent++;
EVENT_DEBUG("GUI : Input ID=" << _pointerID EVENT_DEBUG("GUI : Input ID=" + _pointerID
<< " == >" << eventTable[_pointerID].destinationInputId + " == >" + eventTable[_pointerID].destinationInputId
<< " [" << eventTable[_pointerID].nbClickEvent << "] " << _pos); + " [" + eventTable[_pointerID].nbClickEvent + "] " + _pos);
eventTable[_pointerID].posEvent = _pos; eventTable[_pointerID].posEvent = _pos;
localEventInput(_type, localEventInput(_type,
tmpWidget, tmpWidget,
eventTable[_pointerID].destinationInputId, eventTable[_pointerID].destinationInputId,
(enum gale::key::status)(uint32_t(gale::key::status::pressSingle) + eventTable[_pointerID].nbClickEvent-1), (KeyStatus)(uint(KeyStatus::pressSingle) + eventTable[_pointerID].nbClickEvent-1),
_pos); _pos);
if( eventTable[_pointerID].nbClickEvent >= nbClickMax) { if( eventTable[_pointerID].nbClickEvent >= nbClickMax) {
eventTable[_pointerID].nbClickEvent = 0; eventTable[_pointerID].nbClickEvent = 0;
@ -489,10 +489,10 @@ void ewol::context::InputManager::state(enum gale::key::type _type,
localEventInput(_type, localEventInput(_type,
tmpWidget, tmpWidget,
_pointerID, _pointerID,
gale::key::status::upAfter, KeyStatus::upAfter,
_pos); _pos);
// specific for tuch event // specific for tuch event
if (_type == gale::key::type::finger) { if (_type == KeyType::finger) {
cleanElement(eventTable, _pointerID); cleanElement(eventTable, _pointerID);
} }
} }

View File

@ -16,17 +16,17 @@ namespace ewol {
*/ */
class InputPoperty { class InputPoperty {
public: public:
bool isUsed; boolean isUsed;
int32_t destinationInputId; int destinationInputId;
echrono::Clock lastTimeEvent; echrono::Clock lastTimeEvent;
ewol::WidgetWeak curentWidgetEvent; WeakReference<Widget> curentWidgetEvent;
Vector2f origin; Vector2f origin;
Vector2f size; Vector2f size;
Vector2f downStart; Vector2f downStart;
Vector2f posEvent; Vector2f posEvent;
bool isDown; boolean isDown;
bool isInside; boolean isInside;
int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3 int nbClickEvent; // 0 .. 1 .. 2 .. 3
}; };
/** /**
@ -36,22 +36,22 @@ namespace ewol {
class InputLimit { class InputLimit {
public: public:
echrono::Duration sepatateTime; echrono::Duration sepatateTime;
int32_t DpiOffset; int DpiOffset;
}; };
class Context; class Context;
class InputManager{ class InputManager{
// special grab pointer mode : // special grab pointer mode :
private: private:
ewol::WidgetWeak m_grabWidget; //!< widget that grab the curent pointer. WeakReference<Widget> this.grabWidget; //!< widget that grab the curent pointer.
private: private:
int32_t m_dpi; int this.dpi;
InputLimit m_eventInputLimit; InputLimit this.eventInputLimit;
InputLimit m_eventMouseLimit; InputLimit this.eventMouseLimit;
void calculateLimit(); void calculateLimit();
InputPoperty m_eventInputSaved[MAX_MANAGE_INPUT]; InputPoperty this.eventInputSaved[MAX_MANAGE_INPUT];
InputPoperty m_eventMouseSaved[MAX_MANAGE_INPUT]; InputPoperty this.eventMouseSaved[MAX_MANAGE_INPUT];
void abortElement(InputPoperty* _eventTable, int32_t _idInput, enum gale::key::type _type); void abortElement(InputPoperty* _eventTable, int _idInput, KeyType _type);
void cleanElement(InputPoperty* _eventTable, int32_t _idInput); void cleanElement(InputPoperty* _eventTable, int _idInput);
/** /**
* @brief generate the event on the destinated widget. * @brief generate the event on the destinated widget.
* @param[in] _type Type of the event that might be sended. * @param[in] _type Type of the event that might be sended.
@ -61,10 +61,10 @@ namespace ewol {
* @param[in] _pos position of the event * @param[in] _pos position of the event
* @return true if event has been greped * @return true if event has been greped
*/ */
bool localEventInput(enum gale::key::type _type, boolean localEventInput(KeyType _type,
ewol::WidgetShared _destWidget, Widget _destWidget,
int32_t _IdInput, int _IdInput,
enum gale::key::status _typeEvent, KeyStatus _typeEvent,
Vector2f _pos); Vector2f _pos);
/** /**
* @brief convert the system event id in the correct EWOL id depending of the system management mode * @brief convert the system event id in the correct EWOL id depending of the system management mode
@ -75,19 +75,19 @@ namespace ewol {
* @param[in] _realInputId system Id * @param[in] _realInputId system Id
* @return the ewol input id * @return the ewol input id
*/ */
int32_t localGetDestinationId(enum gale::key::type _type, int localGetDestinationId(KeyType _type,
ewol::WidgetShared _destWidget, Widget _destWidget,
int32_t _realInputId); int _realInputId);
private: private:
ewol::Context& m_context; EwolContext this.context;
public: public:
InputManager(ewol::Context& _context); InputManager(EwolContext _context);
~InputManager(); ~InputManager();
void setDpi(int32_t _newDPI); void setDpi(int _newDPI);
// note if id<0 == > the it was finger event ... // note if id<0 == > the it was finger event ...
void motion(enum gale::key::type _type, int _pointerID, Vector2f _pos ); void motion(KeyType _type, int _pointerID, Vector2f _pos );
void state(enum gale::key::type _type, int _pointerID, bool _isDown, Vector2f _pos); void state(KeyType _type, int _pointerID, boolean _isDown, Vector2f _pos);
public: public:
/** /**
* @brief a new layer on the windows is set == > might remove all the property of the current element ... * @brief a new layer on the windows is set == > might remove all the property of the current element ...
@ -98,21 +98,21 @@ namespace ewol {
* @param _source the widget where the event came from * @param _source the widget where the event came from
* @param _destination the widget where the event mitgh be generated now * @param _destination the widget where the event mitgh be generated now
*/ */
void transfertEvent(ewol::WidgetShared _source, ewol::WidgetShared _destination); void transfertEvent(Widget _source, Widget _destination);
/** /**
* @brief This fonction lock the pointer properties to move in relative instead of absolute * @brief This fonction lock the pointer properties to move in relative instead of absolute
* @param[in] _widget The widget that lock the pointer events * @param[in] _widget The widget that lock the pointer events
*/ */
void grabPointer(ewol::WidgetShared _widget); void grabPointer(Widget _widget);
/** /**
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute * @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/ */
void unGrabPointer(); void unGrabPointer();
private: private:
gale::key::Special m_specialKey; KeySpecial this.specialKey;
public: public:
void setLastKeyboardSpecial(const gale::key::Special& _specialKey) { void setLastKeyboardSpecial( KeySpecial _specialKey) {
m_specialKey = _specialKey; this.specialKey = _specialKey;
} }
}; };
}; };

View File

@ -1,12 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/debug.hpp>
int32_t ewol::getLogId() {
static int32_t g_val = elog::registerInstance("ewol");
return g_val;
}

View File

@ -1,25 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/widget/Widget.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::event::Entry);
etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::Entry& _obj) {
_os << "{type=" << _obj.getType();
_os << " status=" << _obj.getStatus();
if (_obj.getType() == gale::key::keyboard::character) {
_os << " char=" << _obj.getChar();
}
_os << "}";
return _os;
}
etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::EntrySystem& _obj) {
_os << _obj.m_event;
return _os;
}

View File

@ -1,70 +1,43 @@
package org.atriasoft.ewol.event;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once
#include <etk/types.hpp> public class Entry {
#include <gale/key/key.hpp> private final KeyKeyboard type; //!< type of hardware event
private final KeyStatus status; //!< status of hardware event
private final KeySpecial specialKey; //!< input key status (prevent change in time..)
private final Character unicodeData; //!< Unicode data (in some case)
namespace ewol { public Entry(final KeyKeyboard _type, final KeyStatus _status, final KeySpecial _specialKey, final Character _char) {
namespace event { this.type = _type;
class Entry { this.status = _status;
private: this.specialKey = _specialKey;
enum gale::key::keyboard m_type; //!< type of hardware event this.unicodeData = _char;
enum gale::key::status m_status; //!< status of hardware event
gale::key::Special m_specialKey; //!< input key status (prevent change in time..)
char32_t m_unicodeData; //!< Unicode data (in some case)
public:
Entry(enum gale::key::keyboard _type,
enum gale::key::status _status,
gale::key::Special _specialKey,
char32_t _char) :
m_type(_type),
m_status(_status),
m_specialKey(_specialKey),
m_unicodeData(_char) {
}; }
void setType(enum gale::key::keyboard _type) {
m_type = _type;
};
inline const enum gale::key::keyboard& getType() const {
return m_type;
};
void setStatus(enum gale::key::status _status) {
m_status = _status;
};
inline const enum gale::key::status& getStatus() const {
return m_status;
};
void setSpecialKey(const gale::key::Special& _specialKey) {
m_specialKey = _specialKey;
};
inline const gale::key::Special& getSpecialKey() const {
return m_specialKey;
};
void setChar(char32_t _char) {
m_unicodeData = _char;
};
inline const char32_t& getChar() const {
return m_unicodeData;
};
};
etk::Stream& operator <<(etk::Stream& _os, const ewol::event::Entry& _obj);
class EntrySystem { public Character getChar() {
public: return this.unicodeData;
EntrySystem(enum gale::key::keyboard _type,
enum gale::key::status _status,
gale::key::Special _specialKey,
char32_t _char) :
m_event(_type, _status, _specialKey, _char) {
};
ewol::event::Entry m_event;
};
etk::Stream& operator <<(etk::Stream& _os, const ewol::event::EntrySystem& _obj);
}; };
public KeySpecial getSpecialKey() {
return this.specialKey;
};
public KeyStatus getStatus() {
return this.status;
};
public KeyKeyboard getType() {
return this.type;
};
}; };

View File

@ -0,0 +1,13 @@
package org.atriasoft.ewol.event;
import org.atriasoft.gale.key.KeyKeyboard;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
public class EntrySystem {
public final Entry event;
public EntrySystem(final KeyKeyboard _type, final KeyStatus _status, final KeySpecial _specialKey, final Character _char) {
this.event = new Entry(_type, _status, _specialKey, _char);
}
}

View File

@ -0,0 +1,76 @@
package org.atriasoft.ewol.event;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
public class EventInput {
private KeyType type;
private KeyStatus status;
private int inputId;
private Vector2f pos;
private KeySpecial specialKey; //!< input key status (prevent change in time..)
public EventInput(final KeyType _type, final KeyStatus _status, final int _id, final Vector2f _pos, final KeySpecial _specialKey) {
this.type = _type;
this.status = _status;
this.inputId = _id;
this.pos = _pos;
this.specialKey = _specialKey;
};
public int getId() {
return this.inputId;
};
public Vector2f getPos() {
return this.pos;
};
public KeySpecial getSpecialKey() {
return this.specialKey;
};
public KeyStatus getStatus() {
return this.status;
};
public KeyType getType() {
return this.type;
};
/**
* @brief Reset the input property of the curent event.
*/
public void reset() {
// TODO : Call the entry element ant rest it ...
};
public void setId(final int _id) {
this.inputId = _id;
};
public void setPos(final Vector2f _pos) {
this.pos = _pos;
};
public void setSpecialKey(final KeySpecial _specialKey) {
this.specialKey = _specialKey;
};
public void setStatus(final KeyStatus _status) {
this.status = _status;
};
public void setType(final KeyType _type) {
this.type = _type;
}
}

View File

@ -0,0 +1,68 @@
package org.atriasoft.ewol.event;
import org.atriasoft.echrono.Clock;
import org.atriasoft.echrono.Duration;
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
public class EventTime {
private Clock timeSystem; //!< Current system time (micro-second)
private Clock timeUpAppl; //!< Current application wake up-time (micro-second)
private Duration timeDelta; //!< Time from the last cycle call of the system (main appl tick) (second)
private Duration timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (second)
public EventTime(final Clock _timeSystem, final Clock _timeUpAppl, final Duration _timeDelta, final Duration _timeDeltaCall) {
this.timeSystem = _timeSystem;
this.timeUpAppl = _timeUpAppl;
this.timeDelta = _timeDelta;
this.timeDeltaCall = _timeDeltaCall;
};
public Duration getApplUpTime() {
return this.timeSystem.less(this.timeUpAppl);
};
public Clock getApplWakeUpTime() {
return this.timeUpAppl;
};
public float getDelta() {
return this.timeDelta.toSeconds();
};
public float getDeltaCall() {
return this.timeDeltaCall.toSeconds();
};
public Duration getDeltaCallDuration() {
return this.timeDeltaCall;
};
public Duration getDeltaDuration() {
return this.timeDelta;
};
public Clock getTime() {
return this.timeSystem;
};
public void setApplWakeUpTime(final Clock _timeUpAppl) {
this.timeUpAppl = _timeUpAppl;
};
public void setDelta(final Duration _timeDelta) {
this.timeDelta = _timeDelta;
};
public void setDeltaCall(final Duration _timeDeltaCall) {
this.timeDeltaCall = _timeDeltaCall;
};
public void setTime(final Clock _timeSystem) {
this.timeSystem = _timeSystem;
};
}

View File

@ -1,24 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/widget/Widget.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::event::Input);
etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::Input& _obj) {
_os << "{type=" << _obj.getType();
_os << " status=" << _obj.getStatus();
_os << " id=" << etk::toString(_obj.getId());
_os << " pos=" << _obj.getPos();
_os << "}";
return _os;
}
etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::InputSystem& _obj) {
_os << _obj.m_event;
return _os;
}

View File

@ -1,104 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
namespace ewol {
namespace event {
class Input {
private:
enum gale::key::type m_type;
enum gale::key::status m_status;
uint8_t m_inputId;
Vector2f m_pos;
gale::key::Special m_specialKey; //!< input key status (prevent change in time..)
public:
Input(enum gale::key::type _type,
enum gale::key::status _status,
uint8_t _id,
const Vector2f& _pos,
gale::key::Special _specialKey):
m_type(_type),
m_status(_status),
m_inputId(_id),
m_pos(_pos),
m_specialKey(_specialKey) {
};
void setType(enum gale::key::type _type) {
m_type = _type;
};
inline const enum gale::key::type& getType() const {
return m_type;
};
void setStatus(enum gale::key::status _status) {
m_status = _status;
};
inline const enum gale::key::status& getStatus() const {
return m_status;
};
void setId(uint8_t _id) {
m_inputId = _id;
};
inline const uint8_t& getId() const {
return m_inputId;
};
void setPos(const Vector2f& _pos) {
m_pos = _pos;
};
inline const Vector2f& getPos() const {
return m_pos;
};
void setSpecialKey(const gale::key::Special& _specialKey) {
m_specialKey = _specialKey;
};
inline const gale::key::Special& getSpecialKey() const {
return m_specialKey;
};
/**
* @brief Reset the input property of the curent event.
*/
void reset() const {
// TODO : Call the entry element ant rest it ...
}
};
etk::Stream& operator <<(etk::Stream& _os, const ewol::event::Input& _obj);
class InputSystem {
public:
InputSystem(enum gale::key::type _type,
enum gale::key::status _status,
uint8_t _id,
const Vector2f& _pos,
ewol::WidgetShared _dest,
int32_t _realIdEvent,
gale::key::Special _specialKey) :
m_event(_type, _status, _id, _pos, _specialKey),
m_dest(_dest),
m_realIdEvent(_realIdEvent) { };
ewol::event::Input m_event;
private:
ewol::WidgetShared m_dest;
int32_t m_realIdEvent;
public:
void setDestWidget(ewol::WidgetShared _dest) {
m_dest = _dest;
};
inline ewol::WidgetShared getDestWidget() const {
return m_dest;
};
void setRealId(int32_t _realIdEvent) {
m_realIdEvent = _realIdEvent;
};
inline int32_t getRealId() const {
return m_realIdEvent;
};
};
etk::Stream& operator <<(etk::Stream& _os, const ewol::event::InputSystem& _obj);
};
};

View File

@ -0,0 +1,38 @@
package org.atriasoft.ewol.event;
import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.gale.key.KeySpecial;
import org.atriasoft.gale.key.KeyStatus;
import org.atriasoft.gale.key.KeyType;
import jdk.internal.org.jline.reader.Widget;
public class InputSystem {
public EventInput event;
private Widget dest;
private int realIdEvent;
public InputSystem(final KeyType _type, final KeyStatus _status, final int _id, final Vector2f _pos, final Widget _dest, final int _realIdEvent, final KeySpecial _specialKey) {
this.event = new EventInput(_type, _status, _id, _pos, _specialKey);
this.dest = _dest;
this.realIdEvent = _realIdEvent;
}
public Widget getDestWidget() {
return this.dest;
}
public int getRealId() {
return this.realIdEvent;
}
public void setDestWidget(final Widget _dest) {
this.dest = _dest;
}
public void setRealId(final int _realIdEvent) {
this.realIdEvent = _realIdEvent;
}
}

View File

@ -1,35 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/widget/Widget.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::event::Time);
etk::Stream& ewol::event::operator <<(etk::Stream& _os, const ewol::event::Time& _obj) {
_os << "{time=" << _obj.getTime();
_os << " uptime=" << _obj.getApplUpTime();
_os << " delta=" << _obj.getDelta();
_os << " deltaCall=" << _obj.getDeltaCall();
_os << "}";
return _os;
}
namespace etk {
template<> etk::String toString<ewol::event::Time>(ewol::event::Time const& _obj) {
etk::String out;
out = "{[ewol::event::Time]time=" + etk::toString(_obj.getTime());
out += ";uptime=" + etk::toString(_obj.getApplUpTime());
out += ";delta=" + etk::toString(_obj.getDelta());
out += ";deltaCall=" + etk::toString(_obj.getDeltaCall());
out += "}";
return out;
}
}
// declare for signal event
#include <esignal/details/Signal.hxx>
ESIGNAL_DECLARE_SIGNAL(ewol::event::Time);

View File

@ -1,69 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <echrono/Clock.hpp>
#include <echrono/Duration.hpp>
namespace ewol {
namespace event {
class Time {
private:
echrono::Clock m_timeSystem; //!< Current system time (micro-second)
echrono::Clock m_timeUpAppl; //!< Current application wake up-time (micro-second)
echrono::Duration m_timeDelta; //!< Time from the last cycle call of the system (main appl tick) (second)
echrono::Duration m_timeDeltaCall; //!< Time from the last call (when we can manage periodic call with specifying periode) (second)
public:
Time(const echrono::Clock& _timeSystem,
const echrono::Clock& _timeUpAppl,
const echrono::Duration& _timeDelta,
const echrono::Duration& _timeDeltaCall) :
m_timeSystem(_timeSystem),
m_timeUpAppl(_timeUpAppl),
m_timeDelta(_timeDelta),
m_timeDeltaCall(_timeDeltaCall){
};
public:
void setTime(const echrono::Clock& _timeSystem) {
m_timeSystem = _timeSystem;
};
inline const echrono::Clock& getTime() const {
return m_timeSystem;
};
void setApplWakeUpTime(const echrono::Clock& _timeUpAppl) {
m_timeUpAppl = _timeUpAppl;
};
inline const echrono::Clock& getApplWakeUpTime() const {
return m_timeUpAppl;
};
inline echrono::Duration getApplUpTime() const {
return m_timeSystem-m_timeUpAppl;
};
void setDelta(const echrono::Duration& _timeDelta) {
m_timeDelta = _timeDelta;
};
inline const echrono::Duration& getDeltaDuration() const {
return m_timeDelta;
};
inline float getDelta() const {
return m_timeDelta.toSeconds();
};
void setDeltaCall(const echrono::Duration& _timeDeltaCall) {
m_timeDeltaCall = _timeDeltaCall;
};
inline const echrono::Duration& getDeltaCallDuration() const {
return m_timeDeltaCall;
};
inline float getDeltaCall() const {
return m_timeDeltaCall.toSeconds();
};
};
etk::Stream& operator <<(etk::Stream& _os, const ewol::event::Time& _obj);
}
}

View File

@ -17,16 +17,16 @@
#define EWOL_VERSION "0.0.0" #define EWOL_VERSION "0.0.0"
#endif #endif
etk::String ewol::getVersion() { String ewol::getVersion() {
return EWOL_VERSION; return EWOL_VERSION;
} }
int32_t ewol::run(ewol::context::Application* _application, int ewol::run(EwolApplication* _application,
int32_t _argc, int _argc,
const char* _argv[]) { char* _argv[]) {
etranslate::init(_argc, _argv); etranslate::init(_argc, _argv);
return gale::run(ETK_NEW(ewol::Context, _application), _argc, _argv); return gale::run(ETK_NEW(EwolContext, _application), _argc, _argv);
} }

View File

@ -1,14 +1,18 @@
/** @file /** @file
* @author Edouard DUPIN * @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once import org.atriasoft.ewol.context.EwolApplication;
import org.atriasoft.ewol.context.EwolContext;
#include <etk/types.hpp> class Ewol {
#include <ewol/context/Application.hpp> public static EwolContext getContext() {
// TODO Auto-generated method stub
return EwolContext.getContext();
}
namespace ewol {
/** /**
* @brief This is the only one things the User might done in his main(); * @brief This is the only one things the User might done in his main();
* @note To answare you before you ask the question, this is really simple: * @note To answare you before you ask the question, this is really simple:
@ -21,10 +25,5 @@ namespace ewol {
* @param[in] _argv Standard argv * @param[in] _argv Standard argv
* @return normal error int for the application error management * @return normal error int for the application error management
*/ */
int32_t run(ewol::context::Application* _application, int32_t _argc = 0, const char* _argv[] = null); public static int run(final EwolApplication _application, String[] _argv);
/** }
* @brief get EWOL version
* @return The string that describe ewol version
*/
etk::String getVersion();
};

View File

@ -10,7 +10,7 @@
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(enum ewol::gravity); ETK_DECLARE_TYPE(enum ewol::gravity);
etk::String ewol::gravityToString(const enum ewol::gravity _obj) { String ewol::gravityToString( enum ewol::gravity _obj) {
switch(_obj) { switch(_obj) {
case ewol::gravity_center: case ewol::gravity_center:
return "center"; return "center";
@ -34,7 +34,7 @@ etk::String ewol::gravityToString(const enum ewol::gravity _obj) {
return "unknow"; return "unknow";
} }
enum ewol::gravity ewol::stringToGravity(const etk::String& _obj) { enum ewol::gravity ewol::stringToGravity( String _obj) {
if (_obj == "center") { if (_obj == "center") {
return ewol::gravity_center; return ewol::gravity_center;
} else if (_obj == "top-left") { } else if (_obj == "top-left") {
@ -56,31 +56,31 @@ enum ewol::gravity ewol::stringToGravity(const etk::String& _obj) {
} }
return ewol::gravity_center; return ewol::gravity_center;
} }
Vector2f ewol::gravityGenerateDelta(const enum ewol::gravity _gravity, const Vector2f& _deltas) { Vector2f ewol::gravityGenerateDelta( enum ewol::gravity _gravity, Vector2f _deltas) {
Vector2f out(0.0f,0.0f); Vector2f out(0.0f,0.0f);
if (_deltas.x() > 0.0001f) { if (_deltas.x() > 0.0001f) {
if ((uint32_t(_gravity) & uint32_t(ewol::gravity_left)) != 0) { if ((uint(_gravity) uint(ewol::gravity_left)) != 0) {
// nothing to do // nothing to do
} else if ((uint32_t(_gravity) & uint32_t(ewol::gravity_right)) != 0) { } else if ((uint(_gravity) uint(ewol::gravity_right)) != 0) {
out = Vector2f(int32_t(_deltas.x()), 0.0f); out = Vector2f(int(_deltas.x()), 0.0f);
} else { } else {
out = Vector2f(int32_t(_deltas.x()*0.5f), 0.0f); out = Vector2f(int(_deltas.x()*0.5f), 0.0f);
} }
} }
if (_deltas.y() > 0.0001f) { if (_deltas.y() > 0.0001f) {
if ((uint32_t(_gravity) & uint32_t(ewol::gravity_buttom)) != 0) { if ((uint(_gravity) uint(ewol::gravity_buttom)) != 0) {
// nothing to do // nothing to do
} else if ((uint32_t(_gravity) & uint32_t(ewol::gravity_top)) != 0) { } else if ((uint(_gravity) uint(ewol::gravity_top)) != 0) {
out += Vector2f(0.0f, int32_t(_deltas.y())); out += Vector2f(0.0f, int(_deltas.y()));
} else { } else {
out += Vector2f(0.0f, int32_t(_deltas.y()*0.5f)); out += Vector2f(0.0f, int(_deltas.y()*0.5f));
} }
} }
return out; return out;
} }
etk::Stream& ewol::operator <<(etk::Stream& _os, const enum ewol::gravity _obj) { etk::Stream ewol::operator +(etk::Stream _os, enum ewol::gravity _obj) {
_os << ewol::gravityToString(_obj); _os + ewol::gravityToString(_obj);
return _os; return _os;
} }

View File

@ -1,31 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <etk/math/Vector2D.hpp>
namespace ewol {
/**
* @brief Gravity of the widget property
* @not_in_doc
*/
enum gravity {
gravity_center = 0x00, //!< gravity is in center
gravity_top = 0x01, //!< gravity is in top
gravity_buttom = 0x02, //!< gravity is in buttom
gravity_right = 0x04, //!< gravity is in right
gravity_left = 0x08, //!< gravity is in left
gravity_topRight = gravity_top|gravity_right, //!< gravity is in top-right
gravity_topLeft = gravity_top|gravity_left, //!< gravity is in top-left
gravity_buttomRight = gravity_buttom|gravity_right, //!< gravity is in buttom-right
gravity_buttomLeft = gravity_buttom|gravity_left, //!< gravity is in buttom-left
};
etk::Stream& operator <<(etk::Stream& _os, const enum ewol::gravity _obj);
etk::String gravityToString(const enum ewol::gravity _obj);
enum ewol::gravity stringToGravity(const etk::String& _obj);
Vector2f gravityGenerateDelta(const enum ewol::gravity _gravity, const Vector2f& _deltas);
}

View File

@ -3,7 +3,7 @@ package org.atriasoft.ewol.internal;
import io.scenarium.logger.LogLevel; import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger; import io.scenarium.logger.Logger;
class Log { public class Log {
private static final String LIB_NAME = "ewol"; private static final String LIB_NAME = "ewol";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME); private static final String LIB_NAME_DRAW = Logger.getDrawableName(LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL); private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(LIB_NAME, LogLevel.CRITICAL);

View File

@ -0,0 +1,237 @@
package org.atriasoft.ewol.object;
import java.lang.ref.WeakReference;
import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.internal.Log;
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
/**
* @brief Basic message classes for ewol system
* this class mermit at every Object to communicate between them.
*/
public class EwolObject {
private static Integer valUID = 0; //!< Static used for the unique ID definition
/**
* @brief get the curent the system inteface.
* @return current reference on the instance.
*/
protected static EwolContext getContext() {
return Ewol.getContext();
}
/**
* @breif get the current Object manager.
* @return the requested object manager.
*/
public static ObjectManager getObjectManager() {
return Ewol.getContext().getEObjectManager();
}
/**
* @brief Retrive an object with his name (in the global list)
* @param[in] _name Name of the object
* @return the requested object or null
*/
public static EwolObject getObjectNamed(final String _objectName) {
return getObjectManager().getObjectNamed(_objectName);
}
//@EwolPropertyDescription("Object name, might be a unique reference in all the program")
//@JacksonXmlProperty(isAttribute = true, localName = "name")
private String name = ""; //!< name of the element ...
protected WeakReference<EwolObject> parent = null; //!< Reference on the current parent.
protected boolean destroy = false; //!< Flag to know if the object is requesting has destroy.
private final boolean staticObject = false; //!< set this variable at true if this element must not be auto destroy (exemple : use static object);
private final int uniqueId; //!< Object UniqueID == > TODO : Check if it use is needed
private boolean isResource = false; //!< enable this when you want to declare this element is auto-remove
/**
* @brief Constructor.
*/
public EwolObject() {
// note this is nearly atomic ... (but it is enough)
synchronized (valUID) {
this.uniqueId = EwolObject.valUID++;
}
Log.debug("new Object : [" + this.uniqueId + "]");
getObjectManager().add(this);
}
/**
* @brief Auto-destroy the object
*/
protected void autoDestroy() {
Log.verbose("Destroy object: [" + getId() + "] type:" + this.getClass().getCanonicalName());
final EwolObject parent = this.parent.get();
// TODO : set a signal to do this ...
if (parent != null) {
Log.verbose("Destroy object: Call parrent");
parent.requestDestroyFromChild(this);
}
//if no parent ==> noting to do ...
this.destroy = true;
}
/**
* @brief Destroy the current object
*/
public void destroy() {
autoDestroy();
};
/**
* @brief get the UniqueId of the Object
* @return the requested ID
*/
public int getId() {
return this.uniqueId;
}
public String getName() {
return this.name;
};
/**
* @brief load attribute properties with an XML node.
* @param[in] _node Reference on the XML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
/*
boolean loadXMLAttributes( exml::Element _node){
if (_node.exist() == false) {
return false;
}
boolean errorOccured = false;
for( auto it : _node.attributes) {
auto pair = it.getPair();
if (pair.first == "") {
continue;
}
if (properties.set(pair.first, pair.second) == false) {
errorOccured = true;
}
}
return errorOccured;
}
*/
/**
* @brief load properties with an XML node.
* @param[in] _node Reference on the XML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
//boolean loadXML( exml::Element _node);
/**
* @brief store properties in this XML node.
* @param[in,out] _node Reference on the XML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
/*
boolean storeXML(exml::Element _node){
if (_node.exist() == false) {
return false;
}
boolean errorOccured = true;
for (auto it : properties.getAll(true)) {
_node.attributes.set(it.first, it.second);
}
return errorOccured;
}
*/
/**
* @brief get the static status of the Object == > mark at true if the user set the object mark as static allocated element ==> not auto remove element
* @return true if it might not be removed == > usefull for conficuration class
*/
public boolean getStatic() {
return this.staticObject;
}
/**
* @brief Get the resource status of the element.
* @return the resource status.
*/
public boolean getStatusResource() {
return this.isResource;
}
/**
* @brief Retrive an object with his name (in the global list)
* @param[in] _name Name of the object
* @return the requested object or null
*/
public EwolObject getSubObjectNamed(final String _objectName) {
Log.verbose("check if name : " + _objectName + " ?= " + this.propertyName);
if (_objectName == this.propertyName) {
return this;
}
return null;
}
/**
* @brief Check if the current objetc his destroy (in removing)
* @return true The object is removed
* @return false The object is not removed
*/
boolean isDestroyed() {
return this.destroy;
}
/**
* @brief Remove the current parenting.
*/
void removeParent() {
this.parent = null;
}
/**
* @brief Called by a whild that want to remove pointer of itself from the current list of his parrent
* @param[in] _child Object of the child that want to remove itself
*/
protected void requestDestroyFromChild(final EwolObject _child) {
Log.info("requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ...");
Log.critical("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)");
}
public void setName(final String name) {
this.name = name;
}
/**
* @brief Set the Object has new parrent.
* @param[in] _newParent Object that requesting the parenting
*/
public void setParent(final EwolObject _newParent) {
// TODO : Implement change of parent ...
this.parent = new WeakReference<>(_newParent);
}
/**
* @brief Declare this element as a resource (or singleton) this mean the element will
* not be auto Remove at the end of the programm. It just notify that it is not removed.
* @param[in] _val Value of the type of the element.
*/
public void setStatusResource(final boolean _val) {
this.isResource = _val;
}
}

View File

@ -10,25 +10,25 @@
#include <etk/stdTools.hpp> #include <etk/stdTools.hpp>
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::object::Manager); ETK_DECLARE_TYPE(ObjectManager);
ewol::object::Manager::Manager(ewol::Context& _context) : ObjectManager::Manager(EwolContext _context) :
m_context(_context), this.context(_context),
periodicCall(this, "periodic", "Call every time system render"), periodicCall(this, "periodic", "Call every time system render"),
m_applWakeUpTime(0), this.applWakeUpTime(0),
m_lastPeriodicCallTime(0) { this.lastPeriodicCallTime(0) {
Log.debug(" == > init Object-Manager"); Log.debug(" == > init Object-Manager");
periodicCall.setPeriodic(true); periodicCall.setPeriodic(true);
// set the basic time properties : // set the basic time properties :
m_applWakeUpTime = echrono::Clock::now(); this.applWakeUpTime = echrono::Clock::now();
m_lastPeriodicCallTime = m_applWakeUpTime; this.lastPeriodicCallTime = this.applWakeUpTime;
} }
ewol::object::Manager::~Manager() { ObjectManager::~Manager() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
m_workerList.clear(); this.workerList.clear();
bool hasError = false; boolean hasError = false;
if (m_eObjectList.size()!=0) { if (this.eObjectList.size()!=0) {
Log.error("Must not have anymore eObject !!!"); Log.error("Must not have anymore eObject !!!");
hasError = true; hasError = true;
} }
@ -38,76 +38,76 @@ ewol::object::Manager::~Manager() {
displayListObject(); displayListObject();
} }
void ewol::object::Manager::displayListObject() { void ObjectManager::displayListObject() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
Log.info("List loaded object : "); Log.info("List loaded object : ");
for (auto &it : m_eObjectList) { for (auto it : this.eObjectList) {
ewol::ObjectShared element = it.lock(); EwolObject element = it.lock();
if (element != null) { if (element != null) {
Log.info(" [" << element->getId() << "] ref=" << element.useCount()-1 << " name='" << element->propertyName.get() << "' type=" << element->getObjectType()); Log.info(" [" + element.getId() + "] ref=" + element.useCount()-1 + " name='" + element.propertyName.get() + "' type=" + element.getObjectType());
} }
} }
} }
void ewol::object::Manager::unInit() { void ObjectManager::unInit() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
Log.debug(" == > Un-Init Object-Manager"); Log.debug(" == > Un-Init Object-Manager");
if (m_workerList.size() > 0) { if (this.workerList.size() > 0) {
Log.debug(" == > Remove all workers"); Log.debug(" == > Remove all workers");
m_workerList.clear(); this.workerList.clear();
} }
for (auto &it : m_eObjectList) { for (auto it : this.eObjectList) {
ewol::ObjectShared element = it.lock(); EwolObject element = it.lock();
if (element != null) { if (element != null) {
//it->removeObject(); //it.removeObject();
} }
} }
if (m_eObjectList.size() != 0) { if (this.eObjectList.size() != 0) {
Log.error("Have " << m_eObjectList.size() << " active Object"); Log.error("Have " + this.eObjectList.size() + " active Object");
} }
m_eObjectList.clear(); this.eObjectList.clear();
} }
void ewol::object::Manager::add(const ewol::ObjectShared& _object) { void ObjectManager::add( EwolObject _object) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if (_object == null) { if (_object == null) {
Log.error("try to add an inexistant Object in manager"); Log.error("try to add an inexistant Object in manager");
} }
m_eObjectList.pushBack(_object); this.eObjectList.pushBack(_object);
} }
int32_t ewol::object::Manager::getNumberObject() { int ObjectManager::getNumberObject() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
return m_eObjectList.size(); return this.eObjectList.size();
} }
// clean all Object that request an autoRemove ... // clean all Object that request an autoRemove ...
void ewol::object::Manager::cleanInternalRemoved() { void ObjectManager::cleanInternalRemoved() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
size_t nbObject = m_eObjectList.size(); int nbObject = this.eObjectList.size();
Log.verbose("Clean Object List (if needed) : " << m_eObjectList.size() << " elements"); Log.verbose("Clean Object List (if needed) : " + this.eObjectList.size() + " elements");
auto it(m_eObjectList.begin()); auto it(this.eObjectList.begin());
while (it != m_eObjectList.end()) { while (it != this.eObjectList.end()) {
if (it->expired() == true) { if (it.expired() == true) {
it = m_eObjectList.erase(it); it = this.eObjectList.erase(it);
} else { } else {
++it; ++it;
} }
} }
if (m_eObjectList.size() != nbObject) { if (this.eObjectList.size() != nbObject) {
Log.verbose(" remove " << nbObject - m_eObjectList.size() << " deprecated objects"); Log.verbose(" remove " + nbObject - this.eObjectList.size() + " deprecated objects");
} }
} }
ewol::ObjectShared ewol::object::Manager::get(const etk::String& _name) { EwolObject ObjectManager::get( String _name) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if (_name == "") { if (_name == "") {
return null; return null;
} }
for (auto &it : m_eObjectList) { for (auto it : this.eObjectList) {
ewol::ObjectShared element = it.lock(); EwolObject element = it.lock();
if ( element != null if ( element != null
&& element->propertyName.get() == _name) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM element.propertyName.get() == _name) {
return element; return element;
} }
} }
@ -115,47 +115,47 @@ ewol::ObjectShared ewol::object::Manager::get(const etk::String& _name) {
} }
ewol::ObjectShared ewol::object::Manager::getObjectNamed(const etk::String& _name) { EwolObject ObjectManager::getObjectNamed( String _name) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
return ewol::object::Manager::get(_name); return ObjectManager::get(_name);
} }
void ewol::object::Manager::workerAdd(const ewol::ObjectShared& _worker) { void ObjectManager::workerAdd( EwolObject _worker) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
m_workerList.pushBack(_worker); this.workerList.pushBack(_worker);
} }
void ewol::object::Manager::workerRemove(const ewol::ObjectShared& _worker) { void ObjectManager::workerRemove( EwolObject _worker) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
auto it(m_workerList.begin()); auto it(this.workerList.begin());
while (it != m_workerList.end()) { while (it != this.workerList.end()) {
if (*it == _worker) { if (*it == _worker) {
it = m_workerList.erase(it); it = this.workerList.erase(it);
} else { } else {
++it; ++it;
} }
} }
} }
void ewol::object::Manager::timeCall(const echrono::Clock& _localTime) { void ObjectManager::timeCall( echrono::Clock _localTime) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
echrono::Clock previousTime = m_lastPeriodicCallTime; echrono::Clock previousTime = this.lastPeriodicCallTime;
m_lastPeriodicCallTime = _localTime; this.lastPeriodicCallTime = _localTime;
if (periodicCall.size() <= 0) { if (periodicCall.size() <= 0) {
return; return;
} }
echrono::Duration deltaTime = _localTime - previousTime; echrono::Duration deltaTime = _localTime - previousTime;
ewol::event::Time myTime(_localTime, m_applWakeUpTime, deltaTime, deltaTime); ewol::event::Time myTime(_localTime, this.applWakeUpTime, deltaTime, deltaTime);
periodicCall.emit(myTime); periodicCall.emit(myTime);
} }
void ewol::object::Manager::timeCallResume(const echrono::Clock& _localTime) { void ObjectManager::timeCallResume( echrono::Clock _localTime) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
m_lastPeriodicCallTime = _localTime; this.lastPeriodicCallTime = _localTime;
} }
bool ewol::object::Manager::timeCallHave() { boolean ObjectManager::timeCallHave() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
return periodicCall.size() > 0; return periodicCall.size() > 0;
} }

View File

@ -1,105 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <ewol/object/Object.hpp>
#include <esignal/Signal.hpp>
#include <ewol/event/Time.hpp>
#include <echrono/Steady.hpp>
#include <echrono/Duration.hpp>
#include <ethread/MutexRecursive.hpp>
namespace ewol {
class Context;
namespace object {
class Manager : public esignal::Interface {
protected:
ethread::MutexRecursive m_mutex;
private:
List<ewol::ObjectWeak> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
Context& m_context;
public:
Manager(Context& _context);
virtual ~Manager();
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
void unInit();
/**
* @brief Get the number of loaded object in the system
* @return number of Object
*/
int32_t getNumberObject();
/**
* @brief Display all object Open.
*/
void displayListObject();
private:
//! @not_in_doc
friend class ewol::Object;
/**
* @brief Internal API that used only with Object toi reference itself in the manager.
* @note The manager remove the object when the refecence Low down 1 (last keeper)
* @param[in] _object Reference shared pointer on the object
*/
void add(const ewol::ObjectShared& _object);
public:
/**
* @brief clean the weak pointer list (remove weak_ptr that is remoed)
*/
void cleanInternalRemoved();
/**
* @brief Retrive an Object with his name
* @param[in] _name Name of the Object
* @return Pointer on the finded Object.
*/
ewol::ObjectShared get(const etk::String& _name);
public:
/**
* @brief retrive an object with his name
* @param[in] _name Name of the object
* @return the requested object or null
*/
ewol::ObjectShared getObjectNamed(const etk::String& _name);
private:
List<ewol::ObjectShared> m_workerList;
public:
/**
* @brief Add a worker on the system list.
* @param[in] _worker Worker to add in the list.
*/
void workerAdd(const ewol::ObjectShared& _worker);
/**
* @brief Remove a worker on the system list.
* @param[in] _worker Worker to add in the list.
*/
void workerRemove(const ewol::ObjectShared& _worker);
public:
esignal::Signal<ewol::event::Time> periodicCall;
private:
echrono::Clock m_applWakeUpTime; //!< Time of the application initialize
echrono::Clock m_lastPeriodicCallTime; //!< last call time ...
public: // ewol system internal :
/**
* @brief Call every time we can with the current time
* @param[in] _localTime Current system Time.
*/
void timeCall(const echrono::Clock& _localTime);
/**
* @brief If the application is suspended The Ewol Object manager does not know it, just call this to update delta call
* @param[in] _localTime Current system Time.
*/
void timeCallResume(const echrono::Clock& _localTime);
/**
* @breif check if the Interface have some user that request a periodic call
* @return true, have some periodic event...
*/
bool timeCallHave();
};
};
};

View File

@ -1,186 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#include <ewol/object/Object.hpp>
#include <ewol/object/Manager.hpp>
#include <ewol/debug.hpp>
#include <ewol/context/Context.hpp>
#include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::Object);
size_t ewol::Object::m_valUID = 0;
void ewol::Object::autoDestroy() {
if (m_objectHasBeenInit == false) {
EWOL_WARNING("try to auto destroy inside a constructor");
return;
}
Log.verbose("Destroy object: [" << getId() << "] type:" << getObjectType());
ewol::ObjectShared parent = m_parent.lock();
// TODO : set a signal to do this ...
if (parent != null) {
Log.verbose("Destroy object: Call parrent");
parent->requestDestroyFromChild(sharedFromThis());
}
//if no parent ==> noting to do ...
m_destroy = true;
}
bool ewol::Object::objectHasBeenCorectlyInit() {
return m_objectHasBeenInit;
}
void ewol::Object::requestDestroyFromChild(const ewol::ObjectShared& _child) {
Log.info("requestDestroyFromChild(...) is called when an object reference as a parent have a child that request quto-destroy ...");
Log.critical("Call From Child with no effects ==> must implement : requestDestroyFromChild(...)");
}
void ewol::Object::destroy() {
autoDestroy();
}
bool ewol::Object::isDestroyed() const {
return m_destroy;
}
void ewol::Object::setParent(const ewol::ObjectShared& _newParent) {
// TODO : Implement change of parent ...
m_parent = _newParent;
}
void ewol::Object::removeParent() {
m_parent.reset();
}
ewol::Object::Object() :
propertyName(this, "name", "", "Object name, might be a unique reference in all the program"),
m_objectHasBeenInit(false),
m_destroy(false),
m_static(false),
m_isResource(false) {
// note this is nearly atomic ... (but it is enough)
m_uniqueId = m_valUID++;
Log.debug("new Object : [" << m_uniqueId << "]");
}
ewol::Object::~Object() {
Log.debug("delete Object : [" << m_uniqueId << "] : " << getTypeDescription());
m_uniqueId = -1;
}
void ewol::Object::init() {
getObjectManager().add(sharedFromThis());
//parameterDisplay();
m_objectHasBeenInit = true;
}
const char * const ewol::Object::getObjectType() const {
if (m_listType.size() == 0) {
return "ewol::Object";
}
return m_listType.back();
}
void ewol::Object::addObjectType(const char* _type) {
if (_type == null) {
Log.error(" try to add a type with no value...");
return;
}
m_listType.pushBack(_type);
}
etk::String ewol::Object::getTypeDescription() const {
etk::String ret("ewol::Object");
for(auto element : m_listType) {
ret += "|";
ret += element;
}
return ret;
}
bool ewol::Object::isTypeCompatible(const etk::String& _type) const {
if (_type == "ewol::Object") {
return true;
}
for(auto element : m_listType) {
if (_type == element) {
return true;
}
}
return false;
}
bool ewol::Object::loadXMLAttributes(const exml::Element& _node) {
if (_node.exist() == false) {
return false;
}
bool errorOccured = false;
for(const auto it : _node.attributes) {
auto pair = it.getPair();
if (pair.first == "") {
continue;
}
if (properties.set(pair.first, pair.second) == false) {
errorOccured = true;
}
}
return errorOccured;
}
bool ewol::Object::loadXML(const exml::Element& _node) {
return true; //loadXMLAttributes(_node);
}
bool ewol::Object::storeXML(exml::Element& _node) const {
if (_node.exist() == false) {
return false;
}
bool errorOccured = true;
for (auto &it : properties.getAll(true)) {
_node.attributes.set(it.first, it.second);
}
return errorOccured;
}
bool ewol::Object::propertySetOnWidgetNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value) {
ewol::ObjectShared object = getObjectManager().get(_objectName);
if (object == null) {
return false;
}
return object->properties.set(_config, _value);
}
ewol::object::Manager& ewol::Object::getObjectManager() {
ewol::object::Manager& tmp = ewol::getContext().getEObjectManager();
return tmp;
}
ewol::Context& ewol::Object::getContext() {
return ewol::getContext();
}
ewol::ObjectShared ewol::Object::getObjectNamed(const etk::String& _objectName) {
return getObjectManager().getObjectNamed(_objectName);
}
ewol::ObjectShared ewol::Object::getSubObjectNamed(const etk::String& _objectName) {
Log.verbose("check if name : " << _objectName << " ?= " << propertyName.get());
if (_objectName == propertyName.get()) {
return sharedFromThis();
}
return null;
}
bool ewol::propertySetOnObjectNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value) {
ewol::ObjectShared object = ewol::getContext().getEObjectManager().get(_objectName);
if (object == null) {
return false;
}
return object->properties.set(_config, _value);
}

View File

@ -1,339 +0,0 @@
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
#pragma once
#include <etk/types.hpp>
#include <etk/Vector.hpp>
#include <exml/exml.hpp>
#include <ethread/Mutex.hpp>
#include <ememory/memory.hpp>
#include <ewol/debug.hpp>
#include <ememory/memory.hpp>
#include <eproperty/Interface.hpp>
#include <eproperty/Value.hpp>
#include <eproperty/Range.hpp>
#include <eproperty/List.hpp>
#include <esignal/Interface.hpp>
namespace ewol {
// some class need to define element befor other ...
class Object;
namespace object {
class Manager;
}
class Context;
}
template<class TYPE_OBJECT> static void baseInit(const ememory::SharedPtr<TYPE_OBJECT>& _object) {
// end of recurtion
return;
}
template<class TYPE_OBJECT, class TYPE_VAL, class ... TYPE> static void baseInit(const ememory::SharedPtr<TYPE_OBJECT>& _object, const etk::String& _name, const TYPE_VAL& _val, TYPE&& ... _all ) {
eproperty::Property* prop(null);
eproperty::PropertyType<TYPE_VAL>* propType(null);
if (_object == null) {
Log.error("EMPTY pointer");
return;
}
prop = _object->properties.getRaw(_name);
if (prop == null) {
Log.error("property does not exit ... '" << _name << "'");
goto exit_on_error;
}
propType = dynamic_cast<eproperty::PropertyType<TYPE_VAL>*>(prop);
if (propType == null) {
Log.error("property does not cast in requested type ... '" << _name << "' require type : " << /*typeid(_val).name()*/ "?TODO?" << "' instead of '" << prop->getType() << "'");
goto exit_on_error;
}
propType->setDirectCheck(_val);
exit_on_error:
baseInit(_object, etk::forward<TYPE>(_all)... );
return;
}
#define UN_DECLARE_FACTORY(className) \
template<class ... EWOL_FACTORY_CREATE_TYPE> static ememory::SharedPtr<className> create(const EWOL_FACTORY_CREATE_TYPE& ... _all) = delete;
#define DECLARE_FACTORY(className) \
template<class ... EWOL_FACTORY_CREATE_TYPE> static ememory::SharedPtr<className> create(const EWOL_FACTORY_CREATE_TYPE& ... _all) { \
ememory::SharedPtr<className> object(ETK_NEW(className)); \
if (object == null) { \
Log.error("Factory error"); \
return null; \
} \
baseInit(object, _all... ); \
object->init(); \
if (object->objectHasBeenCorectlyInit() == false) { \
Log.critical("Object Is not correctly init : " << #className ); \
} \
return object; \
} \
static ememory::SharedPtr<className> createXml(const exml::Element& _node) { \
ememory::SharedPtr<className> object(ETK_NEW(className)); \
if (object == null) { \
Log.error("Factory error"); \
return null; \
} \
object->loadXMLAttributes(_node); \
object->init(); \
if (object->objectHasBeenCorectlyInit() == false) { \
Log.critical("Object Is not correctly init : " << #className ); \
} \
return object; \
}
#define DECLARE_SINGLE_FACTORY(className, uniqueName) \
template<class ... EWOL_FACTORY_CREATE_TYPE> static ememory::SharedPtr<className> create(const EWOL_FACTORY_CREATE_TYPE& ... _all) { \
ememory::SharedPtr<className> object; \
ememory::SharedPtr<ewol::Object> object2 = getObjectNamed(uniqueName); \
if (object2 != null) { \
object = ememory::dynamicPointerCast<className>(object2); \
if (object == null) { \
Log.critical("Request object element: '" << uniqueName << "' With the wrong type (dynamic cast error)"); \
return null; \
} \
} \
if (object != null) { \
return object; \
} \
object = ememory::SharedPtr<className>(ETK_NEW(className)); \
if (object == null) { \
Log.error("Factory error"); \
return null; \
} \
baseInit(object, "name", etk::String(uniqueName), _all... ); \
object->init(); \
if (object->objectHasBeenCorectlyInit() == false) { \
Log.critical("Object Is not correctly init : " << #className ); \
} \
return object; \
}
namespace ewol {
using ObjectShared = ememory::SharedPtr<ewol::Object>;
using ObjectWeak = ememory::WeakPtr<ewol::Object>;
/**
* @brief Basic message classes for ewol system
* this class mermit at every Object to communicate between them.
*/
class Object : public ememory::EnableSharedFromThis<Object>,
public eproperty::Interface,
public esignal::Interface {
public: // Event list
public: // propertie list
eproperty::Value<etk::String> propertyName; //!< name of the element ...
private:
static size_t m_valUID; //!< Static used for the unique ID definition
private:
bool m_objectHasBeenInit; //!< Know if the init function has bben called
public:
/**
* @brief Destructor
*/
virtual ~Object();
protected:
/**
* @brief Constructor.
*/
Object();
virtual void init();
public:
/**
* @brief Factory
*/
DECLARE_FACTORY(Object);
bool objectHasBeenCorectlyInit();
protected:
ewol::ObjectWeak m_parent; //!< Reference on the current parrent.
bool m_destroy; //!< Flag to know if the object is requesting has destroy.
protected:
/**
* @brief Auto-destroy the object
*/
virtual void autoDestroy();
public:
/**
* @brief Destroy the current object
*/
virtual void destroy();
/**
* @brief Check if the current objetc his destroy (in removing)
* @return true The object is removed
* @return false The object is not removed
*/
bool isDestroyed() const;
protected:
/**
* @brief Called by a whild that want to remove pointer of itself from the current list of his parrent
* @param[in] _child Object of the child that want to remove itself
*/
virtual void requestDestroyFromChild(const ewol::ObjectShared& _child);
public:
/**
* @brief Set the Object has new parrent.
* @param[in] _newParent Object that requesting the parenting
*/
virtual void setParent(const ewol::ObjectShared& _newParent);
/**
* @brief Remove the current parenting.
*/
virtual void removeParent();
private:
List<const char*> m_listType;
public:
/**
* @brief get the current Object type of the Object
* @return the last type name of the element
*/
const char * const getObjectType() const;
/**
* @brief Get the herarchie of the Object type.
* @return descriptive string.
*/
etk::String getTypeDescription() const;
/**
* @brief check if the element herited from a specific type
* @param[in] _type Type to check.
* @return true if the element is compatible.
*/
bool isTypeCompatible(const etk::String& _type) const;
protected:
/**
* @brief Add a type of the list of Object.
* @param[in] _type new type to add.
*/
void addObjectType(const char* _type);
protected:
bool m_static; //!< set this variable at true if this element must not be auto destroy (exemple : use static object)
public:
/**
* @brief get the static status of the Object == > mark at true if the user set the object mark as static allocated element ==> not auto remove element
* @return true if it might not be removed == > usefull for conficuration class
*/
bool getStatic(){
return m_static;
};
private:
int32_t m_uniqueId; //!< Object UniqueID == > TODO : Check if it use is needed
public:
/**
* @brief get the UniqueId of the Object
* @return the requested ID
*/
int32_t getId(){
return m_uniqueId;
};
public:
// TODO : Rework the position on this function ... This is a convignent function ...
bool propertySetOnWidgetNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value);
public:
/**
* @brief load attribute properties with an XML node.
* @param[in] _node Reference on the XML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
bool loadXMLAttributes(const exml::Element& _node);
/**
* @brief load properties with an XML node.
* @param[in] _node Reference on the XML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool loadXML(const exml::Element& _node);
/**
* @brief store properties in this XML node.
* @param[in,out] _node Reference on the XML node.
* @return true : All has been done corectly.
* @return false : An error occured.
*/
virtual bool storeXML(exml::Element& _node) const;
public:
/**
* @breif get the current Object manager.
* @return the requested object manager.
*/
static ewol::object::Manager& getObjectManager();
/**
* @brief get the curent the system inteface.
* @return current reference on the instance.
*/
static ewol::Context& getContext();
private:
bool m_isResource; //!< enable this when you want to declare this element is auto-remove
public:
/**
* @brief Declare this element as a resource (or singleton) this mean the element will
* not be auto Remove at the end of the programm. It just notify that it is not removed.
* @param[in] _val Value of the type of the element.
*/
void setStatusResource(bool _val) {
m_isResource = _val;
}
/**
* @brief Get the resource status of the element.
* @return the resource status.
*/
bool getStatusResource() const {
return m_isResource;
}
/**
* @brief Retrive an object with his name (in the global list)
* @param[in] _name Name of the object
* @return the requested object or null
*/
static ewol::ObjectShared getObjectNamed(const etk::String& _objectName);
/**
* @brief Retrive an object with his name (in the global list)
* @param[in] _name Name of the object
* @return the requested object or null
*/
virtual ewol::ObjectShared getSubObjectNamed(const etk::String& _objectName);
protected:
// TODO : Create a template ...
/**
* @brief link on an signal in the subwiget with his name
*/
#define subBind(_type, _name, _event, _shared_ptr, _func, ...) do {\
ememory::SharedPtr<_type> myObject = ememory::dynamicPointerCast<_type>(getSubObjectNamed(_name)); \
if (myObject != null) { \
myObject->_event.connect(_shared_ptr, _func, ##__VA_ARGS__); \
} else { \
Log.error("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
} \
} while (false)
};
bool propertySetOnObjectNamed(const etk::String& _objectName, const etk::String& _config, const etk::String& _value);
};
/**
* @brief link on an signal in the global object list with his name
*/
#define globalBind(_type, _name, _event, _obj, _func, ...) do {\
ememory::SharedPtr<_type> myObject = ememory::dynamicPointerCast<_type>(ewol::getContext().getEObjectManager().getObjectNamed(_name)); \
if (myObject != null) { \
myObject->_event.connect(_obj, _func, ##__VA_ARGS__); \
} else { \
Log.error("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
} \
} while (false)
/**
* @brief link on an signal in the subWidget of an object with his name
*/
#define externSubBind(_object, _type, _name, _event, _obj, _func, ...) do {\
ememory::SharedPtr<_type> myObject = ememory::dynamicPointerCast<_type>(_object->getObjectNamed(_name)); \
if (myObject != null) { \
myObject->_event.connect(_obj, _func, ##__VA_ARGS__); \
} else { \
Log.error("object named='" << _name << "' not exit or can not be cast in : " << #_type); \
} \
} while (false)

View File

@ -0,0 +1,199 @@
package org.atriasoft.ewol.object;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.atriasoft.echrono.Clock;
import org.atriasoft.echrono.Steady;
import org.atriasoft.echrono.Time;
import org.atriasoft.esignal.Signal;
import org.atriasoft.ewol.context.EwolContext;
import org.atriasoft.ewol.internal.Log;
import org.atriasoft.gale.event.EventTime;
/** @file
* @author Edouard DUPIN
* @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
public class ObjectManager {
private final List<WeakReference<EwolObject>> eObjectList = new ArrayList<>(); // all widget allocated == > all time increment ... never removed ...
private final EwolContext context;
public ObjectManager(final EwolContext _context) {
this.context = _context;
//periodicCall(this, "periodic", "Call every time system render");
Log.debug(" == > init Object-Manager");
this.periodicCall.setPeriodic(true);
// set the basic time properties :
this.applWakeUpTime = Clock.now();
this.lastPeriodicCallTime = new Clock(this.applWakeUpTime.get());
}
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
synchronized void unInit() {
Log.debug(" == > Un-Init Object-Manager");
if (this.workerList.size() > 0) {
Log.debug(" == > Remove all workers");
this.workerList.clear();
}
for (final WeakReference<EwolObject> it : this.eObjectList) {
final EwolObject element = it.get();
if (element != null) {
//it.removeObject();
}
}
if (this.eObjectList.size() != 0) {
Log.error("Have " + this.eObjectList.size() + " active Object");
}
this.eObjectList.clear();
}
/**
* @brief Get the number of loaded object in the system
* @return number of Object
*/
synchronized
int getNumberObject() {
return this.eObjectList.size();
}
/**
* @brief Display all object Open.
*/
synchronized void displayListObject() {
Log.info("List loaded object : ");
for (final WeakReference<EwolObject> it : this.eObjectList) {
final EwolObject element = it.get();
if (element != null) {
Log.info(" [" + element.getId() + "] name='" + element.getName() + "' type=" + element.getClass().getCanonicalName());
}
}
}
/**
* @brief Internal API that used only with Object toi reference itself in the manager.
* @note The manager remove the object when the refecence Low down 1 (last keeper)
* @param[in] _object Reference shared pointer on the object
*/
private synchronized void add(final EwolObject _object) {
if (_object == null) {
Log.error("try to add an inexistant Object in manager");
}
this.eObjectList.add(new WeakReference<>(_object));
}
/**
* @brief clean the weak pointer list (remove weak_ptr that is remoed)
*/
public synchronized void cleanInternalRemoved() {
final int nbObject = this.eObjectList.size();
Log.verbose("Clean Object List (if needed) : " + this.eObjectList.size() + " elements");
final Iterator<WeakReference<EwolObject>> iterator = this.eObjectList.iterator();
while (iterator.hasNext()) {
final WeakReference<EwolObject> elem = iterator.next();
if (elem.get() == null) {
iterator.remove();
}
}
if (this.eObjectList.size() != nbObject) {
Log.verbose(" remove " + (nbObject - this.eObjectList.size()) + " deprecated objects");
}
}
/**
* @brief Retrive an Object with his name
* @param[in] _name Name of the Object
* @return Pointer on the finded Object.
*/
public synchronized EwolObject get(final String _name) {
if (_name.isEmpty() == true) {
return null;
}
for (final WeakReference<EwolObject> it : this.eObjectList) {
final EwolObject element = it.get();
if (element != null && element.getName().contentEquals(_name)) {
return element;
}
}
return null;
}
/**
* @brief retrive an object with his name
* @param[in] _name Name of the object
* @return the requested object or null
*/
public synchronized EwolObject getObjectNamed(final String _name) {
return ObjectManager.get(_name);
}
private final List<EwolObject> workerList = new ArrayList<>();
/**
* @brief Add a worker on the system list.
* @param[in] _worker Worker to add in the list.
*/
public synchronized void workerAdd(final EwolObject _worker) {
this.workerList.add(_worker);
}
/**
* @brief Remove a worker on the system list.
* @param[in] _worker Worker to add in the list.
*/
public synchronized void workerRemove(final EwolObject _worker) {
final Iterator<EwolObject> iterator = this.workerList.iterator();
while (iterator.hasNext()) {
final EwolObject elem = iterator.next();
if (elem == _worker) {
iterator.remove();
}
}
}
public final Signal<EventTime> periodicCall = new Signal<>();
private final Time applWakeUpTime; //!< Time of the application initialize
private Clock lastPeriodicCallTime; //!< last call time ...
/**
* @brief Call every time we can with the current time
* @param[in] _localTime Current system Time.
*/
public synchronized void timeCall( final Clock _localTime){
final Clock previousTime = this.lastPeriodicCallTime;
this.lastPeriodicCallTime = _localTime;
if (this.periodicCall.size() <= 0) {
return;
}
final Duration deltaTime = new Duration(_localTime.get() - previousTime.get());
final EventTime myTime(final _localTime, this.applWakeUpTime, deltaTime, deltaTime);
this.periodicCall.emit(myTime);
}
/**
* @brief If the application is suspended The Ewol Object manager does not know it, just call this to update delta call
* @param[in] _localTime Current system Time.
*/
public synchronized void timeCallResume(final Clock _localTime) {
this.lastPeriodicCallTime = _localTime;
}
/**
* @breif check if the Interface have some user that request a periodic call
* @return true, have some periodic event...
*/
public synchronized boolean timeCallHave() {
return this.periodicCall.size() > 0;
}
}

View File

@ -15,7 +15,7 @@ ewol::object::Worker::Worker() {
} }
void ewol::object::Worker::init() { void ewol::object::Worker::init() {
ewol::Object::init(); EwolObject::init();
getObjectManager().workerAdd(sharedFromThis()); getObjectManager().workerAdd(sharedFromThis());
} }
@ -24,6 +24,6 @@ ewol::object::Worker::~Worker() {
} }
void ewol::object::Worker::destroy() { void ewol::object::Worker::destroy() {
ewol::Object::destroy(); EwolObject::destroy();
getObjectManager().workerRemove(sharedFromThis()); getObjectManager().workerRemove(sharedFromThis());
} }

View File

@ -3,37 +3,20 @@
* @copyright 2011, Edouard DUPIN, all right reserved * @copyright 2011, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file) * @license MPL v2.0 (see license file)
*/ */
#pragma once
#include <ewol/debug.hpp> /**
#include <ewol/object/Object.hpp> * @brief A worker might not been possesed by someone, then the system might keep a pointer on it.
*/
public class Worker extends EwolObject {
/**
* @brief Constructor.
*/
public Worker() {
getObjectManager().workerAdd(this);
}
namespace ewol { @Override
namespace object { public void destroy() {
class Worker; getObjectManager().workerRemove(this);
using WorkerShared = ememory::SharedPtr<ewol::object::Worker>;
using WorkerWeak = ememory::WeakPtr<ewol::object::Worker>;
/**
* @brief A worker might not been possesed by someone, then the system might keep a pointer on it.
*/
class Worker : public ewol::Object {
protected:
/**
* @brief Constructor.
*/
Worker();
void init() override;
public:
/**
* @brief Factory
*/
DECLARE_FACTORY(Worker);
/**
* @brief Destructor
*/
virtual ~Worker();
public:
void destroy() override;
};
} }
} }

View File

@ -14,73 +14,73 @@ ETK_DECLARE_TYPE(ewol::resource::ColorFile);
ewol::resource::ColorFile::ColorFile() : ewol::resource::ColorFile::ColorFile() :
gale::Resource(), gale::Resource(),
// Set the list unodered // Set the list unodered
m_list(0, false), this.list(0, false),
m_errorColor(etk::color::orange) { this.errorColor(etk::color::orange) {
addResourceType("ewol::ColorFile"); addResourceType("ewol::ColorFile");
} }
void ewol::resource::ColorFile::init(const etk::Uri& _uri) { void ewol::resource::ColorFile::init( etk::Uri _uri) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
gale::Resource::init(_uri.get()); gale::Resource::init(_uri.get());
Log.debug("CF : load \"" << _uri << "\""); Log.debug("CF : load \"" + _uri + "\"");
reload(); reload();
Log.debug("List of all color : " << m_list.getKeys()); Log.debug("List of all color : " + this.list.getKeys());
} }
ewol::resource::ColorFile::~ColorFile() { ewol::resource::ColorFile::~ColorFile() {
// remove all element // remove all element
m_list.clear(); this.list.clear();
} }
void ewol::resource::ColorFile::reload() { void ewol::resource::ColorFile::reload() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
// remove all previous set of value : // remove all previous set of value :
for (size_t iii = 0; iii < m_list.size() ; ++iii) { for (int iii = 0; iii < this.list.size() ; ++iii) {
m_list.getValue(iii) = m_errorColor; this.list.getValue(iii) = this.errorColor;
} }
// open and read all json elements: // open and read all json elements:
ejson::Document doc; ejson::Document doc;
if (doc.load(etk::Uri(m_name)) == false) { if (doc.load(etk::Uri(this.name)) == false) {
Log.error("Can not load file : '" << m_name << "'"); Log.error("Can not load file : '" + this.name + "'");
return; return;
} }
ejson::Array baseArray = doc["color"].toArray(); ejson::Array baseArray = doc["color"].toArray();
if (baseArray.exist() == false) { if (baseArray.exist() == false) {
Log.error("Can not get basic array : 'color' in file:" << m_name); Log.error("Can not get basic array : 'color' in file:" + this.name);
doc.display(); doc.display();
return; return;
} }
bool findError = false; boolean findError = false;
for (const auto it : baseArray) { for ( auto it : baseArray) {
ejson::Object tmpObj = it.toObject(); ejson::Object tmpObj = it.toObject();
if (tmpObj.exist() == false) { if (tmpObj.exist() == false) {
Log.error(" can not get object in 'color' : " << it); Log.error(" can not get object in 'color' : " + it);
findError = true; findError = true;
continue; continue;
} }
etk::String name = tmpObj["name"].toString().get(); String name = tmpObj["name"].toString().get();
etk::String color = tmpObj["color"].toString().get(m_errorColor.getHexString()); String color = tmpObj["color"].toString().get(this.errorColor.getHexString());
Log.debug("find new color : '" << name << "' color='" << color << "'"); Log.debug("find new color : '" + name + "' color='" + color + "'");
if (name.size() == 0) { if (name.size() == 0) {
Log.error("Drop an empty name"); Log.error("Drop an empty name");
findError = true; findError = true;
continue; continue;
} }
m_list.add(name, etk::Color<float>(color)); this.list.add(name, etk::Color<float>(color));
} }
if (findError == true) { if (findError == true) {
Log.error("pb in parsing file:" << m_name); Log.error("pb in parsing file:" + this.name);
doc.display(); doc.display();
} }
} }
int32_t ewol::resource::ColorFile::request(const etk::String& _paramName) { int ewol::resource::ColorFile::request( String _paramName) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
// check if the parameters existed : // check if the parameters existed :
if (m_list.exist(_paramName) == false) { if (this.list.exist(_paramName) == false) {
m_list.add(_paramName, m_errorColor); this.list.add(_paramName, this.errorColor);
} }
return m_list.getId(_paramName); return this.list.getId(_paramName);
} }

View File

@ -18,52 +18,52 @@ namespace ewol {
*/ */
class ColorFile : public gale::Resource { class ColorFile : public gale::Resource {
private: private:
etk::Map<etk::String, etk::Color<float> > m_list; //!< List of all color in the file etk::Map<String, etk::Color<float> > this.list; //!< List of all color in the file
etk::Color<float> m_errorColor; //!< Error returned color etk::Color<float> this.errorColor; //!< Error returned color
protected: protected:
/** /**
* @brief Constructor of the color property file * @brief Constructor of the color property file
* @param[in] _uri Name of the file needed * @param[in] _uri Name of the file needed
*/ */
ColorFile(); ColorFile();
void init(const etk::Uri& _uri); void init( etk::Uri _uri);
public: public:
DECLARE_RESOURCE_URI_FACTORY(ColorFile); DECLARE_RESOURCE_URI_FACTORY(ColorFile);
/** /**
* @brief Simple Destructor of this class (nothing specific ...) * @brief Simple Destructor of this class (nothing specific ...)
*/ */
virtual ~ColorFile(); ~ColorFile();
public: public:
/** /**
* @brief Set the error color. * @brief Set the error color.
* @param[in] _errorColor Color that might be set when not finding a color * @param[in] _errorColor Color that might be set when not finding a color
*/ */
void setErrorColor(const etk::Color<float>& _errorColor) { void setErrorColor( etk::Color<float> _errorColor) {
m_errorColor = _errorColor; this.errorColor = _errorColor;
} }
/** /**
* @brief Request the presence of a specific color. * @brief Request the presence of a specific color.
* @param[in] _paramName Name of the color. * @param[in] _paramName Name of the color.
* @return A unique ID of the color (or -1 if an error occured). * @return A unique ID of the color (or -1 if an error occured).
*/ */
int32_t request(const etk::String& _paramName); int request( String _paramName);
/** /**
* @brief Get the associated color of the ID. * @brief Get the associated color of the ID.
* @param[in] _Id Id of the color. * @param[in] _Id Id of the color.
* @return The requested color. * @return The requested color.
*/ */
const etk::Color<float>& get(int32_t _id) const { etk::Color<float> get(int _id) {
if (_id < 0) { if (_id < 0) {
return m_errorColor; return this.errorColor;
} }
return m_list.getValue(_id); return this.list.getValue(_id);
}; };
/** /**
* @brief Get All color name * @brief Get All color name
* @return list of all color existing * @return list of all color existing
*/ */
List<etk::String> getColors() const { List<String> getColors() {
return m_list.getKeys(); return this.list.getKeys();
} }
public: // herited function: public: // herited function:
void reload(); void reload();

View File

@ -16,19 +16,19 @@
ETK_DECLARE_TYPE(ewol::resource::Colored3DObject); ETK_DECLARE_TYPE(ewol::resource::Colored3DObject);
ewol::resource::Colored3DObject::Colored3DObject() : ewol::resource::Colored3DObject::Colored3DObject() :
m_GLprogram(null) { this.GLprogram(null) {
addResourceType("ewol::Colored3DObject"); addResourceType("ewol::Colored3DObject");
} }
void ewol::resource::Colored3DObject::init() { void ewol::resource::Colored3DObject::init() {
gale::Resource::init(); gale::Resource::init();
// get the shader resource : // get the shader resource :
m_GLPosition = 0; this.GLPosition = 0;
m_GLprogram = gale::resource::Program::create("DATA:///simple3D.prog?lib=ewol"); this.GLprogram = gale::resource::Program::create("DATA:///simple3D.prog?lib=ewol");
if (m_GLprogram != null) { if (this.GLprogram != null) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d"); this.GLPosition = this.GLprogram.getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getUniform("EW_color"); this.GLColor = this.GLprogram.getUniform("EW_color");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); this.GLMatrix = this.GLprogram.getUniform("EW_MatrixTransformation");
} }
} }
@ -37,14 +37,14 @@ ewol::resource::Colored3DObject::~Colored3DObject() {
} }
void ewol::resource::Colored3DObject::draw(const List<Vector3f>& _vertices, void ewol::resource::Colored3DObject::draw( List<Vector3f> _vertices,
const etk::Color<float>& _color, etk::Color<float> _color,
bool _updateDepthBuffer, boolean _updateDepthBuffer,
bool _depthtest) { boolean _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
@ -54,23 +54,23 @@ void ewol::resource::Colored3DObject::draw(const List<Vector3f>& _vertices,
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
} }
} }
//Log.debug(" display " << m_coord.size() << " elements" ); //Log.debug(" display " + this.coord.size() + " elements" );
m_GLprogram->use(); this.GLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
mat4 projMatrix = gale::openGL::getMatrix(); mat4 projMatrix = gale::openGL::getMatrix();
mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix();
mat4 tmpMatrix = projMatrix * camMatrix; mat4 tmpMatrix = projMatrix * camMatrix;
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position : // position :
m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z,unused*/, &_vertices[0], 4*sizeof(float)); this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z,unused*/, _vertices[0], 4*sizeof(float));
// color : // color :
m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); this.GLprogram.uniform4fv(this.GLColor, 1/*r,g,b,a*/, (float*)_color);
// Request the draw od the elements: // Request the draw od the elements:
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, _vertices.size()); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, _vertices.size());
m_GLprogram->unUse(); this.GLprogram.unUse();
// Request the draw od the elements: // Request the draw od the elements:
//glDrawArrays(GL_LINES, 0, vertices.size()); //glDrawArrays(GL_LINES, 0, vertices.size());
//m_GLprogram->UnUse(); //this.GLprogram.UnUse();
if (true == _depthtest) { if (true == _depthtest) {
if (false == _updateDepthBuffer) { if (false == _updateDepthBuffer) {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
@ -79,15 +79,15 @@ void ewol::resource::Colored3DObject::draw(const List<Vector3f>& _vertices,
} }
} }
void ewol::resource::Colored3DObject::draw(const List<Vector3f>& _vertices, void ewol::resource::Colored3DObject::draw( List<Vector3f> _vertices,
const etk::Color<float>& _color, etk::Color<float> _color,
mat4& _transformationMatrix, mat4 _transformationMatrix,
bool _updateDepthBuffer, boolean _updateDepthBuffer,
bool _depthtest) { boolean _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
@ -97,20 +97,20 @@ void ewol::resource::Colored3DObject::draw(const List<Vector3f>& _vertices,
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
} }
} }
//Log.debug(" display " << m_coord.size() << " elements" ); //Log.debug(" display " + this.coord.size() + " elements" );
m_GLprogram->use(); this.GLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
mat4 projMatrix = gale::openGL::getMatrix(); mat4 projMatrix = gale::openGL::getMatrix();
mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix();
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position : // position :
m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z*/, &_vertices[0], 4*sizeof(float)); this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z*/, _vertices[0], 4*sizeof(float));
// color : // color :
m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); this.GLprogram.uniform4fv(this.GLColor, 1/*r,g,b,a*/, (float*)_color);
// Request the draw od the elements: // Request the draw od the elements:
gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, _vertices.size()); gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, _vertices.size());
m_GLprogram->unUse(); this.GLprogram.unUse();
if (true == _depthtest) { if (true == _depthtest) {
if (false == _updateDepthBuffer) { if (false == _updateDepthBuffer) {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
@ -119,15 +119,15 @@ void ewol::resource::Colored3DObject::draw(const List<Vector3f>& _vertices,
} }
} }
void ewol::resource::Colored3DObject::drawLine(List<Vector3f>& _vertices, void ewol::resource::Colored3DObject::drawLine(List<Vector3f> _vertices,
const etk::Color<float>& _color, etk::Color<float> _color,
mat4& _transformationMatrix, mat4 _transformationMatrix,
bool _updateDepthBuffer, boolean _updateDepthBuffer,
bool _depthtest) { boolean _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
if (m_GLprogram == null) { if (this.GLprogram == null) {
Log.error("No shader ..."); Log.error("No shader ...");
return; return;
} }
@ -137,20 +137,20 @@ void ewol::resource::Colored3DObject::drawLine(List<Vector3f>& _vertices,
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
} }
} }
//Log.debug(" display " << m_coord.size() << " elements" ); //Log.debug(" display " + this.coord.size() + " elements" );
m_GLprogram->use(); this.GLprogram.use();
// set Matrix: translation/positionMatrix // set Matrix: translation/positionMatrix
mat4 projMatrix = gale::openGL::getMatrix(); mat4 projMatrix = gale::openGL::getMatrix();
mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix();
mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix;
m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); this.GLprogram.uniformMatrix(this.GLMatrix, tmpMatrix);
// position : // position :
m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z*/, &_vertices[0], 4*sizeof(float)); this.GLprogram.sendAttribute(this.GLPosition, 3/*x,y,z*/, _vertices[0], 4*sizeof(float));
// color : // color :
m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); this.GLprogram.uniform4fv(this.GLColor, 1/*r,g,b,a*/, (float*)_color);
// Request the draw od the elements: // Request the draw od the elements:
gale::openGL::drawArrays(gale::openGL::renderMode::line, 0, _vertices.size()); gale::openGL::drawArrays(gale::openGL::renderMode::line, 0, _vertices.size());
m_GLprogram->unUse(); this.GLprogram.unUse();
if (true == _depthtest) { if (true == _depthtest) {
if (false == _updateDepthBuffer) { if (false == _updateDepthBuffer) {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
@ -160,12 +160,12 @@ void ewol::resource::Colored3DObject::drawLine(List<Vector3f>& _vertices,
} }
void ewol::resource::Colored3DObject::drawCubeLine(const Vector3f& _min, void ewol::resource::Colored3DObject::drawCubeLine( Vector3f _min,
const Vector3f& _max, Vector3f _max,
const etk::Color<float>& _color, etk::Color<float> _color,
mat4& _transformationMatrix, mat4 _transformationMatrix,
bool _updateDepthBuffer, boolean _updateDepthBuffer,
bool _depthtest) { boolean _depthtest) {
List<Vector3f> vertices; List<Vector3f> vertices;
vertices.pushBack(Vector3f(_min.x(), _min.y(),_min.z())); vertices.pushBack(Vector3f(_min.x(), _min.y(),_min.z()));
vertices.pushBack(Vector3f(_max.x(), _min.y(),_min.z())); vertices.pushBack(Vector3f(_max.x(), _min.y(),_min.z()));
@ -208,9 +208,9 @@ void ewol::resource::Colored3DObject::drawCubeLine(const Vector3f& _min,
drawLine(vertices, _color, _transformationMatrix, _updateDepthBuffer, _depthtest); drawLine(vertices, _color, _transformationMatrix, _updateDepthBuffer, _depthtest);
} }
void ewol::resource::Colored3DObject::drawSquare(const Vector3f& _size, void ewol::resource::Colored3DObject::drawSquare( Vector3f _size,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor) { etk::Color<float> _tmpColor) {
List<Vector3f> tmpVertices; List<Vector3f> tmpVertices;
static int indices[36] = { 0,1,2, 3,2,1, 4,0,6, static int indices[36] = { 0,1,2, 3,2,1, 4,0,6,
6,0,2, 5,1,4, 4,1,0, 6,0,2, 5,1,4, 4,1,0,
@ -225,7 +225,7 @@ void ewol::resource::Colored3DObject::drawSquare(const Vector3f& _size,
Vector3f(_size[0],-_size[1],-_size[2]), Vector3f(_size[0],-_size[1],-_size[2]),
Vector3f(-_size[0],-_size[1],-_size[2])}; Vector3f(-_size[0],-_size[1],-_size[2])};
tmpVertices.clear(); tmpVertices.clear();
for (int32_t iii=0 ; iii<36 ; iii+=3) { for (int iii=0 ; iii<36 ; iii+=3) {
// normal calculation : // normal calculation :
//btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]); //btVector3 normal = (vertices[indices[iii+2]]-vertices[indices[iii]]).cross(vertices[indices[iii+1]]-vertices[indices[iii]]);
//normal.normalize (); //normal.normalize ();
@ -239,10 +239,10 @@ void ewol::resource::Colored3DObject::drawSquare(const Vector3f& _size,
void ewol::resource::Colored3DObject::drawSphere(float _radius, void ewol::resource::Colored3DObject::drawSphere(float _radius,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor) { etk::Color<float> _tmpColor) {
List<Vector3f> tmpVertices; List<Vector3f> tmpVertices;
for(int32_t iii=0; iii<=_lats; ++iii) { for(int iii=0; iii<=_lats; ++iii) {
float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats); float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats);
float z0 = _radius*sin(lat0); float z0 = _radius*sin(lat0);
float zr0 = _radius*cos(lat0); float zr0 = _radius*cos(lat0);
@ -251,7 +251,7 @@ void ewol::resource::Colored3DObject::drawSphere(float _radius,
float z1 = _radius*sin(lat1); float z1 = _radius*sin(lat1);
float zr1 = _radius*cos(lat1); float zr1 = _radius*cos(lat1);
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
float x = cos(lng); float x = cos(lng);
float y = sin(lng); float y = sin(lng);
@ -279,13 +279,13 @@ void ewol::resource::Colored3DObject::drawCylinder(float _radius,
float _size, float _size,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor) { etk::Color<float> _tmpColor) {
List<Vector3f> tmpVertices; List<Vector3f> tmpVertices;
// center to border (TOP) // center to border (TOP)
// center to border (TOP) // center to border (TOP)
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
float z = _size*0.5f; float z = _size*0.5f;
@ -304,7 +304,7 @@ void ewol::resource::Colored3DObject::drawCylinder(float _radius,
tmpVertices.pushBack(v2); tmpVertices.pushBack(v2);
} }
// Cylinder // Cylinder
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
float z = _size*0.5f; float z = _size*0.5f;
@ -329,7 +329,7 @@ void ewol::resource::Colored3DObject::drawCylinder(float _radius,
tmpVertices.pushBack(v2b); tmpVertices.pushBack(v2b);
} }
// center to border (BUTTOM) // center to border (BUTTOM)
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
float z = _size*-0.5f; float z = _size*-0.5f;
@ -353,14 +353,14 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius,
float _size, float _size,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor) { etk::Color<float> _tmpColor) {
List<Vector3f> tmpVertices; List<Vector3f> tmpVertices;
_lats = int32_t(_lats / 2)*2; _lats = int(_lats / 2)*2;
// center to border (TOP) // center to border (TOP)
float offset = _size*0.5f; float offset = _size*0.5f;
for(int32_t iii=_lats/2+1; iii<=_lats; ++iii) { for(int iii=_lats/2+1; iii<=_lats; ++iii) {
float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats); float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats);
float z0 = _radius*sin(lat0); float z0 = _radius*sin(lat0);
float zr0 = _radius*cos(lat0); float zr0 = _radius*cos(lat0);
@ -369,7 +369,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius,
float z1 = _radius*sin(lat1); float z1 = _radius*sin(lat1);
float zr1 = _radius*cos(lat1); float zr1 = _radius*cos(lat1);
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
float x = cos(lng); float x = cos(lng);
float y = sin(lng); float y = sin(lng);
@ -391,7 +391,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius,
} }
} }
// Cylinder // Cylinder
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
float z = _size*0.5f; float z = _size*0.5f;
@ -417,7 +417,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius,
} }
// center to border (BUTTOM) // center to border (BUTTOM)
offset = -_size*0.5f; offset = -_size*0.5f;
for(int32_t iii=0; iii<=_lats/2; ++iii) { for(int iii=0; iii<=_lats/2; ++iii) {
float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats); float lat0 = M_PI * (-0.5f + float(iii - 1) / _lats);
float z0 = _radius*sin(lat0); float z0 = _radius*sin(lat0);
float zr0 = _radius*cos(lat0); float zr0 = _radius*cos(lat0);
@ -426,7 +426,7 @@ void ewol::resource::Colored3DObject::drawCapsule(float _radius,
float z1 = _radius*sin(lat1); float z1 = _radius*sin(lat1);
float zr1 = _radius*cos(lat1); float zr1 = _radius*cos(lat1);
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
float x = cos(lng); float x = cos(lng);
float y = sin(lng); float y = sin(lng);
@ -454,11 +454,11 @@ void ewol::resource::Colored3DObject::drawCone(float _radius,
float _size, float _size,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor) { etk::Color<float> _tmpColor) {
List<Vector3f> tmpVertices; List<Vector3f> tmpVertices;
// center to border (TOP) // center to border (TOP)
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
Vector3f v1 = Vector3f(0.0f, 0.0f, -_size/2); Vector3f v1 = Vector3f(0.0f, 0.0f, -_size/2);
@ -475,7 +475,7 @@ void ewol::resource::Colored3DObject::drawCone(float _radius,
tmpVertices.pushBack(v2); tmpVertices.pushBack(v2);
} }
// center to border (BUTTOM) // center to border (BUTTOM)
for(int32_t jjj=0; jjj<_longs; ++jjj) { for(int jjj=0; jjj<_longs; ++jjj) {
float lng = 2.0f * M_PI * float(jjj - 1) / _longs; float lng = 2.0f * M_PI * float(jjj - 1) / _longs;
Vector3f v1 = Vector3f(0.0f, 0.0f, _size/2); Vector3f v1 = Vector3f(0.0f, 0.0f, _size/2);
@ -495,25 +495,25 @@ void ewol::resource::Colored3DObject::drawCone(float _radius,
draw(tmpVertices, _tmpColor, _transformationMatrix); draw(tmpVertices, _tmpColor, _transformationMatrix);
} }
void ewol::resource::Colored3DObject::drawTriangles(const List<Vector3f>& _vertex, void ewol::resource::Colored3DObject::drawTriangles( List<Vector3f> _vertex,
const List<uint32_t>& _indice, List<uint> _indice,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor, etk::Color<float> _tmpColor,
const Vector3f& _offset) { Vector3f _offset) {
List<Vector3f> tmpVertices; List<Vector3f> tmpVertices;
for (size_t iii=0; iii<_indice.size()/3; ++iii) { for (int iii=0; iii<_indice.size()/3; ++iii) {
tmpVertices.pushBack(_vertex[_indice[iii*3 + 0]]+_offset); tmpVertices.pushBack(_vertex[_indice[iii*3 + 0]]+_offset);
tmpVertices.pushBack(_vertex[_indice[iii*3 + 1]]+_offset); tmpVertices.pushBack(_vertex[_indice[iii*3 + 1]]+_offset);
tmpVertices.pushBack(_vertex[_indice[iii*3 + 2]]+_offset); tmpVertices.pushBack(_vertex[_indice[iii*3 + 2]]+_offset);
//Log.info(" indices " << _indice[iii*3 + 0] << " " << _indice[iii*3 + 1] << " " << _indice[iii*3 + 2]); //Log.info(" indices " + _indice[iii*3 + 0] + " " + _indice[iii*3 + 1] + " " + _indice[iii*3 + 2]);
//Log.info(" triangle " << _vertex[_indice[iii*3 + 0]] << " " << _vertex[_indice[iii*3 + 1]] << " " << _vertex[_indice[iii*3 + 2]]); //Log.info(" triangle " + _vertex[_indice[iii*3 + 0]] + " " + _vertex[_indice[iii*3 + 1]] + " " + _vertex[_indice[iii*3 + 2]]);
} }
//Log.info("display " << tmpVertices.size() << " vertices form " << _indice.size()); //Log.info("display " + tmpVertices.size() + " vertices form " + _indice.size());
draw(tmpVertices, _tmpColor, _transformationMatrix); draw(tmpVertices, _tmpColor, _transformationMatrix);
} }
namespace etk { namespace etk {
template<> etk::String toString(ewol::resource::Colored3DObject const&) { template<> String toString(ewol::resource::Colored3DObject ) {
return "!!ewol::resource::Colored3DObject!ERROR!CAN_NOT_BE_CONVERT!!"; return "!!ewol::resource::Colored3DObject!ERROR!CAN_NOT_BE_CONVERT!!";
} }
} }
@ -521,7 +521,7 @@ namespace etk {
// declare for signal event // declare for signal event
ESIGNAL_DECLARE_SIGNAL(ewol::resource::Colored3DObject); ESIGNAL_DECLARE_SIGNAL(ewol::resource::Colored3DObject);
ESIGNAL_DECLARE_SIGNAL(ememory::SharedPtr<ewol::resource::Colored3DObject>); ESIGNAL_DECLARE_SIGNAL(ememory::Ptr<ewol::resource::Colored3DObject>);
#endif #endif

View File

@ -19,69 +19,69 @@ namespace ewol {
*/ */
class Colored3DObject : public gale::Resource { class Colored3DObject : public gale::Resource {
protected: protected:
ememory::SharedPtr<gale::resource::Program> m_GLprogram; ememory::Ptr<gale::resource::Program> this.GLprogram;
int32_t m_GLPosition; int this.GLPosition;
int32_t m_GLMatrix; int this.GLMatrix;
int32_t m_GLColor; int this.GLColor;
protected: protected:
Colored3DObject(); Colored3DObject();
void init(); void init();
public: public:
DECLARE_RESOURCE_FACTORY(Colored3DObject); DECLARE_RESOURCE_FACTORY(Colored3DObject);
virtual ~Colored3DObject(); ~Colored3DObject();
public: public:
virtual void draw(const List<Vector3f>& _vertices, void draw( List<Vector3f> _vertices,
const etk::Color<float>& _color, etk::Color<float> _color,
bool _updateDepthBuffer=true, boolean _updateDepthBuffer=true,
bool _depthtest=true); boolean _depthtest=true);
virtual void draw(const List<Vector3f>& _vertices, void draw( List<Vector3f> _vertices,
const etk::Color<float>& _color, etk::Color<float> _color,
mat4& _transformationMatrix, mat4 _transformationMatrix,
bool _updateDepthBuffer=true, boolean _updateDepthBuffer=true,
bool _depthtest=true); boolean _depthtest=true);
virtual void drawLine(List<Vector3f>& _vertices, void drawLine(List<Vector3f> _vertices,
const etk::Color<float>& _color, etk::Color<float> _color,
mat4& _transformationMatrix, mat4 _transformationMatrix,
bool _updateDepthBuffer=true, boolean _updateDepthBuffer=true,
bool _depthtest=true); boolean _depthtest=true);
virtual void drawCubeLine(const Vector3f& _min, void drawCubeLine( Vector3f _min,
const Vector3f& _max, Vector3f _max,
const etk::Color<float>& _color, etk::Color<float> _color,
mat4& _transformationMatrix, mat4 _transformationMatrix,
bool _updateDepthBuffer=true, boolean _updateDepthBuffer=true,
bool _depthtest=true); boolean _depthtest=true);
public: public:
void drawSquare(const Vector3f& _size, void drawSquare( Vector3f _size,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor); etk::Color<float> _tmpColor);
void drawSphere(float _radius, void drawSphere(float _radius,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor); etk::Color<float> _tmpColor);
void drawCylinder(float _radius, void drawCylinder(float _radius,
float _size, float _size,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor); etk::Color<float> _tmpColor);
void drawCapsule(float _radius, void drawCapsule(float _radius,
float _size, float _size,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor); etk::Color<float> _tmpColor);
void drawCone(float _radius, void drawCone(float _radius,
float _size, float _size,
int _lats, int _lats,
int _longs, int _longs,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor); etk::Color<float> _tmpColor);
void drawTriangles(const List<Vector3f>& _vertex, void drawTriangles( List<Vector3f> _vertex,
const List<uint32_t>& _indice, List<uint> _indice,
mat4& _transformationMatrix, mat4 _transformationMatrix,
const etk::Color<float>& _tmpColor, etk::Color<float> _tmpColor,
const Vector3f& _offset=Vector3f(0,0,0.1)); Vector3f _offset=Vector3f(0,0,0.1));
}; };
}; };
}; };

View File

@ -17,76 +17,76 @@ ETK_DECLARE_TYPE(ewol::resource::ConfigFile);
ewol::resource::ConfigFile::ConfigFile() : ewol::resource::ConfigFile::ConfigFile() :
gale::Resource(), gale::Resource(),
// set map unorderred // set map unorderred
m_list(0, false) { this.list(0, false) {
addResourceType("ewol::ConfigFile"); addResourceType("ewol::ConfigFile");
} }
void ewol::resource::ConfigFile::init(const etk::Uri& _uri) { void ewol::resource::ConfigFile::init( etk::Uri _uri) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
gale::Resource::init(_uri.get()); gale::Resource::init(_uri.get());
Log.debug("SFP : load \"" << _uri << "\""); Log.debug("SFP : load \"" + _uri + "\"");
reload(); reload();
} }
ewol::resource::ConfigFile::~ConfigFile() { ewol::resource::ConfigFile::~ConfigFile() {
m_list.clear(); this.list.clear();
} }
void ewol::resource::ConfigFile::reload() { void ewol::resource::ConfigFile::reload() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
// reset all parameters // reset all parameters
for (size_t iii=0; iii<m_list.size(); ++iii){ for (int iii=0; iii<this.list.size(); ++iii){
if (m_list.getValue(iii).exist() == true) { if (this.list.getValue(iii).exist() == true) {
m_list.getValue(iii) = ejson::empty(); this.list.getValue(iii) = ejson::empty();
} }
} }
m_doc.load(etk::Uri(m_name)); this.doc.load(etk::Uri(this.name));
for (auto elementName : m_list.getKeys()) { for (auto elementName : this.list.getKeys()) {
if (m_doc[elementName].exist() == true) { if (this.doc[elementName].exist() == true) {
m_list[elementName] = m_doc[elementName]; this.list[elementName] = this.doc[elementName];
} }
} }
} }
int32_t ewol::resource::ConfigFile::request(const etk::String& _paramName) { int ewol::resource::ConfigFile::request( String _paramName) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
// check if the parameters existed : // check if the parameters existed :
if (m_list.exist(_paramName) == false) { if (this.list.exist(_paramName) == false) {
m_list.add(_paramName, ejson::empty()); this.list.add(_paramName, ejson::empty());
} }
if (m_doc[_paramName].exist() == true) { if (this.doc[_paramName].exist() == true) {
m_list[_paramName] = m_doc[_paramName]; this.list[_paramName] = this.doc[_paramName];
} }
return m_list.getId(_paramName); return this.list.getId(_paramName);
} }
double ewol::resource::ConfigFile::getNumber(int32_t _id) { double ewol::resource::ConfigFile::getNumber(int _id) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if ( _id < 0 if ( _id < 0
|| m_list.getValue(_id).exist() == false) { || this.list.getValue(_id).exist() == false) {
return 0.0; return 0.0;
} }
return m_list.getValue(_id).toNumber().get(); return this.list.getValue(_id).toNumber().get();
} }
etk::String ewol::resource::ConfigFile::getString(int32_t _id) { String ewol::resource::ConfigFile::getString(int _id) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if ( _id < 0 if ( _id < 0
|| m_list.getValue(_id).exist() == false) { || this.list.getValue(_id).exist() == false) {
return ""; return "";
} }
return m_list.getValue(_id).toString().get(); return this.list.getValue(_id).toString().get();
} }
bool ewol::resource::ConfigFile::getBoolean(int32_t _id) { boolean ewol::resource::ConfigFile::getBoolean(int _id) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if ( _id < 0 if ( _id < 0
|| m_list.getValue(_id).exist() == false) { || this.list.getValue(_id).exist() == false) {
return false; return false;
} }
return m_list.getValue(_id).toBoolean().get(); return this.list.getValue(_id).toBoolean().get();
} }

View File

@ -15,22 +15,22 @@ namespace ewol {
namespace resource { namespace resource {
class ConfigFile : public gale::Resource { class ConfigFile : public gale::Resource {
private: private:
ejson::Document m_doc; ejson::Document this.doc;
etk::Map<etk::String, ejson::Value> m_list; etk::Map<String, ejson::Value> this.list;
protected: protected:
ConfigFile(); ConfigFile();
void init(const etk::Uri& _filename); void init( etk::Uri _filename);
public: public:
virtual ~ConfigFile(); ~ConfigFile();
DECLARE_RESOURCE_URI_FACTORY(ConfigFile); DECLARE_RESOURCE_URI_FACTORY(ConfigFile);
public: public:
void reload(); void reload();
int32_t request(const etk::String& _paramName); int request( String _paramName);
double getNumber(int32_t _id); double getNumber(int _id);
etk::String getString(int32_t _id); String getString(int _id);
bool getBoolean(int32_t _id); boolean getBoolean(int _id);
public: public:
/** /**
* @brief keep the resource pointer. * @brief keep the resource pointer.
@ -38,7 +38,7 @@ namespace ewol {
* @param[in] _filename Name of the configuration file. * @param[in] _filename Name of the configuration file.
* @return pointer on the resource or null if an error occured. * @return pointer on the resource or null if an error occured.
*/ */
static ememory::SharedPtr<ewol::resource::ConfigFile> keep(const etk::String& _filename); static ememory::Ptr<ewol::resource::ConfigFile> keep( String _filename);
}; };
}; };
}; };

View File

@ -25,13 +25,13 @@ ETK_DECLARE_TYPE(ewol::resource::DistanceFieldFont);
ewol::resource::DistanceFieldFont::DistanceFieldFont() : ewol::resource::DistanceFieldFont::DistanceFieldFont() :
ewol::resource::Texture(), ewol::resource::Texture(),
m_borderSize(10), this.borderSize(10),
m_textureBorderSize(0,0) { this.textureBorderSize(0,0) {
addResourceType("ewol::resource::DistanceFieldFont"); addResourceType("ewol::resource::DistanceFieldFont");
m_font = null; this.font = null;
m_lastGlyphPos.setValue(1,1); this.lastGlyphPos.setValue(1,1);
m_lastRawHeigh = 0; this.lastRawHeigh = 0;
m_sizeRatio = 1.0f; this.sizeRatio = 1.0f;
} }
/** /**
@ -43,7 +43,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() :
* // out contain: {"DATA:///font", "DATA:///font?lib=ewol"} * // out contain: {"DATA:///font", "DATA:///font?lib=ewol"}
* @example[stop] * @example[stop]
*/ */
static List<etk::Uri> explodeMultiplePath(const etk::Uri& _uri) { static List<etk::Uri> explodeMultiplePath( etk::Uri _uri) {
List<etk::Uri> out; List<etk::Uri> out;
out.pushBack(_uri); out.pushBack(_uri);
if (_uri.getQuery().exist("lib") == true) { if (_uri.getQuery().exist("lib") == true) {
@ -54,10 +54,10 @@ static List<etk::Uri> explodeMultiplePath(const etk::Uri& _uri) {
return out; return out;
} }
void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) { void ewol::resource::DistanceFieldFont::init( String _fontName) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
ewol::resource::Texture::init(_fontName); ewol::resource::Texture::init(_fontName);
etk::String localName = _fontName; String localName = _fontName;
List<etk::Uri> folderList; List<etk::Uri> folderList;
if (ewol::getContext().getFontDefault().getUseExternal() == true) { if (ewol::getContext().getFontDefault().getUseExternal() == true) {
#if defined(__TARGET_OS__Android) #if defined(__TARGET_OS__Android)
@ -67,61 +67,61 @@ void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) {
#endif #endif
} }
etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder();
for (auto &it : explodeMultiplePath(applicationBaseFont)) { for (auto it : explodeMultiplePath(applicationBaseFont)) {
folderList.pushBack(it); folderList.pushBack(it);
} }
for (size_t folderID = 0; folderID < folderList.size() ; folderID++) { for (int folderID = 0; folderID < folderList.size() ; folderID++) {
List<etk::Uri> output = etk::uri::listRecursive(folderList[folderID]); List<etk::Uri> output = etk::uri::listRecursive(folderList[folderID]);
List<etk::String> split = etk::split(localName, ';'); List<String> split = etk::split(localName, ';');
Log.info("try to find font named : " << split << " in: " << output); Log.info("try to find font named : " + split + " in: " + output);
//Log.critical("parse string : " << split); //Log.critical("parse string : " + split);
bool hasFindAFont = false; boolean hasFindAFont = false;
for (size_t jjj=0; jjj<split.size(); jjj++) { for (int jjj=0; jjj<split.size(); jjj++) {
Log.info(" try with : '" << split[jjj] << "'"); Log.info(" try with : '" + split[jjj] + "'");
for (size_t iii=0; iii<output.size(); iii++) { for (int iii=0; iii<output.size(); iii++) {
etk::String nameFolder = output[iii].getPath().getString(); String nameFolder = output[iii].getPath().getString();
//Log.debug(" file : " << output[iii]); //Log.debug(" file : " + output[iii]);
if( true == etk::end_with(nameFolder, split[jjj]+"-"+"regular"+".ttf", false) if( true == etk::end_with(nameFolder, split[jjj]+"-"+"regular"+".ttf", false)
|| true == etk::end_with(nameFolder, split[jjj]+"-"+"r"+".ttf", false) || true == etk::end_with(nameFolder, split[jjj]+"-"+"r"+".ttf", false)
|| true == etk::end_with(nameFolder, split[jjj]+"regular"+".ttf", false) || true == etk::end_with(nameFolder, split[jjj]+"regular"+".ttf", false)
|| true == etk::end_with(nameFolder, split[jjj]+"r"+".ttf", false) || true == etk::end_with(nameFolder, split[jjj]+"r"+".ttf", false)
|| true == etk::end_with(nameFolder, split[jjj]+".ttf", false)) { || true == etk::end_with(nameFolder, split[jjj]+".ttf", false)) {
Log.info(" find Font [Regular] : " << output[iii]); Log.info(" find Font [Regular] : " + output[iii]);
m_fileName = output[iii]; this.fileName = output[iii];
hasFindAFont=true; hasFindAFont=true;
break; break;
} }
} }
if (hasFindAFont == true) { if (hasFindAFont == true) {
Log.info(" find this font : '" << split[jjj] << "'"); Log.info(" find this font : '" + split[jjj] + "'");
break; break;
} else if (jjj == split.size()-1) { } else if (jjj == split.size()-1) {
Log.error("Find NO font in the LIST ... " << split); Log.error("Find NO font in the LIST ... " + split);
} }
} }
if (hasFindAFont == true) { if (hasFindAFont == true) {
Log.info(" find this font : '" << folderList[folderID] << "'"); Log.info(" find this font : '" + folderList[folderID] + "'");
break; break;
} else if (folderID == folderList.size()-1) { } else if (folderID == folderList.size()-1) {
Log.error("Find NO font in the LIST ... " << folderList); Log.error("Find NO font in the LIST ... " + folderList);
} }
} }
if (m_fileName.isEmpty() == true) { if (this.fileName.isEmpty() == true) {
Log.error("can not load FONT name : '" << _fontName << "'" ); Log.error("can not load FONT name : '" + _fontName + "'" );
m_font = null; this.font = null;
return; return;
} }
Log.info("Load FONT name : '" << m_fileName << "'"); Log.info("Load FONT name : '" + this.fileName + "'");
m_font = ewol::resource::FontFreeType::create(m_fileName); this.font = ewol::resource::FontFreeType::create(this.fileName);
if (m_font == null) { if (this.font == null) {
Log.error("Pb Loading FONT name : '" << m_fileName << "'" ); Log.error("Pb Loading FONT name : '" + this.fileName + "'" );
} }
// set the bassic charset: // set the bassic charset:
m_listElement.clear(); this.listElement.clear();
if (m_font == null) { if (this.font == null) {
return; return;
} }
if (importFromFile() == true) { if (importFromFile() == true) {
@ -130,22 +130,22 @@ void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) {
return; return;
} }
m_sizeRatio = ((float)SIZE_GENERATION) / ((float)m_font->getHeight(SIZE_GENERATION)); this.sizeRatio = ((float)SIZE_GENERATION) / ((float)this.font.getHeight(SIZE_GENERATION));
// TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ??? // TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ???
setImageSize(Vector2i(512,32)); setImageSize(Vector2i(512,32));
// now we can acces directly on the image // now we can acces directly on the image
m_data.clear(etk::Color<>(0x00000000)); this.data.clear(etk::Color<>(0x00000000));
// add error glyph // add error glyph
addGlyph(0); addGlyph(0);
// by default we set only the first AINSI char availlable // by default we set only the first AINSI char availlable
for (int32_t iii=0x20; iii<0x7F; iii++) { for (int iii=0x20; iii<0x7F; iii++) {
addGlyph(iii); addGlyph(iii);
} }
flush(); flush();
if (true) { if (true) {
Log.error("Save in cache the loaded data ..... "); Log.error("Save in cache the loaded data ..... ");
egami::store(m_data, "CACHE:///fileFont.bmp"); // ==> for debug test only ... egami::store(this.data, "CACHE:///fileFont.bmp"); // ==> for debug test only ...
egami::store(m_data, "CACHE:///fileFont.png"); egami::store(this.data, "CACHE:///fileFont.png");
} }
exportOnFile(); exportOnFile();
} }
@ -156,16 +156,16 @@ ewol::resource::DistanceFieldFont::~DistanceFieldFont() {
float ewol::resource::DistanceFieldFont::getDisplayRatio(float _size) { float ewol::resource::DistanceFieldFont::getDisplayRatio(float _size) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
return _size / (float)SIZE_GENERATION; return _size / (float)SIZE_GENERATION;
} }
void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) { void ewol::resource::DistanceFieldFont::generateDistanceField( egami::ImageMono _input, egami::Image _output) {
Log.info("Generate Distance field font [START]"); Log.info("Generate Distance field font [START]");
Log.info(" _input.getSize()=" << _input.getSize()); Log.info(" _input.getSize()=" + _input.getSize());
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
int32_t size = _input.getSize().x() * _input.getSize().y(); int size = _input.getSize().x() * _input.getSize().y();
List<short> xdist; List<short> xdist;
List<short> ydist; List<short> ydist;
List<double> gx; List<double> gx;
@ -180,12 +180,12 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image
data.resize(size, 0.0); data.resize(size, 0.0);
outside.resize(size, 0.0); outside.resize(size, 0.0);
inside.resize(size, 0.0); inside.resize(size, 0.0);
Log.info(" size=" << size); Log.info(" size=" + size);
// Convert img into double (data) // Convert img into double (data)
double img_min = 255, img_max = -255; double img_min = 255, img_max = -255;
for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) {
for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) {
int32_t iii = yyy * _input.getSize().x() + xxx; int iii = yyy * _input.getSize().x() + xxx;
double v = _input.get(Vector2i(xxx, yyy)); double v = _input.get(Vector2i(xxx, yyy));
data[iii] = v; data[iii] = v;
if (v > img_max) { if (v > img_max) {
@ -197,43 +197,43 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image
} }
} }
// Rescale image levels between 0 and 1 // Rescale image levels between 0 and 1
for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) {
for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) {
int32_t iii = yyy * _input.getSize().x() + xxx; int iii = yyy * _input.getSize().x() + xxx;
data[iii] = (_input.get(Vector2i(xxx, yyy))-img_min)/img_max; data[iii] = (_input.get(Vector2i(xxx, yyy))-img_min)/img_max;
} }
} }
// Compute outside = edtaa3(bitmap); % Transform background (0's) // Compute outside = edtaa3(bitmap); % Transform background (0's)
computegradient(&data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); computegradient(data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]);
edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &outside[0]); edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &outside[0]);
for(size_t iii = 0; iii < outside.size(); ++iii) { for(int iii = 0; iii < outside.size(); ++iii) {
if( outside[iii] < 0 ) { if( outside[iii] < 0 ) {
outside[iii] = 0.0; outside[iii] = 0.0;
} }
} }
// Compute inside = edtaa3(1-bitmap); % Transform foreground (1's) // Compute inside = edtaa3(1-bitmap); % Transform foreground (1's)
for(size_t iii = 0; iii < gx.size(); ++iii) { for(int iii = 0; iii < gx.size(); ++iii) {
gx[iii] = 0; gx[iii] = 0;
} }
for(size_t iii = 0; iii < gy.size(); ++iii) { for(int iii = 0; iii < gy.size(); ++iii) {
gy[iii] = 0; gy[iii] = 0;
} }
for(size_t iii = 0; iii < data.size(); ++iii) { for(int iii = 0; iii < data.size(); ++iii) {
data[iii] = 1 - data[iii]; data[iii] = 1 - data[iii];
} }
computegradient( &data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); computegradient( data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]);
edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &inside[0]); edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &inside[0]);
for(size_t iii = 0; iii < inside.size(); ++iii) { for(int iii = 0; iii < inside.size(); ++iii) {
if( inside[iii] < 0 ) { if( inside[iii] < 0 ) {
inside[iii] = 0.0; inside[iii] = 0.0;
} }
} }
Log.info(" _output=" << _output); Log.info(" _output=" + _output);
_output.resize(_input.getSize(), etk::Color<>(0)); _output.resize(_input.getSize(), etk::Color<>(0));
_output.clear(etk::Color<>(0)); _output.clear(etk::Color<>(0));
for (int32_t xxx = 0; xxx < _output.getSize().x(); ++xxx) { for (int xxx = 0; xxx < _output.getSize().x(); ++xxx) {
for (int32_t yyy = 0; yyy < _output.getSize().y(); ++yyy) { for (int yyy = 0; yyy < _output.getSize().y(); ++yyy) {
int32_t iii = yyy * _output.getSize().x() + xxx; int iii = yyy * _output.getSize().x() + xxx;
outside[iii] -= inside[iii]; outside[iii] -= inside[iii];
outside[iii] = 128+outside[iii]*16; outside[iii] = 128+outside[iii]*16;
if( outside[iii] < 0 ) { if( outside[iii] < 0 ) {
@ -242,112 +242,112 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image
if( outside[iii] > 255 ) { if( outside[iii] > 255 ) {
outside[iii] = 255; outside[iii] = 255;
} }
uint8_t val = 255 - (unsigned char) outside[iii]; int val = 255 - (unsigned char) outside[iii];
// TODO : Remove multiple size of the map ... // TODO : Remove multiple size of the map ...
_output.set(Vector2i(xxx, yyy), etk::Color<>((int32_t)val,(int32_t)val,(int32_t)val,255)); _output.set(Vector2i(xxx, yyy), etk::Color<>((int)val,(int)val,(int)val,255));
} }
} }
Log.info(" _output=" << _output); Log.info(" _output=" + _output);
} }
bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) { boolean ewol::resource::DistanceFieldFont::addGlyph( Character _val) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
bool hasChange = false; boolean hasChange = false;
if (m_font == null) { if (this.font == null) {
return false; return false;
} }
// add the curent "char" // add the curent "char"
GlyphProperty tmpchar; GlyphProperty tmpchar;
tmpchar.m_UVal = _val; tmpchar.this.UVal = _val;
egami::ImageMono imageGlyphRaw; egami::ImageMono imageGlyphRaw;
egami::Image imageGlyphDistanceField(Vector2i(32,32), egami::colorType::RGBA8); egami::Image imageGlyphDistanceField(Vector2i(32,32), egami::colorType::RGBA8);
Log.debug("Generate Glyph : " << _val); Log.debug("Generate Glyph : " + _val);
if (m_font->getGlyphProperty(SIZE_GENERATION, tmpchar) == true) { if (this.font.getGlyphProperty(SIZE_GENERATION, tmpchar) == true) {
//Log.debug("load char: '" << _val << "'=" << _val); //Log.debug("load char: '" + _val + "'=" + _val);
hasChange = true; hasChange = true;
// change line if needed ... // change line if needed ...
if (m_lastGlyphPos.x() + tmpchar.m_sizeTexture.x()+m_borderSize*2.0 > m_data.getSize().x()) { if (this.lastGlyphPos.x() + tmpchar.this.sizeTexture.x()+this.borderSize*2.0 > this.data.getSize().x()) {
m_lastGlyphPos.setX(1); this.lastGlyphPos.setX(1);
m_lastGlyphPos += Vector2i(0, m_lastRawHeigh); this.lastGlyphPos += Vector2i(0, this.lastRawHeigh);
m_lastRawHeigh = 0; this.lastRawHeigh = 0;
} }
while(m_lastGlyphPos.y()+tmpchar.m_sizeTexture.y()+m_borderSize*2.0 > m_data.getSize().y()) { while(this.lastGlyphPos.y()+tmpchar.this.sizeTexture.y()+this.borderSize*2.0 > this.data.getSize().y()) {
Vector2i size = m_data.getSize(); Vector2i size = this.data.getSize();
size.setY(size.y()*2); size.setY(size.y()*2);
Log.verbose("resize " << m_data.getSize() << " => " << size); Log.verbose("resize " + this.data.getSize() + " => " + size);
m_data.resize(size, etk::Color<>(0)); this.data.resize(size, etk::Color<>(0));
// change the coordonate on the element in the texture // change the coordonate on the element in the texture
for (size_t jjj = 0; jjj < m_listElement.size(); ++jjj) { for (int jjj = 0; jjj < this.listElement.size(); ++jjj) {
m_listElement[jjj].m_texturePosStart *= Vector2f(1.0f, 0.5f); this.listElement[jjj].this.texturePosStart *= Vector2f(1.0f, 0.5f);
m_listElement[jjj].m_texturePosSize *= Vector2f(1.0f, 0.5f); this.listElement[jjj].this.texturePosSize *= Vector2f(1.0f, 0.5f);
} }
} }
m_textureBorderSize = Vector2f(m_borderSize/(float)m_data.getSize().x(), this.textureBorderSize = Vector2f(this.borderSize/(float)this.data.getSize().x(),
m_borderSize/(float)m_data.getSize().y() ); this.borderSize/(float)this.data.getSize().y() );
// draw the glyph // draw the glyph
m_font->drawGlyph(imageGlyphRaw, SIZE_GENERATION, tmpchar, m_borderSize); this.font.drawGlyph(imageGlyphRaw, SIZE_GENERATION, tmpchar, this.borderSize);
generateDistanceField(imageGlyphRaw, imageGlyphDistanceField); generateDistanceField(imageGlyphRaw, imageGlyphDistanceField);
if (_val == 100) { if (_val == 100) {
Log.debug("print char: " << _val << " size=" << imageGlyphDistanceField.getSize()); Log.debug("print char: " + _val + " size=" + imageGlyphDistanceField.getSize());
for (int32_t yyy = 0; yyy < imageGlyphDistanceField.getSize().y(); ++yyy) { for (int yyy = 0; yyy < imageGlyphDistanceField.getSize().y(); ++yyy) {
for (int32_t xxx = 0; xxx < imageGlyphDistanceField.getSize().x(); ++xxx) { for (int xxx = 0; xxx < imageGlyphDistanceField.getSize().x(); ++xxx) {
Log.print((int)(imageGlyphDistanceField.get(Vector2i(xxx, yyy)).r()) << " "); Log.print((int)(imageGlyphDistanceField.get(Vector2i(xxx, yyy)).r()) + " ");
} }
} }
} }
m_data.insert(m_lastGlyphPos, imageGlyphDistanceField); this.data.insert(this.lastGlyphPos, imageGlyphDistanceField);
// set image position // set image position
tmpchar.m_texturePosStart.setValue( ((float)m_lastGlyphPos.x()+(m_borderSize*0.5f)) / (float)m_data.getSize().x(), tmpchar.this.texturePosStart.setValue( ((float)this.lastGlyphPos.x()+(this.borderSize*0.5f)) / (float)this.data.getSize().x(),
((float)m_lastGlyphPos.y()+(m_borderSize*0.5f)) / (float)m_data.getSize().y() ); ((float)this.lastGlyphPos.y()+(this.borderSize*0.5f)) / (float)this.data.getSize().y() );
tmpchar.m_texturePosSize.setValue( ((float)imageGlyphRaw.getSize().x()-m_borderSize) / (float)m_data.getSize().x(), tmpchar.this.texturePosSize.setValue( ((float)imageGlyphRaw.getSize().x()-this.borderSize) / (float)this.data.getSize().x(),
((float)imageGlyphRaw.getSize().y()-m_borderSize) / (float)m_data.getSize().y() ); ((float)imageGlyphRaw.getSize().y()-this.borderSize) / (float)this.data.getSize().y() );
// update the maximum of the line hight : // update the maximum of the line hight :
if (m_lastRawHeigh < imageGlyphRaw.getSize().y()) { if (this.lastRawHeigh < imageGlyphRaw.getSize().y()) {
// note : +1 is for the overlapping of the glyph (Part 2) // note : +1 is for the overlapping of the glyph (Part 2)
m_lastRawHeigh = imageGlyphRaw.getSize().y()+1; this.lastRawHeigh = imageGlyphRaw.getSize().y()+1;
} }
// note : +1 is for the overlapping of the glyph (Part 3) // note : +1 is for the overlapping of the glyph (Part 3)
// update the Bitmap position drawing : // update the Bitmap position drawing :
m_lastGlyphPos += Vector2i(imageGlyphRaw.getSize().x()+1, 0); this.lastGlyphPos += Vector2i(imageGlyphRaw.getSize().x()+1, 0);
} else { } else {
EWOL_WARNING("Did not find char : '" << _val << "'=" << _val); Log.warning("Did not find char : '" + _val + "'=" + _val);
tmpchar.setNotExist(); tmpchar.setNotExist();
} }
m_listElement.pushBack(tmpchar); this.listElement.pushBack(tmpchar);
//m_font[iii]->display(); //this.font[iii].display();
// generate the kerning for all the characters : // generate the kerning for all the characters :
if (tmpchar.exist() == true) { if (tmpchar.exist() == true) {
// TODO : set the kerning back ... // TODO : set the kerning back ...
//m_font[iii]->generateKerning(m_size, m_listElement[iii]); //this.font[iii].generateKerning(this.size, this.listElement[iii]);
} }
if (hasChange == true) { if (hasChange == true) {
flush(); flush();
//Log.error("Save in cache the loaded data ..... "); //Log.error("Save in cache the loaded data ..... ");
//egami::store(m_data, "CACHE:///fileFont.bmp"); // ==> for debug test only ... //egami::store(this.data, "CACHE:///fileFont.bmp"); // ==> for debug test only ...
//egami::store(m_data, "CACHE:///fileFont.png"); //egami::store(this.data, "CACHE:///fileFont.png");
} }
return hasChange; return hasChange;
} }
int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) { int ewol::resource::DistanceFieldFont::getIndex(Character _charcode) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if (_charcode < 0x20) { if (_charcode < 0x20) {
return 0; return 0;
} else if (_charcode < 0x80) { } else if (_charcode < 0x80) {
return _charcode - 0x1F; return _charcode - 0x1F;
} else { } else {
for (size_t iii=0x80-0x20; iii < m_listElement.size(); iii++) { for (int iii=0x80-0x20; iii < this.listElement.size(); iii++) {
//Log.debug("search : '" << charcode << "' =?= '" << (m_listElement[displayMode])[iii].m_UVal << "'"); //Log.debug("search : '" + charcode + "' =?= '" + (this.listElement[displayMode])[iii].this.UVal + "'");
if (_charcode == (m_listElement)[iii].m_UVal) { if (_charcode == (this.listElement)[iii].this.UVal) {
//Log.debug("search : '" << charcode << "'"); //Log.debug("search : '" + charcode + "'");
if ((m_listElement)[iii].exist()) { if ((this.listElement)[iii].exist()) {
//Log.debug("return " << iii); //Log.debug("return " + iii);
return iii; return iii;
} else { } else {
return 0; return 0;
@ -362,68 +362,68 @@ int32_t ewol::resource::DistanceFieldFont::getIndex(char32_t _charcode) {
return 0; return 0;
} }
ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const char32_t& _charcode) { ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer( Character _charcode) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
Log.verbose("getGlyphPointer : " << uint32_t(_charcode)); Log.verbose("getGlyphPointer : " + uint(_charcode));
int32_t index = getIndex(_charcode); int index = getIndex(_charcode);
if( index < 0 if( index < 0
|| (size_t)index >= m_listElement.size() ) { || (int)index >= this.listElement.size() ) {
Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" << index); Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" + index);
if (m_listElement.size() > 0) { if (this.listElement.size() > 0) {
return &((m_listElement)[0]); return ((this.listElement)[0]);
} }
return null; return null;
} }
//Log.error(" index=" << index); //Log.error(" index=" + index);
//Log.error(" m_UVal=" << m_listElement[_displayMode][index].m_UVal); //Log.error(" this.UVal=" + this.listElement[_displayMode][index].this.UVal);
//Log.error(" m_glyphIndex=" << m_listElement[_displayMode][index].m_glyphIndex); //Log.error(" this.glyphIndex=" + this.listElement[_displayMode][index].this.glyphIndex);
//Log.error(" m_advance=" << m_listElement[_displayMode][index].m_advance); //Log.error(" this.advance=" + this.listElement[_displayMode][index].this.advance);
//Log.error(" m_bearing=" << m_listElement[_displayMode][index].m_bearing); //Log.error(" this.bearing=" + this.listElement[_displayMode][index].this.bearing);
return &((m_listElement)[index]); return ((this.listElement)[index]);
} }
void ewol::resource::DistanceFieldFont::exportOnFile() { void ewol::resource::DistanceFieldFont::exportOnFile() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
Log.debug("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'"); Log.debug("EXPORT: DistanceFieldFont : file : '" + this.fileName + ".json'");
ejson::Document doc; ejson::Document doc;
ejson::Array tmpList; ejson::Array tmpList;
for (size_t iii=0; iii<m_listElement.size(); ++iii) { for (int iii=0; iii<this.listElement.size(); ++iii) {
ejson::Object tmpObj; ejson::Object tmpObj;
tmpObj.add("m_UVal", ejson::String(etk::toString(m_listElement[iii].m_UVal))); tmpObj.add("this.UVal", ejson::String(etk::toString(this.listElement[iii].this.UVal)));
tmpObj.add("m_glyphIndex", ejson::Number(m_listElement[iii].m_glyphIndex)); tmpObj.add("this.glyphIndex", ejson::Number(this.listElement[iii].this.glyphIndex));
tmpObj.add("m_sizeTexture", ejson::String((etk::String)m_listElement[iii].m_sizeTexture)); tmpObj.add("this.sizeTexture", ejson::String((String)this.listElement[iii].this.sizeTexture));
tmpObj.add("m_bearing", ejson::String((etk::String)m_listElement[iii].m_bearing)); tmpObj.add("this.bearing", ejson::String((String)this.listElement[iii].this.bearing));
tmpObj.add("m_advance", ejson::String((etk::String)m_listElement[iii].m_advance)); tmpObj.add("this.advance", ejson::String((String)this.listElement[iii].this.advance));
tmpObj.add("m_texturePosStart", ejson::String((etk::String)m_listElement[iii].m_texturePosStart)); tmpObj.add("this.texturePosStart", ejson::String((String)this.listElement[iii].this.texturePosStart));
tmpObj.add("m_texturePosSize", ejson::String((etk::String)m_listElement[iii].m_texturePosSize)); tmpObj.add("this.texturePosSize", ejson::String((String)this.listElement[iii].this.texturePosSize));
tmpObj.add("m_exist", ejson::Boolean(m_listElement[iii].m_exist)); tmpObj.add("this.exist", ejson::Boolean(this.listElement[iii].this.exist));
tmpList.add(tmpObj); tmpList.add(tmpObj);
} }
doc.add("m_listElement", tmpList); doc.add("this.listElement", tmpList);
doc.add("m_sizeRatio", ejson::Number(m_sizeRatio)); doc.add("this.sizeRatio", ejson::Number(this.sizeRatio));
doc.add("m_lastGlyphPos", ejson::String(m_lastGlyphPos)); doc.add("this.lastGlyphPos", ejson::String(this.lastGlyphPos));
doc.add("m_lastRawHeigh", ejson::Number(m_lastRawHeigh)); doc.add("this.lastRawHeigh", ejson::Number(this.lastRawHeigh));
doc.add("m_borderSize", ejson::Number(m_borderSize)); doc.add("this.borderSize", ejson::Number(this.borderSize));
doc.add("m_textureBorderSize", ejson::String(m_textureBorderSize)); doc.add("this.textureBorderSize", ejson::String(this.textureBorderSize));
etk::Uri tmpUri = m_fileName; etk::Uri tmpUri = this.fileName;
tmpUri.setScheme("CACHE"); tmpUri.setScheme("CACHE");
tmpUri.setPath(m_fileName.getPath() + ".json"); tmpUri.setPath(this.fileName.getPath() + ".json");
doc.store(tmpUri); doc.store(tmpUri);
//tmpUri.setPath(m_fileName.getPath() + ".bmp"); //tmpUri.setPath(this.fileName.getPath() + ".bmp");
//egami::store(m_data, tmpUri); //egami::store(this.data, tmpUri);
tmpUri.setPath(m_fileName.getPath() + ".png"); tmpUri.setPath(this.fileName.getPath() + ".png");
egami::store(m_data, tmpUri); egami::store(this.data, tmpUri);
} }
bool ewol::resource::DistanceFieldFont::importFromFile() { boolean ewol::resource::DistanceFieldFont::importFromFile() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
etk::Uri tmpUriJson = m_fileName; etk::Uri tmpUriJson = this.fileName;
tmpUriJson.setScheme("CACHE"); tmpUriJson.setScheme("CACHE");
tmpUriJson.setPath(m_fileName.getPath() + ".json"); tmpUriJson.setPath(this.fileName.getPath() + ".json");
etk::Uri tmpUriBmp = m_fileName; etk::Uri tmpUriBmp = this.fileName;
tmpUriBmp.setScheme("CACHE"); tmpUriBmp.setScheme("CACHE");
tmpUriBmp.setPath(m_fileName.getPath() + ".png"); tmpUriBmp.setPath(this.fileName.getPath() + ".png");
Log.debug("IMPORT: DistanceFieldFont : file : '" << tmpUriJson << "'"); Log.debug("IMPORT: DistanceFieldFont : file : '" + tmpUriJson + "'");
// test file existance: // test file existance:
if ( etk::uri::exist(tmpUriJson) == false if ( etk::uri::exist(tmpUriJson) == false
|| etk::uri::exist(tmpUriBmp) == false) { || etk::uri::exist(tmpUriBmp) == false) {
@ -438,33 +438,33 @@ bool ewol::resource::DistanceFieldFont::importFromFile() {
if (tmpImage.exist() == false) { if (tmpImage.exist() == false) {
return false; return false;
} }
m_data = tmpImage; this.data = tmpImage;
m_sizeRatio = doc["m_sizeRatio"].toNumber().get(0); this.sizeRatio = doc["this.sizeRatio"].toNumber().get(0);
m_lastGlyphPos = doc["m_lastGlyphPos"].toString().get("0,0"); this.lastGlyphPos = doc["this.lastGlyphPos"].toString().get("0,0");
m_lastRawHeigh = doc["m_lastRawHeigh"].toNumber().get(0); this.lastRawHeigh = doc["this.lastRawHeigh"].toNumber().get(0);
m_borderSize = doc["m_borderSize"].toNumber().get(2); this.borderSize = doc["this.borderSize"].toNumber().get(2);
m_textureBorderSize = doc["m_textureBorderSize"].toString().get("0,0"); this.textureBorderSize = doc["this.textureBorderSize"].toString().get("0,0");
ejson::Array tmpList = doc["m_listElement"].toArray(); ejson::Array tmpList = doc["this.listElement"].toArray();
if (tmpList.exist() == false) { if (tmpList.exist() == false) {
Log.error("null pointer array"); Log.error("null pointer array");
return false; return false;
} }
m_listElement.clear(); this.listElement.clear();
for (const auto it : tmpList) { for ( auto it : tmpList) {
const ejson::Object tmpObj = it.toObject(); ejson::Object tmpObj = it.toObject();
if (tmpObj.exist() == false) { if (tmpObj.exist() == false) {
continue; continue;
} }
GlyphProperty prop; GlyphProperty prop;
prop.m_UVal = etk::string_to_int32_t(tmpObj["m_UVal"].toString().get("0")); prop.this.UVal = etk::string_to_int(tmpObj["this.UVal"].toString().get("0"));
prop.m_glyphIndex = tmpObj["m_glyphIndex"].toNumber().get(0); prop.this.glyphIndex = tmpObj["this.glyphIndex"].toNumber().get(0);
prop.m_sizeTexture = tmpObj["m_sizeTexture"].toString().get("0,0"); prop.this.sizeTexture = tmpObj["this.sizeTexture"].toString().get("0,0");
prop.m_bearing = tmpObj["m_bearing"].toString().get("0,0"); prop.this.bearing = tmpObj["this.bearing"].toString().get("0,0");
prop.m_advance = tmpObj["m_advance"].toString().get("0,0"); prop.this.advance = tmpObj["this.advance"].toString().get("0,0");
prop.m_texturePosStart = tmpObj["m_texturePosStart"].toString().get("0,0"); prop.this.texturePosStart = tmpObj["this.texturePosStart"].toString().get("0,0");
prop.m_texturePosSize = tmpObj["m_texturePosSize"].toString().get("0,0"); prop.this.texturePosSize = tmpObj["this.texturePosSize"].toString().get("0,0");
prop.m_exist = tmpObj["m_exist"].toBoolean().get(false); prop.this.exist = tmpObj["this.exist"].toBoolean().get(false);
m_listElement.pushBack(prop); this.listElement.pushBack(prop);
} }
return m_data.exist(); return this.data.exist();
} }

View File

@ -13,24 +13,24 @@ namespace ewol {
namespace resource { namespace resource {
class DistanceFieldFont : public ewol::resource::Texture { class DistanceFieldFont : public ewol::resource::Texture {
private: private:
etk::Uri m_fileName; etk::Uri this.fileName;
float m_sizeRatio; float this.sizeRatio;
// specific element to have the the know if the specify element is known... // specific element to have the the know if the specify element is known...
// == > otherwise I can just generate italic ... // == > otherwise I can just generate italic ...
// == > Bold is a little more complicated (maybe with the bordersize) // == > Bold is a little more complicated (maybe with the bordersize)
ememory::SharedPtr<ewol::resource::FontBase> m_font; ememory::Ptr<ewol::resource::FontBase> this.font;
public: public:
List<GlyphProperty> m_listElement; List<GlyphProperty> this.listElement;
private: private:
// for the texture generation : // for the texture generation :
Vector2i m_lastGlyphPos; Vector2i this.lastGlyphPos;
int32_t m_lastRawHeigh; int this.lastRawHeigh;
protected: protected:
DistanceFieldFont(); DistanceFieldFont();
void init(const etk::String& _fontName); void init( String _fontName);
public: public:
DECLARE_RESOURCE_NAMED_FACTORY(DistanceFieldFont); DECLARE_RESOURCE_NAMED_FACTORY(DistanceFieldFont);
virtual ~DistanceFieldFont(); ~DistanceFieldFont();
public: public:
float getDisplayRatio(float _size); float getDisplayRatio(float _size);
/** /**
@ -39,7 +39,7 @@ namespace ewol {
* @return Dimention of the font need between 2 lines * @return Dimention of the font need between 2 lines
*/ */
float getHeight(float _size) { float getHeight(float _size) {
return ((float)m_font->getHeight(_size)); return ((float)this.font.getHeight(_size));
}; };
/** /**
* @brief get the font size with a specific display size * @brief get the font size with a specific display size
@ -47,20 +47,20 @@ namespace ewol {
* @return Dimention of the font for this compleate line size. * @return Dimention of the font for this compleate line size.
*/ */
float getSize(float _fontHeight) { float getSize(float _fontHeight) {
return m_font->getSizeWithHeight(_fontHeight); return this.font.getSizeWithHeight(_fontHeight);
} }
/** /**
* @brief get the ID of a unicode charcode * @brief get the ID of a unicode charcode
* @param[in] _charcode The unicodeValue * @param[in] _charcode The unicodeValue
* @return The ID in the table (if it does not exist : return 0) * @return The ID in the table (if it does not exist : return 0)
*/ */
int32_t getIndex(char32_t _charcode); int getIndex(Character _charcode);
/** /**
* @brief get the pointer on the coresponding glyph * @brief get the pointer on the coresponding glyph
* @param[in] _charcode The unicodeValue * @param[in] _charcode The unicodeValue
* @return The pointer on the glyph == > never null * @return The pointer on the glyph == > never null
*/ */
ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode); ewol::GlyphProperty* getGlyphPointer( Character _charcode);
public: public:
/** /**
* @brief keep the resource pointer. * @brief keep the resource pointer.
@ -68,29 +68,29 @@ namespace ewol {
* @param[in] _filename Name of the texture font. * @param[in] _filename Name of the texture font.
* @return pointer on the resource or null if an error occured. * @return pointer on the resource or null if an error occured.
*/ */
static ememory::SharedPtr<ewol::resource::DistanceFieldFont> keep(const etk::String& _filename); static ememory::Ptr<ewol::resource::DistanceFieldFont> keep( String _filename);
private: private:
/** /**
* @brief add a glyph in a texture font. * @brief add a glyph in a texture font.
* @param[in] _val Char value to add. * @param[in] _val Char value to add.
* @return true if the image size have change, false otherwise * @return true if the image size have change, false otherwise
*/ */
bool addGlyph(const char32_t& _val); boolean addGlyph( Character _val);
void generateDistanceField(const egami::ImageMono& _input, egami::Image& _output); void generateDistanceField( egami::ImageMono _input, egami::Image _output);
private: private:
float m_borderSize; //!< number of pixel added on the border of a glyph float this.borderSize; //!< number of pixel added on the border of a glyph
Vector2f m_textureBorderSize; //!< Transformed the border size in the texture dimention Vector2f this.textureBorderSize; //!< Transformed the border size in the texture dimention
public: public:
float getPixelBorderSize() { float getPixelBorderSize() {
return m_borderSize; return this.borderSize;
} }
const Vector2f& getTextureBorderSize() { Vector2f getTextureBorderSize() {
return m_textureBorderSize; return this.textureBorderSize;
} }
public: public:
void exportOnFile(); void exportOnFile();
bool importFromFile(); boolean importFromFile();
}; };
}; };
}; };

View File

@ -19,7 +19,7 @@
ETK_DECLARE_TYPE(ewol::resource::FontFreeType); ETK_DECLARE_TYPE(ewol::resource::FontFreeType);
// free Font hnadle of librairies ... entry for acces ... // free Font hnadle of librairies ... entry for acces ...
static int32_t l_countLoaded=0; static int l_countLoaded=0;
static FT_Library library; static FT_Library library;
void ewol::resource::freeTypeInit() { void ewol::resource::freeTypeInit() {
@ -29,7 +29,7 @@ void ewol::resource::freeTypeInit() {
// already loaded ... // already loaded ...
return; return;
} }
int32_t error = FT_Init_FreeType( &library ); int error = FT_Init_FreeType( library );
if(0 != error) { if(0 != error) {
Log.critical(" when loading FreeType Librairy ..."); Log.critical(" when loading FreeType Librairy ...");
} }
@ -42,7 +42,7 @@ void ewol::resource::freeTypeUnInit() {
// already needed ... // already needed ...
return; return;
} }
int32_t error = FT_Done_FreeType( library ); int error = FT_Done_FreeType( library );
library = null; library = null;
if(0 != error) { if(0 != error) {
Log.critical(" when Un-loading FreeType Librairy ..."); Log.critical(" when Un-loading FreeType Librairy ...");
@ -51,50 +51,50 @@ void ewol::resource::freeTypeUnInit() {
ewol::resource::FontFreeType::FontFreeType() { ewol::resource::FontFreeType::FontFreeType() {
addResourceType("ewol::FontFreeType"); addResourceType("ewol::FontFreeType");
m_init = false; this.init = false;
m_FileSize = 0; this.FileSize = 0;
} }
void ewol::resource::FontFreeType::init(const etk::Uri& _uri) { void ewol::resource::FontFreeType::init( etk::Uri _uri) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
ewol::resource::FontBase::init(_uri); ewol::resource::FontBase::init(_uri);
auto fileIO = etk::uri::get(_uri); auto fileIO = etk::uri::get(_uri);
if (fileIO == null) { if (fileIO == null) {
Log.error("File Does not exist : " << _uri); Log.error("File Does not exist : " + _uri);
return; return;
} }
if (fileIO->open(etk::io::OpenMode::Read) == false) { if (fileIO.open(etk::io::OpenMode::Read) == false) {
Log.error("Can not open the file : " << _uri); Log.error("Can not open the file : " + _uri);
return; return;
} }
m_FileBuffer = fileIO->readAll<FT_Byte>(); this.FileBuffer = fileIO.readAll<FT_Byte>();
// close the file: // close the file:
fileIO->close(); fileIO.close();
// load Face ... // load Face ...
int32_t error = FT_New_Memory_Face(library, &m_FileBuffer[0], m_FileBuffer.size(), 0, &m_fftFace ); int error = FT_New_Memory_Face(library, this.FileBuffer[0], this.FileBuffer.size(), 0, this.fftFace );
if( FT_Err_Unknown_File_Format == error) { if( FT_Err_Unknown_File_Format == error) {
Log.error("... the font file could be opened and read, but it appears ... that its font format is unsupported"); Log.error("... the font file could be opened and read, but it appears ... that its font format is unsupported");
} else if (0 != error) { } else if (0 != error) {
Log.error("... another error code means that the font file could not ... be opened or read, or simply that it is broken..."); Log.error("... another error code means that the font file could not ... be opened or read, or simply that it is broken...");
} else { } else {
// all OK // all OK
Log.debug("load font : \"" << _uri << "\" glyph count = " << (int)m_fftFace->num_glyphs); Log.debug("load font : \"" + _uri + "\" glyph count = " + (int)this.fftFace.nuthis.glyphs);
m_init = true; this.init = true;
//display(); //display();
} }
} }
ewol::resource::FontFreeType::~FontFreeType() { ewol::resource::FontFreeType::~FontFreeType() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
// clean the tmp memory // clean the tmp memory
m_FileBuffer.clear(); this.FileBuffer.clear();
// must be deleted fftFace // must be deleted fftFace
FT_Done_Face(m_fftFace); FT_Done_Face(this.fftFace);
} }
Vector2f ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::String& _unicodeString) { Vector2f ewol::resource::FontFreeType::getSize(int _fontSize, String _unicodeString) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if (m_init == false) { if (this.init == false) {
return Vector2f(0,0); return Vector2f(0,0);
} }
// TODO : ... // TODO : ...
@ -102,35 +102,35 @@ Vector2f ewol::resource::FontFreeType::getSize(int32_t _fontSize, const etk::Str
return outputSize; return outputSize;
} }
int32_t ewol::resource::FontFreeType::getHeight(int32_t _fontSize) { int ewol::resource::FontFreeType::getHeight(int _fontSize) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
return _fontSize*1.43f; // this is a really "magic" number ... return _fontSize*1.43f; // this is a really "magic" number ...
} }
float ewol::resource::FontFreeType::getSizeWithHeight(float _fontHeight) { float ewol::resource::FontFreeType::getSizeWithHeight(float _fontHeight) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
return _fontHeight*0.6993f; // this is a really "magic" number ... return _fontHeight*0.6993f; // this is a really "magic" number ...
} }
bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) { boolean ewol::resource::FontFreeType::getGlyphProperty(int _fontSize, ewol::GlyphProperty _property) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if(false == m_init) { if(false == this.init) {
return false; return false;
} }
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
int32_t fontQuality = 96; int fontQuality = 96;
// Select size ... // Select size ...
// note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype
int32_t error = FT_Set_Char_Size(m_fftFace, _fontSize<<6, _fontSize<<6, fontQuality, fontQuality); int error = FT_Set_Char_Size(this.fftFace, _fontSize+6, _fontSize+6, fontQuality, fontQuality);
if (0!=error ) { if (0!=error ) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
return false; return false;
} }
// a small shortcut // a small shortcut
FT_GlyphSlot slot = m_fftFace->glyph; FT_GlyphSlot slot = this.fftFace.glyph;
// retrieve glyph index from character code // retrieve glyph index from character code
int32_t glyph_index = FT_Get_Char_Index(m_fftFace, _property.m_UVal); int glyph_index = FT_Get_Char_Index(this.fftFace, _property.this.UVal);
// load glyph image into the slot (erase previous one) // load glyph image into the slot (erase previous one)
error = FT_Load_Glyph(m_fftFace, // handle to face object error = FT_Load_Glyph(this.fftFace, // handle to face object
glyph_index, // glyph index glyph_index, // glyph index
FT_LOAD_DEFAULT ); FT_LOAD_DEFAULT );
if (0!=error ) { if (0!=error ) {
@ -144,37 +144,37 @@ bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::Gly
return false; return false;
} }
// set properties : // set properties :
_property.m_glyphIndex = glyph_index; _property.this.glyphIndex = glyph_index;
_property.m_sizeTexture.setValue(slot->bitmap.width, slot->bitmap.rows); _property.this.sizeTexture.setValue(slot.bitmap.width, slot.bitmap.rows);
_property.m_bearing.setValue( slot->metrics.horiBearingX>>6 , slot->metrics.horiBearingY>>6 ); _property.this.bearing.setValue( slot.metrics.horiBearingX>>6 , slot.metrics.horiBearingY>>6 );
_property.m_advance.setValue( slot->metrics.horiAdvance>>6 , slot->metrics.vertAdvance>>6 ); _property.this.advance.setValue( slot.metrics.horiAdvance>>6 , slot.metrics.vertAdvance>>6 );
return true; return true;
} }
bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut, boolean ewol::resource::FontFreeType::drawGlyph(egami::Image _imageOut,
int32_t _fontSize, int _fontSize,
Vector2i _glyphPosition, Vector2i _glyphPosition,
ewol::GlyphProperty& _property, ewol::GlyphProperty _property,
int8_t _posInImage) { int8_t _posInImage) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if(m_init == false) { if(this.init == false) {
return false; return false;
} }
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
int32_t fontQuality = 96; int fontQuality = 96;
// Select size ... // Select size ...
// note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype
int32_t error = FT_Set_Char_Size(m_fftFace, _fontSize<<6, _fontSize<<6, fontQuality, fontQuality); int error = FT_Set_Char_Size(this.fftFace, _fontSize+6, _fontSize+6, fontQuality, fontQuality);
if (0!=error ) { if (0!=error ) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
return false; return false;
} }
// a small shortcut // a small shortcut
FT_GlyphSlot slot = m_fftFace->glyph; FT_GlyphSlot slot = this.fftFace.glyph;
// load glyph image into the slot (erase previous one) // load glyph image into the slot (erase previous one)
error = FT_Load_Glyph(m_fftFace, // handle to face object error = FT_Load_Glyph(this.fftFace, // handle to face object
_property.m_glyphIndex, // glyph index _property.this.glyphIndex, // glyph index
FT_LOAD_DEFAULT ); FT_LOAD_DEFAULT );
if (0!=error ) { if (0!=error ) {
Log.error("FT_Load_Glyph specify Glyph"); Log.error("FT_Load_Glyph specify Glyph");
@ -188,10 +188,10 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut,
} }
// draw it on the output Image : // draw it on the output Image :
etk::Color<> tlpppp(0xFF, 0xFF, 0xFF, 0x00); etk::Color<> tlpppp(0xFF, 0xFF, 0xFF, 0x00);
for(size_t jjj=0; jjj < slot->bitmap.rows;jjj++) { for(int jjj=0; jjj < slot.bitmap.rows;jjj++) {
for(size_t iii=0; iii < slot->bitmap.width; iii++){ for(int iii=0; iii < slot.bitmap.width; iii++){
tlpppp = _imageOut.get(Vector2i(_glyphPosition.x()+iii, _glyphPosition.y()+jjj)); tlpppp = _imageOut.get(Vector2i(_glyphPosition.x()+iii, _glyphPosition.y()+jjj));
uint8_t valueColor = slot->bitmap.buffer[iii + slot->bitmap.width*jjj]; int valueColor = slot.bitmap.buffer[iii + slot.bitmap.width*jjj];
// set only alpha : // set only alpha :
switch(_posInImage) { switch(_posInImage) {
default: default:
@ -215,28 +215,28 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut,
return true; return true;
} }
bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut, boolean ewol::resource::FontFreeType::drawGlyph(egami::ImageMono _imageOut,
int32_t _fontSize, int _fontSize,
ewol::GlyphProperty& _property, ewol::GlyphProperty _property,
int32_t _borderSize) { int _borderSize) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if(false == m_init) { if(false == this.init) {
return false; return false;
} }
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
int32_t fontQuality = 96; int fontQuality = 96;
// Select size ... // Select size ...
// note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype
int32_t error = FT_Set_Char_Size(m_fftFace, _fontSize<<6, _fontSize<<6, fontQuality, fontQuality); int error = FT_Set_Char_Size(this.fftFace, _fontSize+6, _fontSize+6, fontQuality, fontQuality);
if (0!=error ) { if (0!=error ) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
return false; return false;
} }
// a small shortcut // a small shortcut
FT_GlyphSlot slot = m_fftFace->glyph; FT_GlyphSlot slot = this.fftFace.glyph;
// load glyph image into the slot (erase previous one) // load glyph image into the slot (erase previous one)
error = FT_Load_Glyph(m_fftFace, // handle to face object error = FT_Load_Glyph(this.fftFace, // handle to face object
_property.m_glyphIndex, // glyph index _property.this.glyphIndex, // glyph index
FT_LOAD_DEFAULT ); FT_LOAD_DEFAULT );
if (0!=error ) { if (0!=error ) {
Log.error("FT_Load_Glyph specify Glyph"); Log.error("FT_Load_Glyph specify Glyph");
@ -249,11 +249,11 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut,
return false; return false;
} }
// resize output image : // resize output image :
_imageOut.resize(Vector2i(slot->bitmap.width+2*_borderSize, slot->bitmap.rows+2*_borderSize), 0); _imageOut.resize(Vector2i(slot.bitmap.width+2*_borderSize, slot.bitmap.rows+2*_borderSize), 0);
for(size_t jjj=0; jjj < slot->bitmap.rows;jjj++) { for(int jjj=0; jjj < slot.bitmap.rows;jjj++) {
for(size_t iii=0; iii < slot->bitmap.width; iii++){ for(int iii=0; iii < slot.bitmap.width; iii++){
uint8_t valueColor = slot->bitmap.buffer[iii + slot->bitmap.width*jjj]; int valueColor = slot.bitmap.buffer[iii + slot.bitmap.width*jjj];
// real set of color // real set of color
_imageOut.set(Vector2i(_borderSize+iii, _borderSize+jjj), valueColor ); _imageOut.set(Vector2i(_borderSize+iii, _borderSize+jjj), valueColor );
} }
@ -262,34 +262,34 @@ bool ewol::resource::FontFreeType::drawGlyph(egami::ImageMono& _imageOut,
} }
void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, List<ewol::GlyphProperty>& listGlyph) { void ewol::resource::FontFreeType::generateKerning(int fontSize, List<ewol::GlyphProperty> listGlyph) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if(m_init == false) { if(this.init == false) {
return; return;
} }
if ((FT_FACE_FLAG_KERNING & m_fftFace->face_flags) == 0) { if ((FT_FACE_FLAG_KERNING this.fftFace.face_flags) == 0) {
Log.info("No kerning generation (disable) in the font"); Log.info("No kerning generation (disable) in the font");
} }
// 300dpi (hight quality) 96 dpi (normal quality) // 300dpi (hight quality) 96 dpi (normal quality)
int32_t fontQuality = 96; int fontQuality = 96;
// Select size ... // Select size ...
// note tha <<6 == *64 corespond with the 1/64th of points calculation of freetype // note tha +6 == *64 corespond with the 1/64th of points calculation of freetype
int32_t error = FT_Set_Char_Size(m_fftFace, fontSize<<6, fontSize<<6, fontQuality, fontQuality); int error = FT_Set_Char_Size(this.fftFace, fontSize+6, fontSize+6, fontQuality, fontQuality);
if (0!=error ) { if (0!=error ) {
Log.error("FT_Set_Char_Size == > error in settings ..."); Log.error("FT_Set_Char_Size == > error in settings ...");
return; return;
} }
// For all the kerning element we get the kerning value : // For all the kerning element we get the kerning value :
for(size_t iii=0; iii<listGlyph.size(); iii++) { for(int iii=0; iii<listGlyph.size(); iii++) {
listGlyph[iii].kerningClear(); listGlyph[iii].kerningClear();
for(size_t kkk=0; kkk<listGlyph.size(); kkk++) { for(int kkk=0; kkk<listGlyph.size(); kkk++) {
FT_Vector kerning; FT_Vector kerning;
FT_Get_Kerning(m_fftFace, listGlyph[kkk].m_glyphIndex, listGlyph[iii].m_glyphIndex, FT_KERNING_UNFITTED, &kerning ); FT_Get_Kerning(this.fftFace, listGlyph[kkk].this.glyphIndex, listGlyph[iii].this.glyphIndex, FT_KERNING_UNFITTED, kerning );
// add the kerning only if != 0 ... // add the kerning only if != 0 ...
if (kerning.x != 0) { if (kerning.x != 0) {
listGlyph[iii].kerningAdd(listGlyph[kkk].m_UVal, listGlyph[iii].kerningAdd(listGlyph[kkk].this.UVal,
kerning.x/32.0f ); kerning.x/32.0f );
//Log.debug("Kerning between : '" << (char)listGlyph[iii].m_UVal << "'&'" << (char)listGlyph[kkk].m_UVal << "' value : " << kerning.x << " => " << (kerning.x/64.0f)); //Log.debug("Kerning between : '" + (char)listGlyph[iii].this.UVal + "''" + (char)listGlyph[kkk].this.UVal + "' value : " + kerning.x + " => " + (kerning.x/64.0f));
} }
} }
} }
@ -297,88 +297,88 @@ void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, List<ewol::
void ewol::resource::FontFreeType::display() { void ewol::resource::FontFreeType::display() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if(m_init == false) { if(this.init == false) {
return; return;
} }
Log.info(" number of glyph = " << (int)m_fftFace->num_glyphs); Log.info(" number of glyph = " + (int)this.fftFace.nuthis.glyphs);
if ((FT_FACE_FLAG_SCALABLE & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_SCALABLE this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_SCALABLE (enable)"); Log.info(" flags = FT_FACE_FLAG_SCALABLE (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_SCALABLE (disable)"); Log.debug(" flags = FT_FACE_FLAG_SCALABLE (disable)");
} }
if ((FT_FACE_FLAG_FIXED_SIZES & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_FIXED_SIZES this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_FIXED_SIZES (enable)"); Log.info(" flags = FT_FACE_FLAG_FIXED_SIZES (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_FIXED_SIZES (disable)"); Log.debug(" flags = FT_FACE_FLAG_FIXED_SIZES (disable)");
} }
if ((FT_FACE_FLAG_FIXED_WIDTH & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_FIXED_WIDTH this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_FIXED_WIDTH (enable)"); Log.info(" flags = FT_FACE_FLAG_FIXED_WIDTH (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_FIXED_WIDTH (disable)"); Log.debug(" flags = FT_FACE_FLAG_FIXED_WIDTH (disable)");
} }
if ((FT_FACE_FLAG_SFNT & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_SFNT this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_SFNT (enable)"); Log.info(" flags = FT_FACE_FLAG_SFNT (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_SFNT (disable)"); Log.debug(" flags = FT_FACE_FLAG_SFNT (disable)");
} }
if ((FT_FACE_FLAG_HORIZONTAL & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_HORIZONTAL this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_HORIZONTAL (enable)"); Log.info(" flags = FT_FACE_FLAG_HORIZONTAL (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_HORIZONTAL (disable)"); Log.debug(" flags = FT_FACE_FLAG_HORIZONTAL (disable)");
} }
if ((FT_FACE_FLAG_VERTICAL & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_VERTICAL this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_VERTICAL (enable)"); Log.info(" flags = FT_FACE_FLAG_VERTICAL (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_VERTICAL (disable)"); Log.debug(" flags = FT_FACE_FLAG_VERTICAL (disable)");
} }
if ((FT_FACE_FLAG_KERNING & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_KERNING this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_KERNING (enable)"); Log.info(" flags = FT_FACE_FLAG_KERNING (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_KERNING (disable)"); Log.debug(" flags = FT_FACE_FLAG_KERNING (disable)");
} }
/* Deprecated flag /* Deprecated flag
if ((FT_FACE_FLAG_FAST_GLYPHS & face->face_flags) != 0) { if ((FT_FACE_FLAG_FAST_GLYPHS face.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_FAST_GLYPHS (enable)"); Log.info(" flags = FT_FACE_FLAG_FAST_GLYPHS (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_FAST_GLYPHS (disable)"); Log.debug(" flags = FT_FACE_FLAG_FAST_GLYPHS (disable)");
} }
*/ */
if ((FT_FACE_FLAG_MULTIPLE_MASTERS & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_MULTIPLE_MASTERS this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_MULTIPLE_MASTERS (enable)"); Log.info(" flags = FT_FACE_FLAG_MULTIPLE_MASTERS (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_MULTIPLE_MASTERS (disable)"); Log.debug(" flags = FT_FACE_FLAG_MULTIPLE_MASTERS (disable)");
} }
if ((FT_FACE_FLAG_GLYPH_NAMES & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_GLYPH_NAMES this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_GLYPH_NAMES (enable)"); Log.info(" flags = FT_FACE_FLAG_GLYPH_NAMES (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_GLYPH_NAMES (disable)"); Log.debug(" flags = FT_FACE_FLAG_GLYPH_NAMES (disable)");
} }
if ((FT_FACE_FLAG_EXTERNAL_STREAM & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_EXTERNAL_STREAM this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_EXTERNAL_STREAM (enable)"); Log.info(" flags = FT_FACE_FLAG_EXTERNAL_STREAM (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_EXTERNAL_STREAM (disable)"); Log.debug(" flags = FT_FACE_FLAG_EXTERNAL_STREAM (disable)");
} }
if ((FT_FACE_FLAG_HINTER & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_HINTER this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_HINTER (enable)"); Log.info(" flags = FT_FACE_FLAG_HINTER (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_HINTER (disable)"); Log.debug(" flags = FT_FACE_FLAG_HINTER (disable)");
} }
if ((FT_FACE_FLAG_CID_KEYED & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_CID_KEYED this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_CID_KEYED (enable)"); Log.info(" flags = FT_FACE_FLAG_CID_KEYED (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_CID_KEYED (disable)"); Log.debug(" flags = FT_FACE_FLAG_CID_KEYED (disable)");
} }
/* /*
if ((FT_FACE_FLAG_TRICKY & m_fftFace->face_flags) != 0) { if ((FT_FACE_FLAG_TRICKY this.fftFace.face_flags) != 0) {
Log.info(" flags = FT_FACE_FLAG_TRICKY (enable)"); Log.info(" flags = FT_FACE_FLAG_TRICKY (enable)");
} else { } else {
Log.debug(" flags = FT_FACE_FLAG_TRICKY (disable)"); Log.debug(" flags = FT_FACE_FLAG_TRICKY (disable)");
} }
*/ */
Log.info(" unit per EM = " << m_fftFace->units_per_EM); Log.info(" unit per EM = " + this.fftFace.units_per_EM);
Log.info(" num of fixed sizes = " << m_fftFace->num_fixed_sizes); Log.info(" num of fixed sizes = " + this.fftFace.nuthis.fixed_sizes);
//Log.info(" Availlable sizes = " << (int)m_fftFace->available_sizes); //Log.info(" Availlable sizes = " + (int)this.fftFace.available_sizes);
//Log.info(" Current size = " << (int)m_fftFace->size); //Log.info(" Current size = " + (int)this.fftFace.size);
} }

View File

@ -20,39 +20,39 @@ namespace ewol {
// show : http://www.freetype.org/freetype2/docs/tutorial/step2.html // show : http://www.freetype.org/freetype2/docs/tutorial/step2.html
class FontFreeType : public ewol::resource::FontBase { class FontFreeType : public ewol::resource::FontBase {
private: private:
List<FT_Byte> m_FileBuffer; List<FT_Byte> this.FileBuffer;
int32_t m_FileSize; int this.FileSize;
FT_Face m_fftFace; FT_Face this.fftFace;
bool m_init; boolean this.init;
void display(); void display();
protected: protected:
FontFreeType(); FontFreeType();
void init(const etk::Uri& _uri); void init( etk::Uri _uri);
public: public:
DECLARE_RESOURCE_URI_FACTORY(FontFreeType); DECLARE_RESOURCE_URI_FACTORY(FontFreeType);
virtual ~FontFreeType(); ~FontFreeType();
public: public:
bool getGlyphProperty(int32_t _fontSize, boolean getGlyphProperty(int _fontSize,
ewol::GlyphProperty& _property); ewol::GlyphProperty _property);
bool drawGlyph(egami::Image& _imageOut, boolean drawGlyph(egami::Image _imageOut,
int32_t _fontSize, int _fontSize,
Vector2i _glyphPosition, Vector2i _glyphPosition,
ewol::GlyphProperty& _property, ewol::GlyphProperty _property,
int8_t _posInImage); int8_t _posInImage);
bool drawGlyph(egami::ImageMono& _imageOut, boolean drawGlyph(egami::ImageMono _imageOut,
int32_t _fontSize, int _fontSize,
ewol::GlyphProperty& _property, ewol::GlyphProperty _property,
int32_t _borderSize = 0); int _borderSize = 0);
Vector2f getSize(int32_t _fontSize, const etk::String& _unicodeString); Vector2f getSize(int _fontSize, String _unicodeString);
int32_t getHeight(int32_t _fontSize); int getHeight(int _fontSize);
float getSizeWithHeight(float _fontHeight); float getSizeWithHeight(float _fontHeight);
void generateKerning(int32_t _fontSize, List<ewol::GlyphProperty>& _listGlyph); void generateKerning(int _fontSize, List<ewol::GlyphProperty> _listGlyph);
}; };
void freeTypeInit(); void freeTypeInit();
void freeTypeUnInit(); void freeTypeUnInit();

View File

@ -21,39 +21,39 @@ ewol::resource::ImageDF::ImageDF() {
void ewol::resource::ImageDF::init() { void ewol::resource::ImageDF::init() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
ewol::resource::Texture::init(); ewol::resource::Texture::init();
} }
void ewol::resource::ImageDF::init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size) { void ewol::resource::ImageDF::init(String _genName, etk::Uri _uri, Vector2i _size) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
ewol::resource::Texture::init(_genName); ewol::resource::Texture::init(_genName);
Log.debug("create a new resource::Image : _genName=" << _genName << " _uri=" << _uri << " size=" << _size); Log.debug("create a new resource::Image : _genName=" + _genName + " _uri=" + _uri + " size=" + _size);
m_data = egami::load(_uri, _size); this.data = egami::load(_uri, _size);
if (m_data.exist() == false) { if (this.data.exist() == false) {
Log.error("ERROR when loading the image : " << _uri); Log.error("ERROR when loading the image : " + _uri);
} }
Vector2i tmp = m_data.getSize(); Vector2i tmp = this.data.getSize();
m_realImageSize = Vector2f(tmp.x(), tmp.y()); this.realImageSize = Vector2f(tmp.x(), tmp.y());
// distance field Generation // distance field Generation
// TODO : if it is not a .edf ==> generate dynamicly ... // TODO : if it is not a .edf ==> generate dynamicly ...
/* /*
egami::ImageMono input; egami::ImageMono input;
input.resize(tmp); input.resize(tmp);
for (size_t yyy = 0; yyy < tmp.y(); ++yyy) { for (int yyy = 0; yyy < tmp.y(); ++yyy) {
for (size_t xxx = 0; xxx < tmp.x(); ++xxx) { for (int xxx = 0; xxx < tmp.x(); ++xxx) {
input.set(Vector2i(xxx, yyy), m_data.get(Vector2i(xxx, yyy)).a() ); input.set(Vector2i(xxx, yyy), this.data.get(Vector2i(xxx, yyy)).a() );
} }
} }
generateDistanceField(input, m_data); generateDistanceField(input, this.data);
*/ */
flush(); flush();
} }
void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _input, egami::Image& _output) { void ewol::resource::ImageDF::generateDistanceField( egami::ImageMono _input, egami::Image _output) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
int32_t size = _input.getSize().x() * _input.getSize().y(); int size = _input.getSize().x() * _input.getSize().y();
List<short> xdist; List<short> xdist;
List<short> ydist; List<short> ydist;
List<double> gx; List<double> gx;
@ -70,9 +70,9 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp
inside.resize(size, 0.0); inside.resize(size, 0.0);
// Convert img into double (data) // Convert img into double (data)
double img_min = 255, img_max = -255; double img_min = 255, img_max = -255;
for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) {
for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) {
int32_t iii = yyy * _input.getSize().x() + xxx; int iii = yyy * _input.getSize().x() + xxx;
double v = _input.get(Vector2i(xxx, yyy)); double v = _input.get(Vector2i(xxx, yyy));
data[iii] = v; data[iii] = v;
if (v > img_max) { if (v > img_max) {
@ -84,35 +84,35 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp
} }
} }
// Rescale image levels between 0 and 1 // Rescale image levels between 0 and 1
for (int32_t yyy = 0; yyy < _input.getSize().y(); ++yyy) { for (int yyy = 0; yyy < _input.getSize().y(); ++yyy) {
for (int32_t xxx = 0; xxx < _input.getSize().x(); ++xxx) { for (int xxx = 0; xxx < _input.getSize().x(); ++xxx) {
int32_t iii = yyy * _input.getSize().x() + xxx; int iii = yyy * _input.getSize().x() + xxx;
data[iii] = (_input.get(Vector2i(xxx, yyy))-img_min)/img_max; data[iii] = (_input.get(Vector2i(xxx, yyy))-img_min)/img_max;
} }
} }
// Compute outside = edtaa3(bitmap); % Transform background (0's) // Compute outside = edtaa3(bitmap); % Transform background (0's)
computegradient(&data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); computegradient(data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]);
edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &outside[0]); edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &outside[0]);
for(size_t iii = 0; iii < outside.size(); ++iii) { for(int iii = 0; iii < outside.size(); ++iii) {
if( outside[iii] < 0 ) { if( outside[iii] < 0 ) {
outside[iii] = 0.0; outside[iii] = 0.0;
} }
} }
// Compute inside = edtaa3(1-bitmap); % Transform foreground (1's) // Compute inside = edtaa3(1-bitmap); % Transform foreground (1's)
for(size_t iii = 0; iii < gx.size(); ++iii) { for(int iii = 0; iii < gx.size(); ++iii) {
gx[iii] = 0; gx[iii] = 0;
} }
for(size_t iii = 0; iii < gy.size(); ++iii) { for(int iii = 0; iii < gy.size(); ++iii) {
gy[iii] = 0; gy[iii] = 0;
} }
for(size_t iii = 0; iii < data.size(); ++iii) { for(int iii = 0; iii < data.size(); ++iii) {
data[iii] = 1 - data[iii]; data[iii] = 1 - data[iii];
} }
computegradient( &data[0], _input.getSize().x(), _input.getSize().y(), &gx[0], &gy[0]); computegradient( data[0], _input.getSize().x(), _input.getSize().y(), gx[0], gy[0]);
edtaa3(&data[0], &gx[0], &gy[0], _input.getSize().x(), _input.getSize().y(), &xdist[0], &ydist[0], &inside[0]); edtaa3(data[0], gx[0], gy[0], _input.getSize().x(), _input.getSize().y(), xdist[0], &ydist[0], &inside[0]);
for(size_t iii = 0; iii < inside.size(); ++iii) { for(int iii = 0; iii < inside.size(); ++iii) {
if( inside[iii] < 0 ) { if( inside[iii] < 0 ) {
inside[iii] = 0.0; inside[iii] = 0.0;
} }
@ -120,9 +120,9 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp
_output.resize(_input.getSize(), etk::Color<>(0)); _output.resize(_input.getSize(), etk::Color<>(0));
_output.clear(etk::Color<>(0)); _output.clear(etk::Color<>(0));
for (int32_t xxx = 0; xxx < _output.getSize().x(); ++xxx) { for (int xxx = 0; xxx < _output.getSize().x(); ++xxx) {
for (int32_t yyy = 0; yyy < _output.getSize().y(); ++yyy) { for (int yyy = 0; yyy < _output.getSize().y(); ++yyy) {
int32_t iii = yyy * _output.getSize().x() + xxx; int iii = yyy * _output.getSize().x() + xxx;
outside[iii] -= inside[iii]; outside[iii] -= inside[iii];
outside[iii] = 128+outside[iii]*16; outside[iii] = 128+outside[iii]*16;
if( outside[iii] < 0 ) { if( outside[iii] < 0 ) {
@ -131,9 +131,9 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp
if( outside[iii] > 255 ) { if( outside[iii] > 255 ) {
outside[iii] = 255; outside[iii] = 255;
} }
uint8_t val = 255 - (unsigned char) outside[iii]; int val = 255 - (unsigned char) outside[iii];
// TODO : Remove multiple size of the map ... // TODO : Remove multiple size of the map ...
_output.set(Vector2i(xxx, yyy), etk::Color<>((int32_t)val,(int32_t)val,(int32_t)val,255)); _output.set(Vector2i(xxx, yyy), etk::Color<>((int)val,(int)val,(int)val,255));
} }
} }
} }
@ -145,30 +145,30 @@ void ewol::resource::ImageDF::generateDistanceField(const egami::ImageMono& _inp
* @param[in] _value Value that we want the next power of 2 * @param[in] _value Value that we want the next power of 2
* @return result value * @return result value
*/ */
static int32_t nextP2(int32_t _value) { static int nextP2(int _value) {
int32_t val=1; int val=1;
for (int32_t iii=1; iii<31; iii++) { for (int iii=1; iii<31; iii++) {
if (_value <= val) { if (_value <= val) {
return val; return val;
} }
val *=2; val *=2;
} }
Log.critical("impossible CASE.... request P2 of " << _value); Log.critical("impossible CASE.... request P2 of " + _value);
return val; return val;
} }
#endif #endif
ememory::SharedPtr<ewol::resource::ImageDF> ewol::resource::ImageDF::create(const etk::Uri& _uri, Vector2i _size) { ememory::Ptr<ewol::resource::ImageDF> ewol::resource::ImageDF::create( etk::Uri _uri, Vector2i _size) {
Log.verbose("KEEP: TextureFile: '" << _uri << "' size=" << _size); Log.verbose("KEEP: TextureFile: '" + _uri + "' size=" + _size);
if (_uri.isEmpty() == true) { if (_uri.isEmpty() == true) {
ememory::SharedPtr<ewol::resource::ImageDF> object(ETK_NEW(ewol::resource::ImageDF)); ememory::Ptr<ewol::resource::ImageDF> object(ETK_NEW(ewol::resource::ImageDF));
if (object == null) { if (object == null) {
Log.error("allocation error of a resource : ??TEX??"); Log.error("allocation error of a resource : ??TEX??");
return null; return null;
} }
object->init(); object.init();
getManager().localAdd(object); getManager().localAdd(object);
return object; return object;
} }
@ -189,8 +189,8 @@ ememory::SharedPtr<ewol::resource::ImageDF> ewol::resource::ImageDF::create(cons
_size = Vector2i(64,64); _size = Vector2i(64,64);
#endif #endif
if ( _size.x() > 0 if ( _size.x() > 0
&& _size.y() > 0) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _size.y() > 0) {
Log.verbose(" == > specific size : " << _size); Log.verbose(" == > specific size : " + _size);
#ifdef __TARGET_OS__Android #ifdef __TARGET_OS__Android
_size.setValue(nextP2(_size.x()), nextP2(_size.y())); _size.setValue(nextP2(_size.x()), nextP2(_size.y()));
#endif #endif
@ -198,27 +198,27 @@ ememory::SharedPtr<ewol::resource::ImageDF> ewol::resource::ImageDF::create(cons
tmpFilename.getQuery().set("y", etk::toString(_size.y())); tmpFilename.getQuery().set("y", etk::toString(_size.y()));
} }
Log.verbose("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); Log.verbose("KEEP: TextureFile: '" + tmpFilename + "' new size=" + _size);
ememory::SharedPtr<ewol::resource::ImageDF> object = null; ememory::Ptr<ewol::resource::ImageDF> object = null;
ememory::SharedPtr<gale::Resource> object2 = getManager().localKeep("DF__" + tmpFilename.getString()); ememory::Ptr<gale::Resource> object2 = getManager().localKeep("DF__" + tmpFilename.getString());
if (object2 != null) { if (object2 != null) {
object = ememory::dynamicPointerCast<ewol::resource::ImageDF>(object2); object = ememory::dynamicPointerCast<ewol::resource::ImageDF>(object2);
if (object == null) { if (object == null) {
Log.critical("Request resource file : '" << tmpFilename << "' With the wrong type (dynamic cast error)"); Log.critical("Request resource file : '" + tmpFilename + "' With the wrong type (dynamic cast error)");
return null; return null;
} }
} }
if (object != null) { if (object != null) {
return object; return object;
} }
Log.info("CREATE: ImageDF: '" << tmpFilename << "' size=" << _size); Log.info("CREATE: ImageDF: '" + tmpFilename + "' size=" + _size);
// need to crate a new one ... // need to crate a new one ...
object = ememory::SharedPtr<ewol::resource::ImageDF>(ETK_NEW(ewol::resource::ImageDF)); object = ememory::Ptr<ewol::resource::ImageDF>(ETK_NEW(ewol::resource::ImageDF));
if (object == null) { if (object == null) {
Log.error("allocation error of a resource : " << _uri); Log.error("allocation error of a resource : " + _uri);
return null; return null;
} }
object->init("DF__" + tmpFilename.getString(), _uri, _size); object.init("DF__" + tmpFilename.getString(), _uri, _size);
getManager().localAdd(object); getManager().localAdd(object);
return object; return object;
} }

View File

@ -14,23 +14,23 @@ namespace ewol {
namespace resource { namespace resource {
class ImageDF : public ewol::resource::Texture { class ImageDF : public ewol::resource::Texture {
protected: protected:
Vector2f m_realImageSize; Vector2f this.realImageSize;
protected: protected:
ImageDF(); ImageDF();
void init(); void init();
void init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size); void init(String _genName, etk::Uri _uri, Vector2i _size);
public: public:
virtual ~ImageDF() { }; ~ImageDF() { };
protected: protected:
/** /**
* @brief Generate distance field of this Image input. * @brief Generate distance field of this Image input.
* @param[in] _input Input image to change in distance field mode. * @param[in] _input Input image to change in distance field mode.
* @param[out] _output New image generate with this image _input. * @param[out] _output New image generate with this image _input.
*/ */
void generateDistanceField(const egami::ImageMono& _input, egami::Image& _output); void generateDistanceField( egami::ImageMono _input, egami::Image _output);
public: public:
const Vector2f& getRealSize() { Vector2f getRealSize() {
return m_realImageSize; return this.realImageSize;
}; };
public: public:
/** /**
@ -40,7 +40,7 @@ namespace ewol {
* @param[in] _requested size of the image (usefull when loading .svg to automatic rescale) * @param[in] _requested size of the image (usefull when loading .svg to automatic rescale)
* @return pointer on the resource or null if an error occured. * @return pointer on the resource or null if an error occured.
*/ */
static ememory::SharedPtr<ewol::resource::ImageDF> create(const etk::Uri& _uri, Vector2i _size=Vector2i(-1,-1)); static ememory::Ptr<ewol::resource::ImageDF> create( etk::Uri _uri, Vector2i _size=Vector2i(-1,-1));
}; };
}; };
}; };

View File

@ -20,9 +20,9 @@ ETK_DECLARE_TYPE(ewol::resource::Texture);
* @param[in] value Value that we want the next power of 2 * @param[in] value Value that we want the next power of 2
* @return result value * @return result value
*/ */
static int32_t nextP2(int32_t _value) { static int nextP2(int _value) {
int32_t val=1; int val=1;
for (int32_t iii=1; iii<31; iii++) { for (int iii=1; iii<31; iii++) {
if (_value <= val) { if (_value <= val) {
return val; return val;
} }
@ -32,7 +32,7 @@ static int32_t nextP2(int32_t _value) {
return val; return val;
} }
void ewol::resource::Texture::init(const etk::String& _filename) { void ewol::resource::Texture::init( String _filename) {
gale::Resource::init(_filename); gale::Resource::init(_filename);
} }
void ewol::resource::Texture::init() { void ewol::resource::Texture::init() {
@ -40,18 +40,18 @@ void ewol::resource::Texture::init() {
} }
ewol::resource::Texture::Texture() : ewol::resource::Texture::Texture() :
m_texId(0), this.texId(0),
#ifdef EWOL_USE_FBO #ifdef EWOL_USE_FBO
m_texPboId(0), this.texPboId(0),
#endif #endif
m_data(Vector2i(32,32),egami::colorType::RGBA8), this.data(Vector2i(32,32),egami::colorType::RGBA8),
m_realImageSize(1,1), this.realImageSize(1,1),
m_lastSize(1,1), this.lastSize(1,1),
m_loaded(false), this.loaded(false),
m_lastTypeObject(0), this.lastTypeObject(0),
m_lastSizeObject(0), this.lastSizeObject(0),
m_repeat(false), this.repeat(false),
m_filter(ewol::resource::TextureFilter::linear) { this.filter(ewol::resource::TextureFilter::linear) {
addResourceType("ewol::compositing::Texture"); addResourceType("ewol::compositing::Texture");
} }
@ -60,34 +60,34 @@ ewol::resource::Texture::~Texture() {
} }
void ewol::resource::Texture::setRepeat(bool _value) { void ewol::resource::Texture::setRepeat(boolean _value) {
m_repeat = _value; this.repeat = _value;
} }
void ewol::resource::Texture::setFilterMode(enum ewol::resource::TextureFilter _filter) { void ewol::resource::Texture::setFilterMode(enum ewol::resource::TextureFilter _filter) {
m_filter = _filter; this.filter = _filter;
} }
#include <egami/egami.hpp> #include <egami/egami.hpp>
bool ewol::resource::Texture::updateContext() { boolean ewol::resource::Texture::updateContext() {
Log.verbose("updateContext [START]"); Log.verbose("updateContext [START]");
if (false) { if (false) {
echrono::Steady tic = echrono::Steady::now(); echrono::Steady tic = echrono::Steady::now();
gale::openGL::flush(); gale::openGL::flush();
echrono::Steady toc = echrono::Steady::now(); echrono::Steady toc = echrono::Steady::now();
Log.verbose(" updateContext [FLUSH] ==> " << (toc - tic)); Log.verbose(" updateContext [FLUSH] ==> " + (toc - tic));
} }
ethread::RecursiveLock lock(m_mutex, true); ethread::RecursiveLock lock(this.mutex, true);
echrono::Steady tic = echrono::Steady::now(); echrono::Steady tic = echrono::Steady::now();
if (lock.tryLock() == false) { if (lock.tryLock() == false) {
//Lock error ==> try later ... //Lock error ==> try later ...
return false; return false;
} }
int32_t typeObject = GL_RGBA; int typeObject = GL_RGBA;
int32_t sizeObject = GL_UNSIGNED_BYTE; int sizeObject = GL_UNSIGNED_BYTE;
int32_t sizeByte = 1; int sizeByte = 1;
switch (m_data.getType()) { switch (this.data.getType()) {
case egami::colorType::RGBA8: case egami::colorType::RGBA8:
typeObject = GL_RGBA; typeObject = GL_RGBA;
sizeObject = GL_UNSIGNED_BYTE; sizeObject = GL_UNSIGNED_BYTE;
@ -112,52 +112,52 @@ bool ewol::resource::Texture::updateContext() {
case egami::colorType::unsignedInt32: case egami::colorType::unsignedInt32:
case egami::colorType::float32: case egami::colorType::float32:
case egami::colorType::float64: case egami::colorType::float64:
Log.error("Not manage the type " << m_data.getType() << " for texture"); Log.error("Not manage the type " + this.data.getType() + " for texture");
break; break;
} }
if (m_loaded == true) { if (this.loaded == true) {
if ( m_lastTypeObject != typeObject if ( this.lastTypeObject != typeObject
|| m_lastSizeObject != sizeObject || this.lastSizeObject != sizeObject
|| m_lastSize != m_data.getSize()) { || this.lastSize != this.data.getSize()) {
EWOL_WARNING("TEXTURE: Rm [" << getId() << "] texId=" << m_texId); Log.warning("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
glDeleteTextures(1, &m_texId); glDeleteTextures(1, this.texId);
m_loaded = false; this.loaded = false;
} }
} }
if (m_loaded == false) { if (this.loaded == false) {
// Request a new texture at openGl : // Request a new texture at openGl :
glGenTextures(1, &m_texId); glGenTextures(1, this.texId);
#ifdef EWOL_USE_FBO #ifdef EWOL_USE_FBO
Log.error("CREATE PBO"); Log.error("CREATE PBO");
glGenBuffers(1, &m_texPboId); glGenBuffers(1, this.texPboId);
Log.error("CREATE PBO 1"); Log.error("CREATE PBO 1");
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_texPboId); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this.texPboId);
Log.error("CREATE PBO 2"); Log.error("CREATE PBO 2");
glBufferData(GL_PIXEL_UNPACK_BUFFER, m_data.getGPUSize().x()*m_data.getGPUSize().y()*sizeByte, 0, GL_STREAM_DRAW); glBufferData(GL_PIXEL_UNPACK_BUFFER, this.data.getGPUSize().x()*this.data.getGPUSize().y()*sizeByte, 0, GL_STREAM_DRAW);
Log.error("CREATE PBO 3"); Log.error("CREATE PBO 3");
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
Log.error("CREATE PBO 4 (done)"); Log.error("CREATE PBO 4 (done)");
#endif #endif
m_lastSize = m_data.getSize(); this.lastSize = this.data.getSize();
m_lastTypeObject = typeObject; this.lastTypeObject = typeObject;
m_lastSizeObject = sizeObject; this.lastSizeObject = sizeObject;
Log.debug("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << "=>" << m_data.getGPUSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType()); Log.debug("TEXTURE: add [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize() + " OGl_Id=" + this.texId + " type=" << this.data.getType());
} else { } else {
Log.debug("TEXTURE: update [" << getId() << "]=" << m_data.getSize() << "=>" << m_data.getGPUSize() << " OGl_Id=" << m_texId << " type=" << m_data.getType()); Log.debug("TEXTURE: update [" + getId() + "]=" + this.data.getSize() + "=>" + this.data.getGPUSize() + " OGl_Id=" + this.texId + " type=" << this.data.getType());
} }
// in all case we set the texture properties : // in all case we set the texture properties :
// TODO : check error ??? // TODO : check error ???
glBindTexture(GL_TEXTURE_2D, m_texId); glBindTexture(GL_TEXTURE_2D, this.texId);
if (m_loaded == false) { if (this.loaded == false) {
if (m_repeat == false) { if (this.repeat == false) {
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE);
} else { } else {
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);
} }
if (m_filter == ewol::resource::TextureFilter::linear) { if (this.filter == ewol::resource::TextureFilter::linear) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
} else { } else {
@ -167,30 +167,30 @@ bool ewol::resource::Texture::updateContext() {
} }
//glPixelStorei(GL_UNPACK_ALIGNMENT,1); //glPixelStorei(GL_UNPACK_ALIGNMENT,1);
echrono::Steady toc1 = echrono::Steady::now(); echrono::Steady toc1 = echrono::Steady::now();
Log.verbose(" BIND ==> " << (toc1 - tic)); Log.verbose(" BIND ==> " + (toc1 - tic));
//egami::store(m_data, etk::String("~/texture_") + etk::toString(getId()) + ".bmp"); //egami::store(this.data, String("~/texture_") + etk::toString(getId()) + ".bmp");
#if defined(__TARGET_OS__Android) \ #if defined(__TARGET_OS__Android) \
|| defined(__TARGET_OS__IOs) || defined(__TARGET_OS__IOs)
// On some embended target, the texture size must be square of 2: // On some embended target, the texture size must be square of 2:
if (m_loaded == false) { if (this.loaded == false) {
// 1: Create the square 2 texture: // 1: Create the square 2 texture:
int32_t bufferSize = m_data.getGPUSize().x() * m_data.getGPUSize().y() * 8; int bufferSize = this.data.getGPUSize().x() * this.data.getGPUSize().y() * 8;
static List<float> tmpData; static List<float> tmpData;
if (tmpData.size() < bufferSize) { if (tmpData.size() < bufferSize) {
tmpData.resize(bufferSize, 0.0f); tmpData.resize(bufferSize, 0.0f);
} }
Log.debug(" CREATE texture ==> " << m_data.getGPUSize()); Log.debug(" CREATE texture ==> " + this.data.getGPUSize());
// 2 create a new empty texture: // 2 create a new empty texture:
#ifdef EWOL_USE_FBO #ifdef EWOL_USE_FBO
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_texPboId); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this.texPboId);
void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_data.getGPUSize().x() * m_data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT); void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, this.data.getGPUSize().x() * this.data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT);
memcpy(pBuff, &tmpData[0], m_data.getGPUSize().x()*m_data.getGPUSize().y()*sizeByte); memcpy(pBuff, tmpData[0], this.data.getGPUSize().x()*this.data.getGPUSize().y()*sizeByte);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glTexImage2D(GL_TEXTURE_2D, // Target glTexImage2D(GL_TEXTURE_2D, // Target
0, // Level 0, // Level
typeObject, // Format internal typeObject, // Format internal
m_data.getGPUSize().x(), this.data.getGPUSize().x(),
m_data.getGPUSize().y(), this.data.getGPUSize().y(),
0, // Border 0, // Border
typeObject, // format typeObject, // format
sizeObject, // type sizeObject, // type
@ -199,26 +199,26 @@ bool ewol::resource::Texture::updateContext() {
glTexImage2D(GL_TEXTURE_2D, // Target glTexImage2D(GL_TEXTURE_2D, // Target
0, // Level 0, // Level
typeObject, // Format internal typeObject, // Format internal
m_data.getGPUSize().x(), this.data.getGPUSize().x(),
m_data.getGPUSize().y(), this.data.getGPUSize().y(),
0, // Border 0, // Border
typeObject, // format typeObject, // format
sizeObject, // type sizeObject, // type
&tmpData[0] ); tmpData[0] );
#endif #endif
} }
#ifdef EWOL_USE_FBO #ifdef EWOL_USE_FBO
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, m_texPboId); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, this.texPboId);
void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_data.getGPUSize().x() * m_data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT); void* pBuff = ::glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, this.data.getGPUSize().x() * this.data.getGPUSize().y() * sizeByte, GL_MAP_WRITE_BIT);
memcpy(pBuff, m_data.getTextureDataPointer(), m_data.getWidth()*m_data.getHeight()*sizeByte); memcpy(pBuff, this.data.getTextureDataPointer(), this.data.getWidth()*this.data.getHeight()*sizeByte);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER); glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
//3 Flush all time the data: //3 Flush all time the data:
glTexSubImage2D(GL_TEXTURE_2D, // Target glTexSubImage2D(GL_TEXTURE_2D, // Target
0, // Level 0, // Level
0, // x offset 0, // x offset
0, // y offset 0, // y offset
m_data.getWidth(), this.data.getWidth(),
m_data.getHeight(), this.data.getHeight(),
typeObject, // format typeObject, // format
sizeObject, // type sizeObject, // type
(void *)0 ); (void *)0 );
@ -230,90 +230,90 @@ bool ewol::resource::Texture::updateContext() {
0, // Level 0, // Level
0, // x offset 0, // x offset
0, // y offset 0, // y offset
m_data.getWidth(), this.data.getWidth(),
m_data.getHeight(), this.data.getHeight(),
typeObject, // format typeObject, // format
sizeObject, // type sizeObject, // type
(void*)((char*)m_data.getTextureDataPointer()) ); (void*)((char*)this.data.getTextureDataPointer()) );
echrono::Steady toc2 = echrono::Steady::now(); echrono::Steady toc2 = echrono::Steady::now();
Log.info(" updateContext [STOP] ==> " << (toc2 - tic1)); Log.info(" updateContext [STOP] ==> " + (toc2 - tic1));
#endif #endif
#else #else
// This is the normal case ==> set the image and after set just the update of the data // This is the normal case ==> set the image and after set just the update of the data
if (m_loaded == false) { if (this.loaded == false) {
glTexImage2D(GL_TEXTURE_2D, // Target glTexImage2D(GL_TEXTURE_2D, // Target
0, // Level 0, // Level
typeObject, // Format internal typeObject, // Format internal
m_data.getWidth(), this.data.getWidth(),
m_data.getHeight(), this.data.getHeight(),
0, // Border 0, // Border
typeObject, // format typeObject, // format
sizeObject, // type sizeObject, // type
m_data.getTextureDataPointer() ); this.data.getTextureDataPointer() );
} else { } else {
glTexSubImage2D(GL_TEXTURE_2D, // Target glTexSubImage2D(GL_TEXTURE_2D, // Target
0, // Level 0, // Level
0, // x offset 0, // x offset
0, // y offset 0, // y offset
m_data.getWidth(), this.data.getWidth(),
m_data.getHeight(), this.data.getHeight(),
typeObject, // format typeObject, // format
sizeObject, // type sizeObject, // type
m_data.getTextureDataPointer() ); this.data.getTextureDataPointer() );
} }
#endif #endif
// now the data is loaded // now the data is loaded
m_loaded = true; this.loaded = true;
echrono::Steady toc = echrono::Steady::now(); echrono::Steady toc = echrono::Steady::now();
//Log.error(" updateContext [STOP] ==> " << (toc - toc1)); //Log.error(" updateContext [STOP] ==> " + (toc - toc1));
return true; return true;
} }
void ewol::resource::Texture::removeContext() { void ewol::resource::Texture::removeContext() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if (m_loaded == true) { if (this.loaded == true) {
// Request remove texture ... // Request remove texture ...
Log.debug("TEXTURE: Rm [" << getId() << "] texId=" << m_texId); Log.debug("TEXTURE: Rm [" + getId() + "] texId=" + this.texId);
// TODO: Check if we are in the correct thread // TODO: Check if we are in the correct thread
glDeleteTextures(1, &m_texId); glDeleteTextures(1, this.texId);
m_loaded = false; this.loaded = false;
} }
} }
void ewol::resource::Texture::removeContextToLate() { void ewol::resource::Texture::removeContextToLate() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
m_loaded = false; this.loaded = false;
m_texId=0; this.texId=0;
} }
void ewol::resource::Texture::flush() { void ewol::resource::Texture::flush() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
// request to the manager to be call at the next update ... // request to the manager to be call at the next update ...
Log.verbose("Request UPDATE of Element"); Log.verbose("Request UPDATE of Element");
getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis())); getManager().update(ememory::dynamicPointerCast<gale::Resource>(sharedFromThis()));
} }
void ewol::resource::Texture::setImageSize(Vector2i _newSize) { void ewol::resource::Texture::setImageSize(Vector2i _newSize) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) ); _newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
m_data.resize(_newSize); this.data.resize(_newSize);
} }
void ewol::resource::Texture::set(egami::Image _image) { void ewol::resource::Texture::set(egami::Image _image) {
Log.debug("Set a new image in a texture:"); Log.debug("Set a new image in a texture:");
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if (_image.exist() == false) { if (_image.exist() == false) {
Log.error("ERROR when loading the image : [raw data]"); Log.error("ERROR when loading the image : [raw data]");
return; return;
} }
Log.debug(" size=" << _image.getSize()); Log.debug(" size=" + _image.getSize());
etk::swap(m_data, _image); etk::swap(this.data, _image);
Vector2i tmp = m_data.getSize(); Vector2i tmp = this.data.getSize();
m_realImageSize = Vector2f(tmp.x(), tmp.y()); this.realImageSize = Vector2f(tmp.x(), tmp.y());
Vector2f compatibilityHWSize = Vector2f(nextP2(tmp.x()), nextP2(tmp.y())); Vector2f compatibilityHWSize = Vector2f(nextP2(tmp.x()), nextP2(tmp.y()));
if (m_realImageSize != compatibilityHWSize) { if (this.realImageSize != compatibilityHWSize) {
Log.verbose("RESIZE Image for HArwareCompatibility:" << m_realImageSize << " => " << compatibilityHWSize); Log.verbose("RESIZE Image for HArwareCompatibility:" + this.realImageSize + " => " + compatibilityHWSize);
m_data.resize(Vector2i(compatibilityHWSize.x(),compatibilityHWSize.y())); this.data.resize(Vector2i(compatibilityHWSize.x(),compatibilityHWSize.y()));
} }
flush(); flush();
} }

View File

@ -20,30 +20,30 @@ namespace ewol {
}; };
class Texture : public gale::Resource { class Texture : public gale::Resource {
protected: protected:
uint32_t m_texId; //!< openGl textureID. uint this.texId; //!< openGl textureID.
#ifdef EWOL_USE_FBO #ifdef EWOL_USE_FBO
uint32_t m_texPboId; //!< openGl textureID. uint this.texPboId; //!< openGl textureID.
#endif #endif
// openGl Context propoerties : // openGl Context propoerties :
egami::Image m_data; egami::Image this.data;
//! Last loaded size in the system openGL //! Last loaded size in the system openGL
Vector2f m_lastSize; Vector2f this.lastSize;
//! some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0 //! some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 . 1.0
Vector2f m_realImageSize; Vector2f this.realImageSize;
// internal state of the openGl system : // internal state of the openGl system :
bool m_loaded; boolean this.loaded;
int32_t m_lastTypeObject; int this.lastTypeObject;
int32_t m_lastSizeObject; int this.lastSizeObject;
protected: protected:
bool m_repeat; //!< repeate mode of the image (repeat the image if out of range [0..1] boolean this.repeat; //!< repeate mode of the image (repeat the image if out of range [0..1]
public: public:
/** /**
* @brief Set the repeate mode of the images if UV range is out of [0..1] * @brief Set the repeate mode of the images if UV range is out of [0..1]
* @param[in] _value Value of the new repeate mode * @param[in] _value Value of the new repeate mode
*/ */
void setRepeat(bool _value); void setRepeat(boolean _value);
protected: protected:
enum ewol::resource::TextureFilter m_filter; //!< Filter apply at the image when rendering it enum ewol::resource::TextureFilter this.filter; //!< Filter apply at the image when rendering it
public: public:
/** /**
* @brief Set the Filter mode to apply at the image when display with a scale (not 1:1 ratio) * @brief Set the Filter mode to apply at the image when display with a scale (not 1:1 ratio)
@ -52,18 +52,18 @@ namespace ewol {
void setFilterMode(enum ewol::resource::TextureFilter _filter); void setFilterMode(enum ewol::resource::TextureFilter _filter);
// Public API: // Public API:
protected: protected:
void init(const etk::String& _filename); void init( String _filename);
void init(); void init();
Texture(); Texture();
public: public:
DECLARE_RESOURCE_FACTORY(Texture); DECLARE_RESOURCE_FACTORY(Texture);
virtual ~Texture(); ~Texture();
public: public:
// You must set the size here, because it will be set in multiple of pow(2) // You must set the size here, because it will be set in multiple of pow(2)
void setImageSize(Vector2i _newSize); void setImageSize(Vector2i _newSize);
// Get the reference on this image to draw nomething on it ... // Get the reference on this image to draw nomething on it ...
inline egami::Image& get() { egami::Image get() {
return m_data; return this.data;
}; };
/** /**
* @brief Set the image in the texture system * @brief Set the image in the texture system
@ -73,17 +73,17 @@ namespace ewol {
void set(egami::Image _image); void set(egami::Image _image);
// Flush the data to send it at the openGl system // Flush the data to send it at the openGl system
void flush(); void flush();
bool updateContext(); boolean updateContext();
void removeContext(); void removeContext();
void removeContextToLate(); void removeContextToLate();
const Vector2i& getOpenGlSize() const { Vector2i getOpenGlSize() {
return m_data.getSize(); return this.data.getSize();
}; };
const Vector2f& getUsableSize() const { Vector2f getUsableSize() {
return m_realImageSize; return this.realImageSize;
}; };
uint32_t getRendererId() const { uint getRendererId() {
return m_texId; return this.texId;
}; };
}; };
} }

View File

@ -14,23 +14,23 @@
#include <etk/typeInfo.hpp> #include <etk/typeInfo.hpp>
ETK_DECLARE_TYPE(ewol::resource::TextureFile); ETK_DECLARE_TYPE(ewol::resource::TextureFile);
const Vector2i ewol::resource::TextureFile::sizeAuto(-1,-1); Vector2i ewol::resource::TextureFile::sizeAuto(-1,-1);
const Vector2i ewol::resource::TextureFile::sizeDefault(0,0); Vector2i ewol::resource::TextureFile::sizeDefault(0,0);
/** /**
* @brief get the next power 2 if the input * @brief get the next power 2 if the input
* @param[in] _value Value that we want the next power of 2 * @param[in] _value Value that we want the next power of 2
* @return result value * @return result value
*/ */
static int32_t nextP2(int32_t _value) { static int nextP2(int _value) {
int32_t val=1; int val=1;
for (int32_t iii=1; iii<31; iii++) { for (int iii=1; iii<31; iii++) {
if (_value <= val) { if (_value <= val) {
return val; return val;
} }
val *=2; val *=2;
} }
Log.critical("impossible CASE.... request P2 of " << _value); Log.critical("impossible CASE.... request P2 of " + _value);
return val; return val;
} }
@ -41,32 +41,32 @@ ewol::resource::TextureFile::TextureFile() {
} }
void ewol::resource::TextureFile::init() { void ewol::resource::TextureFile::init() {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
ewol::resource::Texture::init(); ewol::resource::Texture::init();
} }
void ewol::resource::TextureFile::init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size) { void ewol::resource::TextureFile::init(String _genName, etk::Uri _uri, Vector2i _size) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
ewol::resource::Texture::init(_genName); ewol::resource::Texture::init(_genName);
Log.debug("create a new resource::Image : _genName=" << _genName << " _uri=" << _uri << " size=" << _size); Log.debug("create a new resource::Image : _genName=" + _genName + " _uri=" + _uri + " size=" + _size);
egami::Image tmp = egami::load(_uri, _size); egami::Image tmp = egami::load(_uri, _size);
set(etk::move(tmp)); set(etk::move(tmp));
//m_lastSize = m_realImageSize; //this.lastSize = this.realImageSize;
#ifdef GENERATE_DISTANCE_FIELD_MODE #ifdef GENERATE_DISTANCE_FIELD_MODE
//egami::generateDistanceFieldFile(_uri, etk::String(_uri, 0, _uri.size()-4) + ".bmp"); //egami::generateDistanceFieldFile(_uri, String(_uri, 0, _uri.size()-4) + ".bmp");
egami::generateDistanceFieldFile(_uri, etk::String(_uri, 0, _uri.size()-4) + ".edf"); egami::generateDistanceFieldFile(_uri, String(_uri, 0, _uri.size()-4) + ".edf");
#endif #endif
} }
ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::create(const etk::Uri& _uri, Vector2i _size, Vector2i _sizeRegister) { ememory::Ptr<ewol::resource::TextureFile> ewol::resource::TextureFile::create( etk::Uri _uri, Vector2i _size, Vector2i _sizeRegister) {
Log.verbose("KEEP: TextureFile: '" << _uri << "' size=" << _size << " sizeRegister=" << _sizeRegister); Log.verbose("KEEP: TextureFile: '" + _uri + "' size=" + _size + " sizeRegister=" + _sizeRegister);
if (_uri.isEmpty() == true) { if (_uri.isEmpty() == true) {
ememory::SharedPtr<ewol::resource::TextureFile> object(ETK_NEW(ewol::resource::TextureFile)); ememory::Ptr<ewol::resource::TextureFile> object(ETK_NEW(ewol::resource::TextureFile));
if (object == null) { if (object == null) {
Log.error("allocation error of a resource : ??TEX??"); Log.error("allocation error of a resource : ??TEX??");
return null; return null;
} }
object->init(); object.init();
getManager().localAdd(object); getManager().localAdd(object);
return object; return object;
} }
@ -82,8 +82,8 @@ ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::cre
if (etk::toLower(_uri.getPath().getExtention()) != "svg") { if (etk::toLower(_uri.getPath().getExtention()) != "svg") {
_size = ewol::resource::TextureFile::sizeAuto; _size = ewol::resource::TextureFile::sizeAuto;
} }
if (_size.x()>0 && _size.y()>0) { if (_size.x()>0 LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _size.y()>0) {
Log.verbose(" == > specific size : " << _size); Log.verbose(" == > specific size : " + _size);
_size.setValue(nextP2(_size.x()), nextP2(_size.y())); _size.setValue(nextP2(_size.x()), nextP2(_size.y()));
if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) { if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) {
if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) { if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) {
@ -93,27 +93,27 @@ ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::cre
} }
} }
Log.verbose("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); Log.verbose("KEEP: TextureFile: '" + tmpFilename + "' new size=" + _size);
ememory::SharedPtr<ewol::resource::TextureFile> object = null; ememory::Ptr<ewol::resource::TextureFile> object = null;
ememory::SharedPtr<gale::Resource> object2 = getManager().localKeep(tmpFilename.getString()); ememory::Ptr<gale::Resource> object2 = getManager().localKeep(tmpFilename.getString());
if (object2 != null) { if (object2 != null) {
object = ememory::dynamicPointerCast<ewol::resource::TextureFile>(object2); object = ememory::dynamicPointerCast<ewol::resource::TextureFile>(object2);
if (object == null) { if (object == null) {
Log.critical("Request resource file : '" << tmpFilename << "' With the wrong type (dynamic cast error)"); Log.critical("Request resource file : '" + tmpFilename + "' With the wrong type (dynamic cast error)");
return null; return null;
} }
} }
if (object != null) { if (object != null) {
return object; return object;
} }
Log.debug("CREATE: TextureFile: '" << tmpFilename << "' size=" << _size); Log.debug("CREATE: TextureFile: '" + tmpFilename + "' size=" + _size);
// need to crate a new one ... // need to crate a new one ...
object = ememory::SharedPtr<ewol::resource::TextureFile>(ETK_NEW(ewol::resource::TextureFile)); object = ememory::Ptr<ewol::resource::TextureFile>(ETK_NEW(ewol::resource::TextureFile));
if (object == null) { if (object == null) {
Log.error("allocation error of a resource : " << _uri); Log.error("allocation error of a resource : " + _uri);
return null; return null;
} }
object->init(tmpFilename.getString(), _uri, _size); object.init(tmpFilename.getString(), _uri, _size);
getManager().localAdd(object); getManager().localAdd(object);
return object; return object;
} }

View File

@ -17,17 +17,17 @@ namespace ewol {
namespace resource { namespace resource {
class TextureFile : public ewol::resource::Texture { class TextureFile : public ewol::resource::Texture {
public: public:
static const Vector2i sizeAuto; static Vector2i sizeAuto;
static const Vector2i sizeDefault; static Vector2i sizeDefault;
protected: protected:
TextureFile(); TextureFile();
void init(); void init();
void init(etk::String _genName, const etk::Uri& _uri, const Vector2i& _size); void init(String _genName, etk::Uri _uri, Vector2i _size);
public: public:
virtual ~TextureFile() { }; ~TextureFile() { };
public: public:
const Vector2f& getRealSize() { Vector2f getRealSize() {
return m_realImageSize; return this.realImageSize;
}; };
public: public:
/** /**
@ -38,7 +38,7 @@ namespace ewol {
* @param[in] _sizeRegister size register in named (When you preaload the images the size write here will be ) * @param[in] _sizeRegister size register in named (When you preaload the images the size write here will be )
* @return pointer on the resource or null if an error occured. * @return pointer on the resource or null if an error occured.
*/ */
static ememory::SharedPtr<ewol::resource::TextureFile> create(const etk::Uri& _filename, static ememory::Ptr<ewol::resource::TextureFile> create( etk::Uri _filename,
Vector2i _size=ewol::resource::TextureFile::sizeAuto, Vector2i _size=ewol::resource::TextureFile::sizeAuto,
Vector2i _sizeRegister=ewol::resource::TextureFile::sizeAuto); Vector2i _sizeRegister=ewol::resource::TextureFile::sizeAuto);
}; };

View File

@ -17,29 +17,29 @@
ETK_DECLARE_TYPE(ewol::font::mode); ETK_DECLARE_TYPE(ewol::font::mode);
ETK_DECLARE_TYPE(ewol::resource::TexturedFont); ETK_DECLARE_TYPE(ewol::resource::TexturedFont);
etk::Stream& ewol::operator <<(etk::Stream& _os, enum ewol::font::mode _obj) { etk::Stream ewol::operator +(etk::Stream _os, enum ewol::font::mode _obj) {
switch(_obj) { switch(_obj) {
default : default :
_os << "error"; _os + "error";
break; break;
case ewol::font::Regular: case ewol::font::Regular:
_os << "Regular"; _os + "Regular";
break; break;
case ewol::font::Italic: case ewol::font::Italic:
_os << "Italic"; _os + "Italic";
break; break;
case ewol::font::Bold: case ewol::font::Bold:
_os << "Bold"; _os + "Bold";
break; break;
case ewol::font::BoldItalic: case ewol::font::BoldItalic:
_os << "BoldItalic"; _os + "BoldItalic";
break; break;
} }
return _os; return _os;
} }
ewol::resource::TexturedFont::TexturedFont(): ewol::resource::TexturedFont::TexturedFont():
m_size(10) { this.size(10) {
addResourceType("ewol::resource::TexturedFont"); addResourceType("ewol::resource::TexturedFont");
} }
@ -52,7 +52,7 @@ ewol::resource::TexturedFont::TexturedFont():
* // out contain: {"DATA:///font", "DATA:///font?lib=ewol"} * // out contain: {"DATA:///font", "DATA:///font?lib=ewol"}
* @example[stop] * @example[stop]
*/ */
static List<etk::Uri> explodeMultiplePath(const etk::Uri& _uri) { static List<etk::Uri> explodeMultiplePath( etk::Uri _uri) {
List<etk::Uri> out; List<etk::Uri> out;
out.pushBack(_uri); out.pushBack(_uri);
if (_uri.getQuery().exist("lib") == true) { if (_uri.getQuery().exist("lib") == true) {
@ -63,53 +63,53 @@ static List<etk::Uri> explodeMultiplePath(const etk::Uri& _uri) {
return out; return out;
} }
void ewol::resource::TexturedFont::init(const etk::String& _fontName) { void ewol::resource::TexturedFont::init( String _fontName) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
ewol::resource::Texture::init(_fontName); ewol::resource::Texture::init(_fontName);
Log.debug("Load font : '" << _fontName << "'" ); Log.debug("Load font : '" + _fontName + "'" );
m_font[0] = null; this.font[0] = null;
m_font[1] = null; this.font[1] = null;
m_font[2] = null; this.font[2] = null;
m_font[3] = null; this.font[3] = null;
m_modeWraping[0] = ewol::font::Regular; this.modeWraping[0] = ewol::font::Regular;
m_modeWraping[1] = ewol::font::Regular; this.modeWraping[1] = ewol::font::Regular;
m_modeWraping[2] = ewol::font::Regular; this.modeWraping[2] = ewol::font::Regular;
m_modeWraping[3] = ewol::font::Regular; this.modeWraping[3] = ewol::font::Regular;
m_lastGlyphPos[0].setValue(1,1); this.lastGlyphPos[0].setValue(1,1);
m_lastGlyphPos[1].setValue(1,1); this.lastGlyphPos[1].setValue(1,1);
m_lastGlyphPos[2].setValue(1,1); this.lastGlyphPos[2].setValue(1,1);
m_lastGlyphPos[3].setValue(1,1); this.lastGlyphPos[3].setValue(1,1);
m_lastRawHeigh[0] = 0; this.lastRawHeigh[0] = 0;
m_lastRawHeigh[1] = 0; this.lastRawHeigh[1] = 0;
m_lastRawHeigh[2] = 0; this.lastRawHeigh[2] = 0;
m_lastRawHeigh[3] = 0; this.lastRawHeigh[3] = 0;
int32_t tmpSize = 0; int tmpSize = 0;
// extarct name and size : // extarct name and size :
const char * tmpData = _fontName.c_str(); char * tmpData = _fontName.c_str();
const char * tmpPos = strchr(tmpData, ':'); char * tmpPos = strchr(tmpData, ':');
if (tmpPos == null) { if (tmpPos == null) {
m_size = 1; this.size = 1;
Log.critical("Can not parse the font name: '" << _fontName << "' ??? ':' " ); Log.critical("Can not parse the font name: '" + _fontName + "' ??? ':' " );
return; return;
} else { } else {
if (sscanf(tmpPos+1, "%d", &tmpSize)!=1) { if (sscanf(tmpPos+1, "%d", tmpSize)!=1) {
m_size = 1; this.size = 1;
Log.critical("Can not parse the font name: '" << _fontName << "' == > size ???"); Log.critical("Can not parse the font name: '" + _fontName + "' == > size ???");
return; return;
} }
} }
etk::String localName(_fontName, 0, (tmpPos - tmpData)); String localName(_fontName, 0, (tmpPos - tmpData));
if (tmpSize>400) { if (tmpSize>400) {
Log.error("Font size too big ==> limit at 400 when exxeed ==> error: " << tmpSize << "==>30"); Log.error("Font size too big ==> limit at 400 when exxeed ==> error: " + tmpSize + "==>30");
tmpSize = 30; tmpSize = 30;
} }
m_size = tmpSize; this.size = tmpSize;
List<etk::Uri> folderList; List<etk::Uri> folderList;
if (ewol::getContext().getFontDefault().getUseExternal() == true) { if (ewol::getContext().getFontDefault().getUseExternal() == true) {
@ -120,29 +120,29 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
#endif #endif
} }
etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder();
for (auto &it : explodeMultiplePath(applicationBaseFont)) { for (auto it : explodeMultiplePath(applicationBaseFont)) {
folderList.pushBack(it); folderList.pushBack(it);
} }
for (size_t folderID = 0; folderID < folderList.size() ; folderID++) { for (int folderID = 0; folderID < folderList.size() ; folderID++) {
List<etk::Uri> output = etk::uri::listRecursive(folderList[folderID]); List<etk::Uri> output = etk::uri::listRecursive(folderList[folderID]);
List<etk::String> split = etk::split(localName, ';'); List<String> split = etk::split(localName, ';');
Log.debug("try to find font named : " << split << " in: " << output); Log.debug("try to find font named : " + split + " in: " + output);
//Log.critical("parse string : " << split); //Log.critical("parse string : " + split);
bool hasFindAFont = false; boolean hasFindAFont = false;
for (size_t jjj=0; jjj<split.size(); jjj++) { for (int jjj=0; jjj<split.size(); jjj++) {
Log.debug(" try with : '" << split[jjj] << "'"); Log.debug(" try with : '" + split[jjj] + "'");
for (size_t iii=0; iii<output.size(); iii++) { for (int iii=0; iii<output.size(); iii++) {
etk::String nameFolder = output[iii].getPath().getString(); String nameFolder = output[iii].getPath().getString();
//Log.debug(" file : " << output[iii]); //Log.debug(" file : " + output[iii]);
if( etk::end_with(nameFolder, split[jjj]+"-"+"bold"+".ttf", false) == true if( etk::end_with(nameFolder, split[jjj]+"-"+"bold"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"-"+"b"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"-"+"b"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"-"+"bd"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"-"+"bd"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"bold"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"bold"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"bd"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"bd"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"b"+".ttf", false) == true) { || etk::end_with(nameFolder, split[jjj]+"b"+".ttf", false) == true) {
Log.debug(" find Font [Bold] : " << output[iii]); Log.debug(" find Font [Bold] : " + output[iii]);
m_fileName[ewol::font::Bold] = output[iii]; this.fileName[ewol::font::Bold] = output[iii];
hasFindAFont = true; hasFindAFont = true;
} else if( etk::end_with(nameFolder, split[jjj]+"-"+"oblique"+".ttf", false) == true } else if( etk::end_with(nameFolder, split[jjj]+"-"+"oblique"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"-"+"italic"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"-"+"italic"+".ttf", false) == true
@ -152,8 +152,8 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|| etk::end_with(nameFolder, split[jjj]+"italic"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"italic"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"light"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"light"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"i"+".ttf", false) == true) { || etk::end_with(nameFolder, split[jjj]+"i"+".ttf", false) == true) {
Log.debug(" find Font [Italic] : " << output[iii]); Log.debug(" find Font [Italic] : " + output[iii]);
m_fileName[ewol::font::Italic] = output[iii]; this.fileName[ewol::font::Italic] = output[iii];
hasFindAFont = true; hasFindAFont = true;
} else if( etk::end_with(nameFolder, split[jjj]+"-"+"bolditalic"+".ttf", false) == true } else if( etk::end_with(nameFolder, split[jjj]+"-"+"bolditalic"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"-"+"boldoblique"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"-"+"boldoblique"+".ttf", false) == true
@ -163,176 +163,176 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|| etk::end_with(nameFolder, split[jjj]+"boldoblique"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"boldoblique"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"bi"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"bi"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"z"+".ttf", false) == true) { || etk::end_with(nameFolder, split[jjj]+"z"+".ttf", false) == true) {
Log.debug(" find Font [Bold-Italic] : " << output[iii]); Log.debug(" find Font [Bold-Italic] : " + output[iii]);
m_fileName[ewol::font::BoldItalic] = output[iii]; this.fileName[ewol::font::BoldItalic] = output[iii];
hasFindAFont = true; hasFindAFont = true;
} else if( etk::end_with(nameFolder, split[jjj]+"-"+"regular"+".ttf", false) == true } else if( etk::end_with(nameFolder, split[jjj]+"-"+"regular"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"-"+"r"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"-"+"r"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"regular"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"regular"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+"r"+".ttf", false) == true || etk::end_with(nameFolder, split[jjj]+"r"+".ttf", false) == true
|| etk::end_with(nameFolder, split[jjj]+".ttf", false) == true) { || etk::end_with(nameFolder, split[jjj]+".ttf", false) == true) {
Log.debug(" find Font [Regular] : " << output[iii]); Log.debug(" find Font [Regular] : " + output[iii]);
m_fileName[ewol::font::Regular] = output[iii]; this.fileName[ewol::font::Regular] = output[iii];
hasFindAFont = true; hasFindAFont = true;
} }
} }
if (hasFindAFont == true) { if (hasFindAFont == true) {
Log.debug(" find this font : '" << split[jjj] << "'"); Log.debug(" find this font : '" + split[jjj] + "'");
break; break;
} else if (jjj == split.size()-1) { } else if (jjj == split.size()-1) {
Log.debug("Find NO font in the LIST ... " << split); Log.debug("Find NO font in the LIST ... " + split);
} }
} }
if (hasFindAFont == true) { if (hasFindAFont == true) {
Log.debug(" find this font : '" << folderList[folderID] << "'"); Log.debug(" find this font : '" + folderList[folderID] + "'");
break; break;
} else if (folderID == folderList.size()-1) { } else if (folderID == folderList.size()-1) {
Log.error("Find NO font in the LIST ... " << folderList); Log.error("Find NO font in the LIST ... " + folderList);
} }
} }
// try to find the reference mode : // try to find the reference mode :
enum ewol::font::mode refMode = ewol::font::Regular; enum ewol::font::mode refMode = ewol::font::Regular;
for(int32_t iii=3; iii >= 0; iii--) { for(int iii=3; iii >= 0; iii--) {
if (m_fileName[iii].isEmpty() == false) { if (this.fileName[iii].isEmpty() == false) {
refMode = (enum ewol::font::mode)iii; refMode = (enum ewol::font::mode)iii;
} }
} }
Log.debug(" set reference mode : " << refMode); Log.debug(" set reference mode : " + refMode);
// generate the wrapping on the preventing error // generate the wrapping on the preventing error
for(int32_t iii=3; iii >= 0; iii--) { for(int iii=3; iii >= 0; iii--) {
if (m_fileName[iii].isEmpty() == false) { if (this.fileName[iii].isEmpty() == false) {
m_modeWraping[iii] = (enum ewol::font::mode)iii; this.modeWraping[iii] = (enum ewol::font::mode)iii;
} else { } else {
m_modeWraping[iii] = refMode; this.modeWraping[iii] = refMode;
} }
} }
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) { for (int iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
if (m_fileName[iiiFontId].isEmpty() == true) { if (this.fileName[iiiFontId].isEmpty() == true) {
Log.debug("can not load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size ); Log.debug("can not load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size );
m_font[iiiFontId] = null; this.font[iiiFontId] = null;
continue; continue;
} }
Log.debug("Load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size); Log.debug("Load FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size);
m_font[iiiFontId] = ewol::resource::FontFreeType::create(m_fileName[iiiFontId]); this.font[iiiFontId] = ewol::resource::FontFreeType::create(this.fileName[iiiFontId]);
if (m_font[iiiFontId] == null) { if (this.font[iiiFontId] == null) {
Log.debug("error in loading FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size ); Log.debug("error in loading FONT [" + iiiFontId + "] name : \"" + this.fileName[iiiFontId] + "\" == > size=" + this.size );
} }
} }
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) { for (int iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
// set the bassic charset: // set the bassic charset:
m_listElement[iiiFontId].clear(); this.listElement[iiiFontId].clear();
if (m_font[iiiFontId] == null) { if (this.font[iiiFontId] == null) {
continue; continue;
} }
m_height[iiiFontId] = m_font[iiiFontId]->getHeight(m_size); this.height[iiiFontId] = this.font[iiiFontId].getHeight(this.size);
// TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ??? // TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ???
setImageSize(Vector2i(256,32)); setImageSize(Vector2i(256,32));
// now we can acces directly on the image // now we can acces directly on the image
m_data.clear(etk::Color<>(0x00000000)); this.data.clear(etk::Color<>(0x00000000));
} }
// add error glyph // add error glyph
addGlyph(0); addGlyph(0);
// by default we set only the first AINSI char availlable // by default we set only the first AINSI char availlable
for (int32_t iii=0x20; iii<0x7F; iii++) { for (int iii=0x20; iii<0x7F; iii++) {
Log.verbose("Add clyph :" << iii); Log.verbose("Add clyph :" + iii);
addGlyph(iii); addGlyph(iii);
} }
flush(); flush();
Log.debug("Wrapping properties : "); Log.debug("Wrapping properties : ");
Log.debug(" " << ewol::font::Regular << " == >" << getWrappingMode(ewol::font::Regular)); Log.debug(" " + ewol::font::Regular + " == >" + getWrappingMode(ewol::font::Regular));
Log.debug(" " << ewol::font::Italic << " == >" << getWrappingMode(ewol::font::Italic)); Log.debug(" " + ewol::font::Italic + " == >" + getWrappingMode(ewol::font::Italic));
Log.debug(" " << ewol::font::Bold << " == >" << getWrappingMode(ewol::font::Bold)); Log.debug(" " + ewol::font::Bold + " == >" + getWrappingMode(ewol::font::Bold));
Log.debug(" " << ewol::font::BoldItalic << " == >" << getWrappingMode(ewol::font::BoldItalic)); Log.debug(" " + ewol::font::BoldItalic + " == >" + getWrappingMode(ewol::font::BoldItalic));
} }
ewol::resource::TexturedFont::~TexturedFont() { ewol::resource::TexturedFont::~TexturedFont() {
} }
bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) { boolean ewol::resource::TexturedFont::addGlyph( Character _val) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
bool hasChange = false; boolean hasChange = false;
// for each font : // for each font :
for (int32_t iii=0; iii<4 ; iii++) { for (int iii=0; iii<4 ; iii++) {
if (m_font[iii] == null) { if (this.font[iii] == null) {
continue; continue;
} }
// add the curent "char" // add the curent "char"
GlyphProperty tmpchar; GlyphProperty tmpchar;
tmpchar.m_UVal = _val; tmpchar.this.UVal = _val;
if (m_font[iii]->getGlyphProperty(m_size, tmpchar) == true) { if (this.font[iii].getGlyphProperty(this.size, tmpchar) == true) {
//Log.debug("load char : '" << _val << "'=" << _val.get()); //Log.debug("load char : '" + _val + "'=" + _val.get());
hasChange = true; hasChange = true;
// change line if needed ... // change line if needed ...
if (m_lastGlyphPos[iii].x()+tmpchar.m_sizeTexture.x()+3 > m_data.getSize().x()) { if (this.lastGlyphPos[iii].x()+tmpchar.this.sizeTexture.x()+3 > this.data.getSize().x()) {
m_lastGlyphPos[iii].setX(1); this.lastGlyphPos[iii].setX(1);
m_lastGlyphPos[iii] += Vector2i(0, m_lastRawHeigh[iii]); this.lastGlyphPos[iii] += Vector2i(0, this.lastRawHeigh[iii]);
m_lastRawHeigh[iii] = 0; this.lastRawHeigh[iii] = 0;
} }
while(m_lastGlyphPos[iii].y()+tmpchar.m_sizeTexture.y()+3 > m_data.getSize().y()) { while(this.lastGlyphPos[iii].y()+tmpchar.this.sizeTexture.y()+3 > this.data.getSize().y()) {
Vector2i size = m_data.getSize(); Vector2i size = this.data.getSize();
size.setY(size.y()*2); size.setY(size.y()*2);
m_data.resize(size, etk::Color<>(0)); this.data.resize(size, etk::Color<>(0));
// note : need to rework all the lyer due to the fact that the texture is used by the faur type... // note : need to rework all the lyer due to the fact that the texture is used by the faur type...
for (size_t kkk=0; kkk<4 ; kkk++) { for (int kkk=0; kkk<4 ; kkk++) {
// change the coordonate on the element in the texture // change the coordonate on the element in the texture
for (size_t jjj=0 ; jjj<m_listElement[kkk].size() ; ++jjj) { for (int jjj=0 ; jjj<this.listElement[kkk].size() ; ++jjj) {
m_listElement[kkk][jjj].m_texturePosStart *= Vector2f(1.0f, 0.5f); this.listElement[kkk][jjj].this.texturePosStart *= Vector2f(1.0f, 0.5f);
m_listElement[kkk][jjj].m_texturePosSize *= Vector2f(1.0f, 0.5f); this.listElement[kkk][jjj].this.texturePosSize *= Vector2f(1.0f, 0.5f);
} }
} }
} }
// draw the glyph // draw the glyph
m_font[iii]->drawGlyph(m_data, m_size, m_lastGlyphPos[iii], tmpchar, iii); this.font[iii].drawGlyph(this.data, this.size, this.lastGlyphPos[iii], tmpchar, iii);
// set video position // set video position
tmpchar.m_texturePosStart.setValue( (float)m_lastGlyphPos[iii].x() / (float)m_data.getSize().x(), tmpchar.this.texturePosStart.setValue( (float)this.lastGlyphPos[iii].x() / (float)this.data.getSize().x(),
(float)m_lastGlyphPos[iii].y() / (float)m_data.getSize().y() ); (float)this.lastGlyphPos[iii].y() / (float)this.data.getSize().y() );
tmpchar.m_texturePosSize.setValue( (float)tmpchar.m_sizeTexture.x() / (float)m_data.getSize().x(), tmpchar.this.texturePosSize.setValue( (float)tmpchar.this.sizeTexture.x() / (float)this.data.getSize().x(),
(float)tmpchar.m_sizeTexture.y() / (float)m_data.getSize().y() ); (float)tmpchar.this.sizeTexture.y() / (float)this.data.getSize().y() );
// update the maximum of the line hight : // update the maximum of the line hight :
if (m_lastRawHeigh[iii]<tmpchar.m_sizeTexture.y()) { if (this.lastRawHeigh[iii]<tmpchar.this.sizeTexture.y()) {
// note : +1 is for the overlapping of the glyph (Part 2) // note : +1 is for the overlapping of the glyph (Part 2)
m_lastRawHeigh[iii] = tmpchar.m_sizeTexture.y()+1; this.lastRawHeigh[iii] = tmpchar.this.sizeTexture.y()+1;
} }
// note : +1 is for the overlapping of the glyph (Part 3) // note : +1 is for the overlapping of the glyph (Part 3)
// update the Bitmap position drawing : // update the Bitmap position drawing :
m_lastGlyphPos[iii] += Vector2i(tmpchar.m_sizeTexture.x()+1, 0); this.lastGlyphPos[iii] += Vector2i(tmpchar.this.sizeTexture.x()+1, 0);
} else { } else {
EWOL_WARNING("Did not find char : '" << _val << "'=" << _val); Log.warning("Did not find char : '" + _val + "'=" + _val);
tmpchar.setNotExist(); tmpchar.setNotExist();
} }
m_listElement[iii].pushBack(tmpchar); this.listElement[iii].pushBack(tmpchar);
//m_font[iii]->display(); //this.font[iii].display();
// generate the kerning for all the characters : // generate the kerning for all the characters :
if (tmpchar.exist() == true) { if (tmpchar.exist() == true) {
// TODO : set the kerning back ... // TODO : set the kerning back ...
//m_font[iii]->generateKerning(m_size, m_listElement[iii]); //this.font[iii].generateKerning(this.size, this.listElement[iii]);
} }
} }
if (hasChange == true) { if (hasChange == true) {
flush(); flush();
ewol::getContext().forceRedrawAll(); ewol::getContext().forceRedrawAll();
//egami::store(m_data, "fileFont.bmp"); // ==> for debug test only ... //egami::store(this.data, "fileFont.bmp"); // ==> for debug test only ...
} }
return hasChange; return hasChange;
} }
int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode) { int ewol::resource::TexturedFont::getIndex(Character _charcode, enum ewol::font::mode _displayMode) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
if (_charcode < 0x20) { if (_charcode < 0x20) {
return 0; return 0;
} else if (_charcode < 0x80) { } else if (_charcode < 0x80) {
return _charcode - 0x1F; return _charcode - 0x1F;
} else { } else {
for (size_t iii=0x80-0x20; iii < m_listElement[_displayMode].size(); iii++) { for (int iii=0x80-0x20; iii < this.listElement[_displayMode].size(); iii++) {
//Log.debug("search : '" << charcode << "' =?= '" << (m_listElement[displayMode])[iii].m_UVal << "'"); //Log.debug("search : '" + charcode + "' =?= '" + (this.listElement[displayMode])[iii].this.UVal + "'");
if (_charcode == (m_listElement[_displayMode])[iii].m_UVal) { if (_charcode == (this.listElement[_displayMode])[iii].this.UVal) {
//Log.debug("search : '" << charcode << "'"); //Log.debug("search : '" + charcode + "'");
if ((m_listElement[_displayMode])[iii].exist()) { if ((this.listElement[_displayMode])[iii].exist()) {
//Log.debug("return " << iii); //Log.debug("return " + iii);
return iii; return iii;
} else { } else {
return 0; return 0;
@ -347,23 +347,23 @@ int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ew
return 0; return 0;
} }
ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) { ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer( Character _charcode, enum ewol::font::mode _displayMode) {
ethread::RecursiveLock lock(m_mutex); ethread::RecursiveLock lock(this.mutex);
//Log.debug("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]); //Log.debug("Get glyph property for mode: " + _displayMode + " == > wrapping index : " + this.modeWraping[_displayMode]);
int32_t index = getIndex(_charcode, _displayMode); int index = getIndex(_charcode, _displayMode);
if( index < 0 if( index < 0
|| (size_t)index >= m_listElement[_displayMode].size() ) { || (int)index >= this.listElement[_displayMode].size() ) {
Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" << index); Log.error(" Try to get glyph index inexistant ... == > return the index 0 ... id=" + index);
if (m_listElement[_displayMode].size() > 0) { if (this.listElement[_displayMode].size() > 0) {
return &((m_listElement[_displayMode])[0]); return ((this.listElement[_displayMode])[0]);
} }
return &m_emptyGlyph; return this.emptyGlyph;
} }
//Log.error(" index=" << index); //Log.error(" index=" + index);
//Log.error(" m_UVal=" << m_listElement[_displayMode][index].m_UVal); //Log.error(" this.UVal=" + this.listElement[_displayMode][index].this.UVal);
//Log.error(" m_glyphIndex=" << m_listElement[_displayMode][index].m_glyphIndex); //Log.error(" this.glyphIndex=" + this.listElement[_displayMode][index].this.glyphIndex);
//Log.error(" m_advance=" << m_listElement[_displayMode][index].m_advance); //Log.error(" this.advance=" + this.listElement[_displayMode][index].this.advance);
//Log.error(" m_bearing=" << m_listElement[_displayMode][index].m_bearing); //Log.error(" this.bearing=" + this.listElement[_displayMode][index].this.bearing);
return &((m_listElement[_displayMode])[index]); return ((this.listElement[_displayMode])[index]);
} }

View File

@ -20,47 +20,47 @@ namespace ewol {
BoldItalic, BoldItalic,
}; };
} }
etk::Stream& operator <<(etk::Stream& _os, enum ewol::font::mode _obj); etk::Stream operator +(etk::Stream _os, enum ewol::font::mode _obj);
namespace resource { namespace resource {
class TexturedFont : public ewol::resource::Texture { class TexturedFont : public ewol::resource::Texture {
private: private:
etk::Uri m_fileName[4]; etk::Uri this.fileName[4];
int32_t m_size; int this.size;
int32_t m_height[4]; int this.height[4];
// specific element to have the the know if the specify element is known... // specific element to have the the know if the specify element is known...
// == > otherwise I can just generate italic ... // == > otherwise I can just generate italic ...
// == > Bold is a little more complicated (maybe with the bordersize) // == > Bold is a little more complicated (maybe with the bordersize)
ememory::SharedPtr<ewol::resource::FontBase> m_font[4]; ememory::Ptr<ewol::resource::FontBase> this.font[4];
enum ewol::font::mode m_modeWraping[4]; //!< This is a wrapping mode to prevent the fact that no font is define for a specific mode enum ewol::font::mode this.modeWraping[4]; //!< This is a wrapping mode to prevent the fact that no font is define for a specific mode
public: public:
GlyphProperty m_emptyGlyph; GlyphProperty this.emptyGlyph;
List<GlyphProperty> m_listElement[4]; List<GlyphProperty> this.listElement[4];
private: private:
// for the texture generation : // for the texture generation :
Vector2i m_lastGlyphPos[4]; Vector2i this.lastGlyphPos[4];
int32_t m_lastRawHeigh[4]; int this.lastRawHeigh[4];
protected: protected:
TexturedFont(); TexturedFont();
void init(const etk::String& _fontName); void init( String _fontName);
public: public:
DECLARE_RESOURCE_NAMED_FACTORY(TexturedFont); DECLARE_RESOURCE_NAMED_FACTORY(TexturedFont);
virtual ~TexturedFont(); ~TexturedFont();
public: public:
/** /**
* @brief get the display height of this font * @brief get the display height of this font
* @param[in] _displayMode Mode to display the currrent font * @param[in] _displayMode Mode to display the currrent font
* @return Dimention of the font need between 2 lines * @return Dimention of the font need between 2 lines
*/ */
int32_t getHeight(const enum ewol::font::mode _displayMode = ewol::font::Regular) { int getHeight( enum ewol::font::mode _displayMode = ewol::font::Regular) {
return m_height[_displayMode]; return this.height[_displayMode];
}; };
/** /**
* @brief get the font height (user friendly) * @brief get the font height (user friendly)
* @return Dimention of the font the user requested * @return Dimention of the font the user requested
*/ */
int32_t getFontSize() { int getFontSize() {
return m_size; return this.size;
}; };
/** /**
* @brief get the ID of a unicode charcode * @brief get the ID of a unicode charcode
@ -68,22 +68,22 @@ namespace ewol {
* @param[in] _displayMode Mode to display the currrent font * @param[in] _displayMode Mode to display the currrent font
* @return The ID in the table (if it does not exist : return 0) * @return The ID in the table (if it does not exist : return 0)
*/ */
int32_t getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode); int getIndex(Character _charcode, enum ewol::font::mode _displayMode);
/** /**
* @brief get the pointer on the coresponding glyph * @brief get the pointer on the coresponding glyph
* @param[in] _charcode The unicodeValue * @param[in] _charcode The unicodeValue
* @param[in] _displayMode Mode to display the currrent font * @param[in] _displayMode Mode to display the currrent font
* @return The pointer on the glyph == > never null * @return The pointer on the glyph == > never null
*/ */
ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode); ewol::GlyphProperty* getGlyphPointer( Character _charcode, enum ewol::font::mode _displayMode);
/** /**
* @brief The wrapping mode is used to prevent the non existance of a specific mode. * @brief The wrapping mode is used to prevent the non existance of a specific mode.
* For exemple when a blod mode does not exist, this resend a regular mode. * For exemple when a blod mode does not exist, this resend a regular mode.
* @param[in] _source The requested mode. * @param[in] _source The requested mode.
* @return the best mode we have in stock. * @return the best mode we have in stock.
*/ */
enum ewol::font::mode getWrappingMode(const enum ewol::font::mode _source) { enum ewol::font::mode getWrappingMode( enum ewol::font::mode _source) {
return m_modeWraping[_source]; return this.modeWraping[_source];
}; };
private: private:
/** /**
@ -91,7 +91,7 @@ namespace ewol {
* @param[in] _val Char value to add. * @param[in] _val Char value to add.
* @return true if the image size have change, false otherwise * @return true if the image size have change, false otherwise
*/ */
bool addGlyph(const char32_t& _val); boolean addGlyph( Character _val);
}; };
} }
} }

View File

@ -21,34 +21,34 @@ namespace ewol {
FontBase() { FontBase() {
addResourceType("ewol::FontFreeType"); addResourceType("ewol::FontFreeType");
} }
void init(const etk::Uri& _uri) { void init( etk::Uri _uri) {
gale::Resource::init(_uri); gale::Resource::init(_uri);
}; };
virtual ~FontBase() { }; ~FontBase() { };
virtual bool getGlyphProperty(int32_t _fontSize, boolean getGlyphProperty(int _fontSize,
ewol::GlyphProperty& _property) = 0; ewol::GlyphProperty _property) = 0;
virtual bool drawGlyph(egami::Image& _imageOut, boolean drawGlyph(egami::Image _imageOut,
int32_t _fontSize, int _fontSize,
Vector2i _glyphPosition, Vector2i _glyphPosition,
ewol::GlyphProperty& _property, ewol::GlyphProperty _property,
int8_t _posInImage) = 0; int8_t _posInImage) = 0;
virtual bool drawGlyph(egami::ImageMono& _imageOut, boolean drawGlyph(egami::ImageMono _imageOut,
int32_t _fontSize, int _fontSize,
ewol::GlyphProperty& _property, ewol::GlyphProperty _property,
int32_t _borderSize = 0) = 0; int _borderSize = 0) = 0;
virtual Vector2f getSize(int32_t _fontSize, const etk::String& _unicodeString) = 0; Vector2f getSize(int _fontSize, String _unicodeString) = 0;
virtual float getSizeWithHeight(float _fontHeight) = 0; float getSizeWithHeight(float _fontHeight) = 0;
virtual int32_t getHeight(int32_t _fontSize) = 0; int getHeight(int _fontSize) = 0;
virtual void generateKerning(int32_t _fontSize, List<ewol::GlyphProperty>& _listGlyph) { }; void generateKerning(int _fontSize, List<ewol::GlyphProperty> _listGlyph) { };
virtual void display() {}; void display() {};
}; };
}; };
}; };

View File

@ -15,10 +15,10 @@ namespace ewol {
Y | | | | Y | | | |
^ |------------| |------------| ^ |------------| |------------|
| |
m_advance.y:/-> | this.advance.y:/. |
| | | |
| | | |
m_sizeTex.x/-> | | |------------| |------------| this.sizeTex.x/. | | |------------| |------------|
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
@ -28,18 +28,18 @@ namespace ewol {
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
\-> | | |------------| |------------| \. | | |------------| |------------|
/--> | | /-. | |
\--> \-> | \-. \. |
m_bearing.y | this.bearing.y |
|____*________________________*____________>> X |____*________________________*____________>> X
<------------------------> : m_advance.x <-----------------------. : this.advance.x
<------------> : m_sizeTexture.x <-----------. : this.sizeTexture.x
<---> : m_bearing.x <--. : this.bearing.x
*/ */
/** /**
@ -47,56 +47,56 @@ namespace ewol {
*/ */
class GlyphProperty { class GlyphProperty {
public: public:
char32_t m_UVal; //!< Unicode value Character this.UVal; //!< Unicode value
public: public:
bool m_exist; boolean this.exist;
public: public:
int32_t m_glyphIndex; //!< Glyph index in the system int this.glyphIndex; //!< Glyph index in the system
Vector2i m_sizeTexture; //!< size of the element to display Vector2i this.sizeTexture; //!< size of the element to display
Vector2i m_bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string) Vector2i this.bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string)
Vector2i m_advance; //!< space use in the display for this specific char Vector2i this.advance; //!< space use in the display for this specific char
Vector2f m_texturePosStart; //!< Texture normalized position (START) Vector2f this.texturePosStart; //!< Texture normalized position (START)
Vector2f m_texturePosSize; //!< Texture normalized position (SIZE) Vector2f this.texturePosSize; //!< Texture normalized position (SIZE)
private: private:
List<ewol::Kerning> m_kerning; //!< kerning values of link of all elements List<ewol::Kerning> this.kerning; //!< kerning values of link of all elements
public: public:
GlyphProperty() : GlyphProperty() :
m_UVal(0), this.UVal(0),
m_exist(true), this.exist(true),
m_glyphIndex(0), this.glyphIndex(0),
m_sizeTexture(10,10), this.sizeTexture(10,10),
m_bearing(2,2), this.bearing(2,2),
m_advance(10,10), this.advance(10,10),
m_texturePosStart(0,0), this.texturePosStart(0,0),
m_texturePosSize(0,0) { this.texturePosSize(0,0) {
}; };
float kerningGet(const char32_t _charcode) { float kerningGet( Character _charcode) {
for(size_t iii=0; iii<m_kerning.size(); iii++ ) { for(int iii=0; iii<this.kerning.size(); iii++ ) {
if (m_kerning[iii].m_UVal == _charcode) { if (this.kerning[iii].this.UVal == _charcode) {
return m_kerning[iii].m_value; return this.kerning[iii].this.value;
} }
} }
return 0; return 0;
}; };
void kerningAdd(const char32_t _charcode, float _value) { void kerningAdd( Character _charcode, float _value) {
m_kerning.pushBack(ewol::Kerning(_charcode, _value)); this.kerning.pushBack(ewol::Kerning(_charcode, _value));
}; };
void kerningClear() { void kerningClear() {
m_kerning.clear(); this.kerning.clear();
}; };
/** /**
* @brief get the status of the char, if it exist or not in the FONT * @brief get the status of the char, if it exist or not in the FONT
* @return true if the char is availlable, false otherwise * @return true if the char is availlable, false otherwise
*/ */
bool exist() const { boolean exist() {
return m_exist; return this.exist;
}; };
/** /**
* @brief set the element doen not exist !!! * @brief set the element doen not exist !!!
*/ */
void setNotExist() { void setNotExist() {
m_exist = false; this.exist = false;
}; };
}; };
}; };

View File

@ -39,25 +39,25 @@ namespace ewol {
*/ */
class Kerning { class Kerning {
public: public:
char32_t m_UVal; //!< unicode value (the previous character that must be before) Character this.UVal; //!< unicode value (the previous character that must be before)
float m_value; //!< kerning real offset float this.value; //!< kerning real offset
public: public:
/** /**
* @brief Simple constructor that allow to allocate the List element * @brief Simple ructor that allow to allocate the List element
*/ */
Kerning() : Kerning() :
m_UVal(0), this.UVal(0),
m_value(0) { this.value(0) {
}; };
/** /**
* @brief Normal constructor * @brief Normal ructor
* @param[in] _charcode The Unicode value of the coresponding character that might be before * @param[in] _charcode The Unicode value of the coresponding character that might be before
* @param[in] _value The Kerning value of the offset (nb pixel number) * @param[in] _value The Kerning value of the offset (nb pixel number)
*/ */
Kerning(const char32_t _charcode, const float _value) : Kerning( Character _charcode, float _value) :
m_UVal(_charcode), this.UVal(_charcode),
m_value(_value) { this.value(_value) {
}; };
/** /**

View File

@ -13,52 +13,52 @@
#include <ewol/widget/Manager.hpp> #include <ewol/widget/Manager.hpp>
#include <ewol/widget/meta/StdPopUp.hpp> #include <ewol/widget/meta/StdPopUp.hpp>
void ewol::tools::message::create(enum ewol::tools::message::type _type, const etk::String& _message) { void ewol::tools::message::create(enum ewol::tools::message::type _type, String _message) {
ewol::widget::StdPopUpShared tmpPopUp = widget::StdPopUp::create(); ewol::widget::StdPopUp tmpPopUp = widget::StdPopUp::create();
if (tmpPopUp == null) { if (tmpPopUp == null) {
Log.error("Can not create a simple pop-up"); Log.error("Can not create a simple pop-up");
return; return;
} }
switch(_type) { switch(_type) {
case ewol::tools::message::type::info: case ewol::tools::message::type::info:
tmpPopUp->propertyTitle.set("<bold>_T{Info}</bold>"); tmpPopUp.propertyTitle.set("<bold>_T{Info}</bold>");
break; break;
case ewol::tools::message::type::warning: case ewol::tools::message::type::warning:
tmpPopUp->propertyTitle.set("<bold><font color='orange'>_T{Warning}</font></bold>"); tmpPopUp.propertyTitle.set("<bold><font color='orange'>_T{Warning}</font></bold>");
break; break;
case ewol::tools::message::type::error: case ewol::tools::message::type::error:
tmpPopUp->propertyTitle.set("<bold><font color='red'>_T{Error}</font></bold>"); tmpPopUp.propertyTitle.set("<bold><font color='red'>_T{Error}</font></bold>");
break; break;
case ewol::tools::message::type::critical: case ewol::tools::message::type::critical:
tmpPopUp->propertyTitle.set("<bold><font colorBg='red'>_T{Critical}</font></bold>"); tmpPopUp.propertyTitle.set("<bold><font colorBg='red'>_T{Critical}</font></bold>");
break; break;
} }
tmpPopUp->propertyComment.set(_message); tmpPopUp.propertyComment.set(_message);
tmpPopUp->addButton("_T{close}", true); tmpPopUp.addButton("_T{close}", true);
tmpPopUp->propertyCloseOutEvent.set(true); tmpPopUp.propertyCloseOutEvent.set(true);
// get windows: // get windows:
ewol::Context& context = ewol::getContext(); EwolContext context = ewol::getContext();
ewol::widget::WindowsShared windows = context.getWindows(); ewol::widget::Windows windows = context.getWindows();
if (windows == null) { if (windows == null) {
Log.error("can not get the current windows ... ==> can not display message : " << _message); Log.error("can not get the current windows ... ==> can not display message : " + _message);
return; return;
} }
windows->popUpWidgetPush(tmpPopUp); windows.popUpWidgetPush(tmpPopUp);
} }
void ewol::tools::message::displayInfo(const etk::String& _message) { void ewol::tools::message::displayInfo( String _message) {
ewol::tools::message::create(ewol::tools::message::type::info, _message); ewol::tools::message::create(ewol::tools::message::type::info, _message);
} }
void ewol::tools::message::displayWarning(const etk::String& _message) { void ewol::tools::message::displayWarning( String _message) {
ewol::tools::message::create(ewol::tools::message::type::warning, _message); ewol::tools::message::create(ewol::tools::message::type::warning, _message);
} }
void ewol::tools::message::displayError(const etk::String& _message) { void ewol::tools::message::displayError( String _message) {
ewol::tools::message::create(ewol::tools::message::type::error, _message); ewol::tools::message::create(ewol::tools::message::type::error, _message);
} }
void ewol::tools::message::displayCritical(const etk::String& _message) { void ewol::tools::message::displayCritical( String _message) {
ewol::tools::message::create(ewol::tools::message::type::critical, _message); ewol::tools::message::create(ewol::tools::message::type::critical, _message);
} }

View File

@ -25,27 +25,27 @@ namespace ewol {
* @param[in] _type Type of the error. * @param[in] _type Type of the error.
* @param[in] _message message to display (decorated text) * @param[in] _message message to display (decorated text)
*/ */
void create(enum ewol::tools::message::type _type, const etk::String& _message); void create(enum ewol::tools::message::type _type, String _message);
/** /**
* @brief Create a simple information message * @brief Create a simple information message
* @param[in] _message message to display (decorated text) * @param[in] _message message to display (decorated text)
*/ */
void displayInfo(const etk::String& _message); void displayInfo( String _message);
/** /**
* @brief Create a simple warning message * @brief Create a simple warning message
* @param[in] _message message to display (decorated text) * @param[in] _message message to display (decorated text)
*/ */
void displayWarning(const etk::String& _message); void displayWarning( String _message);
/** /**
* @brief Create a simple error message * @brief Create a simple error message
* @param[in] _message message to display (decorated text) * @param[in] _message message to display (decorated text)
*/ */
void displayError(const etk::String& _message); void displayError( String _message);
/** /**
* @brief Create a simple critical message * @brief Create a simple critical message
* @param[in] _message message to display (decorated text) * @param[in] _message message to display (decorated text)
*/ */
void displayCritical(const etk::String& _message); void displayCritical( String _message);
} }
} }
} }

View File

@ -12,10 +12,10 @@
ETK_DECLARE_TYPE(ewol::widget::Button); ETK_DECLARE_TYPE(ewol::widget::Button);
ETK_DECLARE_TYPE(ewol::widget::Button::buttonLock); ETK_DECLARE_TYPE(ewol::widget::Button::buttonLock);
// DEFINE for the shader display system: // DEFINE for the shader display system:
const static int32_t STATUS_UP(0); static int STATUS_UP(0);
const static int32_t STATUS_HOVER(2); static int STATUS_HOVER(2);
const static int32_t STATUS_PRESSED(1); static int STATUS_PRESSED(1);
const static int32_t STATUS_DOWN(3); static int STATUS_DOWN(3);
ewol::widget::Button::Button() : ewol::widget::Button::Button() :
signalPressed(this, "pressed", "Button is pressed"), signalPressed(this, "pressed", "Button is pressed"),
@ -24,15 +24,15 @@ ewol::widget::Button::Button() :
signalEnter(this, "enter", "The cursor enter inside the button"), signalEnter(this, "enter", "The cursor enter inside the button"),
signalLeave(this, "leave", "the cursor leave the button"), signalLeave(this, "leave", "the cursor leave the button"),
signalValue(this, "value", "button value change"), signalValue(this, "value", "button value change"),
propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "The display name for config file", &ewol::widget::Button::onChangePropertyShape), propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "The display name for config file", ewol::widget::Button::onChangePropertyShape),
propertyValue(this, "value", false, "Value of the Button", &ewol::widget::Button::onChangePropertyValue), propertyValue(this, "value", false, "Value of the Button", ewol::widget::Button::onChangePropertyValue),
propertyLock(this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder", &ewol::widget::Button::onChangePropertyLock), propertyLock(this, "lock", lockNone, "Lock the button in a special state to permit changing state only by the coder", ewol::widget::Button::onChangePropertyLock),
propertyToggleMode(this, "toggle", false, "The Button can toogle", &ewol::widget::Button::onChangePropertyToggleMode), propertyToggleMode(this, "toggle", false, "The Button can toogle", ewol::widget::Button::onChangePropertyToggleMode),
propertyEnableSingle(this, "enable-single", false, "If one element set in the Button ==> display only set", &ewol::widget::Button::onChangePropertyEnableSingle), propertyEnableSingle(this, "enable-single", false, "If one element set in the Button ==> display only set", ewol::widget::Button::onChangePropertyEnableSingle),
m_mouseHover(false), this.mouseHover(false),
m_buttonPressed(false), this.buttonPressed(false),
m_selectableAreaPos(0,0), this.selectableAreaPos(0,0),
m_selectableAreaSize(0,0) { this.selectableAreaSize(0,0) {
addObjectType("ewol::widget::Button"); addObjectType("ewol::widget::Button");
// set property list: // set property list:
@ -59,22 +59,22 @@ ewol::widget::Button::~Button() {
} }
void ewol::widget::Button::onChangeSize() { void ewol::widget::Button::onChangeSize() {
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
ewol::Padding ret = onChangeSizePadded(padding); ewol::Padding ret = onChangeSizePadded(padding);
//Log.debug(" configuring : origin=" << origin << " size=" << subElementSize << ""); //Log.debug(" configuring : origin=" + origin + " size=" + subElementSize + "");
m_selectableAreaPos = Vector2f(ret.xLeft(), ret.yButtom()); this.selectableAreaPos = Vector2f(ret.xLeft(), ret.yButtom());
m_selectableAreaSize = m_size - (m_selectableAreaPos + Vector2f(ret.xRight(), ret.yTop())); this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop()));
} }
void ewol::widget::Button::calculateMinMaxSize() { void ewol::widget::Button::calculateMinMaxSize() {
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
calculateMinMaxSizePadded(padding); calculateMinMaxSizePadded(padding);
} }
void ewol::widget::Button::onDraw() { void ewol::widget::Button::onDraw() {
// draw the shaaper (if needed indeed) // draw the shaaper (if needed indeed)
m_shaper.draw(); this.shaper.draw();
} }
void ewol::widget::Button::onRegenerateDisplay() { void ewol::widget::Button::onRegenerateDisplay() {
@ -82,70 +82,70 @@ void ewol::widget::Button::onRegenerateDisplay() {
if (needRedraw() == false) { if (needRedraw() == false) {
return; return;
} }
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
m_shaper.setShape(Vector2f(0,0), this.shaper.setShape(Vector2f(0,0),
m_size, this.size,
Vector2fClipInt32(m_selectableAreaPos+Vector2f(padding.xLeft(),padding.yButtom()) ), Vector2fClipInt32(this.selectableAreaPos+Vector2f(padding.xLeft(),padding.yButtom()) ),
Vector2fClipInt32(m_selectableAreaSize-Vector2f(padding.x(),padding.y()) ) ); Vector2fClipInt32(this.selectableAreaSize-Vector2f(padding.x(),padding.y()) ) );
//Log.error("pos=" << m_origin << " size=" << m_size); //Log.error("pos=" + this.origin + " size=" + this.size);
} }
bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { boolean ewol::widget::Button::onEventInput( ewol::event::Input _event) {
Log.verbose("Event on BT : " << _event); Log.verbose("Event on BT : " + _event);
// disable event in the lock access mode : // disable event in the lock access mode :
if(ewol::widget::Button::lockAccess == *propertyLock) { if(ewol::widget::Button::lockAccess == *propertyLock) {
return false; return false;
} }
if( _event.getStatus() == gale::key::status::leave if( _event.getStatus() == KeyStatus::leave
|| _event.getStatus() == gale::key::status::abort) { || _event.getStatus() == KeyStatus::abort) {
m_mouseHover = false; this.mouseHover = false;
m_buttonPressed = false; this.buttonPressed = false;
} else { } else {
Vector2f relativePos = relativePosition(_event.getPos()); Vector2f relativePos = relativePosition(_event.getPos());
// prevent error from ouside the button // prevent error from ouside the button
if( relativePos.x() < m_selectableAreaPos.x() if( relativePos.x() < this.selectableAreaPos.x()
|| relativePos.y() < m_selectableAreaPos.y() || relativePos.y() < this.selectableAreaPos.y()
|| relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() || relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x()
|| relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { || relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) {
m_mouseHover = false; this.mouseHover = false;
m_buttonPressed = false; this.buttonPressed = false;
} else { } else {
m_mouseHover = true; this.mouseHover = true;
} }
} }
Log.verbose("Event on BT ... mouse hover : " << m_mouseHover); Log.verbose("Event on BT ... mouse hover : " + this.mouseHover);
if (m_mouseHover == true) { if (this.mouseHover == true) {
if (_event.getId() == 1) { if (_event.getId() == 1) {
if(_event.getStatus() == gale::key::status::down) { if(_event.getStatus() == KeyStatus::down) {
Log.verbose(*propertyName << " : Generate event : " << signalDown); Log.verbose(*propertyName + " : Generate event : " + signalDown);
signalDown.emit(); signalDown.emit();
m_buttonPressed = true; this.buttonPressed = true;
markToRedraw(); markToRedraw();
} }
if(_event.getStatus() == gale::key::status::up) { if(_event.getStatus() == KeyStatus::up) {
Log.verbose(*propertyName << " : Generate event : " << signalUp); Log.verbose(*propertyName + " : Generate event : " + signalUp);
signalUp.emit(); signalUp.emit();
m_buttonPressed = false; this.buttonPressed = false;
markToRedraw(); markToRedraw();
} }
if(_event.getStatus() == gale::key::status::pressSingle) { if(_event.getStatus() == KeyStatus::pressSingle) {
if ( ( *propertyValue == true if ( ( *propertyValue == true
&& *propertyLock == ewol::widget::Button::lockWhenPressed) LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenPressed)
|| ( *propertyValue == false || ( *propertyValue == false
&& *propertyLock == ewol::widget::Button::lockWhenReleased) ) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyLock == ewol::widget::Button::lockWhenReleased) ) {
// nothing to do : Lock mode ... // nothing to do : Lock mode ...
// user might set himself the new correct value with @ref setValue(xxx) // user might set himself the new correct value with @ref setValue(xxx)
} else { } else {
// inverse value : // inverse value :
propertyValue.set((*propertyValue)?false:true); propertyValue.set((*propertyValue)?false:true);
Log.verbose(*propertyName << " : Generate event : " << signalPressed); Log.verbose(*propertyName + " : Generate event : " + signalPressed);
signalPressed.emit(); signalPressed.emit();
Log.verbose(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue ); Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue );
signalValue.emit(*propertyValue); signalValue.emit(*propertyValue);
if( *propertyToggleMode == false if( *propertyToggleMode == false
&& *propertyValue == true) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM *propertyValue == true) {
propertyValue.set(false); propertyValue.set(false);
Log.verbose(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue); Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + *propertyValue);
signalValue.emit(*propertyValue); signalValue.emit(*propertyValue);
} }
} }
@ -154,15 +154,15 @@ bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) {
} }
} }
CheckStatus(); CheckStatus();
return m_mouseHover; return this.mouseHover;
} }
bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) { boolean ewol::widget::Button::onEventEntry( ewol::event::Entry _event) {
//Log.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data));
if( _event.getType() == gale::key::keyboard::character if( _event.getType() == KeyKeyboard::character
&& _event.getStatus() == gale::key::status::down LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down
&& _event.getChar() == '\r') { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') {
signalEnter.emit(); signalEnter.emit();
return true; return true;
} }
@ -170,17 +170,17 @@ bool ewol::widget::Button::onEventEntry(const ewol::event::Entry& _event) {
} }
void ewol::widget::Button::onLostFocus() { void ewol::widget::Button::onLostFocus() {
m_buttonPressed = false; this.buttonPressed = false;
Log.verbose(propertyName.get() << " : Remove Focus ..."); Log.verbose(propertyName.get() + " : Remove Focus ...");
CheckStatus(); CheckStatus();
} }
void ewol::widget::Button::CheckStatus() { void ewol::widget::Button::CheckStatus() {
if (m_buttonPressed == true) { if (this.buttonPressed == true) {
changeStatusIn(STATUS_PRESSED); changeStatusIn(STATUS_PRESSED);
return; return;
} }
if (m_mouseHover == true) { if (this.mouseHover == true) {
changeStatusIn(STATUS_HOVER); changeStatusIn(STATUS_HOVER);
return; return;
} }
@ -190,42 +190,42 @@ void ewol::widget::Button::CheckStatus() {
changeStatusIn(STATUS_UP); changeStatusIn(STATUS_UP);
} }
void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) { void ewol::widget::Button::changeStatusIn(int _newStatusId) {
if (m_shaper.changeStatusIn(_newStatusId) == true) { if (this.shaper.changeStatusIn(_newStatusId) == true) {
m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::Button::periodicCall); this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::Button::periodicCall);
markToRedraw(); markToRedraw();
} }
} }
void ewol::widget::Button::periodicCall(const ewol::event::Time& _event) { void ewol::widget::Button::periodicCall( ewol::event::Time _event) {
if (m_shaper.periodicCall(_event) == false) { if (this.shaper.periodicCall(_event) == false) {
m_PCH.disconnect(); this.PCH.disconnect();
} }
markToRedraw(); markToRedraw();
} }
void ewol::widget::Button::onChangePropertyShape() { void ewol::widget::Button::onChangePropertyShape() {
m_shaper.setSource(*propertyShape); this.shaper.setSource(*propertyShape);
markToRedraw(); markToRedraw();
} }
void ewol::widget::Button::onChangePropertyValue() { void ewol::widget::Button::onChangePropertyValue() {
if (*propertyToggleMode == true) { if (*propertyToggleMode == true) {
if (*propertyValue == false) { if (*propertyValue == false) {
m_idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} else { } else {
m_idWidgetDisplayed = 1; this.idWidgetDisplayed = 1;
} }
} }
if (*propertyEnableSingle == true) { if (*propertyEnableSingle == true) {
if ( m_idWidgetDisplayed == 0 if ( this.idWidgetDisplayed == 0
&& m_subWidget[0] == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
&& m_subWidget[1] != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
m_idWidgetDisplayed = 1; this.idWidgetDisplayed = 1;
} else if ( m_idWidgetDisplayed == 1 } else if ( this.idWidgetDisplayed == 1
&& m_subWidget[1] == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
&& m_subWidget[0] != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
m_idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} }
} }
CheckStatus(); CheckStatus();
@ -234,8 +234,8 @@ void ewol::widget::Button::onChangePropertyValue() {
void ewol::widget::Button::onChangePropertyLock() { void ewol::widget::Button::onChangePropertyLock() {
if(ewol::widget::Button::lockAccess == *propertyLock) { if(ewol::widget::Button::lockAccess == *propertyLock) {
m_buttonPressed = false; this.buttonPressed = false;
m_mouseHover = false; this.mouseHover = false;
} }
CheckStatus(); CheckStatus();
markToRedraw(); markToRedraw();
@ -247,23 +247,23 @@ void ewol::widget::Button::onChangePropertyToggleMode() {
// TODO : change display and send event ... // TODO : change display and send event ...
} }
if (*propertyToggleMode == false) { if (*propertyToggleMode == false) {
m_idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} else { } else {
if (*propertyValue == false) { if (*propertyValue == false) {
m_idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} else { } else {
m_idWidgetDisplayed = 1; this.idWidgetDisplayed = 1;
} }
} }
if (*propertyEnableSingle == true) { if (*propertyEnableSingle == true) {
if ( m_idWidgetDisplayed == 0 if ( this.idWidgetDisplayed == 0
&& m_subWidget[0] == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
&& m_subWidget[1] != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
m_idWidgetDisplayed = 1; this.idWidgetDisplayed = 1;
} else if ( m_idWidgetDisplayed == 1 } else if ( this.idWidgetDisplayed == 1
&& m_subWidget[1] == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
&& m_subWidget[0] != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
m_idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} }
} }
CheckStatus(); CheckStatus();
@ -272,17 +272,17 @@ void ewol::widget::Button::onChangePropertyToggleMode() {
void ewol::widget::Button::onChangePropertyEnableSingle() { void ewol::widget::Button::onChangePropertyEnableSingle() {
if (*propertyEnableSingle == true) { if (*propertyEnableSingle == true) {
if ( m_idWidgetDisplayed == 0 if ( this.idWidgetDisplayed == 0
&& m_subWidget[0] == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] == null
&& m_subWidget[1] != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] != null) {
m_idWidgetDisplayed = 1; this.idWidgetDisplayed = 1;
} else if ( m_idWidgetDisplayed == 1 } else if ( this.idWidgetDisplayed == 1
&& m_subWidget[1] == null LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null
&& m_subWidget[0] != null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[0] != null) {
m_idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} else if ( m_subWidget[0] == null } else if ( this.subWidget[0] == null
&& m_subWidget[1] == null) { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM this.subWidget[1] == null) {
m_idWidgetDisplayed = 0; this.idWidgetDisplayed = 0;
} }
} }
} }

View File

@ -19,7 +19,7 @@
namespace ewol { namespace ewol {
namespace widget { namespace widget {
class Button; class Button;
using ButtonShared = ememory::SharedPtr<ewol::widget::Button>; using Button = ememory::Ptr<ewol::widget::Button>;
using ButtonWeak = ememory::WeakPtr<ewol::widget::Button>; using ButtonWeak = ememory::WeakPtr<ewol::widget::Button>;
/** /**
* @brief a composed button is a button with an inside composed with the specify XML element * @brief a composed button is a button with an inside composed with the specify XML element
@ -47,61 +47,61 @@ namespace ewol {
eproperty::Value<bool> propertyToggleMode; //!< The button is able to toggle. eproperty::Value<bool> propertyToggleMode; //!< The button is able to toggle.
eproperty::Value<bool> propertyEnableSingle; //!< When a single subwidget is set display all time it. eproperty::Value<bool> propertyEnableSingle; //!< When a single subwidget is set display all time it.
private: private:
ewol::compositing::Shaper m_shaper; //!< Compositing theme. ewol::compositing::Shaper this.shaper; //!< Compositing theme.
protected: protected:
/** /**
* @brief Constructor * @brief Constructor
* @param[in] _shaperName Shaper file properties * @param[in] _shaperName Shaper file properties
*/ */
Button(); Button();
void init() override; void init() ;
public: public:
DECLARE_WIDGET_FACTORY(Button, "Button"); DECLARE_WIDGET_FACTORY(Button, "Button");
/** /**
* @brief Destructor * @brief Destructor
*/ */
virtual ~Button(); ~Button();
private: private:
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed. boolean this.buttonPressed; //!< Flag to know if the button is curently pressed.
// hover area : // hover area :
Vector2f m_selectableAreaPos; //!< Start position of the events Vector2f this.selectableAreaPos; //!< Start position of the events
Vector2f m_selectableAreaSize; //!< size of the event positions Vector2f this.selectableAreaSize; //!< size of the event positions
private: private:
/** /**
* @brief internal system to change the property of the current status * @brief internal system to change the property of the current status
* @param[in] _newStatusId new state * @param[in] _newStatusId new state
*/ */
void changeStatusIn(int32_t _newStatusId); void changeStatusIn(int _newStatusId);
/** /**
* @brief update the status with the internal satte of the button ... * @brief update the status with the internal satte of the button ...
*/ */
void CheckStatus(); void CheckStatus();
protected: // Derived function protected: // Derived function
virtual void onDraw() override; void onDraw() ;
public: public:
void calculateMinMaxSize() override; void calculateMinMaxSize() ;
void onChangeSize() override; void onChangeSize() ;
void onRegenerateDisplay() override; void onRegenerateDisplay() ;
bool onEventInput(const ewol::event::Input& _event) override; boolean onEventInput( ewol::event::Input _event) ;
bool onEventEntry(const ewol::event::Entry& _event) override; boolean onEventEntry( ewol::event::Entry _event) ;
void onDetectPresenceToggleWidget() override { void onDetectPresenceToggleWidget() {
propertyToggleMode.set(true); propertyToggleMode.set(true);
} }
protected: protected:
esignal::Connection m_PCH; //!< Periodic Call Handle to remove it when needed esignal::Connection this.PCH; //!< Periodic Call Handle to remove it when needed
/** /**
* @brief Periodic call to update grapgic display * @brief Periodic call to update grapgic display
* @param[in] _event Time generic event * @param[in] _event Time generic event
*/ */
void periodicCall(const ewol::event::Time& _event); void periodicCall( ewol::event::Time _event);
void onLostFocus() override; void onLostFocus() ;
protected: protected:
virtual void onChangePropertyShape(); void onChangePropertyShape();
virtual void onChangePropertyValue(); void onChangePropertyValue();
virtual void onChangePropertyLock(); void onChangePropertyLock();
virtual void onChangePropertyToggleMode(); void onChangePropertyToggleMode();
virtual void onChangePropertyEnableSingle(); void onChangePropertyEnableSingle();
}; };
}; };
}; };

View File

@ -24,9 +24,9 @@ ETK_DECLARE_TYPE(ewol::widget::ButtonColor);
ewol::widget::ButtonColor::ButtonColor() : ewol::widget::ButtonColor::ButtonColor() :
signalChange(this, "change", "Button color change value"), signalChange(this, "change", "Button color change value"),
propertyValue(this, "color", etk::color::black, "Current color", &ewol::widget::ButtonColor::onChangePropertyValue), propertyValue(this, "color", etk::color::black, "Current color", ewol::widget::ButtonColor::onChangePropertyValue),
propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "shape of the widget", &ewol::widget::ButtonColor::onChangePropertyShape), propertyShape(this, "shape", etk::Uri("THEME_GUI:///Button.json?lib=ewol"), "shape of the widget", ewol::widget::ButtonColor::onChangePropertyShape),
m_widgetContextMenu(null) { this.widgetContextMenu(null) {
addObjectType("ewol::widget::ButtonColor"); addObjectType("ewol::widget::ButtonColor");
changeStatusIn(STATUS_UP); changeStatusIn(STATUS_UP);
// Limit event at 1: // Limit event at 1:
@ -35,7 +35,7 @@ ewol::widget::ButtonColor::ButtonColor() :
} }
void ewol::widget::ButtonColor::init() { void ewol::widget::ButtonColor::init() {
ewol::Widget::init(); Widget::init();
propertyShape.notifyChange(); propertyShape.notifyChange();
propertyValue.notifyChange(); propertyValue.notifyChange();
} }
@ -45,19 +45,19 @@ ewol::widget::ButtonColor::~ButtonColor() {
} }
void ewol::widget::ButtonColor::calculateMinMaxSize() { void ewol::widget::ButtonColor::calculateMinMaxSize() {
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
etk::String label = propertyValue.getString(); String label = propertyValue.getString();
Vector3f minSize = m_text.calculateSize(label); Vector3f minSize = this.text.calculateSize(label);
m_minSize.setX(padding.x()*2 + minSize.x() + 7); this.minSize.setX(padding.x()*2 + minSize.x() + 7);
m_minSize.setY(padding.y()*2 + minSize.y() ); this.minSize.setY(padding.y()*2 + minSize.y() );
markToRedraw(); markToRedraw();
} }
void ewol::widget::ButtonColor::onDraw() { void ewol::widget::ButtonColor::onDraw() {
m_shaper.draw(); this.shaper.draw();
m_text.draw(); this.text.draw();
} }
@ -66,153 +66,153 @@ void ewol::widget::ButtonColor::onRegenerateDisplay() {
return; return;
} }
Log.debug("redraw"); Log.debug("redraw");
m_text.clear(); this.text.clear();
m_shaper.clear(); this.shaper.clear();
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
etk::String label = propertyValue.getString(); String label = propertyValue.getString();
Vector2i localSize = m_minSize; Vector2i localSize = this.minSize;
Vector3f tmpOrigin((m_size.x() - m_minSize.x()) / 2.0, Vector3f tmpOrigin((this.size.x() - this.minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0, (this.size.y() - this.minSize.y()) / 2.0,
0); 0);
// no change for the text orogin : // no change for the text orogin :
Vector3f tmpTextOrigin((m_size.x() - m_minSize.x()) / 2.0, Vector3f tmpTextOrigin((this.size.x() - this.minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0, (this.size.y() - this.minSize.y()) / 2.0,
0); 0);
if (propertyFill->x() == true) { if (propertyFill.x() == true) {
localSize.setX(m_size.x()); localSize.setX(this.size.x());
tmpOrigin.setX(0); tmpOrigin.setX(0);
tmpTextOrigin.setX(0); tmpTextOrigin.setX(0);
} }
if (propertyFill->y() == true) { if (propertyFill.y() == true) {
localSize.setY(m_size.y()); localSize.setY(this.size.y());
} }
tmpOrigin += Vector3f(padding.xLeft(), padding.yButtom(), 0); tmpOrigin += Vector3f(padding.xLeft(), padding.yButtom(), 0);
tmpTextOrigin += Vector3f(padding.xLeft(), padding.yButtom(), 0); tmpTextOrigin += Vector3f(padding.xLeft(), padding.yButtom(), 0);
localSize -= Vector2i(padding.x(), padding.y()); localSize -= Vector2i(padding.x(), padding.y());
// clean the element // clean the element
m_text.reset(); this.text.reset();
if( propertyValue.get().r() < 100 if( propertyValue.get().r() < 100
|| propertyValue.get().g() < 100 || propertyValue.get().g() < 100
|| propertyValue.get().b() < 100) { || propertyValue.get().b() < 100) {
m_text.setColor(etk::color::white); this.text.setColor(etk::color::white);
} else { } else {
m_text.setColor(etk::color::black); this.text.setColor(etk::color::black);
} }
m_text.setPos(tmpTextOrigin); this.text.setPos(tmpTextOrigin);
m_text.setColorBg(propertyValue.get()); this.text.setColorBg(propertyValue.get());
m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignCenter); this.text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignCenter);
m_text.print(label); this.text.print(label);
if (propertyFill->y() == true) { if (propertyFill.y() == true) {
tmpOrigin.setY(padding.yButtom()); tmpOrigin.setY(padding.yButtom());
} }
// selection area : // selection area :
m_selectableAreaPos = Vector2f(tmpOrigin.x()-padding.xLeft(), tmpOrigin.y()-padding.yButtom()); this.selectableAreaPos = Vector2f(tmpOrigin.x()-padding.xLeft(), tmpOrigin.y()-padding.yButtom());
m_selectableAreaSize = localSize + Vector2f(padding.x(),padding.y()); this.selectableAreaSize = localSize + Vector2f(padding.x(),padding.y());
Vector3f tmpp = m_text.calculateSize(label); Vector3f tmpp = this.text.calculateSize(label);
m_shaper.setShape(m_selectableAreaPos, this.shaper.setShape(this.selectableAreaPos,
m_selectableAreaSize, this.selectableAreaSize,
Vector2f(tmpTextOrigin.x(), tmpTextOrigin.y()), Vector2f(tmpTextOrigin.x(), tmpTextOrigin.y()),
Vector2f(tmpp.x(), tmpp.y())); Vector2f(tmpp.x(), tmpp.y()));
} }
bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { boolean ewol::widget::ButtonColor::onEventInput( ewol::event::Input _event) {
bool previousHoverState = m_mouseHover; boolean previousHoverState = this.mouseHover;
if(gale::key::status::leave == _event.getStatus()) { if(KeyStatus::leave == _event.getStatus()) {
m_mouseHover = false; this.mouseHover = false;
m_buttonPressed = false; this.buttonPressed = false;
} else { } else {
Vector2f relativePos = relativePosition(_event.getPos()); Vector2f relativePos = relativePosition(_event.getPos());
// prevent error from ouside the button // prevent error from ouside the button
if( relativePos.x() < m_selectableAreaPos.x() if( relativePos.x() < this.selectableAreaPos.x()
|| relativePos.y() < m_selectableAreaPos.y() || relativePos.y() < this.selectableAreaPos.y()
|| relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() || relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x()
|| relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { || relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) {
m_mouseHover = false; this.mouseHover = false;
m_buttonPressed = false; this.buttonPressed = false;
} else { } else {
m_mouseHover = true; this.mouseHover = true;
} }
} }
bool previousPressed = m_buttonPressed; boolean previousPressed = this.buttonPressed;
//Log.debug("Event on BT ... mouse position : " << m_mouseHover); //Log.debug("Event on BT ... mouse position : " + this.mouseHover);
if (true == m_mouseHover) { if (true == this.mouseHover) {
if (1 == _event.getId()) { if (1 == _event.getId()) {
if(gale::key::status::down == _event.getStatus()) { if(KeyStatus::down == _event.getStatus()) {
m_buttonPressed = true; this.buttonPressed = true;
markToRedraw(); markToRedraw();
} }
if(gale::key::status::up == _event.getStatus()) { if(KeyStatus::up == _event.getStatus()) {
m_buttonPressed = false; this.buttonPressed = false;
markToRedraw(); markToRedraw();
} }
if(gale::key::status::pressSingle == _event.getStatus()) { if(KeyStatus::pressSingle == _event.getStatus()) {
m_buttonPressed = false; this.buttonPressed = false;
m_mouseHover = false; this.mouseHover = false;
// create a context menu : // create a context menu :
m_widgetContextMenu = ewol::widget::ContextMenu::create(); this.widgetContextMenu = ewol::widget::ContextMenu::create();
if (m_widgetContextMenu == null) { if (this.widgetContextMenu == null) {
Log.error("Allocation Error"); Log.error("Allocation Error");
return true; return true;
} }
Vector2f tmpPos = m_origin + m_selectableAreaPos + m_selectableAreaSize; Vector2f tmpPos = this.origin + this.selectableAreaPos + this.selectableAreaSize;
tmpPos.setX( tmpPos.x() - m_minSize.x()/2.0); tmpPos.setX( tmpPos.x() - this.minSize.x()/2.0);
m_widgetContextMenu->setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos ); this.widgetContextMenu.setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos );
ewol::widget::ColorChooserShared myColorChooser = widget::ColorChooser::create(); ewol::widget::ColorChooser myColorChooser = widget::ColorChooser::create();
myColorChooser->propertyValue.set(propertyValue.get()); myColorChooser.propertyValue.set(propertyValue.get());
// set it in the pop-up-system : // set it in the pop-up-system :
m_widgetContextMenu->setSubWidget(myColorChooser); this.widgetContextMenu.setSubWidget(myColorChooser);
myColorChooser->signalChange.connect(sharedFromThis(), &ewol::widget::ButtonColor::onCallbackColorChange); myColorChooser.signalChange.connect(sharedFromThis(), ewol::widget::ButtonColor::onCallbackColorChange);
ewol::widget::WindowsShared currentWindows = getWindows(); ewol::widget::Windows currentWindows = getWindows();
if (currentWindows == null) { if (currentWindows == null) {
Log.error("Can not get the curent Windows..."); Log.error("Can not get the curent Windows...");
m_widgetContextMenu.reset(); this.widgetContextMenu.reset();
} else { } else {
currentWindows->popUpWidgetPush(m_widgetContextMenu); currentWindows.popUpWidgetPush(this.widgetContextMenu);
} }
markToRedraw(); markToRedraw();
} }
} }
} }
if( m_mouseHover != previousHoverState if( this.mouseHover != previousHoverState
|| m_buttonPressed != previousPressed) { || this.buttonPressed != previousPressed) {
if (m_buttonPressed == true) { if (this.buttonPressed == true) {
changeStatusIn(STATUS_PRESSED); changeStatusIn(STATUS_PRESSED);
} else { } else {
if (m_mouseHover == true) { if (this.mouseHover == true) {
changeStatusIn(STATUS_HOVER); changeStatusIn(STATUS_HOVER);
} else { } else {
changeStatusIn(STATUS_UP); changeStatusIn(STATUS_UP);
} }
} }
} }
return m_mouseHover; return this.mouseHover;
} }
void ewol::widget::ButtonColor::onCallbackColorChange(const etk::Color<>& _color) { void ewol::widget::ButtonColor::onCallbackColorChange( etk::Color<> _color) {
propertyValue.set(_color); propertyValue.set(_color);
} }
void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) { void ewol::widget::ButtonColor::changeStatusIn(int _newStatusId) {
if (m_shaper.changeStatusIn(_newStatusId) == true) { if (this.shaper.changeStatusIn(_newStatusId) == true) {
m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::ButtonColor::periodicCall); this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::ButtonColor::periodicCall);
markToRedraw(); markToRedraw();
} }
} }
void ewol::widget::ButtonColor::periodicCall(const ewol::event::Time& _event) { void ewol::widget::ButtonColor::periodicCall( ewol::event::Time _event) {
if (m_shaper.periodicCall(_event) == false) { if (this.shaper.periodicCall(_event) == false) {
m_PCH.disconnect(); this.PCH.disconnect();
} }
markToRedraw(); markToRedraw();
} }
@ -222,7 +222,7 @@ void ewol::widget::ButtonColor::onChangePropertyValue() {
} }
void ewol::widget::ButtonColor::onChangePropertyShape() { void ewol::widget::ButtonColor::onChangePropertyShape() {
m_shaper.setSource(propertyShape.get()); this.shaper.setSource(propertyShape.get());
markToRedraw(); markToRedraw();
} }

View File

@ -18,60 +18,60 @@
namespace ewol { namespace ewol {
namespace widget { namespace widget {
class ButtonColor; class ButtonColor;
using ButtonColorShared = ememory::SharedPtr<ewol::widget::ButtonColor>; using ButtonColor = ememory::Ptr<ewol::widget::ButtonColor>;
using ButtonColorWeak = ememory::WeakPtr<ewol::widget::ButtonColor>; using ButtonColorWeak = ememory::WeakPtr<ewol::widget::ButtonColor>;
class ButtonColor : public ewol::Widget { class ButtonColor : public Widget {
public: // signals public: // signals
esignal::Signal<etk::Color<>> signalChange; esignal::Signal<etk::Color<>> signalChange;
public: // properties public: // properties
eproperty::Value<etk::Color<>> propertyValue; //!< Current color. eproperty::Value<etk::Color<>> propertyValue; //!< Current color.
eproperty::Value<etk::Uri> propertyShape; //!< Current color. eproperty::Value<etk::Uri> propertyShape; //!< Current color.
private: private:
ewol::compositing::Shaper m_shaper; //!< Compositing theme. ewol::compositing::Shaper this.shaper; //!< Compositing theme.
ewol::compositing::Text m_text; //!< Compositing Test display. ewol::compositing::Text this.text; //!< Compositing Test display.
ewol::widget::ContextMenuShared m_widgetContextMenu; //!< Specific context menu. ewol::widget::ContextMenu this.widgetContextMenu; //!< Specific context menu.
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). boolean this.mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed. boolean this.buttonPressed; //!< Flag to know if the button is curently pressed.
// hover area : // hover area :
Vector2f m_selectableAreaPos; //!< Start position of the events Vector2f this.selectableAreaPos; //!< Start position of the events
Vector2f m_selectableAreaSize; //!< size of the event positions Vector2f this.selectableAreaSize; //!< size of the event positions
protected: protected:
/** /**
* @brief Main constructor. * @brief Main ructor.
* @param[in] _baseColor basic displayed color. * @param[in] _baseColor basic displayed color.
* @param[in] _shaperName The new shaper filename. * @param[in] _shaperName The new shaper filename.
*/ */
ButtonColor(); ButtonColor();
void init() override; void init() ;
public: public:
DECLARE_WIDGET_FACTORY(ButtonColor, "ButtonColor"); DECLARE_WIDGET_FACTORY(ButtonColor, "ButtonColor");
/** /**
* @brief Main destructor. * @brief Main destructor.
*/ */
virtual ~ButtonColor(); ~ButtonColor();
protected: protected:
void onDraw() override; void onDraw() ;
public: public:
void calculateMinMaxSize() override; void calculateMinMaxSize() ;
void onRegenerateDisplay() override; void onRegenerateDisplay() ;
bool onEventInput(const ewol::event::Input& _event) override; boolean onEventInput( ewol::event::Input _event) ;
private: private:
/** /**
* @brief internal system to change the property of the current status * @brief internal system to change the property of the current status
* @param[in] _newStatusId new state * @param[in] _newStatusId new state
*/ */
void changeStatusIn(int32_t _newStatusId); void changeStatusIn(int _newStatusId);
esignal::Connection m_PCH; //!< Periodic call handle to remove it when needed esignal::Connection this.PCH; //!< Periodic call handle to remove it when needed
/** /**
* @brief Periodic call to update grapgic display * @brief Periodic call to update grapgic display
* @param[in] _event Time generic event * @param[in] _event Time generic event
*/ */
void periodicCall(const ewol::event::Time& _event); void periodicCall( ewol::event::Time _event);
// Callback function: // Callback function:
void onCallbackColorChange(const etk::Color<>& _color); void onCallbackColorChange( etk::Color<> _color);
protected: protected:
virtual void onChangePropertyValue(); void onChangePropertyValue();
virtual void onChangePropertyShape(); void onChangePropertyShape();
}; };
}; };
}; };

View File

@ -25,17 +25,17 @@ ewol::widget::CheckBox::CheckBox() :
propertyValue(this, "value", propertyValue(this, "value",
false, false,
"Basic value of the widget", "Basic value of the widget",
&ewol::widget::CheckBox::onChangePropertyValue), ewol::widget::CheckBox::onChangePropertyValue),
propertyShape(this, "shape", propertyShape(this, "shape",
etk::Uri("THEME_GUI:///CheckBox.json?lib=ewol"), etk::Uri("THEME_GUI:///CheckBox.json?lib=ewol"),
"The display name for config file", "The display name for config file",
&ewol::widget::CheckBox::onChangePropertyShape), ewol::widget::CheckBox::onChangePropertyShape),
m_mouseHover(false), this.mouseHover(false),
m_buttonPressed(false), this.buttonPressed(false),
m_selectableAreaPos(0,0), this.selectableAreaPos(0,0),
m_selectableAreaSize(0,0), this.selectableAreaSize(0,0),
m_shaperIdSize(-1), this.shaperIdSize(-1),
m_shaperIdSizeInsize(-1) { this.shaperIdSizeInsize(-1) {
addObjectType("ewol::widget::CheckBox"); addObjectType("ewol::widget::CheckBox");
// shaper satatus update: // shaper satatus update:
CheckStatus(); CheckStatus();
@ -55,28 +55,28 @@ ewol::widget::CheckBox::~CheckBox() {
} }
void ewol::widget::CheckBox::onChangeSize() { void ewol::widget::CheckBox::onChangeSize() {
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
padding.setXLeft(padding.xLeft()*2.0f + boxSize); padding.setXLeft(padding.xLeft()*2.0f + boxSize);
ewol::Padding ret = onChangeSizePadded(padding); ewol::Padding ret = onChangeSizePadded(padding);
Log.debug(" configuring : padding=" << padding << " boxSize=" << boxSize << ""); Log.debug(" configuring : padding=" + padding + " boxSize=" + boxSize + "");
m_selectableAreaPos = Vector2f(ret.xLeft()/*-boxSize*/, ret.yButtom()); this.selectableAreaPos = Vector2f(ret.xLeft()/*-boxSize*/, ret.yButtom());
m_selectableAreaSize = m_size - (m_selectableAreaPos + Vector2f(ret.xRight(), ret.yTop())); this.selectableAreaSize = this.size - (this.selectableAreaPos + Vector2f(ret.xRight(), ret.yTop()));
} }
void ewol::widget::CheckBox::calculateMinMaxSize() { void ewol::widget::CheckBox::calculateMinMaxSize() {
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
padding.setXLeft(padding.xLeft()*2.0f + boxSize); padding.setXLeft(padding.xLeft()*2.0f + boxSize);
calculateMinMaxSizePadded(padding); calculateMinMaxSizePadded(padding);
if (m_minSize.y() < padding.y()+boxSize) { if (this.minSize.y() < padding.y()+boxSize) {
m_minSize.setY(padding.y()+boxSize); this.minSize.setY(padding.y()+boxSize);
} }
} }
void ewol::widget::CheckBox::onDraw() { void ewol::widget::CheckBox::onDraw() {
// draw the shaaper (if needed indeed) // draw the shaaper (if needed indeed)
m_shaper.draw(); this.shaper.draw();
} }
void ewol::widget::CheckBox::onRegenerateDisplay() { void ewol::widget::CheckBox::onRegenerateDisplay() {
@ -84,83 +84,83 @@ void ewol::widget::CheckBox::onRegenerateDisplay() {
if (needRedraw() == false) { if (needRedraw() == false) {
return; return;
} }
ewol::Padding padding = m_shaper.getPadding(); ewol::Padding padding = this.shaper.getPadding();
float boxSize = m_shaper.getConfigNumber(m_shaperIdSize); float boxSize = this.shaper.getConfigNumber(this.shaperIdSize);
float boxInside = m_shaper.getConfigNumber(m_shaperIdSizeInsize); float boxInside = this.shaper.getConfigNumber(this.shaperIdSizeInsize);
m_shaper.clear(); this.shaper.clear();
Log.debug(" configuring : boxSize=" << boxSize << " boxInside=" << boxInside << ""); Log.debug(" configuring : boxSize=" + boxSize + " boxInside=" + boxInside + "");
Vector2f origin(m_selectableAreaPos + Vector2f(0, (m_selectableAreaSize.y() - (boxSize+padding.y()))*0.5f)); Vector2f origin(this.selectableAreaPos + Vector2f(0, (this.selectableAreaSize.y() - (boxSize+padding.y()))*0.5f));
Vector2f size = Vector2f(boxSize+padding.x(), boxSize+padding.y()); Vector2f size = Vector2f(boxSize+padding.x(), boxSize+padding.y());
Vector2f origin2 = m_selectableAreaPos + Vector2f((boxSize-boxInside)*0.5f, (m_selectableAreaSize.y() - (boxInside+padding.y()))*0.5f); Vector2f origin2 = this.selectableAreaPos + Vector2f((boxSize-boxInside)*0.5f, (this.selectableAreaSize.y() - (boxInside+padding.y()))*0.5f);
Vector2f size2 = Vector2f(boxInside+padding.x(), boxInside+padding.y()); Vector2f size2 = Vector2f(boxInside+padding.x(), boxInside+padding.y());
m_shaper.setShape(Vector2fClipInt32(origin), this.shaper.setShape(Vector2fClipInt32(origin),
Vector2fClipInt32(size), Vector2fClipInt32(size),
Vector2fClipInt32(origin2+Vector2f(padding.xLeft(),padding.yButtom()) ), Vector2fClipInt32(origin2+Vector2f(padding.xLeft(),padding.yButtom()) ),
Vector2fClipInt32(size2-Vector2f(padding.x(),padding.y()) )); Vector2fClipInt32(size2-Vector2f(padding.x(),padding.y()) ));
} }
bool ewol::widget::CheckBox::onEventInput(const ewol::event::Input& _event) { boolean ewol::widget::CheckBox::onEventInput( ewol::event::Input _event) {
Log.verbose("Event on BT : " << _event); Log.verbose("Event on BT : " + _event);
bool previousHoverState = m_mouseHover; boolean previousHoverState = this.mouseHover;
if( gale::key::status::leave == _event.getStatus() if( KeyStatus::leave == _event.getStatus()
|| gale::key::status::abort == _event.getStatus()) { || KeyStatus::abort == _event.getStatus()) {
m_mouseHover = false; this.mouseHover = false;
m_buttonPressed = false; this.buttonPressed = false;
} else { } else {
Vector2f relativePos = relativePosition(_event.getPos()); Vector2f relativePos = relativePosition(_event.getPos());
// prevent error from ouside the button // prevent error from ouside the button
if( relativePos.x() < m_selectableAreaPos.x() if( relativePos.x() < this.selectableAreaPos.x()
|| relativePos.y() < m_selectableAreaPos.y() || relativePos.y() < this.selectableAreaPos.y()
|| relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() || relativePos.x() > this.selectableAreaPos.x() + this.selectableAreaSize.x()
|| relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { || relativePos.y() > this.selectableAreaPos.y() + this.selectableAreaSize.y() ) {
m_mouseHover = false; this.mouseHover = false;
m_buttonPressed = false; this.buttonPressed = false;
} else { } else {
m_mouseHover = true; this.mouseHover = true;
} }
} }
bool previousPressed = m_buttonPressed; boolean previousPressed = this.buttonPressed;
Log.verbose("Event on BT ... mouse hover : " << m_mouseHover); Log.verbose("Event on BT ... mouse hover : " + this.mouseHover);
if (m_mouseHover == true) { if (this.mouseHover == true) {
if (_event.getId() == 1) { if (_event.getId() == 1) {
if(gale::key::status::down == _event.getStatus()) { if(KeyStatus::down == _event.getStatus()) {
Log.verbose(*propertyName << " : Generate event : " << signalDown); Log.verbose(*propertyName + " : Generate event : " + signalDown);
signalDown.emit(); signalDown.emit();
m_buttonPressed = true; this.buttonPressed = true;
markToRedraw(); markToRedraw();
} }
if(gale::key::status::up == _event.getStatus()) { if(KeyStatus::up == _event.getStatus()) {
Log.verbose(*propertyName << " : Generate event : " << signalUp); Log.verbose(*propertyName + " : Generate event : " + signalUp);
signalUp.emit(); signalUp.emit();
m_buttonPressed = false; this.buttonPressed = false;
markToRedraw(); markToRedraw();
} }
if(gale::key::status::pressSingle == _event.getStatus()) { if(KeyStatus::pressSingle == _event.getStatus()) {
// inverse value : // inverse value :
propertyValue.set((*propertyValue)?false:true); propertyValue.set((*propertyValue)?false:true);
Log.verbose(*propertyName << " : Generate event : " << signalPressed); Log.verbose(*propertyName + " : Generate event : " + signalPressed);
signalPressed.emit(); signalPressed.emit();
Log.verbose(*propertyName << " : Generate event : " << signalValue << " val=" << propertyValue ); Log.verbose(*propertyName + " : Generate event : " + signalValue + " val=" + propertyValue );
signalValue.emit(*propertyValue); signalValue.emit(*propertyValue);
markToRedraw(); markToRedraw();
} }
} }
} }
if( m_mouseHover != previousHoverState if( this.mouseHover != previousHoverState
|| m_buttonPressed != previousPressed) { || this.buttonPressed != previousPressed) {
CheckStatus(); CheckStatus();
} }
return m_mouseHover; return this.mouseHover;
} }
bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) { boolean ewol::widget::CheckBox::onEventEntry( ewol::event::Entry _event) {
//Log.debug("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //Log.debug("BT PRESSED : \"" + UTF8_data + "\" size=" + strlen(UTF8_data));
if( _event.getType() == gale::key::keyboard::character if( _event.getType() == KeyKeyboard::character
&& _event.getStatus() == gale::key::status::down LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getStatus() == KeyStatus::down
&& _event.getChar() == '\r') { LOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOMLOM _event.getChar() == '\r') {
signalEnter.emit(); signalEnter.emit();
return true; return true;
} }
@ -168,49 +168,49 @@ bool ewol::widget::CheckBox::onEventEntry(const ewol::event::Entry& _event) {
} }
void ewol::widget::CheckBox::CheckStatus() { void ewol::widget::CheckBox::CheckStatus() {
if (m_shaper.setState(*propertyValue==true?1:0) == true) { if (this.shaper.setState(*propertyValue==true?1:0) == true) {
markToRedraw(); markToRedraw();
} }
if (m_buttonPressed == true) { if (this.buttonPressed == true) {
changeStatusIn(STATUS_PRESSED); changeStatusIn(STATUS_PRESSED);
return; return;
} }
if (m_mouseHover == true) { if (this.mouseHover == true) {
changeStatusIn(STATUS_HOVER); changeStatusIn(STATUS_HOVER);
return; return;
} }
changeStatusIn(STATUS_UP); changeStatusIn(STATUS_UP);
} }
void ewol::widget::CheckBox::changeStatusIn(int32_t _newStatusId) { void ewol::widget::CheckBox::changeStatusIn(int _newStatusId) {
if (m_shaper.changeStatusIn(_newStatusId) == true) { if (this.shaper.changeStatusIn(_newStatusId) == true) {
m_PCH = getObjectManager().periodicCall.connect(this, &ewol::widget::CheckBox::periodicCall); this.PCH = getObjectManager().periodicCall.connect(this, ewol::widget::CheckBox::periodicCall);
markToRedraw(); markToRedraw();
} }
} }
void ewol::widget::CheckBox::periodicCall(const ewol::event::Time& _event) { void ewol::widget::CheckBox::periodicCall( ewol::event::Time _event) {
if (m_shaper.periodicCall(_event) == false) { if (this.shaper.periodicCall(_event) == false) {
m_PCH.disconnect(); this.PCH.disconnect();
} }
markToRedraw(); markToRedraw();
} }
void ewol::widget::CheckBox::onChangePropertyShape() { void ewol::widget::CheckBox::onChangePropertyShape() {
m_shaper.setSource(*propertyShape); this.shaper.setSource(*propertyShape);
m_shaperIdSize = m_shaper.requestConfig("box-size"); this.shaperIdSize = this.shaper.requestConfig("box-size");
m_shaperIdSizeInsize = m_shaper.requestConfig("box-inside"); this.shaperIdSizeInsize = this.shaper.requestConfig("box-inside");
markToRedraw(); markToRedraw();
} }
void ewol::widget::CheckBox::onChangePropertyValue() { void ewol::widget::CheckBox::onChangePropertyValue() {
if (*propertyValue == false) { if (*propertyValue == false) {
m_idWidgetDisplayed = convertId(0); this.idWidgetDisplayed = convertId(0);
} else { } else {
m_idWidgetDisplayed = convertId(1); this.idWidgetDisplayed = convertId(1);
} }
CheckStatus(); CheckStatus();
markToRedraw(); markToRedraw();
m_shaper.setActivateState(*propertyValue==true?1:0); this.shaper.setActivateState(*propertyValue==true?1:0);
} }

Some files were not shown because too many files have changed in this diff Show More