+++ /dev/null
-The follwing images were drawn by Marina Proni <marina.proni@profusion.mobi>
-and are licensed under Creative Commons Attribution-ShareAlike 3.0
-Unported License:
-
- arrows.png
- background.jpg
- ball-blue70.png
- ball-blue.png
- ball-green70.png
- ball-green.png
- ball-red70.png
- ball-red.png
- bg_floor.jpg
- bt_jump.png
- bt_jump_pressed.png
- bt_restart.png
- bt_restart_pressed.png
- bt_shoot.png
- bt_shoot_pressed.png
- bt_stop.png
- bt_stop_pressed.png
- collisionL.png
- cube-blue.png
- cube-purple.png
- hexagon.png
- list-item-corner.png
- list-item-corner-pressed.png
- list-item.png
- list-item-pressed.png
- list.png
- pentagon.png
- shadow-ball.png
- shadow-cube.png
- spinner_base.png
- spinner_bt_left.png
- spinner_bt_left_pressed.png
- spinner_bt_right.png
- spinner_bt_right_pressed.png
- star.png
-
-===
-
-Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
-
-
-THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
-
-BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
-
-1. Definitions
-
- a. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
- b. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined below) for the purposes of this License.
- c. "Creative Commons Compatible License" means a license that is listed at http://creativecommons.org/compatiblelicenses that has been approved by Creative Commons as being essentially equivalent to this License, including, at a minimum, because that license: (i) contains terms that have the same purpose, meaning and effect as the License Elements of this License; and, (ii) explicitly permits the relicensing of adaptations of works made available under that license under this License or a Creative Commons jurisdiction license with the same License Elements as this License.
- d. "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
- e. "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike.
- f. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
- g. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
- h. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
- i. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
- j. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
- k. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
-
-2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
-
-3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
-
- a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
- b. to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
- c. to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
- d. to Distribute and Publicly Perform Adaptations.
-
- e. For the avoidance of doubt:
- i. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
- ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
- iii. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
-
-The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
-
-4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
-
- a. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested.
- b. You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License. If you license the Adaptation under one of the licenses mentioned in (iv), you must comply with the terms of that license. If you license the Adaptation under the terms of any of the licenses mentioned in (i), (ii) or (iii) (the "Applicable License"), you must comply with the terms of the Applicable License generally and the following provisions: (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform; (II) You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License; (III) You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform; (IV) when You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License.
- c. If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Ssection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
- d. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
-
-5. Representations, Warranties and Disclaimer
-
-UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
-
-6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-7. Termination
-
- a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
- b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
-
-8. Miscellaneous
-
- a. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
- b. Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
- c. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
- d. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
- e. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
- f. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
-
+++ /dev/null
-#define ADD_CIRCLE(_group, _file) \
- images { \
- image: #_file##".png" COMP; \
- } \
- group { \
- name: #_group; \
- parts { \
- part { \
- name: "ball"; \
- mouse_events: 0; \
- type: IMAGE; \
- description { \
- state: "default" 0.0; \
- image.normal: #_file##".png"; \
- } \
- } \
- } \
- }
-
-ADD_CIRCLE(blue-ball, ball-blue)
-ADD_CIRCLE(big-blue-ball, ball-blue70)
-ADD_CIRCLE(red-ball, ball-red)
-ADD_CIRCLE(big-red-ball, ball-red70)
-ADD_CIRCLE(green-ball, ball-green)
-ADD_CIRCLE(big-green-ball, ball-green70)
-
-ADD_CIRCLE(coin0, coin0)
-ADD_CIRCLE(coin1, coin1)
-
-#undef ADD_CIRCLE
+++ /dev/null
-#define BUTTON_GROUP(_name) \
- group { \
- name: "elm/button/base/ephysics-test-"#_name; \
- \
- images { \
- image: "bt_"##_name##".png" COMP; \
- image: "bt_"##_name##"_pressed.png" COMP; \
- } \
- \
- parts { \
- \
- part { \
- name: "blocker"; \
- type: RECT; \
- mouse_events: 1; \
- description { \
- state: "default" 0.0; \
- color: 255 255 255 0; \
- } \
- } \
- \
- part { \
- name: "base"; \
- type: IMAGE; \
- mouse_events: 0; \
- description { \
- state: "default" 0.0; \
- min: 80 28; \
- max: 80 28; \
- aspect: 1 1; \
- image.normal: "bt_"##_name##".png"; \
- } \
- description { \
- state: "pressed" 0.0; \
- inherit: "default" 0.0; \
- image.normal: "bt_"##_name##"_pressed.png"; \
- } \
- description { \
- state: "disabled" 0.0; \
- inherit: "default" 0.0; \
- color: 255 255 255 80; \
- } \
- } \
- \
- part { \
- name: "over"; \
- type: RECT; \
- mouse_events: 1; \
- ignore_flags: ON_HOLD; \
- description { \
- state: "default" 0.0; \
- color: 255 255 255 0; \
- } \
- description { \
- state: "disabled" 0.0; \
- inherit: "default" 0.0; \
- visible: 0; \
- } \
- } \
- \
- } \
- \
- programs { \
- \
- program { \
- name: "bt_click"; \
- source: "ephysics_test"; \
- signal: "click"; \
- in: 0.2 0; \
- action: STATE_SET "pressed" 0.0; \
- target: "base"; \
- after: "bt_click2"; \
- } \
- \
- program { \
- name: "bt_click2"; \
- in: 0.4 0; \
- action: STATE_SET "default" 0.0; \
- target: "base"; \
- after: "bt_clicked"; \
- } \
- \
- program { \
- name: "bt_clicked"; \
- source: "over"; \
- signal: "mouse,clicked,1"; \
- action: SIGNAL_EMIT "elm,action,click" ""; \
- } \
- \
- program { \
- name: "bt_pressed"; \
- source: "over"; \
- signal: "mouse,down,1"; \
- action: STATE_SET "pressed" 0.0; \
- target: "base"; \
- } \
- \
- program { \
- name: "bt_unpressed"; \
- source: "over"; \
- signal: "mouse,up,1"; \
- action: STATE_SET "default" 0.0; \
- target: "base"; \
- } \
- \
- program { \
- name: "disable"; \
- source: "elm"; \
- signal: "elm,state,disabled"; \
- action: STATE_SET "disabled" 0.0; \
- target: "base"; \
- target: "over"; \
- } \
- \
- program { \
- name: "enable"; \
- source: "elm"; \
- signal: "elm,state,enabled"; \
- action: STATE_SET "default" 0.0; \
- target: "base"; \
- target: "over"; \
- } \
- \
- } \
- \
- }
-
-BUTTON_GROUP(jump)
-BUTTON_GROUP(restart)
-BUTTON_GROUP(shoot)
-BUTTON_GROUP(stop)
-
-#undef BUTTON_GROUP
+++ /dev/null
-#define ADD_CUBE(_group, _file) \
- images { \
- image: #_file##".png" COMP; \
- } \
- group { \
- name: #_group; \
- parts { \
- part { \
- name: "cube"; \
- type: IMAGE; \
- mouse_events: 1; \
- repeat_events: 0; \
- description { \
- state: "default" 0.0; \
- image.normal: #_file##".png"; \
- } \
- } \
- } \
- }
-
-ADD_CUBE(blue-cube, cube-blue);
-ADD_CUBE(purple-cube, cube-purple);
-ADD_CUBE(purple-cube420, cube-purple420);
-ADD_CUBE(cube_top, cube_top);
-ADD_CUBE(cube_bottom, cube_bottom);
-ADD_CUBE(cube_front, cube_front);
-ADD_CUBE(cube_back, cube_back);
-ADD_CUBE(cube_right, cube_right);
-ADD_CUBE(cube_left, cube_left);
-
-ADD_CUBE(dice1, dice1);
-ADD_CUBE(dice2, dice2);
-ADD_CUBE(dice3, dice3);
-ADD_CUBE(dice4, dice4);
-ADD_CUBE(dice5, dice5);
-ADD_CUBE(dice6, dice6);
-
-#undef ADD_CUBE
+++ /dev/null
- images {
- image: "collisionL.png" COMP;
- }
-
- group {
- name: "impact";
-
- parts {
-
- part {
- name: "impact";
- mouse_events: 0;
- type: IMAGE;
- description {
- state: "default" 0.0;
- image.normal: "collisionL.png";
- color: 255 255 255 0;
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 255 255 255 255;
- }
- }
-
- }
-
- programs {
-
- program {
- name: "impact,show";
- source: "ephysics_test";
- signal: "impact,show";
- action: STATE_SET "visible" 0.0;
- transition: LINEAR 0.2;
- target: "impact";
- after: "impact,show2";
- }
-
- program {
- name: "impact,show2";
- action: STATE_SET "default" 0.0;
- transition: LINEAR 0.2;
- target: "impact";
- }
-
- }
-
- }
+++ /dev/null
-externals {
- external: "elm";
-}
-
-collections {
-#include "sandbox_misc.edc"
-}
+++ /dev/null
-externals {
- external: "elm";
-}
-
-collections {
-#include "balls.edc"
-#include "buttons.edc"
-#include "cubes.edc"
-#include "effects.edc"
-#include "frame.edc"
-#include "list.edc"
-#include "loading_bar.edc"
-#include "pages.edc"
-#include "shadows.edc"
-#include "shapes.edc"
-#include "spinner.edc"
-#include "toggle.edc"
-#include "others.edc"
-}
+++ /dev/null
- group {
- name: "floor";
-
- images {
- image: "bg_floor.jpg" COMP;
- }
-
- parts {
-
- part {
- name: "floor";
- type: IMAGE;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 750 224;
- image.normal: "bg_floor.jpg";
- }
- }
-
- }
-
- }
-
- group {
- name: "frame";
-
- images {
- image: "arrows.png" COMP;
- image: "background.jpg" COMP;
- }
-
- styles {
- style {
- name: "test_style";
- base: "font=Sans font_size=20 align=justify color=#c6b19a";
- tag: "br" "\n";
- tag: "tab" "\t";
- }
- }
-
- parts {
-
- part {
- name: "bg";
- type: RECT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 512 384;
- color: 153 134 117 255;
- }
- }
-
- part {
- name: "borders";
- type: IMAGE;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 512 384;
- image.normal: "background.jpg";
- visible: 0;
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- visible: 1;
- }
- }
-
- part {
- name: "arrows";
- type: IMAGE;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 326 241;
- max: 326 241;
- rel1.offset: -18 10;
- color: 255 255 255 0;
- image.normal: "arrows.png";
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 255 255 255 255;
- }
- }
-
- part {
- name: "arrows_msg";
- type: TEXT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- rel1.relative: 0.08 0.96;
- rel2.relative: 0.92 1.0;
- text {
- font: "Sans";
- size: 12;
- text: "Press the arrows on the keyboard to give "
- "impulse to the object.";
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 95 56 19 255;
- }
- }
-
- part {
- name: "controls_msg";
- type: TEXTBLOCK;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1.relative: 0.3 0.3;
- rel2.relative: 0.3 0.3;
- color: 0 0 0 0;
- text {
- style: "test_style";
- min: 1 1;
- max: 1 1;
- text: "Impulse Controls:<br>"
- " X Axis <tab> H - L<br>"
- " Y Axis <tab> J - K<br>"
- " Z Axis <tab> F - G";
- }
- }
- description {
- state: "msg1" 0.0;
- inherit: "default" 0.0;
- color: 95 56 19 255;
- }
- description {
- state: "msg2" 0.0;
- inherit: "msg1" 0.0;
- text.text: "Impulse Controls:<br>"
- " Pitch <tab> Y - O<br>"
- " Yaw <tab> U - I<br>"
- " Roll <tab> R - T";
- }
- }
-
- part {
- name: "grab_msg";
- type: TEXT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- rel1.relative: 0.08 0.96;
- rel2.relative: 0.92 1.0;
- text {
- font: "Sans";
- size: 12;
- text: "Drag a body to move it.";
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 95 56 19 255;
- }
- }
-
- part {
- name: "light_msg";
- type: TEXT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- rel1.relative: 0.08 0.96;
- rel2.relative: 0.92 1.0;
- text {
- font: "Sans";
- size: 12;
- text: "Press x to turn lights on/off.";
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 95 56 19 255;
- }
- }
-
- part {
- name: "linear_vel";
- type: TEXT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- rel1.relative: 0.08 0.40;
- rel2.relative: 0.92 0.44;
- text {
- font: "Sans";
- size: 12;
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 198 177 153 255;
- }
- }
-
- part {
- name: "linear_acc";
- type: TEXT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- rel1.relative: 0.08 0.44;
- rel2.relative: 0.92 0.48;
- text {
- font: "Sans";
- size: 12;
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 198 177 153 255;
- }
- }
-
- part {
- name: "angular_vel";
- type: TEXT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- rel1.relative: 0.08 0.54;
- rel2.relative: 0.92 0.58;
- text {
- font: "Sans";
- size: 12;
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 198 177 153 255;
- }
- }
-
- part {
- name: "angular_acc";
- type: TEXT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- rel1.relative: 0.08 0.58;
- rel2.relative: 0.92 0.62;
- text {
- font: "Sans";
- size: 12;
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- color: 198 177 153 255;
- }
- }
-
- part {
- name: "restart_button";
- type: EXTERNAL;
- source: "elm/button";
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1.relative: 1 0.08;
- rel2.relative: 1 0.08;
- fixed: 1 1;
- align: 1 0.5;
- params {
- string: "style" "ephysics-test-restart";
- }
- }
- }
-
- part {
- name: "extra_button";
- type: SWALLOW;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1.relative: 0 0.08;
- rel2.relative: 0 0.08;
- fixed: 1 1;
- align: 0 0.5;
- }
- }
-
- part {
- name: "extra_input";
- type: SWALLOW;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- rel1.relative: 0.5 0.08;
- rel2.relative: 0.5 0.08;
- fixed: 1 1;
- align: 0.5 0.5;
- }
- }
-
- part {
- name: "loading_bar";
- type: GROUP;
- source: "loading_bar";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- align: 0.5 1;
- visible: 0;
- rel2.offset: -1 -5;
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- visible: 1;
- }
- }
-
- }
-
- programs {
-
- program {
- name: "restart_clicked";
- source: "restart_button";
- signal: "clicked";
- action: SIGNAL_EMIT "restart" "test-theme";
- }
-
- program {
- name: "arrows,show";
- source: "ephysics_test";
- signal: "arrows,show";
- action: STATE_SET "visible" 0.0;
- target: "arrows";
- target: "arrows_msg";
- }
-
- program {
- name: "controls,show";
- source: "ephysics_test";
- signal: "controls,show";
- action: STATE_SET "msg1" 0.0;
- target: "controls_msg";
- after: "controls,show,2";
- }
-
- program {
- name: "controls,show,2";
- in: 4 0;
- action: STATE_SET "msg2" 0.0;
- target: "controls_msg";
- after: "controls,show,3";
- }
-
- program {
- name: "controls,show,3";
- in: 4 0;
- action: STATE_SET "msg1" 0.0;
- target: "controls_msg";
- after: "controls,show,2";
- }
-
- program {
- name: "grab,show";
- source: "ephysics_test";
- signal: "grab,show";
- action: STATE_SET "visible" 0.0;
- target: "arrows";
- target: "grab_msg";
- }
-
- program {
- name: "light,show";
- source: "ephysics_test";
- signal: "light,show";
- action: STATE_SET "visible" 0.0;
- target: "light_msg";
- }
-
- program {
- name: "borders,show";
- source: "ephysics_test";
- signal: "borders,show";
- action: STATE_SET "visible" 0.0;
- target: "borders";
- }
-
- program {
- name: "velocity,show";
- source: "ephysics_test";
- signal: "velocity,show";
- action: STATE_SET "visible" 0.0;
- target: "linear_vel";
- target: "linear_acc";
- target: "angular_vel";
- target: "angular_acc";
- }
-
- program {
- name: "loading_bar,show";
- source: "ephysics_test";
- signal: "loading_bar,show";
- action: STATE_SET "visible" 0.0;
- target: "loading_bar";
- }
-
- }
-
- }
+++ /dev/null
- images {
- image: "list-item-corner-pressed.png" COMP;
- image: "list-item-corner.png" COMP;
- image: "list-item-pressed.png" COMP;
- image: "list-item.png" COMP;
- }
-
- group {
- name: "elm/list/base/ephysics-test";
-
- parts {
-
- part {
- name: "bg";
- type: RECT;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- color: 179 149 117 255;
- }
- }
-
- part {
- name: "elm.swallow.content";
- type: SWALLOW;
- description {
- state: "default" 0.0;
- rel1.offset: 0 40;
- rel2.offset: -1 -41;
- }
- }
-
- part {
- name: "sb_vbar";
- type: RECT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- fixed: 1 1;
- visible: 0;
- min: 10 17;
- align: 1.0 0.0;
- rel1 {
- relative: 1.0 0.0;
- to_y: "elm.swallow.content";
- to_x: "elm.swallow.content";
- }
- rel2 {
- relative: 1.0 1.0;
- to_x: "elm.swallow.content";
- to_y: "elm.swallow.content";
- }
- }
- }
-
- part {
- name: "elm.dragable.vbar";
- type: RECT;
- mouse_events: 1;
- dragable {
- x: 0 0 0;
- y: 1 1 0;
- confine: "sb_vbar";
- }
- description {
- state: "default" 0.0;
- fixed: 1 1;
- min: 8 15;
- max: 8 99999;
- color: 139 97 57 255;
- rel1 {
- relative: 0.5 0.5;
- offset: 0 0;
- to: "sb_vbar";
- }
- rel2 {
- relative: 0.5 0.5;
- offset: 0 0;
- to: "sb_vbar";
- }
- }
- }
-
- }
-
- }
-
- group {
- name: "elm/list/item/ephysics-test";
- alias: "elm/list/item_odd/ephysics-test";
-
- parts {
-
- part {
- name: "event";
- type: RECT;
- repeat_events: 1;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- }
- }
-
- part {
- name: "base";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 8 60;
- rel2.relative: 0.8 1;
- image.normal: "list-item.png";
- }
- description {
- state: "selected" 0.0;
- inherit: "default" 0.0;
- image.normal: "list-item-pressed.png";
- }
- }
-
- part {
- name: "base-corner";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 42 60;
- max: 42 60;
- rel1 {
- to: "base";
- relative: 1 0;
- }
- align: 0 0.5;
- image.normal: "list-item-corner.png";
- }
- description {
- state: "selected" 0.0;
- inherit: "default" 0.0;
- image.normal: "list-item-corner-pressed.png";
- }
- }
-
- part {
- name: "elm.text";
- type: TEXT;
- mouse_events: 0;
- scale: 1;
- description {
- state: "default" 0.0;
- color: 232 224 215 255;
- text {
- font: "Sans";
- style: "Bold";
- size: 18;
- min: 1 1;
- align: 0 0.5;
- }
- align: 0 0.5;
- rel1.offset: 36 0;
- }
- }
-
- }
-
- programs {
-
- program {
- name: "go_active";
- source: "elm";
- signal: "elm,state,selected";
- action: STATE_SET "selected" 0.0;
- target: "base";
- target: "base-corner";
- }
-
- program {
- name: "go_passive";
- source: "elm";
- signal: "elm,state,unselected";
- action: STATE_SET "default" 0.0;
- target: "base";
- target: "base-corner";
- }
-
- }
-
- }
+++ /dev/null
- group {
- name: "loading_bar";
- min: 440 16;
- max: 440 16;
-
- images {
- image: "loading_bar.png" COMP;
- image: "loading_knob.png" COMP;
- }
-
- parts {
-
- part {
- name: "bar";
- type: IMAGE;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 440 8;
- max: 440 8;
- image.normal: "loading_bar.png";
- }
- }
-
- part {
- name: "knob";
- type: IMAGE;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 56 16;
- max: 56 16;
- rel1.to: "bar";
- rel2.to: "bar";
- align: 0 0.5;
- image.normal: "loading_knob.png";
- }
- description {
- state: "end" 0.0;
- inherit: "default" 0.0;
- align: 1 0.5;
- }
- }
-
- }
-
- programs {
-
- program {
- name: "loading_bar,show";
- source: "ephysics_test";
- signal: "loading_bar,show";
- action: STATE_SET "end" 0.0;
- transition: LINEAR 1.5;
- target: "knob";
- after: "knob,restart";
- }
-
- program {
- name: "knob,restart";
- action: STATE_SET "default" 0.0;
- transition: LINEAR 1.5;
- target: "knob";
- after: "loading_bar,show";
- }
-
- }
-
- }
+++ /dev/null
- images {
- image: "green-flag.png" COMP;
- image: "brown-pole.png" COMP;
- image: "door-front.png" COMP;
- image: "door-back.png" COMP;
- image: "door-post.png" COMP;
- }
-
- group {
- name: "green-flag";
-
- parts {
-
- part {
- name: "flag";
- mouse_events: 1;
- repeat_events: 0;
- type: IMAGE;
- description {
- state: "default" 0.0;
- image.normal: "green-flag.png";
- }
- }
-
- }
-
- }
-
- group {
- name: "brown-pole";
-
- parts {
-
- part {
- name: "pole";
- mouse_events: 0;
- type: IMAGE;
- description {
- state: "default" 0.0;
- image.normal: "brown-pole.png";
- }
- }
-
- }
-
- }
-
- group {
- name: "door-front";
-
- parts {
-
- part {
- name: "door-front";
- mouse_events: 0;
- type: IMAGE;
- description {
- state: "default" 0.0;
- image.normal: "door-front.png";
- }
- }
-
- }
-
- }
-
- group {
- name: "door-back";
-
- parts {
-
- part {
- name: "door-back";
- mouse_events: 0;
- type: IMAGE;
- description {
- state: "default" 0.0;
- image.normal: "door-back.png";
- }
- }
-
- }
-
- }
-
- group {
- name: "door-post";
-
- parts {
-
- part {
- name: "door-post";
- mouse_events: 0;
- type: IMAGE;
- description {
- state: "default" 0.0;
- image.normal: "door-post.png";
- }
- }
-
- }
-
- }
\ No newline at end of file
+++ /dev/null
-#define PAGE_GROUP(_name) \
- group { \
- name: "page-"##_name##""; \
- images { \
- image: "page_"##_name##".png" COMP; \
- } \
-\
- parts { \
-\
- part { \
- name: "page"; \
- mouse_events: 1; \
- repeat_events: 1; \
- type: IMAGE; \
- description { \
- state: "default" 0.0; \
- image.normal: "page_"##_name##".png"; \
- } \
- } \
-\
- } \
-\
- } \
-
-PAGE_GROUP(00)
-PAGE_GROUP(01)
-PAGE_GROUP(02)
-PAGE_GROUP(03)
-
-#undef PAGE_GROUP
\ No newline at end of file
+++ /dev/null
- group {
- name: "sandbox";
- min: 1280 720;
- max: 1280 720;
-
- externals {
- external: "elm";
- }
-
- images{
- image: "background.jpg" COMP;
- }
-
- parts {
- part {
- name: "bg";
- type: EXTERNAL;
- source: "elm/bg";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1.relative: 0.7 0;
- rel2.relative: 1 1;
- fixed: 1 1;
- align: 1 0.5;
- }
- }
- part {
- name: "bg_world";
- type: IMAGE;
- description {
- state: "default" 0.0;
- rel1.relative: 0.0 0.0;
- rel2.relative: 0.7 1.0;
- fixed: 1 1;
- image.normal: "background.jpg";
- }
- }
- part {
- name: "swallow";
- type: SWALLOW;
- description {
- state: "default" 0;
- rel1.relative: 0.7 0;
- rel2.relative: 1 1;
- fixed: 1 1;
- }
- }
- }
- }
-
-#define SANDBOX_BALL_ADD(_name, _img) \
- images { \
- image: #_img##".png" COMP; \
- } \
- group { \
- name: #_name; \
- parts { \
- part { \
- name: "ball"; \
- mouse_events: 0; \
- type: IMAGE; \
- description { \
- state: "default" 0.0; \
- image.normal: #_img##".png"; \
- } \
- } \
- } \
- }
-
-SANDBOX_BALL_ADD(Custom, ball-red70)
-SANDBOX_BALL_ADD(Concrete, ball-concrete)
-SANDBOX_BALL_ADD(Iron, ball-iron)
-SANDBOX_BALL_ADD(Plastic, ball-plastic)
-SANDBOX_BALL_ADD(Polystyrene, ball-polystyrene)
-SANDBOX_BALL_ADD(Rubber, ball-rubber)
-SANDBOX_BALL_ADD(Wood, ball-wood)
-
-#undef SANDBOX_BALL_ADD
+++ /dev/null
-#define SHADOW_ALPHA_ID 1
-
- images {
- image: "shadow-ball.png" COMP;
- image: "shadow-cube.png" COMP;
- }
-
-#define SHADOW_GROUP(_name) \
- group { \
- name: #_name; \
- \
- script { \
- public message(Msg_Type:type, id, ...) \
- { \
- if ((type == MSG_FLOAT) && (id == SHADOW_ALPHA_ID)) \
- { \
- new Float:shadow_alpha = getfarg(2); \
- set_tween_state(PART:"shadow", shadow_alpha, "default", 0.0, \
- "visible", 0.0); \
- } \
- } \
- } \
- \
- parts { \
- \
- part { \
- name: "shadow"; \
- mouse_events: 0; \
- type: IMAGE; \
- description { \
- state: "default" 0.0; \
- image.normal: _name##".png"; \
- color: 255 255 255 0; \
- } \
- description { \
- state: "visible" 0.0; \
- inherit: "default" 0.0; \
- color: 255 255 255 255; \
- } \
- } \
- } \
- \
- }
-
-SHADOW_GROUP(shadow-ball)
-SHADOW_GROUP(shadow-cube)
-
-#undef SHADOW_GROUP
-#undef SHADOW_ALPHA_ID
+++ /dev/null
-#define ADD_SHAPE(_name) \
- images { \
- image: #_name##".png" COMP; \
- } \
- group { \
- name: #_name; \
- parts { \
- part { \
- name: #_name; \
- mouse_events: 0; \
- type: IMAGE; \
- description { \
- state: "default" 0.0; \
- image.normal: #_name##".png"; \
- } \
- } \
- } \
- }
-
-ADD_SHAPE(hexagon)
-ADD_SHAPE(pentagon)
-ADD_SHAPE(star)
-
-#undef ADD_SHAPE
+++ /dev/null
-group {
- name: "elm/spinner/base/ephysics-test";
-
- images {
- image: "spinner_bt_left.png" COMP;
- image: "spinner_bt_left_pressed.png" COMP;
- image: "spinner_bt_right.png" COMP;
- image: "spinner_bt_right_pressed.png" COMP;
- image: "spinner_base.png" COMP;
- }
-
- parts {
-
- part {
- name: "blocker";
- type: RECT;
- mouse_events: 1;
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- }
- }
-
- part {
- name: "base";
- type: IMAGE;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- min: 140 28;
- max: 1000 28;
- rel1.offset: 30 0;
- rel2.offset: -31 -1;
- image.normal: "spinner_base.png";
- }
- }
-
- part {
- name: "left_bt";
- mouse_events: 1;
- description {
- state: "default" 0.0;
- min: 30 28;
- max: 30 28;
- rel1.to_y: "base";
- rel2 {
- to: "base";
- relative: 0 1;
- }
- image.normal: "spinner_bt_left.png";
- }
- description {
- state: "clicked" 0.0;
- inherit: "default" 0.0;
- image.normal: "spinner_bt_left_pressed.png";
- }
- }
-
- part {
- name: "right_bt";
- mouse_events: 1;
- description {
- state: "default" 0.0;
- min: 30 28;
- max: 30 28;
- rel1 {
- to: "base";
- relative: 1 0;
- }
- rel2.to_y: "base";
- image.normal: "spinner_bt_right.png";
- }
- description {
- state: "clicked" 0.0;
- inherit: "default" 0.0;
- image.normal: "spinner_bt_right_pressed.png";
- }
- }
-
- part {
- name: "elm.text";
- type: TEXT;
- mouse_events: 0;
- description { state: "default" 0.0;
- visible: 1;
- color: 223 215 208 255;
- rel1.to: "base";
- rel2.to: "base";
- text {
- font: "Arial";
- style: "Bold";
- size: 12;
- align: 0.5 0.5;
- }
- }
- }
-
- part {
- name: "elm.dragable.slider";
- type: RECT;
- mouse_events: 0;
- scale: 1;
-
- dragable {
- x: 1 1 0;
- y: 0 0 0;
- }
-
- description {
- state: "default" 0.0;
- rel1.to: "blocker";
- rel2.to: "blocker";
- color: 0 0 0 0;
- }
- }
-
- part {
- name: "elm.swallow.entry";
- type: SWALLOW;
- description {
- state: "default" 0.0;
- visible: 0;
- align: 0.5 0.5;
- rel1 { relative: 1.0 0.5;
- offset: 3 2;
- to_x: "left_bt";
- to_y: "base";
- }
- rel2 { relative: 0.0 0.5;
- offset: -3 -2;
- to_x: "right_bt";
- to_y: "base";
- }
- fixed: 1 1;
- color: 0 0 0 0;
- }
- }
- }
-
- programs {
-
- program {
- name: "left_bt_clicked";
- signal: "mouse,down,1";
- source: "left_bt";
- action: STATE_SET "clicked" 0.0;
- target: "left_bt";
- after: "left_bt_clicked_emit";
- }
-
- program {
- name: "left_bt_clicked_emit";
- action: SIGNAL_EMIT "elm,action,decrement,start" "";
- }
-
- program {
- name: "left_bt_unclicked";
- signal: "mouse,up,1";
- source: "left_bt";
- action: STATE_SET "default" 0.0;
- target: "left_bt";
- after: "left_bt_unclicked_emit";
- }
-
- program {
- name: "left_bt_unclicked_emit";
- action: SIGNAL_EMIT "elm,action,decrement,stop" "";
- }
-
- program {
- name: "right_bt_clicked";
- signal: "mouse,down,1";
- source: "right_bt";
- action: STATE_SET "clicked" 0.0;
- target: "right_bt";
- after: "right_bt_clicked_emit";
- }
-
- program {
- name: "right_bt_clicked_emit";
- action: SIGNAL_EMIT "elm,action,increment,start" "";
- }
-
- program {
- name: "right_bt_unclicked";
- signal: "mouse,up,1";
- source: "right_bt";
- action: STATE_SET "default" 0.0;
- target: "right_bt";
- after: "right_bt_unclicked_emit";
- }
-
- program {
- name: "right_bt_unclicked_emit";
- action: SIGNAL_EMIT "elm,action,increment,stop" "";
- }
-
- }
-
-}
+++ /dev/null
-group {
- name: "elm/check/base/ephysics-test";
-
- images {
- image: "tog_base_on.png" COMP;
- image: "tog_base_off.png" COMP;
- image: "tog_bt_on.png" COMP;
- image: "tog_bt_off.png" COMP;
- }
-
- script {
- public is_rtl;
- public is_drag;
- public was_drag;
- }
-
- parts {
-
- part { name: "bg";
- type: RECT;
- mouse_events: 0;
- scale: 1;
- description { state: "default" 0.0;
- fixed: 1 0;
- rel1.relative: 1.0 0.0;
- rel1.offset: -4 3;
- rel2.offset: -4 -4;
- align: 1.0 0.5;
- min: 100 26;
- max: 100 26;
- visible: 0;
- }
- }
-
- part {
- name: "clipper";
- type: RECT;
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1.to: "bg";
- rel2.to: "bg";
- color: 255 255 255 255;
- }
- }
-
- part {
- name: "button";
- type: RECT;
- scale: 1;
- clip_to: "clipper";
- mouse_events: 1;
- dragable {
- x: 1 1 0;
- y: 0 0 0;
- confine: "bg";
- }
- description {
- state: "default" 0.0;
- fixed: 1 1;
- rel1.to: "bg";
- rel2.to: "bg";
- min: 28 24;
- max: 28 24;
- aspect: 1.0 1.0;
- aspect_preference: VERTICAL;
- color: 0 0 0 0;
- }
- }
-
- part {
- name: "button_events";
- type: RECT;
- dragable {
- events: "button";
- }
- description {
- state: "default" 0.0;
- color: 0 0 0 0;
- }
- }
-
- part {
- name: "onrect";
- type: IMAGE;
- scale: 1;
- clip_to: "clipper";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1.to: "button";
- rel1.relative: 1.0 0.0;
- rel2.to: "button";
- rel2.relative: 1.0 1.0;
- fixed: 1 1;
- align: 1 0.5;
- min: 100 26;
- max: 100 26;
- image.normal: "tog_base_on.png";
- }
- }
-
- part {
- name: "offrect";
- type: IMAGE;
- scale: 1;
- clip_to: "clipper";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1.to: "button";
- rel1.relative: 0 0.0;
- rel2.to: "button";
- rel2.relative: 0 1.0;
- fixed: 1 1;
- align: 0 0.5;
- min: 100 26;
- max: 100 26;
- image.normal: "tog_base_off.png";
- }
- }
-
- part {
- name: "button0";
- type: IMAGE;
- clip_to: "clipper";
- mouse_events: 0;
- description {
- state: "default" 0.0;
- rel1.to: "button";
- rel2.to: "button";
- image.normal: "tog_bt_on.png";
- }
- description {
- state: "on" 0.0;
- inherit: "default" 0.0;
- }
- description {
- state: "off" 0.0;
- inherit: "default" 0.0;
- image.normal: "tog_bt_off.png";
- }
- }
-
- part {
- name: "elm.offtext";
- type: TEXT;
- mouse_events: 0;
- scale: 1;
- clip_to: "clipper";
- description {
- state: "default" 0.0;
- fixed: 1 1;
- rel1.to_x: "button";
- rel1.relative: 1.0 0.0;
- rel2.to_x: "offrect";
- color: 0 0 0 255;
- text {
- font: "Sans,Edje-Vera";
- size: 10;
- min: 0 1;
- align: 0.5 0.5;
- }
- }
- }
-
- part {
- name: "elm.ontext";
- type: TEXT;
- effect: SOFT_SHADOW;
- mouse_events: 0;
- scale: 1;
- clip_to: "clipper";
- description {
- state: "default" 0.0;
- fixed: 1 1;
- rel1.to_x: "onrect";
- rel1.offset: 1 1;
- rel2.to_x: "button";
- rel2.offset: 0 0;
- rel2.relative: 0.0 1.0;
- color: 224 224 224 255;
- color3: 0 0 0 64;
- text {
- font: "Sans,Edje-Vera";
- size: 10;
- min: 0 1;
- align: 0.5 0.5;
- }
- }
- }
-
- part {
- name: "elm.swallow.content";
- type: SWALLOW;
- description {
- state: "default" 0.0;
- fixed: 1 0;
- visible: 0;
- align: 0.0 0.5;
- rel1.offset: 4 4;
- rel2.relative: 0.0 1.0;
- rel2.offset: 3 -5;
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- visible: 1;
- aspect: 1.0 1.0;
- rel2.offset: 4 -5;
- }
- }
-
- part {
- name: "elm.text";
- type: TEXT;
- mouse_events: 0;
- scale: 1;
- description {
- state: "default" 0.0;
- visible: 0;
- rel1.to_x: "elm.swallow.content";
- rel1.relative: 1.0 0.0;
- rel1.offset: 0 4;
- rel2.to_x: "bg";
- rel2.relative: 0.0 1.0;
- rel2.offset: -7 -5;
- color: 0 0 0 255;
- text {
- font: "Sans,Edje-Vera";
- size: 10;
- min: 0 0;
- align: 0.0 0.5;
- }
- }
- description {
- state: "visible" 0.0;
- inherit: "default" 0.0;
- visible: 1;
- text.min: 1 1;
- }
- }
-
- }
-
- programs {
-
- program {
- signal: "mouse,clicked,1";
- source: "button";
- script {
- new Float:dx, Float:dy;
- get_drag(PART:"button", dx, dy);
-
- if (!get_int(was_drag)) {
- if (dx > 0.5)
- set_drag(PART:"button", 0.0, 0.0);
- else
- set_drag(PART:"button", 1.0, 0.0);
- if (((get_int(is_rtl) == 1) && (dx <= 0.5)) ||
- (get_int(is_rtl) == 0) && (dx > 0.5))
- emit("elm,action,check,off", "");
- else
- emit("elm,action,check,on", "");
- }
- }
- }
-
- program {
- signal: "drag";
- source: "button";
- script {
- set_int(is_drag, 1);
- }
- }
-
- program {
- signal: "mouse,down,1";
- source: "button";
- script {
- set_int(was_drag, 0);
- set_int(is_drag, 0);
- }
- }
-
- program {
- name: "drag_end";
- signal: "mouse,up,1";
- source: "button";
- script {
- new Float:dx, Float:dy;
- get_drag(PART:"button", dx, dy);
- if (dx > 0.5)
- {
- set_drag(PART:"button", 1.0, 0.0);
- }
- else
- {
- set_drag(PART:"button", 0.0, 0.0);
- }
- if (((get_int(is_rtl) == 1) && (dx <= 0.5)) ||
- (get_int(is_rtl) == 0) && (dx > 0.5)) {
- emit("elm,action,check,on", "");
- }
- else {
- emit("elm,action,check,off", "");
- }
- set_int(was_drag, get_int(is_drag));
- set_int(is_drag, 0);
- }
- }
-
- program {
- name: "check_on";
- signal: "elm,state,check,on";
- source: "elm";
- script {
- new Float:drag;
- if (get_int(is_rtl) == 0) {
- drag = 100.0;
- }
- else {
- drag = 0.0;
- }
- set_drag(PART:"button", drag, 0.0);
- set_state(PART:"button0", "on", 0.0);
- }
- }
-
- program {
- name: "check_off";
- signal: "elm,state,check,off";
- source: "elm";
- script {
- new Float:drag;
- if (get_int(is_rtl) == 0) {
- drag = 0.0;
- }
- else {
- drag = 100.0;
- }
- set_drag(PART:"button", drag, 0.0);
- set_state(PART:"button0", "off", 0.0);
- }
- }
-
- program {
- name: "text_show";
- signal: "elm,state,text,visible";
- source: "elm";
- action: STATE_SET "visible" 0.0;
- target: "elm.text";
- }
-
- program {
- name: "text_hide";
- signal: "elm,state,text,hidden";
- source: "elm";
- action: STATE_SET "default" 0.0;
- target: "elm.text";
- }
-
- program {
- name: "icon_show";
- signal: "elm,state,icon,visible";
- source: "elm";
- action: STATE_SET "visible" 0.0;
- target: "elm.swallow.content";
- }
-
- program {
- name: "icon_hide";
- signal: "elm,state,icon,hidden";
- source: "elm";
- action: STATE_SET "default" 0.0;
- target: "elm.swallow.content";
- }
-
- program {
- name: "to_rtl";
- signal: "edje,state,rtl";
- source: "edje";
- script {
- set_int(is_rtl, 1);
- }
- }
-
- program {
- name: "to_ltr";
- signal: "edje,state,ltr";
- source: "edje";
- script {
- set_int(is_rtl, 0);
- }
- }
-
- }
-
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include<stdio.h>
-#include<string.h>
-#include<Eina.h>
-#include<Elementary.h>
-#include<EPhysics.h>
-
-#define SANDBOX_THEME "ephysics_sandbox"
-#define WIDTH (1280)
-#define HEIGHT (720)
-#define DEPTH (100)
-#define INITIAL_MASS (15)
-
-static const char *materials[] =
-{
- "Custom", "Concrete", "Iron", "Plastic", "Polystyrene", "Rubber", "Wood"
-};
-
-typedef struct _World_Data World_Data;
-typedef struct _Body_Data Body_Data;
-
-struct _World_Data {
- EPhysics_Body *top, *bottom, *left, *right;
- Evas_Object *win, *tb, *nf;
- EPhysics_World *world;
- Body_Data *bd1, *bd2;
-};
-
-struct _Body_Data {
- World_Data *wd;
- EPhysics_Body *body;
- struct {
- struct {
- Evas_Object *x, *y, *relx, *rely;
- }impulse;
- struct {
- Evas_Object *x, *y, *relx, *rely, *torque;
- }force;
- struct {
- Evas_Object *x, *y, *angular;
- }velocity;
- Evas_Object *hardness;
- }controls;
-};
-
-
-/*** Sandbox Callbacks ***/
-static void
-_body_del(void *data __UNUSED__, EPhysics_Body *body __UNUSED__,
- void *event_info)
-{
- if (event_info) evas_object_del(event_info);
-}
-
-static void
-_world_gravity_x_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- double gravity_y, gravity_z;
-
- ephysics_world_gravity_get(world, NULL, &gravity_y, &gravity_z);
- ephysics_world_gravity_set(world, elm_slider_value_get(obj), gravity_y,
- gravity_z);
-}
-
-static void
-_world_gravity_y_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- double gravity_x, gravity_z;
-
- ephysics_world_gravity_get(world, &gravity_x, NULL, &gravity_z);
- ephysics_world_gravity_set(world, gravity_x, elm_slider_value_get(obj),
- gravity_z);
-}
-
-static void
-_world_rate_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- ephysics_world_rate_set(world, elm_slider_value_get(obj));
-}
-
-static void
-_world_max_sleeping_time_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- ephysics_world_max_sleeping_time_set(world, elm_slider_value_get(obj));
-}
-
-static void
-_world_friction_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- World_Data *wd = data;
- ephysics_body_friction_set(wd->top, elm_slider_value_get(obj));
- ephysics_body_friction_set(wd->bottom, elm_slider_value_get(obj));
- ephysics_body_friction_set(wd->left, elm_slider_value_get(obj));
- ephysics_body_friction_set(wd->right, elm_slider_value_get(obj));
-}
-
-static void
-_world_restitution_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- World_Data *wd = data;
- ephysics_body_restitution_set(wd->top, elm_slider_value_get(obj));
- ephysics_body_restitution_set(wd->bottom, elm_slider_value_get(obj));
- ephysics_body_restitution_set(wd->left, elm_slider_value_get(obj));
- ephysics_body_restitution_set(wd->right, elm_slider_value_get(obj));
-}
-
-static void
-_type_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- double mass, friction, restitution, lin_damping, ang_damping;
- double lin_sleeping, ang_sleeping;
- EPhysics_Body_Material material;
- EPhysics_Quaternion rotation;
- Evas_Object *body_image;
- EPhysics_World *world;
- Body_Data *bd = data;
- EPhysics_Body *body = bd->body;
-
- mass = ephysics_body_mass_get(body);
- ephysics_body_rotation_get(body, &rotation);
- friction = ephysics_body_friction_get(body);
- restitution = ephysics_body_restitution_get(body);
- ephysics_body_damping_get(body, &lin_damping, &ang_damping);
- ephysics_body_sleeping_threshold_get(body, &lin_sleeping, &ang_sleeping);
- material = ephysics_body_material_get(body);
-
- world = ephysics_body_world_get(body);
- body_image = ephysics_body_evas_object_unset(body);
-
- ephysics_body_del(body);
-
- if (elm_radio_value_get(obj))
- {
- body = ephysics_body_soft_cylinder_add(world);
- ephysics_body_soft_body_hardness_set(
- body, elm_slider_value_get(bd->controls.hardness));
- elm_object_disabled_set(bd->controls.hardness, EINA_FALSE);
- }
- else
- {
- body = ephysics_body_sphere_add(world);
- elm_object_disabled_set(bd->controls.hardness, EINA_TRUE);
- }
-
- ephysics_body_evas_object_set(body, body_image, EINA_TRUE);
- ephysics_body_mass_set(body, mass);
- ephysics_body_rotation_set(body, &rotation);
- ephysics_body_friction_set(body, friction);
- ephysics_body_restitution_set(body, restitution);
- ephysics_body_damping_set(body, lin_damping, ang_damping);
- ephysics_body_sleeping_threshold_set(body, lin_sleeping, ang_sleeping);
- ephysics_body_material_set(body, material);
-
- ephysics_body_force_apply(body,
- elm_slider_value_get(bd->controls.force.x),
- elm_slider_value_get(bd->controls.force.y), 0,
- elm_slider_value_get(bd->controls.force.relx),
- elm_slider_value_get(bd->controls.force.rely), 0);
- ephysics_body_torque_apply(body, 0, 0,
- elm_slider_value_get(bd->controls.force.torque));
-
- bd->body = body;
-}
-
-static void
-_material_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = evas_object_data_get(obj, "bd");
- Evas_Object *win = bd->wd->win;
- EPhysics_Body *body = bd->body;
- EPhysics_Body_Material material = (EPhysics_Body_Material) data;
- Evas_Object *body_image;
- int x, y, w, h;
-
- elm_object_text_set(obj, materials[material]);
- ephysics_body_material_set(body, material);
-
- elm_slider_value_set(evas_object_data_get(obj, "mass"),
- ephysics_body_mass_get(body));
- elm_slider_value_set(evas_object_data_get(obj, "density"),
- ephysics_body_density_get(body));
- elm_slider_value_set(evas_object_data_get(obj, "friction"),
- ephysics_body_friction_get(body));
- elm_slider_value_set(evas_object_data_get(obj, "restitution"),
- ephysics_body_restitution_get(body));
-
- body_image = ephysics_body_evas_object_unset(body);
- evas_object_geometry_get(body_image, &x, &y, &w, &h);
- evas_object_del(body_image);
-
- body_image = elm_image_add(win);
- elm_image_file_set(
- body_image, PACKAGE_DATA_DIR "/" SANDBOX_THEME ".edj",
- materials[material]);
- evas_object_resize(body_image, w, h);
- evas_object_move(body_image, x, y);
- evas_object_show(body_image);
- ephysics_body_evas_object_set(body, body_image, EINA_FALSE);
-}
-
-static void
-_mass_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- double mass = elm_slider_value_get(obj);
- ephysics_body_mass_set(bd->body, mass);
- elm_slider_value_set(evas_object_data_get(obj, "density"),
- mass / ephysics_body_volume_get(bd->body));
-}
-
-static void
-_density_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- ephysics_body_density_set(bd->body, elm_slider_value_get(obj));
- elm_slider_value_set(evas_object_data_get(obj, "mass"),
- ephysics_body_mass_get(bd->body));
-}
-
-static void
-_rotation_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_Quaternion quat;
- Body_Data *bd = data;
- ephysics_quaternion_euler_set(&quat, 0, 0, elm_slider_value_get(obj));
- ephysics_body_rotation_set(bd->body, &quat);
-}
-
-static void
-_friction_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- ephysics_body_friction_set(bd->body, elm_slider_value_get(obj));
-}
-
-static void
-_restitution_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- ephysics_body_restitution_set(bd->body, elm_slider_value_get(obj));
-}
-
-static void
-_linear_damping_set_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- double ang_damping;
- ephysics_body_damping_get(bd->body, NULL, &ang_damping);
- ephysics_body_damping_set(bd->body, elm_slider_value_get(obj), ang_damping);
-}
-
-static void
-_angular_damping_set_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- double lin_damping;
- ephysics_body_damping_get(bd->body, &lin_damping, NULL);
- ephysics_body_damping_set(bd->body, lin_damping, elm_slider_value_get(obj));
-}
-
-static void
-_lin_sleeping_threshold_set_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- double ang_sleeping;
- ephysics_body_sleeping_threshold_get(bd->body, NULL, &ang_sleeping);
- ephysics_body_sleeping_threshold_set(bd->body, elm_slider_value_get(obj),
- ang_sleeping);
-}
-
-static void
-_ang_sleeping_threshold_set_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- double lin_sleeping;
- ephysics_body_sleeping_threshold_get(bd->body, &lin_sleeping, NULL);
- ephysics_body_sleeping_threshold_set(bd->body, lin_sleeping,
- elm_slider_value_get(obj));
-}
-
-static void
-_torque_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- ephysics_body_torque_apply(bd->body, 0, 0, elm_slider_value_get(obj));
-}
-
-static void
-_impulse_x_x_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Evas_Coord rel_x, rel_y;
- Body_Data *bd = data;
- double y;
-
- y = elm_slider_value_get(evas_object_data_get(obj, "y"));
- rel_x = elm_slider_value_get(evas_object_data_get(obj, "relx"));
- rel_y = elm_slider_value_get(evas_object_data_get(obj, "rely"));
- ephysics_body_impulse_apply(bd->body, elm_slider_value_get(obj), y, 0,
- rel_x, rel_y, 0);
-}
-
-static void
-_impulse_x_rel_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- Evas_Object *aux;
- Evas_Coord rel_y;
- double x, y;
-
- aux = evas_object_data_get(obj, "x");
- x = elm_slider_value_get(aux);
- y = elm_slider_value_get(evas_object_data_get(aux, "y"));
- rel_y = elm_slider_value_get(evas_object_data_get(aux, "rely"));
- ephysics_body_impulse_apply(bd->body, x, y, 0,
- elm_slider_value_get(obj), rel_y, 0);
-}
-
-static void
-_impulse_y_y_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- Evas_Object *aux;
- Evas_Coord rel_x, rel_y;
- double x;
-
- aux = evas_object_data_get(obj, "x");
- x = elm_slider_value_get(aux);
- rel_x = elm_slider_value_get(evas_object_data_get(aux, "relx"));
- rel_y = elm_slider_value_get(evas_object_data_get(aux, "rely"));
- ephysics_body_impulse_apply(bd->body, x, elm_slider_value_get(obj), 0,
- rel_x, rel_y, 0);
-}
-
-static void
-_impulse_y_rel_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- Evas_Object *aux;
- Evas_Coord rel_x;
- double x, y;
-
- aux = evas_object_data_get(obj, "x");
- x = elm_slider_value_get(aux);
- y = elm_slider_value_get(evas_object_data_get(aux, "y"));
- rel_x = elm_slider_value_get(evas_object_data_get(aux, "relx"));
- ephysics_body_impulse_apply(bd->body, x, y, 0,
- rel_x, 0, elm_slider_value_get(obj));
-}
-
-static void
-_force_x_x_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Evas_Coord rel_x, rel_y;
- Body_Data *bd = data;
- double y;
-
- y = elm_slider_value_get(evas_object_data_get(obj, "y"));
- rel_x = elm_slider_value_get(evas_object_data_get(obj, "relx"));
- rel_y = elm_slider_value_get(evas_object_data_get(obj, "rely"));
- ephysics_body_force_apply(bd->body, elm_slider_value_get(obj), y, 0,
- rel_x, rel_y, 0);
-}
-
-static void
-_force_x_rel_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- Evas_Object *aux;
- Evas_Coord rel_y;
- double x, y;
-
- aux = evas_object_data_get(obj, "x");
- x = elm_slider_value_get(aux);
- y = elm_slider_value_get(evas_object_data_get(aux, "y"));
- rel_y = elm_slider_value_get(evas_object_data_get(aux, "rely"));
- ephysics_body_force_apply(bd->body, x, y, 0,
- elm_slider_value_get(obj), rel_y, 0);
-}
-
-static void
-_force_y_y_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Evas_Coord rel_x, rel_y;
- Body_Data *bd = data;
- Evas_Object *aux;
- double x;
-
- aux = evas_object_data_get(obj, "x");
- x = elm_slider_value_get(aux);
- rel_x = elm_slider_value_get(evas_object_data_get(aux, "relx"));
- rel_y = elm_slider_value_get(evas_object_data_get(aux, "rely"));
- ephysics_body_force_apply(bd->body, x, elm_slider_value_get(obj), 0,
- rel_x, rel_y, 0);
-}
-
-static void
-_force_y_rel_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- Evas_Object *aux;
- Evas_Coord rel_x;
- double x, y;
-
- aux = evas_object_data_get(obj, "x");
- x = elm_slider_value_get(aux);
- y = elm_slider_value_get(evas_object_data_get(aux, "y"));
- rel_x = elm_slider_value_get(evas_object_data_get(aux, "relx"));
- ephysics_body_force_apply(bd->body, x, y, 0,
- rel_x, elm_slider_value_get(obj), 0);
-}
-
-static void
-_linear_velocity_x_set_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- double ylinear;
- ylinear = elm_slider_value_get(evas_object_data_get(obj, "y"));
- ephysics_body_linear_velocity_set(bd->body, elm_slider_value_get(obj),
- ylinear, 0);
-}
-
-static void
-_linear_velocity_y_set_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- double xlinear;
- xlinear = elm_slider_value_get(evas_object_data_get(obj, "x"));
- ephysics_body_linear_velocity_set(bd->body, xlinear,
- elm_slider_value_get(obj), 0);
-}
-
-static void
-_angular_velocity_set_cb(void *data, Evas_Object *obj,
- void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- ephysics_body_angular_velocity_set(bd->body, 0, 0,
- elm_slider_value_get(obj));
-}
-
-static void
-_hardness_set_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Body_Data *bd = data;
- ephysics_body_soft_body_hardness_set(bd->body, elm_slider_value_get(obj));
-}
-
-static void
-_simulate_body(Body_Data *bd, Evas_Coord x, Evas_Coord y)
-{
- ephysics_body_stop(bd->body);
- ephysics_body_geometry_set(bd->body, x, y, -15, 70, 70, 30);
- ephysics_body_linear_velocity_set(bd->body,
- elm_slider_value_get(
- bd->controls.velocity.x),
- elm_slider_value_get(
- bd->controls.velocity.y), 0);
- ephysics_body_angular_velocity_set(bd->body, 0, 0,
- elm_slider_value_get(
- bd->controls.velocity.angular));
- ephysics_body_impulse_apply(bd->body,
- elm_slider_value_get(bd->controls.impulse.x),
- elm_slider_value_get(bd->controls.impulse.y), 0,
- elm_slider_value_get(bd->controls.impulse.relx),
- elm_slider_value_get(bd->controls.impulse.rely),
- 0);
-}
-
-static void
-_simulate(World_Data *wd)
-{
- _simulate_body(wd->bd1, (int) WIDTH / 5, (int) HEIGHT / 5);
- _simulate_body(wd->bd2, (int) WIDTH / 2, (int) HEIGHT / 5);
-}
-
-static void
-_simulate_cb(void *data, Evas_Object *obj __UNUSED__,
- void *event_info __UNUSED__)
-{
- _simulate(data);
-}
-
-static void
-_promote(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- elm_naviframe_item_promote(data);
-}
-
-/*** Sandbox Widgets ***/
-static void
-_label_add(Evas_Object *bxparent, const char *subcategory, float align)
-{
- Evas_Object *label;
-
- label = elm_label_add(bxparent);
- elm_object_text_set(label, subcategory);
- evas_object_size_hint_weight_set(label, 0.0, 0.0);
- evas_object_size_hint_align_set(label, align, 0.5);
- elm_box_pack_end(bxparent, label);
- evas_object_show(label);
-}
-
-static Evas_Object *
-_material_selector_add(Body_Data *bd, Evas_Object *bxparent)
-{
- Evas_Object *box, *hv;
-
- box = elm_box_add(bxparent);
- elm_box_horizontal_set(box, EINA_TRUE);
- elm_box_homogeneous_set(box, EINA_TRUE);
- elm_box_padding_set(box, 25, 0);
- evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0.0);
- evas_object_show(box);
- elm_box_pack_end(bxparent, box);
-
- _label_add(box, "Body Material", 1);
-
- hv = elm_hoversel_add(box);
- elm_hoversel_hover_parent_set(hv, bd->wd->nf);
- elm_object_text_set(hv, materials[EPHYSICS_BODY_MATERIAL_CUSTOM]);
- elm_hoversel_item_add(hv, materials[EPHYSICS_BODY_MATERIAL_CUSTOM],
- NULL, ELM_ICON_NONE, _material_set_cb,
- (void *) EPHYSICS_BODY_MATERIAL_CUSTOM);
- elm_hoversel_item_add(hv, materials[EPHYSICS_BODY_MATERIAL_CONCRETE],
- NULL, ELM_ICON_NONE, _material_set_cb,
- (void *) EPHYSICS_BODY_MATERIAL_CONCRETE);
- elm_hoversel_item_add(hv, materials[EPHYSICS_BODY_MATERIAL_IRON],
- NULL, ELM_ICON_NONE, _material_set_cb,
- (void *) EPHYSICS_BODY_MATERIAL_IRON);
- elm_hoversel_item_add(hv, materials[EPHYSICS_BODY_MATERIAL_PLASTIC],
- NULL, ELM_ICON_NONE, _material_set_cb,
- (void *) EPHYSICS_BODY_MATERIAL_PLASTIC);
- elm_hoversel_item_add(hv, materials[EPHYSICS_BODY_MATERIAL_POLYSTYRENE],
- NULL, ELM_ICON_NONE, _material_set_cb,
- (void *) EPHYSICS_BODY_MATERIAL_POLYSTYRENE);
- elm_hoversel_item_add(hv, materials[EPHYSICS_BODY_MATERIAL_RUBBER],
- NULL, ELM_ICON_NONE, _material_set_cb,
- (void *) EPHYSICS_BODY_MATERIAL_RUBBER);
- elm_hoversel_item_add(hv, materials[EPHYSICS_BODY_MATERIAL_WOOD],
- NULL, ELM_ICON_NONE, _material_set_cb,
- (void *) EPHYSICS_BODY_MATERIAL_WOOD);
-
- evas_object_size_hint_align_set(hv, 0.5, 0.5);
- elm_box_pack_end(box, hv);
- evas_object_show(hv);
- evas_object_data_set(hv, "bd", bd);
-
- return hv;
-}
-
-static void
-_type_radio_add(Body_Data *bd, Evas_Object *bxparent)
-{
- Evas_Object *dbx, *rbx, *rd, *rdg;
-
- dbx = elm_box_add(bxparent);
- elm_box_horizontal_set(dbx, EINA_TRUE);
- evas_object_size_hint_weight_set(dbx, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(dbx, EVAS_HINT_FILL, 0.0);
- elm_box_homogeneous_set(dbx, EINA_TRUE);
- elm_box_align_set(dbx, 1, 0.5);
- elm_box_pack_end(bxparent, dbx);
- evas_object_show(dbx);
-
- _label_add(dbx, "Body Type", 1);
-
- rbx = elm_box_add(bxparent);
- elm_box_horizontal_set(rbx, EINA_TRUE);
- evas_object_size_hint_weight_set(rbx, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(rbx, EVAS_HINT_FILL, 0.0);
- elm_box_padding_set(rbx, 25, 0);
- elm_box_align_set(rbx, 0.5, 0.5);
- elm_box_pack_end(dbx, rbx);
- evas_object_show(rbx);
-
- rd = elm_radio_add(bxparent);
- elm_radio_state_value_set(rd, 0);
- elm_object_text_set(rd, "Solid");
- evas_object_size_hint_align_set(rd, 1, 0.5);
- evas_object_size_hint_weight_set(rd, 0, EVAS_HINT_EXPAND);
- elm_box_pack_end(rbx, rd);
- evas_object_show(rd);
- rdg = rd;
- evas_object_smart_callback_add(rd, "changed", _type_set_cb, bd);
-
- rd = elm_radio_add(bxparent);
- elm_radio_state_value_set(rd, 1);
- elm_radio_group_add(rd, rdg);
- elm_object_text_set(rd, "Soft");
- evas_object_size_hint_align_set(rd, 1, 0.5);
- evas_object_size_hint_weight_set(rd, 0, EVAS_HINT_EXPAND);
- elm_box_pack_end(rbx, rd);
- evas_object_show(rd);
- evas_object_smart_callback_add(rd, "changed", _type_set_cb, bd);
-}
-
-static Evas_Object *
-_slider_add(Evas_Object *bxparent, const char *subcategory, const char *itemlb,
- float min, float max, float initial)
-{
- Evas_Object *sl, *dbx;
-
- dbx = elm_box_add(bxparent);
- elm_box_horizontal_set(dbx, EINA_TRUE);
- evas_object_size_hint_weight_set(dbx, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(dbx, EVAS_HINT_FILL, 0.0);
- elm_box_homogeneous_set(dbx, EINA_TRUE);
- elm_box_align_set(dbx, 0, 0.5);
- elm_box_pack_end(bxparent, dbx);
- evas_object_show(dbx);
-
- _label_add(dbx, subcategory, 1);
-
- sl = elm_slider_add(bxparent);
- elm_slider_unit_format_set(sl, itemlb);
- elm_slider_min_max_set(sl, min, max);
- elm_slider_value_set(sl, initial);
- elm_slider_span_size_set(sl, 100);
- evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(sl, 0, 0.5);
- elm_box_pack_end(dbx, sl);
- evas_object_show(sl);
-
- return sl;
-}
-
-static Evas_Object *
-_category_add(Evas_Object *bxparent, const char *label, Eina_Bool collapse)
-{
- Evas_Object *cfr, *cbx;
-
- cfr = elm_frame_add(bxparent);
- elm_frame_autocollapse_set(cfr, collapse);
- elm_frame_collapse_set(cfr, collapse);
- elm_object_text_set(cfr, label);
- evas_object_size_hint_weight_set(cfr, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_fill_set(cfr, EVAS_HINT_FILL, 0.0);
- elm_box_pack_end(bxparent, cfr);
- evas_object_show(cfr);
-
- cbx = elm_box_add(bxparent);
- elm_box_horizontal_set(cbx, EINA_FALSE);
- evas_object_size_hint_weight_set(cbx, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(cbx, EVAS_HINT_FILL, 0.0);
- elm_object_content_set(cfr, cbx);
- evas_object_show(cbx);
-
- return cbx;
-}
-
-/*** Sandbox Pages ***/
-static void
-_menu_page_add(Evas_Object *win, Evas_Object **scroller_box,
- Evas_Object **content_box)
-{
- Evas_Object *scbx, *bx, *sc;
-
- scbx = elm_box_add(win);
- evas_object_size_hint_weight_set(scbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(scbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(scbx);
-
- sc = elm_scroller_add(win);
- elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
- elm_scroller_policy_set(sc, ELM_SCROLLER_POLICY_OFF,
- ELM_SCROLLER_POLICY_AUTO);
- evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(scbx, sc);
- evas_object_show(sc);
-
- bx = elm_box_add(win);
- evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0);
- evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0);
- evas_object_show(bx);
- elm_object_content_set(sc, bx);
-
- *scroller_box = scbx;
- *content_box = bx;
-}
-
-static void
-_menu_body_page_add(World_Data *wd, Body_Data *bd, const char *pg_label)
-{
- Evas_Object *bx, *bxbody, *scbxbody, *widget, *aux_widget, *material_widget;
- Elm_Object_Item *it;
-
- _menu_page_add(wd->win, &scbxbody, &bxbody);
- bx = _category_add(bxbody, "", EINA_FALSE);
- _type_radio_add(bd, bx);
- material_widget = _material_selector_add(bd, bx);
-
- bx = _category_add(bxbody, "Properties", EINA_TRUE);
- aux_widget = _slider_add(bx, "Mass (kg)", "%1.3f", 0, 99999, INITIAL_MASS);
- evas_object_data_set(material_widget, "mass", aux_widget);
- widget = _slider_add(bx, "Density (kg/m³)", "%1.3f", 0, 9999, 0);
- evas_object_data_set(aux_widget, "density", widget);
- evas_object_data_set(material_widget, "density", widget);
- evas_object_smart_callback_add(aux_widget, "delay,changed", _mass_set_cb,
- bd);
- evas_object_data_set(widget, "mass", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed", _density_set_cb,
- bd);
- widget = _slider_add(bx, "Rotation (rad)", "%1.3f", -3.1415, 3.1415, 0);
- evas_object_smart_callback_add(widget, "delay,changed", _rotation_set_cb,
- bd);
- widget = _slider_add(bx, "Friction", "%1.3f", 0, 1, 0.5);
- evas_object_data_set(material_widget, "friction", widget);
- evas_object_smart_callback_add(widget, "delay,changed", _friction_set_cb,
- bd);
- widget = _slider_add(bx, "Restitution", "%1.3f", 0, 1, 0);
- evas_object_data_set(material_widget, "restitution", widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _restitution_set_cb, bd);
- _label_add(bx, "Damping", 0.5);
- widget = _slider_add(bx, "Linear", "%1.3f", 0, 1, 0);
- evas_object_smart_callback_add(widget, "delay,changed",
- _linear_damping_set_cb, bd);
- widget = _slider_add(bx, "Angular", "%1.3f", 0, 1, 0);
- evas_object_smart_callback_add(widget, "delay,changed",
- _angular_damping_set_cb, bd);
- _label_add(bx, "Sleeping Threshold", 0.5);
- widget = _slider_add(bx, "Linear (p/s)", "%1.2f",
- 0, 250, 24);
- evas_object_smart_callback_add(widget, "delay,changed",
- _lin_sleeping_threshold_set_cb, bd);
- widget = _slider_add(bx, "Angular (º/s)", "%1.2f",
- 0, 360, 57.29);
- evas_object_smart_callback_add(widget, "delay,changed",
- _ang_sleeping_threshold_set_cb, bd);
-
- bx = _category_add(bxbody, "Actions", EINA_TRUE);
- _label_add(bx, "Impulse X", 0.5);
- aux_widget = _slider_add(bx, "X (kg * p/s)", "%1.3f",
- -9999, 9999, 0);
- bd->controls.impulse.x = aux_widget;
- widget = _slider_add(bx, "Rel Position X", "%1.2f",
- -360, 360, 0);
- bd->controls.impulse.relx = widget;
- evas_object_data_set(aux_widget, "relx", widget);
- _label_add(bx, "Impulse Y", 0.5);
- widget = _slider_add(bx, "Y (kg * p/s)", "%1.3f", -9999, 9999, 0);
- bd->controls.impulse.y = widget;
- evas_object_data_set(aux_widget, "y", widget);
- widget = _slider_add(bx, "Rel Position Y", "%1.2f", -360, 360, 0);
- bd->controls.impulse.rely = widget;
- evas_object_data_set(aux_widget, "rely", widget);
- evas_object_smart_callback_add(aux_widget, "delay,changed",
- _impulse_x_x_set_cb, bd);
- evas_object_data_set(widget, "x", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _impulse_x_rel_set_cb, bd);
- widget = evas_object_data_get(aux_widget, "y");
- evas_object_data_set(widget, "x", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _impulse_y_y_set_cb, bd);
- widget = evas_object_data_get(aux_widget, "relx");
- evas_object_data_set(widget, "x", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _impulse_y_rel_set_cb, bd);
-
- _label_add(bx, "Force X", 0.5);
- aux_widget = _slider_add(bx, "X (kg * p/s/s)", "%1.3f", -1999, 1999, 0);
- bd->controls.force.x = aux_widget;
- widget = _slider_add(bx, "Rel Position X", "%1.2f", -360, 360, 0);
- bd->controls.force.relx = widget;
- evas_object_data_set(aux_widget, "relx", widget);
- _label_add(bx, "Force Y", 0.5);
- widget = _slider_add(bx, "Y (kg * p/s/s)", "%1.3f", -1999, 1999, 0);
- bd->controls.force.y = widget;
- evas_object_data_set(aux_widget, "y", widget);
- widget = _slider_add(bx, "Rel Position Y", "%1.2f", -360, 360, 0);
- bd->controls.force.rely = widget;
- evas_object_data_set(aux_widget, "rely", widget);
- evas_object_smart_callback_add(aux_widget, "delay,changed",
- _force_x_x_set_cb, bd);
- evas_object_data_set(widget, "x", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _force_x_rel_set_cb, bd);
- widget = evas_object_data_get(aux_widget, "y");
- evas_object_data_set(widget, "x", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _force_y_y_set_cb, bd);
- widget = evas_object_data_get(aux_widget, "relx");
- evas_object_data_set(widget, "x", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _force_y_rel_set_cb, bd);
- widget = _slider_add(bx, "Torque", "%1.3f", -100, 100, 0);
- bd->controls.force.torque = widget;
- evas_object_smart_callback_add(widget, "delay,changed", _torque_set_cb, bd);
-
- _label_add(bx, "Linear Velocity", 0.5);
- aux_widget = _slider_add(bx, "X (p/s)", "%1.2f", -1499, 1499, 0);
- bd->controls.velocity.x = aux_widget;
- widget = _slider_add(bx, "Y (p/s)", "%1.2f", -1499, 1499, 0);
- bd->controls.velocity.y = widget;
- evas_object_data_set(aux_widget, "y", widget);
- evas_object_smart_callback_add(aux_widget, "delay,changed",
- _linear_velocity_x_set_cb, bd);
- evas_object_data_set(widget, "x", aux_widget);
- evas_object_smart_callback_add(widget, "delay,changed",
- _linear_velocity_y_set_cb, bd);
-
- widget = _slider_add(bx, "Angular Velocity (º/s)", "%1.2f", -360, 360, 0);
- bd->controls.velocity.angular = widget;
- evas_object_smart_callback_add(widget, "delay,changed",
- _angular_velocity_set_cb, bd);
-
- bx = _category_add(bxbody, "Soft Body", EINA_TRUE);
- widget = _slider_add(bx, "Hardness (%)", "%1.2f%", 0, 100, 100);
- bd->controls.hardness = widget;
- elm_object_disabled_set(widget, EINA_TRUE);
- evas_object_smart_callback_add(widget, "delay,changed", _hardness_set_cb,
- bd);
-
- it = elm_naviframe_item_insert_before(wd->nf,
- evas_object_data_get(wd->nf, "world"),
- NULL, NULL, NULL, scbxbody, NULL);
- elm_naviframe_item_title_visible_set(it, EINA_FALSE);
- elm_toolbar_item_append(wd->tb, NULL, pg_label, _promote, it);
-}
-
-static void
-_menu_world_page_add(World_Data *wd)
-{
- Evas_Object *bx, *scbx, *bxparent, *widget;
- Elm_Object_Item *it;
-
- _menu_page_add(wd->win, &scbx, &bxparent);
-
- bx = _category_add(bxparent, "World", EINA_FALSE);
- _label_add(bx, "Gravity (px/s²)", 0.5);
- widget = _slider_add(bx, "X:", "%1.2f", -1000, 1000, 0);
- evas_object_smart_callback_add(widget, "delay,changed", _world_gravity_x_cb,
- wd->world);
- widget = _slider_add(bx, "Y:", "%1.2f", -1000, 1000, 294);
- evas_object_smart_callback_add(widget, "delay,changed",
- _world_gravity_y_cb, wd->world);
- widget = _slider_add(bx, "Rate (px/m)", "%1.0f", 1, 100, 30);
- evas_object_smart_callback_add(widget, "delay,changed", _world_rate_cb,
- wd->world);
- widget = _slider_add(bx, "Max Sleeping Time (s)", "%1.0f", 0, 50, 2);
- evas_object_smart_callback_add(widget, "delay,changed",
- _world_max_sleeping_time_cb, wd->world);
-
- bx = _category_add(bxparent, "Boundaries", EINA_FALSE);
- widget = _slider_add(bx, "Friction", "%1.3f", 0, 1, 0.5);
- evas_object_smart_callback_add(widget, "delay,changed",
- _world_friction_cb, wd);
- widget = _slider_add(bx, "Restitution", "%1.3f", 0, 1, 0);
- evas_object_smart_callback_add(widget, "delay,changed",
- _world_restitution_cb, wd);
-
- it = elm_naviframe_item_push(wd->nf, NULL, NULL, NULL, scbx, NULL);
- evas_object_data_set(wd->nf, "world", it);
- elm_naviframe_item_title_visible_set(it, EINA_FALSE);
- elm_toolbar_item_append(wd->tb, NULL, "World", _promote, it);
-}
-
-static void
-_menu_create(World_Data *wd)
-{
- Evas_Object *mainbx, *dbx, *btn, *bg, *layout;
-
- bg = elm_bg_add(wd->win);
- elm_win_resize_object_add(wd->win, bg);
- evas_object_size_hint_min_set(bg, WIDTH, HEIGHT);
- evas_object_size_hint_max_set(bg, WIDTH, HEIGHT);
-
- layout = elm_layout_add(wd->win);
- elm_layout_file_set(layout, PACKAGE_DATA_DIR "/" SANDBOX_THEME ".edj",
- "sandbox");
- evas_object_resize(layout, WIDTH, HEIGHT);
- evas_object_show(layout);
-
- mainbx = elm_box_add(wd->win);
- evas_object_size_hint_fill_set(mainbx, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_content_set(layout, "swallow", mainbx);
- evas_object_show(mainbx);
-
- dbx = elm_box_add(mainbx);
- elm_box_horizontal_set(dbx, EINA_TRUE);
- evas_object_size_hint_weight_set(dbx, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(dbx, EVAS_HINT_FILL, 0.0);
- elm_box_align_set(dbx, 0, 0.5);
- elm_box_pack_end(mainbx, dbx);
- evas_object_show(dbx);
-
- wd->tb = elm_toolbar_add(wd->win);
- evas_object_size_hint_weight_set(wd->tb, EVAS_HINT_EXPAND, 0);
- evas_object_size_hint_fill_set(wd->tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_toolbar_select_mode_set(wd->tb, ELM_OBJECT_SELECT_MODE_ALWAYS);
- elm_box_pack_end(dbx, wd->tb);
- evas_object_show(wd->tb);
-
- btn = elm_button_add(wd->win);
- elm_object_text_set(btn, "Restart");
- evas_object_size_hint_min_set(btn, 100, 30);
- evas_object_size_hint_align_set(btn, 1, 0.5);
- elm_box_pack_end(dbx, btn);
- evas_object_show(btn);
- evas_object_smart_callback_add(btn, "clicked", _simulate_cb, wd);
-
-
- wd->nf = elm_naviframe_add(wd->win);
- evas_object_size_hint_weight_set(wd->nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_fill_set(wd->nf, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_box_pack_end(mainbx, wd->nf);
- evas_object_show(wd->nf);
-}
-
-static EPhysics_Body *
-_body_add(Evas_Object *win, EPhysics_World *world, int x, int y)
-{
- Evas_Object *body_image;
- EPhysics_Body *body;
-
- body_image = elm_image_add(win);
- elm_image_file_set(
- body_image, PACKAGE_DATA_DIR "/" SANDBOX_THEME ".edj", "Custom");
- evas_object_resize(body_image, 70, 70);
- evas_object_move(body_image, x, y);
- evas_object_show(body_image);
-
- body = ephysics_body_cylinder_add(world);
- ephysics_body_evas_object_set(body, body_image, EINA_TRUE);
- ephysics_body_mass_set(body, INITIAL_MASS);
- ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL,
- _body_del, NULL);
-
- return body;
-}
-
-EAPI int
-elm_main()
-{
- EPhysics_World *world;
- Body_Data bd1, bd2;
- Evas_Object *win;
- World_Data wd;
-
- if (!ephysics_init())
- {
- fprintf(stderr, "Failed to init ephysics\n");
- elm_shutdown();
- return -1;
- }
-
- elm_theme_extension_add(NULL, PACKAGE_DATA_DIR "/" SANDBOX_THEME ".edj");
- elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
-
- win = elm_win_add(NULL, "Sandbox", ELM_WIN_BASIC);
- elm_win_title_set(win, "EPhysics Sandbox");
- elm_win_autodel_set(win, EINA_TRUE);
- evas_object_show(win);
-
- world = ephysics_world_new();
- ephysics_world_simulation_set(world, 1/100.f, 10);
- ephysics_world_render_geometry_set(world, 80, 80, -50,
- (int) WIDTH * 0.7 - 160, HEIGHT - 160,
- DEPTH);
- wd.top = ephysics_body_top_boundary_add(world);
- wd.bottom = ephysics_body_bottom_boundary_add(world);
- wd.left = ephysics_body_left_boundary_add(world);
- wd.right = ephysics_body_right_boundary_add(world);
-
- wd.world = world;
- wd.win = win;
- wd.bd1 = &bd1;
- wd.bd2 = &bd2;
- bd1.wd = &wd;
- bd2.wd = &wd;
-
- _menu_create(&wd);
- _menu_world_page_add(&wd);
- _menu_body_page_add(&wd, &bd1, "Body 1");
- _menu_body_page_add(&wd, &bd2, "Body 2");
-
- bd1.body = _body_add(win, world, WIDTH / 5, HEIGHT / 5);
- bd2.body = _body_add(win, world, WIDTH / 2, HEIGHT / 5);
-
- _simulate(&wd);
-
- elm_run();
-
- ephysics_shutdown();
- elm_shutdown();
- return 0;
-}
-ELM_MAIN()
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_pos_print_cb(void *data __UNUSED__, EPhysics_Body *body, void *event_info __UNUSED__)
-{
- EPhysics_Quaternion quat;
- Evas_Coord x, y, z;
-
- ephysics_body_geometry_get(body, &x, &y, &z, NULL, NULL, NULL);
- ephysics_body_rotation_get(body, &quat);
-
- printf("Position X:%i Y:%i Z:%i\n", x, y, z);
- printf("Rotation X:%lf Y:%lf Z:%lf W:%lf\n", quat.x, quat.y, quat.z, quat.w);
-}
-
-static Eina_Bool
-_on_keydown(void *data, Evas_Object *obj __UNUSED__, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
-{
- Evas_Event_Key_Down *ev = event_info;
- EPhysics_Body *body = data;
-
- if (type != EVAS_CALLBACK_KEY_UP)
- return EINA_FALSE;
-
- if (!strcmp(ev->keyname, "j"))
- ephysics_body_central_impulse_apply(body, 0, -20, 0);
- else if (!strcmp(ev->keyname, "k"))
- ephysics_body_central_impulse_apply(body, 0, 20, 0);
- else if (!strcmp(ev->keyname, "l"))
- ephysics_body_central_impulse_apply(body, 20, 0, 0);
- else if (!strcmp(ev->keyname, "h"))
- ephysics_body_central_impulse_apply(body, -20, 0, 0);
- else if (!strcmp(ev->keyname, "f"))
- ephysics_body_central_impulse_apply(body, 0, 0, -20);
- else if (!strcmp(ev->keyname, "g"))
- ephysics_body_central_impulse_apply(body, 0, 0, 20);
- else if (!strcmp(ev->keyname, "u"))
- ephysics_body_torque_impulse_apply(body, 0, -2, 0);
- else if (!strcmp(ev->keyname, "i"))
- ephysics_body_torque_impulse_apply(body, 0, 2, 0);
- else if (!strcmp(ev->keyname, "o"))
- ephysics_body_torque_impulse_apply(body, 2, 0, 0);
- else if (!strcmp(ev->keyname, "y"))
- ephysics_body_torque_impulse_apply(body, -2, 0, 0);
- else if (!strcmp(ev->keyname, "r"))
- ephysics_body_torque_impulse_apply(body, 0, 0, -2);
- else if (!strcmp(ev->keyname, "t"))
- ephysics_body_torque_impulse_apply(body, 0, 0, 2);
-
- return EINA_TRUE;
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *cube, *shadow;
- EPhysics_Body *box;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, WIDTH / 3, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- cube = elm_image_add(test_data->win);
- elm_image_file_set(
- cube, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube");
- evas_object_move(cube, WIDTH / 2, HEIGHT / 2);
- evas_object_resize(cube, 70, 70);
- evas_object_show(cube);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, cube);
-
- box = ephysics_body_box_add(test_data->world);
- ephysics_body_evas_object_set(box, cube, EINA_TRUE);
- ephysics_body_restitution_set(box, 0);
- ephysics_body_friction_set(box, 0);
- ephysics_body_sleeping_threshold_set(box, 0, 0);
- ephysics_body_damping_set(box, 0, 0);
- ephysics_body_linear_movement_enable_set(box, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
- ephysics_body_angular_movement_enable_set(box, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
- ephysics_body_event_callback_add(box, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- ephysics_body_event_callback_add(box, EPHYSICS_CALLBACK_BODY_UPDATE,
- _pos_print_cb, NULL);
- test_data->bodies = eina_list_append(test_data->bodies, box);
- test_data->data = box;
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- elm_object_event_callback_del(test_data->win, _on_keydown, test_data->data);
- test_clean(test_data);
- _world_populate(test_data);
- elm_object_event_callback_add(test_data->win, _on_keydown, test_data->data);
-}
-
-void
-test_bouncing_3d(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Bouncing 3D", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
- elm_object_signal_emit(test_data->layout, "controls,show", "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_gravity_set(world, 0, 0, 0);
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
- EINA_TRUE);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0);
- ephysics_body_friction_set(boundary, 0);
-
- boundary = ephysics_body_right_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0);
- ephysics_body_friction_set(boundary, 0);
-
- boundary = ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0);
- ephysics_body_friction_set(boundary, 0);
-
- boundary = ephysics_body_front_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0);
- ephysics_body_friction_set(boundary, 0);
-
- boundary = ephysics_body_back_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0);
- ephysics_body_friction_set(boundary, 0);
-
- ephysics_body_top_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0);
- ephysics_body_friction_set(boundary, 0);
-
- _world_populate(test_data);
- elm_object_event_callback_add(test_data->win, _on_keydown, test_data->data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static Evas_Object *
-_obj_face_add(Test_Data *test_data, const char *group, Evas_Coord x, Evas_Coord y)
-{
- Evas_Object *obj;
-
- obj = elm_image_add(test_data->win);
- elm_image_file_set(obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- group);
- evas_object_move(obj, x, y);
- evas_object_resize(obj, 70, 70);
- evas_object_show(obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, obj);
-
- return obj;
-}
-
-static EPhysics_Body *
-_coin_add(Test_Data *test_data, Evas_Coord x, Evas_Coord y)
-{
- Evas_Object *front, *back, *shadow;
- EPhysics_Body *coin;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, x, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- front = _obj_face_add(test_data, "coin0", x, y);
- back = _obj_face_add(test_data, "coin1", x, y);
-
- coin = ephysics_body_cylinder_add(test_data->world);
- ephysics_body_resize(coin, 1, 1, 1);
- ephysics_body_face_evas_object_set(coin,
- EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_FRONT,
- front, EINA_TRUE);
- ephysics_body_face_evas_object_set(coin,
- EPHYSICS_BODY_CYLINDER_FACE_MIDDLE_BACK,
- back, EINA_FALSE);
- ephysics_body_restitution_set(coin, 0.82);
- ephysics_body_damping_set(coin, 0, 0.2);
- ephysics_body_linear_movement_enable_set(coin, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
- ephysics_body_angular_movement_enable_set(coin, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
- ephysics_body_event_callback_add(coin, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, coin);
-
- return coin;
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- EPhysics_Body *coin;
- int y;
-
- y = FLOOR_Y - 70 - 20;
-
- coin = _coin_add(test_data, 60, y);
- ephysics_body_central_impulse_apply(coin, 0, -320, 0);
- ephysics_body_torque_impulse_apply(coin, -4, 0, 0);
-
- coin = _coin_add(test_data, 140, y);
- ephysics_body_central_impulse_apply(coin, 0, -300, 0);
- ephysics_body_torque_impulse_apply(coin, 8, 0, 0);
-
- coin = _coin_add(test_data, 220, y);
- ephysics_body_central_impulse_apply(coin, 40, -340, 80);
- ephysics_body_torque_impulse_apply(coin, 5, -1, 0);
-
- coin = _coin_add(test_data, 300, y);
- ephysics_body_central_impulse_apply(coin, 0, -280, 0);
- ephysics_body_torque_impulse_apply(coin, 4, 1, 0);
-
- coin = _coin_add(test_data, 380, y);
- ephysics_body_central_impulse_apply(coin, 40, -240, 0);
- ephysics_body_torque_impulse_apply(coin, 3, 1, 1);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- test_clean(data);
- _world_populate(data);
-}
-
-void
-test_coins(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Raster's Coins", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH * 2);
- ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
- EINA_TRUE);
-
- ephysics_world_point_light_position_set(world, 0, 100, -400);
- ephysics_world_ambient_light_color_set(world, 60, 60, 60);
- ephysics_world_light_all_bodies_set(world, EINA_TRUE);
-
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.7);
-
- ephysics_body_right_boundary_add(test_data->world);
- ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_front_boundary_add(test_data->world);
- ephysics_body_back_boundary_add(test_data->world);
- ephysics_body_top_boundary_add(test_data->world);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-typedef struct _Speed_Data Speed_Data;
-
-struct _Speed_Data {
- Test_Data base;
- Evas_Object *bt;
- Evas_Object *sp;
- EPhysics_Body *ball;
-};
-
-static void
-_shoot(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Speed_Data *speed_data = data;
- double impulse, rate;
-
- rate = ephysics_world_rate_get(ephysics_body_world_get(speed_data->ball));
- impulse = elm_spinner_value_get(speed_data->sp);
-
- elm_object_disabled_set(obj, EINA_TRUE);
- ephysics_body_central_impulse_apply(speed_data->ball, impulse * rate, 0, 0);
-}
-
-static void
-_world_populate(Speed_Data *speed_data)
-{
- Evas_Object *sphere, *shadow;
- EPhysics_Body *ball;
-
- shadow = elm_layout_add(speed_data->base.win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, 80, FLOOR_Y);
- evas_object_resize(shadow, 54, 3);
- evas_object_show(shadow);
- speed_data->base.evas_objs = eina_list_append(speed_data->base.evas_objs,
- shadow);
-
- sphere = elm_image_add(speed_data->base.win);
- elm_image_file_set(
- sphere, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "red-ball");
- evas_object_move(sphere, 80, FLOOR_Y - 54);
- evas_object_resize(sphere, 54, 54);
- evas_object_show(sphere);
- speed_data->base.evas_objs = eina_list_append(speed_data->base.evas_objs,
- sphere);
-
- ball = ephysics_body_sphere_add(speed_data->base.world);
- ephysics_body_evas_object_set(ball, sphere, EINA_TRUE);
- ephysics_body_restitution_set(ball, 0.8);
- ephysics_body_friction_set(ball, 0.2);
- ephysics_body_event_callback_add(ball, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- speed_data->base.bodies = eina_list_append(speed_data->base.bodies, ball);
- speed_data->ball = ball;
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Speed_Data *speed_data = data;
-
- DBG("Restart pressed");
- test_clean((Test_Data *) speed_data);
- _world_populate(speed_data);
- elm_object_disabled_set(speed_data->bt, EINA_FALSE);
-}
-
-static void
-_win_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- Speed_Data *speed_data = data;
-
- test_clean((Test_Data *)speed_data);
- evas_object_del(speed_data->base.layout);
- ephysics_world_del(speed_data->base.world);
- free(speed_data);
- ephysics_shutdown();
-}
-
-void
-test_collision_speed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Speed_Data *speed_data;
- Evas_Object *bt, *sp;
-
- if (!ephysics_init())
- return;
-
- speed_data = calloc(1, sizeof(Speed_Data));
- if (!speed_data)
- {
- ERR("Failed to create test data");
- ephysics_shutdown();
- return;
- }
-
- test_win_add((Test_Data *) speed_data, "Collision with High Speed",
- EINA_FALSE);
- elm_object_signal_emit(speed_data->base.layout, "borders,show",
- "ephysics_test");
- evas_object_event_callback_add(speed_data->base.win, EVAS_CALLBACK_DEL,
- _win_del, speed_data);
- elm_layout_signal_callback_add(speed_data->base.layout, "restart",
- "test-theme", _restart, speed_data);
-
- bt = elm_button_add(speed_data->base.win);
- elm_object_style_set(bt, "ephysics-test-shoot");
- elm_layout_content_set(speed_data->base.layout, "extra_button", bt);
- evas_object_smart_callback_add(bt, "clicked", _shoot, speed_data);
- speed_data->bt = bt;
-
- sp = elm_spinner_add(speed_data->base.win);
- elm_spinner_min_max_set(sp, 0, 300);
- elm_spinner_step_set(sp, 5);
- elm_spinner_value_set(sp, 100);
- elm_object_style_set(sp, "ephysics-test");
- elm_layout_content_set(speed_data->base.layout, "extra_input", sp);
- speed_data->sp = sp;
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- ephysics_world_simulation_set(world, 1/260.f, 5);
- speed_data->base.world = world;
-
- boundary = ephysics_body_bottom_boundary_add(world);
- ephysics_body_restitution_set(boundary, 0.65);
- ephysics_body_friction_set(boundary, 4);
-
- boundary = ephysics_body_right_boundary_add(world);
- ephysics_body_restitution_set(boundary, 0.4);
- ephysics_body_friction_set(boundary, 3);
-
- boundary = ephysics_body_left_boundary_add(world);
- ephysics_body_restitution_set(boundary, 0.4);
- ephysics_body_friction_set(boundary, 3);
-
- ephysics_body_top_boundary_add(world);
-
- _world_populate(speed_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-#define BOX_SIZE (70)
-
-static void
-_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
-{
- EPhysics_Quaternion quat_prev, quat_delta, quat;
- Evas_Event_Mouse_Move *mmove = event_info;
- EPhysics_Body *body = data;
- double rx, ry;
-
- if (mmove->buttons != 1) return;
-
- rx = mmove->cur.output.y - mmove->prev.output.y;
- ry = mmove->cur.output.x - mmove->prev.output.x;
-
- ephysics_body_rotation_get(body, &quat_prev);
- ephysics_quaternion_euler_set(&quat_delta, -ry * 3.43, - rx * 2.29, 0);
- ephysics_quaternion_multiply(&quat_prev, &quat_delta, &quat);
- ephysics_body_rotation_set(body, &quat);
-}
-
-static void
-_obj_face_add(Test_Data *test_data, EPhysics_Body *body, EPhysics_Body_Face face, const char *group, Evas_Coord x, Evas_Coord y)
-{
- Evas_Object *obj;
-
- obj = elm_image_add(test_data->win);
- elm_image_file_set(obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- group);
- evas_object_move(obj, x, y);
- evas_object_resize(obj, BOX_SIZE, BOX_SIZE);
- evas_object_show(obj);
-
- ephysics_body_face_evas_object_set(body, face, obj, EINA_TRUE);
-
- test_data->evas_objs = eina_list_append(test_data->evas_objs, obj);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- EPhysics_Body *box;
- Evas_Object *rect;
- Evas_Coord x, y;
- Evas *evas;
-
- x = (WIDTH - BOX_SIZE) / 2;
- y = (HEIGHT - BOX_SIZE) / 2;
-
- box = ephysics_body_box_add(test_data->world);
-
- _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_FRONT, "cube_front",
- x, y);
- _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_BACK, "cube_back",
- x, y);
- _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_TOP, "cube_top",
- x, y);
- _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_BOTTOM, "cube_bottom",
- x, y);
- _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_RIGHT, "cube_right",
- x, y);
- _obj_face_add(test_data, box, EPHYSICS_BODY_BOX_FACE_LEFT, "cube_left",
- x, y);
-
- ephysics_body_damping_set(box, 0, 0.2);
- ephysics_body_linear_movement_enable_set(box, EINA_FALSE, EINA_FALSE,
- EINA_FALSE);
- ephysics_body_angular_movement_enable_set(box, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
- test_data->bodies = eina_list_append(test_data->bodies, box);
-
- evas = evas_object_evas_get(test_data->win);
- rect = evas_object_rectangle_add(evas);
- evas_object_resize(rect, 120, 120);
- evas_object_move(rect, (WIDTH - 120) / 2, (HEIGHT - 120) / 2);
- evas_object_color_set(rect, 0, 0, 0, 0);
- evas_object_show(rect);
- evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_MOVE,
- _mouse_move_cb, box);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- test_clean(data);
- _world_populate(data);
-}
-
-void
-test_cube_3d(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Cube 3D", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH * 2);
- ephysics_world_gravity_set(world, 0, 0, 0);
- ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
- EINA_TRUE);
- test_data->world = world;
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static Evas_Object *
-_obj_face_add(Test_Data *test_data, const char *group, Evas_Coord x, Evas_Coord y)
-{
- Evas_Object *obj;
-
- obj = elm_image_add(test_data->win);
- elm_image_file_set(obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- group);
- evas_object_move(obj, x, y);
- evas_object_resize(obj, 70, 70);
- evas_object_show(obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, obj);
-
- return obj;
-}
-
-static EPhysics_Body *
-_box_add(Test_Data *test_data, Evas_Coord x, Evas_Coord y)
-{
- Evas_Object *front, *back, *top, *bottom, *right, *left, *shadow;
- EPhysics_Body *box;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, x, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- front = _obj_face_add(test_data, "dice1", x, y);
- back = _obj_face_add(test_data, "dice6", x, y);
- top = _obj_face_add(test_data, "dice2", x, y);
- bottom = _obj_face_add(test_data, "dice5", x, y);
- right = _obj_face_add(test_data, "dice3", x, y);
- left = _obj_face_add(test_data, "dice4", x, y);
-
- box = ephysics_body_box_add(test_data->world);
- ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_FRONT,
- front, EINA_TRUE);
- ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_BACK,
- back, EINA_TRUE);
- ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_TOP,
- top, EINA_TRUE);
- ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_BOTTOM,
- bottom, EINA_TRUE);
- ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_RIGHT,
- right, EINA_TRUE);
- ephysics_body_face_evas_object_set(box, EPHYSICS_BODY_BOX_FACE_LEFT,
- left, EINA_TRUE);
- ephysics_body_restitution_set(box, 0.7);
- ephysics_body_sleeping_threshold_set(box, 0, 0);
- ephysics_body_damping_set(box, 0, 0);
- ephysics_body_linear_movement_enable_set(box, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
- ephysics_body_angular_movement_enable_set(box, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
- ephysics_body_event_callback_add(box, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, box);
-
- return box;
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- EPhysics_Body *box;
-
- box = _box_add(test_data, WIDTH / 2, HEIGHT / 4);
- ephysics_body_torque_impulse_apply(box, 6, -2, 0);
- box = _box_add(test_data, 80, 80);
- ephysics_body_torque_impulse_apply(box, 0, 0, 3);
- ephysics_body_central_impulse_apply(box, 80, 0, 0);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- test_clean(data);
- _world_populate(data);
-}
-
-void
-test_dices(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Dices", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH * 2);
- ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
- EINA_TRUE);
-
- ephysics_world_point_light_position_set(world, 0, 100, -400);
- ephysics_world_ambient_light_color_set(world, 60, 60, 60);
- ephysics_world_light_all_bodies_set(world, EINA_TRUE);
-
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.7);
-
- ephysics_body_right_boundary_add(test_data->world);
- ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_back_boundary_add(test_data->world);
- ephysics_body_top_boundary_add(test_data->world);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_world_populate(Test_Data *test_data)
-{
- static const char name[] = "EPHYSICS";
- EPhysics_Body *text_body;
- unsigned int i = 0;
- Evas_Object *text;
- char buf[3];
- int x, y, w;
-
- for (i = 0; i < strlen(name); i++)
- {
- sprintf(buf, "%c", name[i]);
- text = evas_object_text_add(evas_object_evas_get(test_data->win));
- evas_object_text_text_set(text, buf);
- evas_object_text_font_set(text, "Sans", 48);
- evas_object_color_set(text, 95, 56, 19, 255);
- evas_object_geometry_get(text, NULL, NULL, &w, NULL);
- x = WIDTH / 5 + i * 40;
- y = HEIGHT / 8 + i * 28;
- evas_object_move(text, x, y);
- evas_object_show(text);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, text);
-
- text_body = ephysics_body_box_add(test_data->world);
- ephysics_body_evas_object_set(text_body, text, EINA_FALSE);
- ephysics_body_geometry_set(text_body, x, y, -15, w * 5 / 6, 40, 30);
- ephysics_body_friction_set(text_body, 0.1);
- ephysics_body_restitution_set(text_body, 0.95);
- test_data->bodies = eina_list_append(test_data->bodies, text_body);
- }
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_falling_letters(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Falling Letters", EINA_TRUE);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.3);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-typedef struct _Dragging_Data
-{
- EPhysics_Body *body;
- int node;
-} Dragging_Data;
-
-static void
-_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- ephysics_world_light_all_bodies_set(world, elm_check_state_get(obj));
-}
-
-static void
-_on_delete(void *data __UNUSED__, EPhysics_Body *body, void *event_info __UNUSED__)
-{
- Dragging_Data *dragging = ephysics_body_data_get(body);
- free(dragging);
-}
-
-static void
-_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
-{
- Dragging_Data *dragging = data;
- Evas_Event_Mouse_Down *mdown = event_info;
- Evas_Coord x, y;
-
- if (mdown->button != 1) return;
-
- evas_object_geometry_get(obj, &x, &y, NULL, NULL);
- dragging->node = ephysics_body_soft_body_triangle_index_get(
- dragging->body, mdown->output.x - x, mdown->output.y - y);
-
- ephysics_body_soft_body_dragging_set(dragging->body,
- dragging->node);
-
- DBG("Mouse down on %i, %i", mdown->output.x - x, mdown->output.y - y);
- DBG("Selected node: %i", dragging->node);
-}
-
-static void
-_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
-{
- Evas_Event_Mouse_Up *mup = event_info;
- Dragging_Data *dragging = data;
- if (mup->button != 1) return;
- ephysics_body_soft_body_dragging_unset(dragging->body);
- dragging->node = -1;
-}
-
-static void
-_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
-{
- Dragging_Data *dragging = data;
- Evas_Event_Mouse_Move *mmove = event_info;
- Evas_Coord nx, ny;
- Evas_Coord x, y;
-
- evas_object_geometry_get(obj, &x, &y, NULL, NULL);
- DBG("canvas = (%i, %i), output = (%i, %i)\n", mmove->cur.canvas.x,
- mmove->cur.canvas.y, mmove->cur.output.x, mmove->cur.output.y);
-
- if ((mmove->buttons != 1) || (dragging->node < 0)) return;
-
- nx = mmove->cur.output.x;
- ny = mmove->cur.output.y;
-
- DBG("Node: %d, nx: %d, ny: %d", dragging->node, nx, ny);
- ephysics_body_soft_body_triangle_move(dragging->body,
- dragging->node, nx, ny, 10);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *evas_obj;
- EPhysics_Body *flag_body, *pole_body;
- Dragging_Data *dragging;
-
- dragging = calloc(1, sizeof(Dragging_Data));
- dragging->node = -1;
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(
- evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "brown-pole");
- evas_object_move(evas_obj, 150, FLOOR_Y - 280);
- evas_object_resize(evas_obj, 17, 280);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- pole_body = ephysics_body_box_add(test_data->world);
- ephysics_body_mass_set(pole_body, 0);
- ephysics_body_evas_object_set(pole_body, evas_obj, EINA_TRUE);
- ephysics_body_restitution_set(pole_body, 0.5);
- ephysics_body_friction_set(pole_body, 0.1);
- test_data->bodies = eina_list_append(test_data->bodies, pole_body);
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(
- evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "green-flag");
- evas_object_move(evas_obj, 150 + 12, FLOOR_Y - 280 + 14);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- flag_body = ephysics_body_cloth_add(test_data->world, 0, 0);
- ephysics_body_soft_body_bending_constraints_add(flag_body, 1);
- ephysics_body_soft_body_position_iterations_set(flag_body, 10);
- ephysics_body_mass_set(flag_body, 10);
- ephysics_body_soft_body_hardness_set(flag_body, 1);
- ephysics_body_evas_object_set(flag_body, evas_obj, EINA_TRUE);
- ephysics_body_restitution_set(flag_body, 0.5);
- ephysics_body_friction_set(flag_body, 0.1);
- test_data->bodies = eina_list_append(test_data->bodies, flag_body);
- ephysics_body_cloth_anchor_full_add(flag_body, pole_body,
- EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_LEFT);
-
- evas_object_resize(evas_obj, 180, 126);
-
- dragging->body = flag_body;
- ephysics_body_data_set(flag_body, dragging);
-
- evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_MOUSE_DOWN,
- _mouse_down_cb, dragging);
- evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_MOUSE_UP,
- _mouse_up_cb, dragging);
- evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_MOUSE_MOVE,
- _mouse_move_cb, dragging);
-
- ephysics_body_event_callback_add(flag_body, EPHYSICS_CALLBACK_BODY_DEL,
- _on_delete, NULL);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_flag(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_World *world;
- Test_Data *test_data;
- Evas_Object *tg;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Flag", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- tg = elm_check_add(test_data->win);
- elm_object_style_set(tg, "ephysics-test");
- evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, 0.5);
- elm_check_state_set(tg, EINA_TRUE);
- evas_object_show(tg);
- elm_layout_content_set(test_data->layout, "extra_input", tg);
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- evas_object_smart_callback_add(tg, "changed", _changed_cb, world);
-
- ephysics_world_point_light_position_set(world, 300, 50, -200);
- ephysics_world_light_all_bodies_set(world, EINA_TRUE);
- ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
- EINA_TRUE);
-
- ephysics_body_top_boundary_add(test_data->world);
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-#define PAGE_NUM 3
-
-typedef struct _Page_Data
-{
- EPhysics_Body *body;
- Evas_Object *evas_obj;
- int order;
- struct {
- Evas_Coord x;
- Evas_Coord y;
- int node;
- } click_data;
- Evas_Coord x;
-} Page_Data;
-
-static void
-_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- ephysics_world_light_all_bodies_set(world, elm_check_state_get(obj));
-}
-
-static int
-_pages_sort_cb(const void *d1, const void *d2)
-{
- const Page_Data *page1, *page2;
-
- page1 = d1;
- page2 = d2;
-
- if (!page1) return -1;
- if (!page2) return 1;
-
- if (page1->order < page2->order) return -1;
- if (page2->order > page2->order) return 1;
-
- return 0;
-}
-
-static void
-_pages_restack(Eina_Hash *pages, Page_Data *page_data)
-{
- Page_Data *data;
- Eina_Iterator *it;
- Eina_List *l, *list = NULL;
- Eina_Bool found = EINA_FALSE;
- int i = 1;
-
- it = eina_hash_iterator_data_new(pages);
- while (eina_iterator_next(it, (void **)&data))
- list = eina_list_append(list, data);
- eina_iterator_free(it);
-
- list = eina_list_sort(list, eina_list_count(list), _pages_sort_cb);
- EINA_LIST_REVERSE_FOREACH(list, l, data)
- {
- if (found)
- {
- evas_object_layer_set(data->evas_obj, data->order);
- continue;
- }
-
- if (data->evas_obj == page_data->evas_obj)
- {
- found = EINA_TRUE;
- continue;
- }
- evas_object_layer_set(data->evas_obj, i);
- i++;
- }
-
- eina_list_free(list);
- evas_object_layer_set(page_data->evas_obj, PAGE_NUM);
-}
-
-static void
-_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
-{
- Test_Data *test_data = data;
- Eina_Hash *pages = test_data->data;
- Page_Data *page_data = eina_hash_find(pages, &obj);
- Evas_Event_Mouse_Down *mdown = event_info;
- Evas_Coord x, y;
-
- evas_object_geometry_get(obj, &x, &y, NULL, NULL);
- page_data->click_data.x = mdown->output.x;
- page_data->click_data.y = mdown->output.y;
- page_data->click_data.node = ephysics_body_soft_body_triangle_index_get(
- page_data->body, mdown->canvas.x -x, mdown->canvas.y -y);
-
- _pages_restack(pages, page_data);
- ephysics_body_soft_body_dragging_set(page_data->body,
- page_data->click_data.node);
-}
-
-static void
-_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Test_Data *test_data = data;
- Eina_Hash *pages = test_data->data;
- Page_Data *page_data = eina_hash_find(pages, &obj);
-
- ephysics_body_soft_body_dragging_unset(page_data->body);
-}
-
-static void
-_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
-{
- Test_Data *test_data = data;
- Eina_Hash *pages = test_data->data;
- Page_Data *page_data = eina_hash_find(pages, &obj);
- Evas_Event_Mouse_Move *mmove = event_info;
- Evas_Coord nx, ny, nz, zl, dist;
-
- if (mmove->buttons != 1 || page_data->click_data.node < 0) return;
-
- nx = mmove->cur.output.x;
- ny = mmove->cur.output.y;
-
- // distance between the clicked and the evas object x coordinates
- zl = sqrt(pow(page_data->click_data.x - page_data->x, 2));
-
- // distance between the current cursor x and the evas object x coordnates
- dist = sqrt(pow(nx - page_data->x, 2));
-
- // difference between both distances, the closer the x the highter the z
- nz = zl - dist;
-
- DBG("node: %d, nx: %d, ny: %d\n", page_data->click_data.node, nx, ny);
- ephysics_body_soft_body_triangle_move(page_data->body,
- page_data->click_data.node, nx, ny,
- -nz);
-}
-
-static void
-_page_update_cb(void *data __UNUSED__, EPhysics_Body *body, void *event_info __UNUSED__)
-{
- Evas_Coord z;
-
- ephysics_body_geometry_get(body, NULL, NULL, &z, NULL, NULL, NULL);
- if (z > -5 && z < 0) ephysics_body_stop(body);
- ephysics_body_evas_object_update(body);
-}
-
-static Page_Data *
-_page_add(Test_Data *test_data, EPhysics_Body *anchor, const char *img, Evas_Coord z)
-{
- Evas_Object *evas_obj;
- EPhysics_Body *body;
- Evas_Coord x, y;
- Page_Data *page_data;
-
- page_data = calloc(1, sizeof(Page_Data));
-
- x = WIDTH / 2;
- y = FLOOR_Y - 280;
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(
- evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", img);
- evas_object_move(evas_obj, x, y);
- evas_object_resize(evas_obj, 200, 282);
- evas_object_show(evas_obj);
- evas_object_layer_set(evas_obj, z);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- evas_object_geometry_get(evas_obj, &page_data->x, NULL, NULL, NULL);
-
- body = ephysics_body_cloth_add(test_data->world, 10, 10);
- ephysics_body_soft_body_anchor_hardness_set(body, 10);
- ephysics_body_soft_body_drag_coefficient_set(body, 0.0008);
- ephysics_body_soft_body_bending_constraints_add(body, 2);
- ephysics_body_restitution_set(body, 0);
- ephysics_body_friction_set(body, 0.9);
- ephysics_body_evas_object_set(body, evas_obj, EINA_TRUE);
-
- ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_UPDATE,
- _page_update_cb, NULL);
-
- ephysics_body_move(body, x, y, -z * 3);
-
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
- test_data->bodies = eina_list_append(test_data->bodies, body);
-
- ephysics_body_cloth_anchor_full_add(body, anchor,
- EPHYSICS_BODY_CLOTH_ANCHOR_SIDE_LEFT);
-
-
- page_data->body = body;
- page_data->evas_obj = evas_obj;
-
- return page_data;
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *evas_obj;
- EPhysics_Body *anchor;
- const char *img;
- Eina_Hash *pages;
- Page_Data *page_data;
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(
- evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "page-00");
- evas_object_move(evas_obj, (WIDTH / 2) - 200, FLOOR_Y - 280);
- evas_object_resize(evas_obj, 200, 282);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- anchor = ephysics_body_back_boundary_add(test_data->world);
- ephysics_body_restitution_set(anchor, 0);
- ephysics_body_friction_set(anchor, 0.9);
- test_data->bodies = eina_list_append(test_data->bodies, anchor);
-
- pages = eina_hash_pointer_new(NULL);
- test_data->data = pages;
-
- for (int i = 1; i <= PAGE_NUM; i++)
- {
- img = eina_stringshare_printf("page-0%d", (PAGE_NUM + 1) - i);
- page_data = _page_add(test_data, anchor, img, i);
- page_data->order = i;
- eina_hash_add(pages, &page_data->evas_obj, page_data);
-
- ephysics_body_collision_group_add(page_data->body, img);
-
- evas_object_event_callback_add(page_data->evas_obj,
- EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb,
- test_data);
- evas_object_event_callback_add(page_data->evas_obj,
- EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb,
- test_data);
- evas_object_event_callback_add(page_data->evas_obj,
- EVAS_CALLBACK_MOUSE_MOVE, _mouse_move_cb,
- test_data);
- }
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- eina_hash_free(test_data->data);
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_flip_page(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_World *world;
- Test_Data *test_data;
- Evas_Object *tg;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
-
- test_win_add(test_data, "Flip Page", EINA_TRUE);
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
-
- world = ephysics_world_new();
- ephysics_world_simulation_set(world, 1/100.f, 5);
- ephysics_world_gravity_set(world, 0, 0, 9.8);
- ephysics_world_render_geometry_set(world, 0, 0, 20, WIDTH, HEIGHT, 2);
-
- ephysics_world_point_light_position_set(world, WIDTH / 2, HEIGHT / 2, -200);
- ephysics_camera_perspective_set(ephysics_world_camera_get(world), WIDTH/2,
- HEIGHT/2, 0, 1800);
- ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
- EINA_TRUE);
- test_data->world = world;
- _world_populate(test_data);
-
- tg = elm_check_add(test_data->win);
- elm_object_style_set(tg, "ephysics-test");
- evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, 0.5);
- elm_check_state_set(tg, EINA_FALSE);
- evas_object_show(tg);
- elm_layout_content_set(test_data->layout, "extra_input", tg);
-
- evas_object_smart_callback_add(tg, "changed", _changed_cb, world);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-typedef struct _Dragging_Data {
- int mouse_status; // 0, up, 1, down
- double curr_mass;
- struct {
- int x;
- int y;
- } clicked_position;
-} Dragging_Data;
-
-static void
-_on_delete(void *data __UNUSED__, EPhysics_Body *body, void *event_info __UNUSED__)
-{
- Dragging_Data *dragging = ephysics_body_data_get(body);
- if (dragging)
- free(dragging);
-}
-
-static void
-_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Dragging_Data *dragging = ephysics_body_data_get(data);
- Evas_Event_Mouse_Down *mdown = event_info;
- Evas_Coord x, y;
-
- evas_object_geometry_get(obj, &x, &y, NULL, NULL);
- dragging->mouse_status = 1;
- dragging->clicked_position.x = mdown->output.x - x;
- dragging->clicked_position.y = mdown->output.y - y;
- dragging->curr_mass = ephysics_body_mass_get(data);
- ephysics_body_mass_set(data, 0);
-}
-
-static void
-_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- Dragging_Data *dragging = ephysics_body_data_get(data);
- dragging->mouse_status = 0;
- ephysics_body_mass_set(data, dragging->curr_mass);
- dragging->curr_mass = 0;
-}
-
-static void
-_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
-{
- EPhysics_Body *body = data;
- Dragging_Data *dragging = ephysics_body_data_get(body);
- Evas_Event_Mouse_Move *mmove = event_info;
- Evas_Coord nx, ny;
-
- if (!dragging->mouse_status) return;
-
- nx = mmove->cur.output.x - dragging->clicked_position.x;
- ny = mmove->cur.output.y - dragging->clicked_position.y;
-
- if (nx < 0 || ny < 0) return;
- ephysics_body_move(body, nx, ny, -15);
-}
-
-static void
-_box_add(Test_Data *test_data, Evas_Coord x, Evas_Coord y, const char *file)
-{
- Evas_Object *evas_obj, *shadow;
- EPhysics_Body *body;
- Dragging_Data *dragging;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-cube");
- evas_object_move(shadow, x, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(
- evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", file);
- evas_object_move(evas_obj, x, y - 70);
- evas_object_resize(evas_obj, 70, 70);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- body = ephysics_body_box_add(test_data->world);
- ephysics_body_evas_object_set(body, evas_obj, EINA_TRUE);
- ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, body);
-
- dragging = calloc(1, sizeof(Dragging_Data));
- ephysics_body_data_set(body, dragging);
-
- evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_MOUSE_DOWN,
- _mouse_down_cb, body);
- evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_MOUSE_UP,
- _mouse_up_cb, body);
- evas_object_event_callback_add(evas_obj, EVAS_CALLBACK_MOUSE_MOVE,
- _mouse_move_cb, body);
- ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL,
- _on_delete, NULL);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- _box_add(test_data, WIDTH / 3, FLOOR_Y, "blue-cube");
- _box_add(test_data, WIDTH / 3 - 70, FLOOR_Y, "purple-cube");
- _box_add(test_data, WIDTH / 3 + 70, FLOOR_Y, "purple-cube");
- _box_add(test_data, WIDTH / 3 + 140, FLOOR_Y, "blue-cube");
- _box_add(test_data, WIDTH / 3 - 35, FLOOR_Y - 70, "purple-cube");
- _box_add(test_data, WIDTH / 3 + 35, FLOOR_Y - 70, "blue-cube");
- _box_add(test_data, WIDTH / 3 + 105, FLOOR_Y - 70, "purple-cube");
- _box_add(test_data, WIDTH / 3, FLOOR_Y - 140, "blue-cube");
- _box_add(test_data, WIDTH / 3 + 70, FLOOR_Y - 140, "purple-cube");
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_grab(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Grab", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
- elm_object_signal_emit(test_data->layout, "grab,show", "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.65);
- ephysics_body_friction_set(boundary, 4);
-
- boundary = ephysics_body_right_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.4);
- ephysics_body_friction_set(boundary, 3);
-
- boundary = ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.4);
- ephysics_body_friction_set(boundary, 3);
-
- ephysics_body_top_boundary_add(test_data->world);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_add_sphere(Test_Data *test_data, int i)
-{
- EPhysics_Body *body;
- Evas_Object *sphere;
- static const char *colors[] = {"blue-ball", "red-ball", "green-ball"};
-
- sphere = elm_image_add(test_data->win);
- elm_image_file_set(
- sphere, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", colors[i % 3]);
- evas_object_move(sphere, 50 + (i % 34) * 12, 40 + i / 34 * 12);
- evas_object_resize(sphere, 10, 10);
- evas_object_show(sphere);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
-
- body = ephysics_body_sphere_add(test_data->world);
- ephysics_body_restitution_set(body, 0.85);
- ephysics_body_evas_object_set(body, sphere, EINA_TRUE);
- test_data->bodies = eina_list_append(test_data->bodies, body);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- int i;
- for (i = 0; i < 612; i++)
- _add_sphere(test_data, i);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- test_clean(data);
- _world_populate(data);
-}
-
-void
-test_heavy(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Heavy", EINA_TRUE);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_layout_signal_emit(test_data->layout, "loading_bar,show",
- "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 1);
-
- ephysics_body_top_boundary_add(test_data->world);
- ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_right_boundary_add(test_data->world);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_door_create(Test_Data *test_data, Evas_Object *front, Evas_Object *back, Evas_Object *right, Evas_Object *left, Evas_Object *top)
-{
- EPhysics_Body *body;
- EPhysics_Constraint *constraint;
- Evas_Coord x, y, z, w, h, d;
-
- body = ephysics_body_box_add(test_data->world);
- test_data->bodies = eina_list_append(test_data->bodies, body);
-
- ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_TOP, top,
- EINA_TRUE);
-
- ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_RIGHT, right,
- EINA_TRUE);
-
- ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_LEFT, left,
- EINA_TRUE);
-
- ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_FRONT, front,
- EINA_TRUE);
-
- ephysics_body_face_evas_object_set(body, EPHYSICS_BODY_BOX_FACE_BACK, back,
- EINA_TRUE);
-
- ephysics_body_angular_movement_enable_set(body, EINA_FALSE, EINA_TRUE,
- EINA_FALSE);
-
- ephysics_body_linear_movement_enable_set(body, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
-
- ephysics_body_geometry_get(body, &x, &y, &z, &w, &h, &d);
- ephysics_body_resize(body, w, h, 6);
- ephysics_body_move(body, x, y, 150);
- ephysics_body_geometry_get(body, &x, &y, &z, &w, &h, &d);
-
- constraint = ephysics_constraint_add(body);
- ephysics_constraint_angular_limit_set(constraint, 0, 0, 90, 0, 0, 0);
- ephysics_constraint_anchor_set(constraint, x - 2, y + h / 2, z + d / 2, 0, 0,
- 0);
- test_data->constraints = eina_list_append(test_data->constraints, constraint);
- ephysics_body_impulse_apply(body, 0, 0, -10, x + w, y + h / 2, z);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *front, *back, *right, *left, *top;
-
- front = elm_image_add(test_data->win);
- elm_image_file_set(
- front, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "door-front");
- evas_object_resize(front, 139, 270);
- evas_object_move(front, WIDTH / 3, FLOOR_Y - 290);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, front);
-
- back = elm_image_add(test_data->win);
- elm_image_file_set(
- back, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "door-back");
- evas_object_resize(back, 139, 270);
- evas_object_move(back, WIDTH / 3, FLOOR_Y - 290);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, back);
-
- right = evas_object_rectangle_add(evas_object_evas_get(test_data->win));
- evas_object_color_set(right, 117, 75, 35, 255);
- evas_object_resize(right, 6, 270);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, right);
-
- left = evas_object_rectangle_add(evas_object_evas_get(test_data->win));
- evas_object_color_set(left, 117, 75, 35, 255);
- evas_object_resize(left, 6, 270);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, left);
-
- top = evas_object_rectangle_add(evas_object_evas_get(test_data->win));
- evas_object_color_set(top, 117, 75, 35, 255);
- evas_object_resize(top, 139, 6);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, top);
-
- _door_create(test_data, front, back, right, left, top);
-
- evas_object_show(front);
- evas_object_show(back);
- evas_object_show(right);
- evas_object_show(left);
- evas_object_show(top);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_hinge(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Camera *cam;
- EPhysics_World *world;
- Test_Data *test_data;
- Evas_Object *floor_obj, *door_post;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Hinge", EINA_TRUE);
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
-
- floor_obj = elm_image_add(test_data->win);
- elm_image_file_set(
- floor_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "floor");
- evas_object_move(floor_obj, 0, FLOOR_Y - 20);
- evas_object_resize(floor_obj, FLOOR_WIDTH, 224);
- evas_object_show(floor_obj);
-
- door_post = elm_image_add(test_data->win);
- elm_image_file_set(
- door_post, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "door-post");
- evas_object_resize(door_post, 147, 278);
- evas_object_move(door_post, WIDTH / 3 - 5, FLOOR_Y - 295);
- evas_object_show(door_post);
-
- world = ephysics_world_new();
- cam = ephysics_world_camera_get(world);
- ephysics_world_render_geometry_set(world, 0, 0, 0, WIDTH - 100, FLOOR_Y - 300,
- 300);
- ephysics_camera_perspective_enabled_set(cam, EINA_TRUE);
-
- test_data->world = world;
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-struct _Ball_Props {
- int color;
- int size;
- int x;
- int y;
-};
-
-static void
-_jump(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- Eina_List *l, *bodies;
- EPhysics_Body *body;
- Test_Data *test_data = data;
- EPhysics_World *world = test_data->world;
- Evas_Object *bt = test_data->data;
-
- elm_object_disabled_set(bt, EINA_TRUE);
- bodies = ephysics_world_bodies_get(world);
- EINA_LIST_FOREACH(bodies, l, body)
- ephysics_body_central_impulse_apply(body, 0, -300, 0);
- eina_list_free(bodies);
-}
-
-static void
-_add_sphere(Test_Data *test_data, int i)
-{
- Evas_Object *sphere, *shadow;
- EPhysics_Body *fall_body;
-
- static const char *colors[] = {"big-blue-ball", "red-ball", "green-ball"};
- static const struct _Ball_Props props[] = {
- {2, 54, 220, 136},
- {0, 70, 180, 178}, {0, 70, 248, 178},
- {1, 54, 166, 244}, {1, 54, 220, 244}, {1, 54, 274, 244},
- {2, 54, 138, 290}, {2, 54, 192, 290},
- {2, 54, 246, 290}, {2, 54, 300, 290},
- };
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, props[i].x, FLOOR_Y);
- evas_object_resize(shadow, props[i].size, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- sphere = elm_image_add(test_data->win);
- elm_image_file_set(
- sphere, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- colors[props[i].color]);
- evas_object_move(sphere, props[i].x, props[i].y);
- evas_object_resize(sphere, props[i].size, props[i].size);
- evas_object_show(sphere);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
-
- fall_body = ephysics_body_sphere_add(test_data->world);
- ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
- ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- ephysics_body_restitution_set(fall_body, 0.95);
- ephysics_body_friction_set(fall_body, 1);
- test_data->bodies = eina_list_append(test_data->bodies, fall_body);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- int i;
-
- for (i = 0; i < 10; i++)
- _add_sphere(test_data, i);
-
- elm_object_signal_emit(test_data->data, "click", "ephysics_test");
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
- Evas_Object *bt = test_data->data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
- elm_object_disabled_set(bt, EINA_FALSE);
-}
-
-static void
-_world_stopped_cb(void *data, EPhysics_World *world __UNUSED__, void *event_info __UNUSED__)
-{
- Evas_Object *bt = data;
- elm_object_disabled_set(bt, EINA_FALSE);
- INF("World stopped\n");
-}
-
-static void
-_world_update_cb(void *data __UNUSED__, EPhysics_World *world __UNUSED__, void *event_info __UNUSED__)
-{
- INF("World update\n");
-}
-
-void
-test_jumping_balls(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
- Evas_Object *bt;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Jumping Balls", EINA_TRUE);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- bt = elm_button_add(test_data->win);
- elm_object_style_set(bt, "ephysics-test-jump");
- elm_layout_content_set(test_data->layout, "extra_button", bt);
- evas_object_smart_callback_add(bt, "clicked", _jump, test_data);
-
- test_data->data = bt;
- ephysics_world_event_callback_add(world, EPHYSICS_CALLBACK_WORLD_STOPPED,
- _world_stopped_cb, bt);
- ephysics_world_event_callback_add(world, EPHYSICS_CALLBACK_WORLD_UPDATE,
- _world_update_cb, NULL);
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.65);
- ephysics_body_friction_set(boundary, 2);
-
- ephysics_body_top_boundary_add(test_data->world);
- ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_right_boundary_add(test_data->world);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- ephysics_world_light_all_bodies_set(world, elm_check_state_get(obj));
-}
-
-static void
-_ball_add(Test_Data *test_data, int x)
-{
- Evas_Object *sphere, *shadow;
- EPhysics_Body *ball;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, WIDTH / 3, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- sphere = elm_image_add(test_data->win);
- elm_image_file_set(
- sphere, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "big-blue-ball");
- evas_object_move(sphere, x, HEIGHT / 8);
- evas_object_resize(sphere, 70, 70);
- evas_object_show(sphere);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
-
- ball = ephysics_body_sphere_add(test_data->world);
- ephysics_body_evas_object_set(ball, sphere, EINA_TRUE);
- ephysics_body_restitution_set(ball, 0.95);
- ephysics_body_friction_set(ball, 0.1);
- ephysics_body_event_callback_add(ball, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, ball);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- _ball_add(test_data, WIDTH / 3);
- _ball_add(test_data, WIDTH / 3 + 160);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- test_clean(data);
- _world_populate(data);
-}
-
-void
-test_light(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
- Evas_Object *tg;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Light", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- tg = elm_check_add(test_data->win);
- elm_object_style_set(tg, "ephysics-test");
- evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, 0.5);
- elm_check_state_set(tg, EINA_TRUE);
- evas_object_show(tg);
- elm_layout_content_set(test_data->layout, "extra_input", tg);
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- evas_object_smart_callback_add(tg, "changed", _changed_cb, world);
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.65);
- ephysics_body_friction_set(boundary, 4);
-
- ephysics_world_point_light_position_set(world, 200, 300, -120);
- ephysics_world_point_light_color_set(world, 255, 120, 120);
- ephysics_world_ambient_light_color_set(world, 40, 40, 40);
- ephysics_world_light_all_bodies_set(world, EINA_TRUE);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_material_change(Test_Data *test_data)
-{
- double density, mass, restitution, friction;
- EPhysics_Body *body;
- Evas_Object *sp;
- int material;
-
- sp = test_data->data;
- material = (int) elm_spinner_value_get(sp);
- body = evas_object_data_get(sp, "body");
-
- ephysics_body_material_set(body, material);
-
- material = ephysics_body_material_get(body);
- density = ephysics_body_density_get(body);
- mass = ephysics_body_mass_get(body);
- restitution = ephysics_body_restitution_get(body);
- friction = ephysics_body_friction_get(body);
-
- INF("Material: %i, Density: %lf, Mass: %lf, Restitution: %lf, Friction: %lf",
- material, density, mass, restitution, friction);
-}
-
-static void
-_material_changed_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- _material_change(data);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *sphere, *shadow;
- EPhysics_Body *fall_body;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, WIDTH / 3, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- sphere = elm_image_add(test_data->win);
- elm_image_file_set(
- sphere, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "big-blue-ball");
- evas_object_move(sphere, WIDTH / 3, HEIGHT / 8);
- evas_object_resize(sphere, 70, 70);
- evas_object_show(sphere);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
-
- fall_body = ephysics_body_sphere_add(test_data->world);
- ephysics_body_evas_object_set(fall_body, sphere, EINA_TRUE);
- ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, fall_body);
-
- evas_object_data_set(test_data->data, "body", fall_body);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- DBG("Restart pressed");
- test_clean(data);
- _world_populate(data);
- _material_change(data);
-}
-
-void
-test_material(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
- Evas_Object *sp;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Material", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- sp = elm_spinner_add(test_data->win);
- elm_spinner_min_max_set(sp, 0, 6);
- elm_spinner_step_set(sp, 1);
- elm_spinner_wrap_set(sp, EINA_TRUE);
- elm_spinner_special_value_add(sp, 0, "Custom");
- elm_spinner_special_value_add(sp, 1, "Concrete");
- elm_spinner_special_value_add(sp, 2, "Iron");
- elm_spinner_special_value_add(sp, 3, "Plastic");
- elm_spinner_special_value_add(sp, 4, "Polystyrene");
- elm_spinner_special_value_add(sp, 5, "Rubber");
- elm_spinner_special_value_add(sp, 6, "Wood");
- elm_spinner_editable_set(sp, EINA_FALSE);
- elm_object_style_set(sp, "ephysics-test");
- evas_object_smart_callback_add(sp, "delay,changed", _material_changed_cb,
- test_data);
- elm_layout_content_set(test_data->layout, "extra_input", sp);
- test_data->data = sp;
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 1);
-
- _world_populate(test_data);
- _material_change(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_world_populate(Test_Data *test_data)
-{
- EPhysics_Body *box_body1, *box_body2;
- Evas_Object *box1, *box2, *sh1, *sh2;
-
- sh1 = elm_layout_add(test_data->win);
- elm_layout_file_set(
- sh1, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-cube");
- evas_object_move(sh1, WIDTH / 6, FLOOR_Y);
- evas_object_resize(sh1, 70, 3);
- evas_object_show(sh1);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, sh1);
-
- box1 = elm_image_add(test_data->win);
- elm_image_file_set(
- box1, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "blue-cube");
- evas_object_move(box1, WIDTH / 6, FLOOR_Y - 70);
- evas_object_resize(box1, 70, 70);
- evas_object_show(box1);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, box1);
-
- box_body1 = ephysics_body_box_add(test_data->world);
- ephysics_body_mass_set(box_body1, 0);
- ephysics_body_evas_object_set(box_body1, box1, EINA_TRUE);
- ephysics_body_event_callback_add(box_body1, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, sh1);
- ephysics_body_restitution_set(box_body1, 0.3);
- ephysics_body_friction_set(box_body1, 0.1);
- test_data->bodies = eina_list_append(test_data->bodies, box_body1);
-
- sh2 = elm_layout_add(test_data->win);
- elm_layout_file_set(
- sh2, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-cube");
- evas_object_move(sh2, WIDTH / 6 + 60, FLOOR_Y);
- evas_object_resize(sh2, 70, 3);
- evas_object_show(sh2);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, sh2);
-
- box2 = elm_image_add(test_data->win);
- elm_image_file_set(
- box2, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube");
- evas_object_move(box2, WIDTH / 6 + 60, HEIGHT / 8);
- evas_object_resize(box2, 70, 70);
- evas_object_show(box2);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, box2);
-
- box_body2 = ephysics_body_box_add(test_data->world);
- ephysics_body_evas_object_set(box_body2, box2, EINA_TRUE);
- ephysics_body_event_callback_add(box_body2, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, sh2);
- ephysics_body_restitution_set(box_body2, 0.5);
- ephysics_body_friction_set(box_body2, 0.1);
- test_data->bodies = eina_list_append(test_data->bodies, box_body2);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_rotate(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Rotate", EINA_TRUE);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.65);
- ephysics_body_friction_set(boundary, 3);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *evas_obj, *shadow;
- EPhysics_Body *fall_body;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, 200, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- "big-red-ball");
- evas_object_move(evas_obj, 200, 200);
- evas_object_resize(evas_obj, 70, 70);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- fall_body = ephysics_body_soft_cylinder_add(test_data->world);
- ephysics_body_soft_body_hardness_set(fall_body, 10);
- ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
- ephysics_body_restitution_set(fall_body, 0.95);
- ephysics_body_friction_set(fall_body, 0.1);
- ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, fall_body);
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, 200, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- "big-blue-ball");
- evas_object_move(evas_obj, 300, 100);
- evas_object_resize(evas_obj, 70, 70);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- fall_body = ephysics_body_soft_cylinder_add(test_data->world);
- ephysics_body_soft_body_hardness_set(fall_body, 30);
- ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
- ephysics_body_restitution_set(fall_body, 0.95);
- ephysics_body_friction_set(fall_body, 0.1);
- ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, fall_body);
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, 100, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- "big-blue-ball");
- evas_object_move(evas_obj, 200, 50);
- evas_object_resize(evas_obj, 70, 70);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- fall_body = ephysics_body_sphere_add(test_data->world);
- ephysics_body_mass_set(fall_body, 2);
- ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
- ephysics_body_restitution_set(fall_body, 0.95);
- ephysics_body_friction_set(fall_body, 0.1);
- ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, fall_body);
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-cube");
- evas_object_move(shadow, 100, FLOOR_Y);
- evas_object_resize(shadow, 70, 3);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- evas_obj = elm_image_add(test_data->win);
- elm_image_file_set(
- evas_obj, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube");
- evas_object_move(evas_obj, 100, 220);
- evas_object_resize(evas_obj, 70, 70);
- evas_object_show(evas_obj);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, evas_obj);
-
- fall_body = ephysics_body_soft_box_add(test_data->world);
- ephysics_body_soft_body_hardness_set(fall_body, 10);
- ephysics_body_evas_object_set(fall_body, evas_obj, EINA_TRUE);
- ephysics_body_event_callback_add(fall_body, EPHYSICS_CALLBACK_BODY_UPDATE,
- update_object_cb, shadow);
- ephysics_body_restitution_set(fall_body, 0.5);
- ephysics_body_friction_set(fall_body, 0.1);
- test_data->bodies = eina_list_append(test_data->bodies, fall_body);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_soft_body(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Soft Body", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_simulation_set(world, 1/150.f, 5);
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.65);
- ephysics_body_friction_set(boundary, 4);
-
- boundary = ephysics_body_right_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.4);
- ephysics_body_friction_set(boundary, 3);
-
- boundary = ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 0.4);
- ephysics_body_friction_set(boundary, 3);
-
- ephysics_body_top_boundary_add(test_data->world);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
-{
- EPhysics_Body *body = data;
- Evas_Event_Mouse_Down *mdown = event_info;
- Evas_Coord w, h, x, y, z, d;
- Eina_List *triangles;
- int *ldata;
-
- ephysics_body_geometry_get(body, NULL, NULL, &z, NULL, NULL, &d);
-
- w = 80;
- h = 80;
- x = mdown->output.x - (w / 2);
- y = mdown->output.y - (h / 2);
- d = d / 2;
-
- triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, z,
- w, h, d);
- ephysics_body_soft_body_triangle_list_impulse_apply(body, triangles, 0, 0,
- 200);
- EINA_LIST_FREE(triangles, ldata)
- free(ldata);
-}
-
-static void
-_soft_sphere_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *back_face)
-{
- EPhysics_Body *body;
- Evas_Coord x, y, w, h;
-
-
- body = ephysics_body_soft_sphere_add(test_data->world, 500);
-
- ephysics_body_soft_body_position_iterations_set(body, 16);
- ephysics_body_soft_body_anchor_hardness_set(body, 0);
- ephysics_body_soft_body_hardness_set(body, 3);
-
- ephysics_body_face_evas_object_set(body,
- EPHYSICS_BODY_SPHERE_FACE_FRONT,
- front_face, EINA_TRUE);
-
- ephysics_body_face_evas_object_set(body,
- EPHYSICS_BODY_SPHERE_FACE_BACK,
- back_face, EINA_TRUE);
-
- ephysics_body_geometry_get(body, &x, &y, NULL, &w, &h, NULL);
- ephysics_body_geometry_set(body, x, y, 30, w, h, h);
-
- ephysics_body_linear_movement_enable_set(body, EINA_FALSE, EINA_FALSE,
- EINA_FALSE);
- ephysics_body_angular_movement_enable_set(body, EINA_FALSE, EINA_FALSE,
- EINA_FALSE);
-
- test_data->bodies = eina_list_append(test_data->bodies, body);
-
- evas_object_event_callback_add(front_face, EVAS_CALLBACK_MOUSE_DOWN,
- _mouse_down_cb, body);
-
- evas_object_event_callback_add(back_face, EVAS_CALLBACK_MOUSE_DOWN,
- _mouse_down_cb, body);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *front_face, *back_face;
-
- front_face = elm_image_add(test_data->win);
- elm_image_file_set(
- front_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- "purple-cube420");
- evas_object_move(front_face, WIDTH / 4, HEIGHT / 4);
- evas_object_resize(front_face, 280, 280);
- evas_object_show(front_face);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, front_face);
-
- back_face = elm_image_add(test_data->win);
- elm_image_file_set(
- back_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj",
- "purple-cube420");
- evas_object_move(back_face, WIDTH / 4, HEIGHT / 4);
- evas_object_resize(back_face, 280, 280);
- evas_object_show(back_face);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, back_face);
-
- _soft_sphere_add(test_data, front_face, back_face);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-static void
-_changed_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
-{
- EPhysics_World *world = data;
- ephysics_world_light_all_bodies_set(world, elm_check_state_get(obj));
-}
-
-void
-test_soft_button(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_World *world;
- Test_Data *test_data;
- Evas_Object *tg;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Soft Button", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- tg = elm_check_add(test_data->win);
- elm_object_style_set(tg, "ephysics-test");
- evas_object_size_hint_weight_set(tg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(tg, EVAS_HINT_FILL, 0.5);
- elm_check_state_set(tg, EINA_FALSE);
- evas_object_show(tg);
- elm_layout_content_set(test_data->layout, "extra_input", tg);
-
- world = ephysics_world_new();
- ephysics_world_simulation_set(world, 1/260.f, 5);
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- ephysics_world_point_light_position_set(world, 300, 50, -200);
- ephysics_camera_perspective_enabled_set(ephysics_world_camera_get(world),
- EINA_TRUE);
-
- evas_object_smart_callback_add(tg, "changed", _changed_cb, world);
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-static void
-_mouse_down_cb(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
-{
- EPhysics_Body *body = data;
- Evas_Event_Mouse_Down *mdown = event_info;
- Evas_Coord w, h, x, y, z, d;
- Eina_List *triangles;
- int *ldata;
-
- ephysics_body_geometry_get(body, NULL, NULL, &z, NULL, NULL, &d);
-
- w = 20;
- h = 20;
- x = mdown->output.x - (w / 2);
- y = mdown->output.y - (h / 2);
- d = d / 2;
-
- triangles = ephysics_body_soft_body_triangles_inside_get(body, x, y, z,
- w, h, d);
- ephysics_body_soft_body_triangle_list_impulse_apply(body, triangles, 0, 0,
- 10);
- EINA_LIST_FREE(triangles, ldata)
- free(ldata);
-}
-
-static void
-_soft_sphere_add(Test_Data *test_data, Evas_Object *front_face, Evas_Object *back_face)
-{
- EPhysics_Body *body;
- Evas_Coord w, h;
-
-
- body = ephysics_body_soft_sphere_add(test_data->world, 100);
-
- ephysics_body_face_evas_object_set(body,
- EPHYSICS_BODY_SPHERE_FACE_FRONT, front_face, EINA_TRUE);
-
- ephysics_body_face_evas_object_set(body,
- EPHYSICS_BODY_SPHERE_FACE_BACK, back_face, EINA_TRUE);
-
- ephysics_body_geometry_get(body, NULL, NULL, NULL, &w, &h, NULL);
- ephysics_body_resize(body, w, h, h);
- test_data->bodies = eina_list_append(test_data->bodies, body);
-
- ephysics_body_linear_movement_enable_set(body, EINA_FALSE, EINA_FALSE,
- EINA_TRUE);
- ephysics_body_angular_movement_enable_set(body, EINA_TRUE, EINA_TRUE,
- EINA_TRUE);
-
- evas_object_event_callback_add(front_face, EVAS_CALLBACK_MOUSE_DOWN,
- _mouse_down_cb, body);
-
- evas_object_event_callback_add(back_face, EVAS_CALLBACK_MOUSE_DOWN,
- _mouse_down_cb, body);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *front_face, *back_face;
-
- front_face = elm_image_add(test_data->win);
- elm_image_file_set(
- front_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube");
- evas_object_move(front_face, WIDTH / 2 - 35, HEIGHT / 2 - 35);
- evas_object_resize(front_face, 70, 70);
- evas_object_show(front_face);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, front_face);
-
- back_face = elm_image_add(test_data->win);
- elm_image_file_set(
- back_face, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "purple-cube");
- evas_object_move(back_face, WIDTH / 2 - 35, HEIGHT / 2 - 35);
- evas_object_resize(back_face, 70, 70);
- evas_object_show(back_face);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, back_face);
-
- _soft_sphere_add(test_data, front_face, back_face);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_soft_sphere(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Soft Sphere", EINA_TRUE);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
-
- world = ephysics_world_new();
- ephysics_world_simulation_set(world, 1/150.f, 5);
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- ephysics_world_point_light_position_set(world, 300, 50, -200);
-
- _world_populate(test_data);
-}
+++ /dev/null
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "ephysics_test.h"
-
-typedef struct _Old_Rate Old_Rate;
-struct _Old_Rate {
- EPhysics_Body *body;
- double w;
- double h;
-};
-
-static void
-_win_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- free(data);
-}
-
-static void
-_win_resize_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
-{
- Test_Data *test_data = data;
- EPhysics_Body *sphere_body;
- double ratew, rateh;
- Evas_Object *sphere;
- Old_Rate *old_rate;
- int ww, wh, x, y;
-
- evas_object_geometry_get(obj, NULL, NULL, &ww, &wh);
- ratew = (double) ww / WIDTH;
- rateh = (double) wh / HEIGHT;
-
- /* Since we don't support different rates on ephysics world, we
- should make sure window keeps its aspect.
- Maybe if we decide it should be supported someday,
- this example could be modified just dropping the following check. */
- if (ratew > rateh)
- {
- ww = rateh * WIDTH;
- evas_object_resize(obj, ww, wh);
- return;
- }
- else if (ratew < rateh)
- {
- wh = ratew * HEIGHT;
- evas_object_resize(obj, ww, wh);
- return;
- }
-
- evas_object_resize(test_data->layout, ww, wh);
- ephysics_world_rate_set(test_data->world, 30 * rateh);
- ephysics_world_render_geometry_set(test_data->world, 50 * ratew, 40 *rateh,
- -50,
- (WIDTH - 100) * ratew,
- (FLOOR_Y - 40) * rateh,
- DEPTH);
-
- old_rate = test_data->data;
- if (!old_rate) return;
- sphere_body = old_rate->body;
-
- sphere = ephysics_body_evas_object_get(sphere_body);
- evas_object_geometry_get(sphere, &x, &y, NULL, NULL);
-
- ephysics_body_move(sphere_body, x * (ratew / old_rate->w),
- y * (rateh / old_rate->h), -15);
- evas_object_resize(sphere, 70 * ratew, 70 * rateh);
-
- old_rate->w = ratew;
- old_rate->h = rateh;
-}
-
-static void
-_update_object_cb(void *data, EPhysics_Body *body, void *event_info)
-{
- Evas_Object *sphere = event_info;
- Evas_Object *shadow = data;
- Edje_Message_Float msg;
- Old_Rate *old_rate;
- Evas_Object *edje;
- int x, y, w, h;
-
- ephysics_body_evas_object_update(body);
- old_rate = ephysics_body_data_get(body);
- evas_object_geometry_get(sphere, &x, &y, &w, &h);
-
- if (y > SH_THRESHOLD * old_rate->h)
- {
- int sh_w;
-
- msg.val = (double) (y - SH_THRESHOLD * old_rate->h) /
- ((FLOOR_Y - SH_THRESHOLD) * old_rate->h - h);
- sh_w = (1 + 2 * msg.val) * w / 3;
- evas_object_resize(shadow, sh_w, 3 * old_rate->h);
- evas_object_move(shadow, x + (w - sh_w) / 2, FLOOR_Y * old_rate->h);
- }
- else
- msg.val = 0;
-
- edje = elm_layout_edje_get(shadow);
- edje_object_message_send(edje, EDJE_MESSAGE_FLOAT, SHADOW_ALPHA_ID, &msg);
-}
-
-static void
-_world_populate(Test_Data *test_data)
-{
- Evas_Object *sphere, *shadow;
- EPhysics_Body *sphere_body;
- Old_Rate *old_rate;
- int w, h;
-
- old_rate = test_data->data;
- if (!test_data->data)
- old_rate = calloc(1, sizeof(Old_Rate));
- if (!old_rate) return;
- test_data->data = old_rate;
-
- evas_object_geometry_get(test_data->win, NULL, NULL, &w, &h);
- old_rate->w = (double) w / WIDTH;
- old_rate->h = (double) h / HEIGHT;
-
- shadow = elm_layout_add(test_data->win);
- elm_layout_file_set(
- shadow, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "shadow-ball");
- evas_object_move(shadow, WIDTH / 3 * old_rate->w, FLOOR_Y * old_rate->h);
- evas_object_resize(shadow, 70 * old_rate->w, 3 * old_rate->h);
- evas_object_show(shadow);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, shadow);
-
- sphere = elm_image_add(test_data->win);
- elm_image_file_set(
- sphere, PACKAGE_DATA_DIR "/" EPHYSICS_TEST_THEME ".edj", "big-blue-ball");
- evas_object_move(sphere, WIDTH / 3 * old_rate->w, HEIGHT / 2 * old_rate->h);
- evas_object_resize(sphere, 70 * old_rate->w, 70 * old_rate->h);
- evas_object_show(sphere);
- test_data->evas_objs = eina_list_append(test_data->evas_objs, sphere);
-
- sphere_body = ephysics_body_sphere_add(test_data->world);
- ephysics_body_evas_object_set(sphere_body, sphere, EINA_TRUE);
- ephysics_body_restitution_set(sphere_body, 1.0);
- ephysics_body_event_callback_add(sphere_body, EPHYSICS_CALLBACK_BODY_UPDATE,
- _update_object_cb, shadow);
- test_data->bodies = eina_list_append(test_data->bodies, sphere_body);
- old_rate->body = sphere_body;
- ephysics_body_data_set(sphere_body, old_rate);
-}
-
-static void
-_restart(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
-{
- Test_Data *test_data = data;
-
- DBG("Restart pressed");
- test_clean(test_data);
- _world_populate(test_data);
-}
-
-void
-test_win_resize(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
-{
- EPhysics_Body *boundary;
- EPhysics_World *world;
- Test_Data *test_data;
-
- if (!ephysics_init())
- return;
-
- test_data = test_data_new();
- test_win_add(test_data, "Win Resize", EINA_TRUE);
- evas_object_event_callback_add(test_data->win, EVAS_CALLBACK_RESIZE,
- _win_resize_cb, test_data);
-
- elm_layout_signal_callback_add(test_data->layout, "restart", "test-theme",
- _restart, test_data);
- elm_object_signal_emit(test_data->layout, "borders,show", "ephysics_test");
- evas_object_size_hint_weight_set(test_data->layout, EVAS_HINT_EXPAND,
- EVAS_HINT_EXPAND);
- elm_win_aspect_set(test_data->win, (double) WIDTH / HEIGHT);
- evas_object_event_callback_add(test_data->win, EVAS_CALLBACK_DEL,
- _win_del, test_data->data);
-
- world = ephysics_world_new();
- ephysics_world_render_geometry_set(world, 50, 40, -50,
- WIDTH - 100, FLOOR_Y - 40, DEPTH);
- test_data->world = world;
-
- boundary = ephysics_body_bottom_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 1.0);
-
- boundary = ephysics_body_right_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 1.0);
-
- boundary = ephysics_body_left_boundary_add(test_data->world);
- ephysics_body_restitution_set(boundary, 1.0);
-
- ephysics_body_top_boundary_add(test_data->world);
-
- _world_populate(test_data);
-}