summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS4
-rw-r--r--COPYING674
-rw-r--r--INSTALL35
-rw-r--r--NEWS73
-rw-r--r--README16
-rw-r--r--doc/mainpage.dox9
-rw-r--r--doc/port_offsets.diabin0 -> 1324 bytes
-rw-r--r--doc/reference.doxygen.in1515
-rw-r--r--ganv.pc.in11
-rw-r--r--ganv/Box.hpp46
-rw-r--r--ganv/Canvas.hpp216
-rw-r--r--ganv/Circle.hpp82
-rw-r--r--ganv/Edge.hpp99
-rw-r--r--ganv/Item.hpp90
-rw-r--r--ganv/Module.hpp121
-rw-r--r--ganv/Node.hpp81
-rw-r--r--ganv/Port.hpp73
-rw-r--r--ganv/box.h125
-rw-r--r--ganv/canvas.h105
-rw-r--r--ganv/circle.h55
-rw-r--r--ganv/edge.h116
-rw-r--r--ganv/ganv.hpp29
-rw-r--r--ganv/module.h89
-rw-r--r--ganv/node.h209
-rw-r--r--ganv/port.h126
-rw-r--r--ganv/text.h63
-rw-r--r--ganv/types.h29
-rw-r--r--ganv/types.hpp33
-rw-r--r--ganv/wrap.hpp112
-rwxr-xr-xgtkdoc.sh21
-rw-r--r--src/Canvas.cpp1953
-rw-r--r--src/Port.cpp52
-rw-r--r--src/boilerplate.h45
-rw-r--r--src/box.c504
-rw-r--r--src/circle.c351
-rw-r--r--src/color.h51
-rw-r--r--src/edge.c658
-rw-r--r--src/ganv-private.h69
-rw-r--r--src/ganv_bench.cpp182
-rw-r--r--src/gettext.h28
-rw-r--r--src/module.c792
-rw-r--r--src/node.c546
-rw-r--r--src/port.c420
-rw-r--r--src/text.c371
-rwxr-xr-xwafbin0 -> 90296 bytes
-rw-r--r--wscript148
46 files changed, 10427 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..f1bb6b3
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+Author:
+
+David Robillard <d@drobilla.net>
+
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..f6e4dd4
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,35 @@
+This software requires only Python to build.
+
+Like an auto* project, building has three phases:
+
+
+* Configure: ./waf configure [OPTIONS]
+
+ Example:
+ ./waf configure --prefix=/some/where --debug --strict
+
+ If --debug is not given, the flags from the environment variables
+ CFLAGS and CXXFLAGS will be used.
+
+ The default prefix is /usr/local
+
+
+* Build: ./waf [OPTIONS]
+
+ Example:
+ ./waf -j4
+
+
+* Install: ./waf install [OPTIONS]
+
+ The environment variable DESTDIR can be used to add any prefix to
+ the install paths (useful for packaging). Example:
+
+ DESTDIR=/home/drobilla/packages ./waf install
+
+
+*** IMPORTANT: You must use absolute paths everywhere
+
+
+Run './waf --help' for detailed option information.
+
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..0794700
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,73 @@
+flowcanvas (UNRELEASED) stable;
+
+ * Begin using library and pkg-config names suitable for parallel
+ installation. This version of flowcanvas is flowcanvas-1 and is
+ NOT compatible with previous versions
+ * Clean up API and improve documentation.
+ * Add font size API
+ * Use system theme font size by default
+ * Size empty ports in font based units so they look right when zoomed
+ * Adjust padding and placement to precisely fit text
+ * Add ability to select connections directly
+ * Add Connection::set_curved()
+ * Fix lingering handle when deleting connections
+ * Dramatically increase performance by rendering text manually
+ rather than using the truly awful Gnome::Canvas::Text.
+ * Remove use of boost smart pointers. Adding and removing from containers
+ (e.g. Canvas, Module) is now done automatically.
+ * Clean up API/ABI by hiding private implementations.
+ * Add ability to select connections by their handles, either individually
+ or in groups with rect select.
+ * Further slight improvements in memory consumption and alignment.
+ * Improve scalability to graphs with many connections (eliminate linear
+ connection searches and redundant connection collections).
+ * Switch to GPLv3+
+
+ -- David Robillard <d@drobilla.net> UNRELEASED
+
+flowcanvas (0.7.1) stable;
+
+ * Reduce memory consumption and improve alignment
+ * Eliminate port control "gauge" overhead for non-control ports
+ * Add "partner" concept for aligning related but unconnected nodes
+ * Add missing #includes
+ * Expand README
+ * Add missing COPYING file to distribution
+ * Upgrade to waf 1.6.2
+
+ -- David Robillard <d@drobilla.net> Tue, 11 Jan 2011 17:42:07 -0500
+
+flowcanvas (0.6.4) stable;
+
+ * Consistently call Item::store_location when items are moved,
+ previous versions didn't on arrange or when dragging a selection
+ * Fix centering (e.g. on arrange, initial view)
+ * Upgrade to waf 1.5.18
+
+ -- David Robillard <d@drobilla.net> Fri, 03 Sep 2010 20:24:36 -0400
+
+flowcanvas (0.6.0) stable;
+
+ * Switch to waf build system
+ * Fix compilation with GCC 4.4
+ * Make Canvas::scroll_to_center() public
+ * Add item entered/left signals
+ * Add vertical flow layout w/o port labels (pd style)
+ * Fix some stuck cursor grab issues
+ * Slightly more sophisticated port and module sizing
+ * Resize performance improvements
+
+ -- David Robillard <d@drobilla.net> Tue, 08 Dec 2009 20:46:57 -0500
+
+flowcanvas (0.5.1) stable;
+
+ * Multiple selection
+ * Gray background when canvas is locked
+
+ -- David Robillard <d@drobilla.net> Sun, 07 Sep 2008 14:10:32 -0400
+
+flowcanvas (0.5.0) stable;
+
+ * Initial Debian release
+
+ -- David Robillard <d@drobilla.net> Sun, 06 Jul 2008 16:35:31 -0400
diff --git a/README b/README
new file mode 100644
index 0000000..5aa9740
--- /dev/null
+++ b/README
@@ -0,0 +1,16 @@
+Ganv
+----
+
+Ganv is an interactive Gtkmm canvas widget for graph-based interfaces
+(patchers, modular synthesizers, finite state automata, interactive graphs,
+etc).
+
+Ganv provides classes for "Modules" (boxes with "Ports"), Circles, and
+Edges (lines that connect either Ports or Circles). The user can rearrange
+items, or Ganv can automatically arrange items using GraphViz. Edges can
+be made by the user one at a time with the mouse, or in groups using the mouse
+and keyboard.
+
+For more information, see <http://drobilla.net/software/ganv>.
+
+ -- David Robillard <d@drobilla.net>
diff --git a/doc/mainpage.dox b/doc/mainpage.dox
new file mode 100644
index 0000000..08e04c2
--- /dev/null
+++ b/doc/mainpage.dox
@@ -0,0 +1,9 @@
+/** @mainpage
+
+@section Overview
+
+FlowCanvas is a canvas widget for modular/patching/dataflow/graph/etc interfaces.
+
+See the class heirarchy for an index of the available functionality.
+
+*/
diff --git a/doc/port_offsets.dia b/doc/port_offsets.dia
new file mode 100644
index 0000000..5a39bcc
--- /dev/null
+++ b/doc/port_offsets.dia
Binary files differ
diff --git a/doc/reference.doxygen.in b/doc/reference.doxygen.in
new file mode 100644
index 0000000..681371f
--- /dev/null
+++ b/doc/reference.doxygen.in
@@ -0,0 +1,1515 @@
+# Doxyfile 1.6.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME = "Ganv"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER = @GANV_VERSION@
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY = @GANV_DOC_DIR@
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE = 4
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL = YES
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES = NO
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS = NO
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME = YES
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = NO
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text "
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = @GANV_SRCDIR@/doc/mainpage.dox \
+ @GANV_SRCDIR@/ganv
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION =
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = NO
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE = 10
+
+# When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
+# there is already a search function so this one should typically
+# be disabled.
+
+SEARCHENGINE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = YES
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = YES
diff --git a/ganv.pc.in b/ganv.pc.in
new file mode 100644
index 0000000..e05eac5
--- /dev/null
+++ b/ganv.pc.in
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: ganv
+Version: @GANV_VERSION@
+Description: A Gtkmm canvas widget for graph based interfaces
+Requires: libgnomecanvas-2.0 gobject-2.0
+Libs: -L${libdir} -l@LIB_GANV@
+Cflags: -I${includedir}/ganv-@GANV_MAJOR_VERSION@
diff --git a/ganv/Box.hpp b/ganv/Box.hpp
new file mode 100644
index 0000000..c35ea26
--- /dev/null
+++ b/ganv/Box.hpp
@@ -0,0 +1,46 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_BOX_HPP
+#define GANV_BOX_HPP
+
+#include "ganv/Node.hpp"
+#include "ganv/box.h"
+
+namespace Ganv {
+
+class Box : public Node
+{
+public:
+ Box(Canvas* canvas, GanvBox* gobj)
+ : Node(canvas, GANV_NODE(gobj))
+ {}
+
+ RW_PROPERTY(const char*, label);
+
+ METHODRET0(ganv_box, double, get_width)
+ METHOD1(ganv_box, set_width, double, width)
+ METHODRET0(ganv_box, double, get_height)
+ METHOD1(ganv_box, set_height, double, height)
+
+ GanvBox* gobj() { return GANV_BOX(_gobj); }
+ const GanvBox* gobj() const { return GANV_BOX(_gobj); }
+};
+
+} // namespace Ganv
+
+#endif // GANV_BOX_HPP
diff --git a/ganv/Canvas.hpp b/ganv/Canvas.hpp
new file mode 100644
index 0000000..032b701
--- /dev/null
+++ b/ganv/Canvas.hpp
@@ -0,0 +1,216 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_CANVAS_HPP
+#define GANV_CANVAS_HPP
+
+#include <string>
+
+#include <glib.h>
+#include <glibmm.h>
+#include <gtkmm/layout.h>
+
+#include "ganv/canvas.h"
+#include "ganv/wrap.hpp"
+
+GANV_GLIB_WRAP(Canvas)
+
+/** Ganv namespace, everything is defined under this.
+ *
+ * @ingroup Ganv
+ */
+namespace Ganv {
+
+class Edge;
+class Node;
+class Port;
+
+/** @defgroup Ganv Ganv
+ *
+ * A generic dataflow widget using libgnomecanvas.
+ */
+
+/** The 'master' canvas widget which contains all other objects.
+ *
+ * Applications must override some virtual methods to make the widget actually
+ * do anything (e.g. connect).
+ *
+ * @ingroup Ganv
+ */
+class Canvas
+{
+public:
+ Canvas(double width, double height);
+ virtual ~Canvas();
+
+ Gtk::Layout& widget();
+
+ /** Remove all ports and edges and modules. */
+ void destroy();
+
+ /** Get the edge from @c tail to @c head if one exists. */
+ Edge* get_edge(Node* tail, Node* head) const;
+
+ /** Delete the edge from @c tail to @c head. */
+ void remove_edge(Node* tail, Node* head);
+
+ /** Place @c i at a reasonable default location. */
+ void set_default_placement(Node* i);
+
+ /** Unselect all selected objects. */
+ virtual void clear_selection();
+
+ void select_all();
+
+ /**
+ Add @a item to the current selection.
+ All edges between selected items will be automatically selected.
+ */
+ void select_item(Node* item);
+
+ /** Unselect @c item. */
+ void unselect_item(Node* item);
+
+ /** Unselect all ports. */
+ void unselect_ports();
+
+ /** Select @c c. */
+ void select_edge(Edge* e);
+
+ /** Unselect @c c. */
+ void unselect_edge(Edge* c);
+
+ RW_PROPERTY(gboolean, locked);
+
+ /** Return the current zoom factor (pixels per unit). */
+ double get_zoom();
+
+ /** Set the current zoom factor (pixels per unit). */
+ void set_zoom(double pix_per_unit);
+
+ /** Zoom so all canvas contents are visible. */
+ void zoom_full();
+
+ METHODRET0(ganv_canvas, double, get_font_size)
+ METHODRET0(ganv_canvas, double, get_default_font_size)
+
+ /** Set the current font size. */
+ void set_font_size(double points);
+
+ /** Set both the zoom factor and font size. */
+ void set_zoom_and_font_size(double zoom, double points);
+
+ /** Write a Graphviz DOT description of the canvas to @c filename. */
+ void render_to_dot(const std::string& filename);
+
+ /** Automatically arrange the canvas contents if Graphviz is available. */
+ void arrange(bool use_length_hints=false);
+
+ /** Shift all canvas contents so the top-left object is at (x, y). */
+ void move_contents_to(double x, double y);
+
+ /** Return the width of the canvas. */
+ double width() const;
+
+ /** Return the height of the canvas. */
+ double height() const;
+
+ /** Resize the canvas to the given dimensions. */
+ void resize(double width, double height);
+
+ /** The direction of the "signal flow" on the canvas. */
+ enum FlowDirection {
+ HORIZONTAL,
+ VERTICAL
+ };
+
+ /** Set the flow direction of the canvas. */
+ void set_direction(FlowDirection d);
+
+ /** Return the current flow direction of the canvas. */
+ FlowDirection direction() const;
+
+ /**
+ Called whenever a edge is made.
+ This should be overridden by an implementation to do something.
+ */
+ virtual void connect(Node* /*tail*/,
+ Node* /*head*/) {}
+
+ /**
+ Called whenever a edge is severed.
+ This should be overridden by an implementation to do something.
+ */
+ virtual void disconnect(Node* /*tail*/,
+ Node* /*head*/) {}
+
+ typedef void (*NodeFunction)(GanvNode* node, void* data);
+
+ void for_each_node(NodeFunction f, void* data);
+ void for_each_selected_node(NodeFunction f, void* data);
+
+ typedef void (*EdgePtrFunction)(GanvEdge* edge, void* data);
+
+ void for_each_edge(EdgePtrFunction f, void* data);
+ void for_each_selected_edge(EdgePtrFunction f, void* data);
+
+ METHOD2(ganv_canvas, for_each_edge_from,
+ const GanvNode*, tail,
+ GanvEdgeFunction, f);
+
+ METHOD2(ganv_canvas, for_each_edge_to,
+ const GanvNode*, head,
+ GanvEdgeFunction, f);
+
+ METHOD2(ganv_canvas, for_each_edge_on,
+ const GanvNode*, node,
+ GanvEdgeFunction, f);
+
+ GQuark wrapper_key();
+
+ GnomeCanvasGroup* root();
+
+ GdkCursor* move_cursor();
+
+ void get_scroll_offsets(int& cx, int& cy) const;
+ void scroll_to(int x, int y);
+
+ GanvCanvas* gobj();
+ const GanvCanvas* gobj() const;
+
+ /** Canvas event handler. */
+ virtual bool on_event(GdkEvent* event);
+
+ /** Signal emitted when the mouse pointer enters an Item. */
+ sigc::signal<void, GnomeCanvasItem*> signal_item_entered;
+
+ /** Signal emitted when the mouse pointer leaves an Item. */
+ sigc::signal<void, GnomeCanvasItem*> signal_item_left;
+
+private:
+ Canvas(const Canvas&); ///< Noncopyable
+ const Canvas& operator=(const Canvas&); ///< Noncopyable
+
+ inline GanvCanvasImpl* impl() { return _gobj->impl; }
+ inline const GanvCanvasImpl* impl() const { return _gobj->impl; }
+
+ GanvCanvas* const _gobj;
+};
+
+} // namespace Ganv
+
+#endif // GANV_CANVAS_HPP
diff --git a/ganv/Circle.hpp b/ganv/Circle.hpp
new file mode 100644
index 0000000..beb1be5
--- /dev/null
+++ b/ganv/Circle.hpp
@@ -0,0 +1,82 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_CIRCLE_HPP
+#define GANV_CIRCLE_HPP
+
+#include <algorithm>
+#include <map>
+#include <string>
+#include <stdint.h>
+
+#include <gdkmm/types.h>
+
+#include "ganv/types.hpp"
+#include "ganv/Node.hpp"
+#include "ganv/circle.h"
+
+GANV_GLIB_WRAP(Circle)
+
+namespace Ganv {
+
+class Canvas;
+
+/** An elliptical Item which is Node.
+ *
+ * Unlike a Module, this doesn't contain ports, but is directly joinable itself
+ * (think your classic circles 'n' lines diagram, ala FSM).
+ *
+ * @ingroup Ganv
+ */
+class Circle : public Node
+{
+public:
+ static const uint32_t FILL_COLOUR = 0x1E2224FF;
+ static const uint32_t BORDER_COLOUR = 0xD3D7CFFF;
+
+ Circle(Canvas& canvas,
+ const std::string& name,
+ double x,
+ double y,
+ double radius,
+ bool show_title)
+ : Node(&canvas,
+ GANV_NODE(
+ gnome_canvas_item_new(
+ GNOME_CANVAS_GROUP(canvas.root()),
+ ganv_circle_get_type(),
+ "x", x,
+ "y", y,
+ "can-tail", TRUE,
+ "can-head", TRUE,
+ "radius", radius,
+ "fill-color", FILL_COLOUR,
+ "border-color", BORDER_COLOUR,
+ "label", name.c_str(),
+ "draggable", TRUE,
+ NULL)))
+ {}
+
+ RW_PROPERTY(double, radius);
+
+ GanvCircle* gobj() { return GANV_CIRCLE(_gobj); }
+ const GanvCircle* gobj() const { return GANV_CIRCLE(_gobj); }
+};
+
+} // namespace Ganv
+
+#endif // GANV_CIRCLE_HPP
diff --git a/ganv/Edge.hpp b/ganv/Edge.hpp
new file mode 100644
index 0000000..e9760c5
--- /dev/null
+++ b/ganv/Edge.hpp
@@ -0,0 +1,99 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_EDGE_HPP
+#define GANV_EDGE_HPP
+
+#include <stdint.h>
+
+#include <libgnomecanvas/gnome-canvas.h>
+
+#include <gdk/gdkevents.h>
+
+#include "ganv/Canvas.hpp"
+#include "ganv/Item.hpp"
+#include "ganv/Node.hpp"
+#include "ganv/edge.h"
+
+GANV_GLIB_WRAP(Edge)
+
+namespace Ganv {
+
+class Canvas;
+
+/** A edge (line) between two Node objects.
+ *
+ * @ingroup Ganv
+ */
+class Edge : public Item
+{
+public:
+ Edge(Canvas& canvas,
+ Node* tail,
+ Node* head,
+ uint32_t color,
+ bool show_arrowhead = false,
+ bool curved = true)
+ : Item(GNOME_CANVAS_ITEM(
+ g_object_ref(
+ ganv_edge_new(
+ canvas.gobj(),
+ tail->gobj(),
+ head->gobj(),
+ "color", color,
+ "curved", (gboolean)curved,
+ "arrowhead", (gboolean)show_arrowhead,
+ NULL))))
+ {}
+
+ Edge(GanvEdge* gobj)
+ : Item(GNOME_CANVAS_ITEM(g_object_ref(gobj)))
+ {}
+
+ virtual ~Edge() {
+ if (_gobj && _gobj->parent) {
+ g_object_unref(_gobj);
+ }
+ }
+
+ /** Return true iff the handle is within the given rectangle. */
+ virtual gboolean is_within(double x1, double y1,
+ double x2, double y2) const {
+ return ganv_edge_is_within(gobj(), x1, y1, x2, y2);
+ }
+
+ RW_PROPERTY(gboolean, curved)
+ RW_PROPERTY(gboolean, selected)
+ RW_PROPERTY(gboolean, highlighted)
+ RW_PROPERTY(guint, color)
+
+ METHODRETWRAP0(ganv_edge, Node*, get_tail);
+ METHODRETWRAP0(ganv_edge, Node*, get_head);
+
+ METHOD1(ganv_edge, tick, double, seconds);
+
+ GanvEdge* gobj() { return (GanvEdge*)_gobj; }
+ const GanvEdge* gobj() const { return (GanvEdge*)_gobj; }
+
+private:
+ Edge(const Edge& copy);
+ Edge& operator=(const Edge& other);
+};
+
+} // namespace Ganv
+
+#endif // GANV_EDGE_HPP
diff --git a/ganv/Item.hpp b/ganv/Item.hpp
new file mode 100644
index 0000000..534048f
--- /dev/null
+++ b/ganv/Item.hpp
@@ -0,0 +1,90 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_ITEM_HPP
+#define GANV_ITEM_HPP
+
+#include <assert.h>
+
+#include <glib.h>
+#include <libgnomecanvas/gnome-canvas.h>
+
+#include <sigc++/signal.h>
+#include <sigc++/trackable.h>
+
+#include "ganv/wrap.hpp"
+#include "ganv/Canvas.hpp"
+
+namespace Ganv {
+
+class Canvas;
+
+/** An item on the canvas.
+ */
+class Item : public sigc::trackable {
+public:
+ Item(GnomeCanvasItem* gobj)
+ : _gobj(gobj)
+ {
+ GQuark wrapper_key = g_quark_from_string("ganvmm");
+ if (gobj && gobj->parent) {
+ g_object_set_qdata(G_OBJECT(_gobj), wrapper_key, this);
+ g_signal_connect(G_OBJECT(_gobj),
+ "event", G_CALLBACK(on_item_event), this);
+ }
+ }
+
+ virtual ~Item() {}
+ RW_PROPERTY(double, x)
+ RW_PROPERTY(double, y)
+
+ METHOD0(gnome_canvas_item, show);
+ METHOD0(gnome_canvas_item, hide);
+ METHOD0(gnome_canvas_item, raise_to_top);
+ METHOD2(gnome_canvas_item, move, double, dx, double, dy);
+
+ GnomeCanvasItem* property_parent() const {
+ GnomeCanvasItem* parent;
+ g_object_get(G_OBJECT(_gobj), "parent", &parent, NULL);
+ return parent;
+ }
+
+ Canvas* canvas() const {
+ return Glib::wrap(GANV_CANVAS(_gobj->canvas));
+ }
+
+ GnomeCanvasItem* gobj() const { return _gobj; }
+
+ SIGNAL(event, GdkEvent*)
+ SIGNAL(click, GdkEventButton*)
+
+protected:
+ GnomeCanvasItem* const _gobj;
+
+private:
+ static gboolean
+ on_item_event(GnomeCanvasItem* canvasitem,
+ GdkEvent* ev,
+ void* item)
+ {
+ return ((Item*)item)->on_event(ev);
+ }
+};
+
+} // namespace Ganv
+
+#endif // GANV_ITEM_HPP
diff --git a/ganv/Module.hpp b/ganv/Module.hpp
new file mode 100644
index 0000000..3ccabcf
--- /dev/null
+++ b/ganv/Module.hpp
@@ -0,0 +1,121 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_MODULE_HPP
+#define GANV_MODULE_HPP
+
+#include <string>
+#include <vector>
+
+#include <gtkmm/container.h>
+
+#include "ganv/Canvas.hpp"
+#include "ganv/Node.hpp"
+#include "ganv/Port.hpp"
+#include "ganv/module.h"
+
+GANV_GLIB_WRAP(Module)
+
+namespace Ganv {
+
+class Canvas;
+
+/** A rectangular Item which can hold a Port.
+ *
+ * @ingroup Ganv
+ */
+class Module : public Box
+{
+public:
+ Module(Canvas& canvas,
+ const std::string& name,
+ double x = 0,
+ double y = 0,
+ bool show_title = true,
+ bool show_port_labels = true)
+ : Box(&canvas, GANV_BOX(
+ gnome_canvas_item_new(
+ GNOME_CANVAS_GROUP(canvas.root()),
+ ganv_module_get_type(),
+ "x", x,
+ "y", y,
+ "can-tail", FALSE,
+ "can-head", FALSE,
+ "radius-tl", 4.0,
+ "radius-tr", 4.0,
+ "radius-br", 4.0,
+ "radius-bl", 4.0,
+ "label", name.c_str(),
+ "draggable", TRUE,
+ NULL)))
+ {}
+
+ template<typename P, typename C>
+ class iterator_base {
+ public:
+ iterator_base(C** p) : _ptr(p) {}
+ template<typename T, typename U>
+ iterator_base(const iterator_base<T, U>& i)
+ : _ptr(const_cast<C**>(i._ptr))
+ {}
+ P* operator*() const { return Glib::wrap(*_ptr); }
+ P* operator->() const { return Glib::wrap(*_ptr); }
+ iterator_base operator++(int) { return iterator_base<P, C>(_ptr + 1); }
+ iterator_base& operator++() { ++_ptr; return *this; }
+ bool operator==(const iterator_base<P, C>& i) const { return _ptr == i._ptr; }
+ bool operator!=(const iterator_base<P, C>& i) const { return _ptr != i._ptr; }
+ private:
+ template<typename T, typename U> friend class iterator_base;
+ C** _ptr;
+ };
+
+ typedef iterator_base<Port, GanvPort> iterator;
+ typedef iterator_base<const Port, const GanvPort> const_iterator;
+
+ iterator begin() { return iterator((GanvPort**)gobj()->ports->pdata); }
+ iterator end() { return iterator((GanvPort**)gobj()->ports->pdata + gobj()->ports->len); }
+ iterator back() { return iterator((GanvPort**)gobj()->ports->pdata + gobj()->ports->len - 1); }
+ const_iterator begin() const { return const_iterator((const GanvPort**)gobj()->ports->pdata); }
+ const_iterator end() const { return const_iterator((const GanvPort**)gobj()->ports->pdata + gobj()->ports->len); }
+ const_iterator back() const { return const_iterator((const GanvPort**)gobj()->ports->pdata + gobj()->ports->len - 1); }
+
+ void set_icon(Gdk::Pixbuf* icon) {
+ ganv_module_set_icon(gobj(), icon->gobj());
+ }
+
+ void embed(Gtk::Widget* widget) {
+ ganv_module_embed(gobj(), widget->gobj());
+ }
+
+ void for_each_port(GanvPortFunction f, void* data) {
+ ganv_module_for_each_port(gobj(), f, data);
+ }
+
+ size_t num_ports() const { return gobj()->ports->len; }
+
+ RW_PROPERTY(gboolean, stacked)
+ RW_PROPERTY(gboolean, show_port_labels)
+ METHODRET0(ganv_module, double, get_empty_port_breadth)
+ METHODRET0(ganv_module, double, get_empty_port_depth)
+
+ GanvModule* gobj() { return GANV_MODULE(_gobj); }
+ const GanvModule* gobj() const { return GANV_MODULE(_gobj); }
+};
+
+} // namespace Ganv
+
+#endif // GANV_MODULE_HPP
diff --git a/ganv/Node.hpp b/ganv/Node.hpp
new file mode 100644
index 0000000..f040e76
--- /dev/null
+++ b/ganv/Node.hpp
@@ -0,0 +1,81 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_NODE_HPP
+#define GANV_NODE_HPP
+
+#include <glib.h>
+#include <libgnomecanvas/gnome-canvas.h>
+#include <assert.h>
+
+#include "ganv/node.h"
+#include "ganv/Item.hpp"
+
+GANV_GLIB_WRAP(Node)
+
+namespace Ganv {
+
+class Canvas;
+class Node;
+
+/** An object a Edge can connect to.
+ */
+class Node : public Item {
+public:
+ Node(Canvas* canvas, GanvNode* gobj)
+ : Item(GNOME_CANVAS_ITEM(g_object_ref(gobj)))
+ {}
+
+ ~Node() {
+ g_object_unref(_gobj);
+ }
+
+ RW_PROPERTY(const char*, label)
+ RW_PROPERTY(double, dash_length)
+ RW_PROPERTY(double, dash_offset)
+ RW_PROPERTY(double, border_width)
+ RW_PROPERTY(guint, fill_color)
+ RW_PROPERTY(guint, border_color)
+ RW_PROPERTY(gboolean, can_tail)
+ RW_PROPERTY(gboolean, can_head)
+ RW_PROPERTY(gboolean, selected)
+ RW_PROPERTY(gboolean, highlighted)
+ RW_PROPERTY(gboolean, draggable)
+
+ RW_OBJECT_PROPERTY(Node*, partner);
+
+ METHOD1(ganv_node, tick, double, seconds);
+
+ virtual gboolean is_within(double x1, double y1,
+ double x2, double y2) const {
+ return ganv_node_is_within(gobj(), x1, y1, x2, y2);
+ }
+
+ GanvNode* gobj() { return GANV_NODE(_gobj); }
+ const GanvNode* gobj() const { return GANV_NODE(_gobj); }
+
+ METHOD2(ganv_node, move, double, dx, double, dy)
+ METHOD2(ganv_node, move_to, double, x, double, y)
+
+ METHOD0(ganv_node, disconnect);
+
+ sigc::signal<void> signal_moved;
+};
+
+} // namespace Ganv
+
+#endif // GANV_NODE_HPP
diff --git a/ganv/Port.hpp b/ganv/Port.hpp
new file mode 100644
index 0000000..2645b01
--- /dev/null
+++ b/ganv/Port.hpp
@@ -0,0 +1,73 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_PORT_HPP
+#define GANV_PORT_HPP
+
+#include <stdint.h>
+
+#include <string>
+
+#include <libgnomecanvas/gnome-canvas.h>
+#include <gdkmm/types.h>
+
+#include "ganv/Box.hpp"
+#include "ganv/port.h"
+
+GANV_GLIB_WRAP(Port)
+
+namespace Ganv {
+
+class Module;
+
+/** A port on a Module.
+ *
+ * This is a group that contains both the label and rectangle for a port.
+ *
+ * @ingroup Ganv
+ */
+class Port : public Box
+{
+public:
+ Port(Module& module,
+ const std::string& name,
+ bool is_input,
+ uint32_t color);
+
+ METHODRET0(ganv_port, gboolean, is_input)
+ METHODRET0(ganv_port, gboolean, is_output)
+
+ METHODRET0(ganv_port, double, get_natural_width);
+ METHODRET0(ganv_port, float, get_control_value)
+ METHODRET0(ganv_port, float, get_control_min)
+ METHODRET0(ganv_port, float, get_control_max)
+ METHOD0(ganv_port, show_control)
+ METHOD0(ganv_port, hide_control)
+ METHOD1(ganv_port, set_control_is_toggle, gboolean, is_toggle)
+ METHOD1(ganv_port, set_control_value, float, value)
+ METHOD1(ganv_port, set_control_min, float, min)
+ METHOD1(ganv_port, set_control_max, float, max)
+
+ Module* get_module() const;
+
+ GanvPort* gobj() { return GANV_PORT(_gobj); }
+ const GanvPort* gobj() const { return GANV_PORT(_gobj); }
+};
+
+} // namespace Ganv
+
+#endif // GANV_PORT_HPP
diff --git a/ganv/box.h b/ganv/box.h
new file mode 100644
index 0000000..c50f5c7
--- /dev/null
+++ b/ganv/box.h
@@ -0,0 +1,125 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_BOX_H
+#define GANV_BOX_H
+
+#include "ganv/node.h"
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_BOX (ganv_box_get_type())
+#define GANV_BOX(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_BOX, GanvBox))
+#define GANV_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_BOX, GanvBoxClass))
+#define GANV_IS_BOX(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_BOX))
+#define GANV_IS_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_BOX))
+#define GANV_BOX_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_BOX, GanvBoxClass))
+
+typedef struct _GanvBox GanvBox;
+typedef struct _GanvBoxClass GanvBoxClass;
+
+typedef struct {
+ double x1, y1, x2, y2;
+ double border_width;
+ gboolean stacked;
+} GanvBoxCoords;
+
+struct _GanvBox
+{
+ GanvNode node;
+ GanvBoxCoords coords;
+ GanvBoxCoords old_coords;
+ double radius_tl;
+ double radius_tr;
+ double radius_br;
+ double radius_bl;
+};
+
+struct _GanvBoxClass {
+ GanvNodeClass parent_class;
+
+ void (*set_width)(GanvBox* box,
+ double width);
+
+ void (*set_height)(GanvBox* box,
+ double height);
+};
+
+GType ganv_box_get_type(void);
+
+static inline double
+ganv_box_get_x1(const GanvBox* box)
+{
+ return box->coords.x1;
+}
+
+static inline double
+ganv_box_get_y1(const GanvBox* box)
+{
+ return box->coords.y1;
+}
+
+static inline double
+ganv_box_get_x2(const GanvBox* box)
+{
+ return box->coords.x2;
+}
+
+static inline double
+ganv_box_get_y2(const GanvBox* box)
+{
+ return box->coords.y2;
+}
+
+static inline double
+ganv_box_get_width(const GanvBox* box)
+{
+ return box->coords.x2 - box->coords.x1;
+}
+
+static inline void
+ganv_box_set_width(GanvBox* box,
+ double width)
+{
+ GANV_BOX_GET_CLASS(box)->set_width(box, width);
+}
+
+static inline double
+ganv_box_get_height(const GanvBox* box)
+{
+ return box->coords.y2 - box->coords.y1;
+}
+
+static inline void
+ganv_box_set_height(GanvBox* box,
+ double height)
+{
+ GANV_BOX_GET_CLASS(box)->set_height(box, height);
+}
+
+static inline double
+ganv_box_get_border_width(const GanvBox* box)
+{
+ return box->coords.border_width;
+}
+
+void
+ganv_box_normalize(GanvBox* box);
+
+G_END_DECLS
+
+#endif /* GANV_BOX_H */
diff --git a/ganv/canvas.h b/ganv/canvas.h
new file mode 100644
index 0000000..00d722d
--- /dev/null
+++ b/ganv/canvas.h
@@ -0,0 +1,105 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_CANVAS_H
+#define GANV_CANVAS_H
+
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include "ganv/types.h"
+#include "ganv/edge.h"
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_CANVAS (ganv_canvas_get_type())
+#define GANV_CANVAS(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_CANVAS, GanvCanvas))
+#define GANV_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_CANVAS, GanvCanvasClass))
+#define GANV_IS_CANVAS(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_CANVAS))
+#define GANV_IS_CANVAS_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_CANVAS))
+#define GANV_CANVAS_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_CANVAS, GanvCanvasClass))
+
+struct GanvCanvasImpl;
+
+typedef struct _GanvCanvasClass GanvCanvasClass;
+
+typedef enum {
+ GANV_VERTICAL,
+ GANV_HORIZONTAL
+} GanvDirection;
+
+struct _GanvCanvas
+{
+ GnomeCanvas canvas;
+ struct GanvCanvasImpl* impl;
+ GanvDirection direction;
+ gboolean locked;
+};
+
+struct _GanvCanvasClass {
+ GnomeCanvasClass parent_class;
+};
+
+GType ganv_canvas_get_type(void);
+
+GanvCanvas* ganv_canvas_new(void);
+
+GnomeCanvasGroup*
+ganv_canvas_get_root(const GanvCanvas* canvas);
+
+/** Get the default font size in points. */
+double
+ganv_canvas_get_default_font_size(const GanvCanvas* canvas);
+
+/** Get the current font size in points. */
+double
+ganv_canvas_get_font_size(const GanvCanvas* canvas);
+
+void
+ganv_canvas_clear_selection(GanvCanvas* canvas);
+
+typedef void (*GanvEdgeFunction)(GanvEdge* edge);
+
+/**
+ * ganv_canvas_for_each_edge_from:
+ * @f: (scope call): A function to call on every edge leaving @tail.
+ */
+void
+ganv_canvas_for_each_edge_from(GanvCanvas* canvas,
+ const GanvNode* tail,
+ GanvEdgeFunction f);
+
+/**
+ * ganv_canvas_for_each_edge_to:
+ * @f: (scope call): A function to call on every edge entering @head.
+ */
+void
+ganv_canvas_for_each_edge_to(GanvCanvas* canvas,
+ const GanvNode* head,
+ GanvEdgeFunction f);
+
+/**
+ * ganv_canvas_for_each_edge_on:
+ * @f: (scope call): A function to call on every edge attached to @node.
+ */
+void
+ganv_canvas_for_each_edge_on(GanvCanvas* canvas,
+ const GanvNode* node,
+ GanvEdgeFunction f);
+
+G_END_DECLS
+
+#endif /* GANV_CANVAS_H */
diff --git a/ganv/circle.h b/ganv/circle.h
new file mode 100644
index 0000000..8356294
--- /dev/null
+++ b/ganv/circle.h
@@ -0,0 +1,55 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_CIRCLE_H
+#define GANV_CIRCLE_H
+
+#include "ganv/node.h"
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_CIRCLE (ganv_circle_get_type())
+#define GANV_CIRCLE(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_CIRCLE, GanvCircle))
+#define GANV_CIRCLE_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_CIRCLE, GanvCircleClass))
+#define GANV_IS_CIRCLE(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_CIRCLE))
+#define GANV_IS_CIRCLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_CIRCLE))
+#define GANV_CIRCLE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_CIRCLE, GanvCircleClass))
+
+typedef struct _GanvCircle GanvCircle;
+typedef struct _GanvCircleClass GanvCircleClass;
+
+typedef struct {
+ double x, y, radius;
+ double width;
+} GanvCircleCoords;
+
+struct _GanvCircle
+{
+ GanvNode node;
+ GanvCircleCoords coords;
+ GanvCircleCoords old_coords;
+};
+
+struct _GanvCircleClass {
+ GanvNodeClass parent_class;
+};
+
+GType ganv_circle_get_type(void);
+
+G_END_DECLS
+
+#endif /* GANV_CIRCLE_H */
diff --git a/ganv/edge.h b/ganv/edge.h
new file mode 100644
index 0000000..91708ba
--- /dev/null
+++ b/ganv/edge.h
@@ -0,0 +1,116 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_EDGE_H
+#define GANV_EDGE_H
+
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include "ganv/types.h"
+#include "ganv/node.h"
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_EDGE (ganv_edge_get_type())
+#define GANV_EDGE(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_EDGE, GanvEdge))
+#define GANV_EDGE_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_EDGE, GanvEdgeClass))
+#define GANV_IS_EDGE(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_EDGE))
+#define GANV_IS_EDGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_EDGE))
+#define GANV_EDGE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_EDGE, GanvEdgeClass))
+
+typedef struct _GanvEdgeClass GanvEdgeClass;
+
+typedef struct {
+ double x1, y1, x2, y2;
+ double cx1, cy1, cx2, cy2;
+ double handle_x, handle_y, handle_radius;
+ double width;
+ gboolean curved;
+ gboolean arrowhead;
+} GanvEdgeCoords;
+
+struct _GanvEdge
+{
+ GnomeCanvasItem item;
+ GanvNode* tail;
+ GanvNode* head;
+ GanvEdgeCoords coords;
+ GanvEdgeCoords old_coords;
+ double dash_length;
+ double dash_offset;
+ guint color;
+ gboolean selected;
+ gboolean highlighted;
+ gboolean ghost;
+};
+
+struct _GanvEdgeClass {
+ GnomeCanvasItemClass parent_class;
+};
+
+GType ganv_edge_get_type(void);
+
+GanvEdge*
+ganv_edge_new(GanvCanvas* canvas,
+ GanvNode* tail,
+ GanvNode* head,
+ const char* first_prop_name, ...);
+
+gboolean
+ganv_edge_is_within(const GanvEdge* edge,
+ double x1,
+ double y1,
+ double x2,
+ double y2);
+
+void
+ganv_edge_update_location(GanvEdge* edge);
+
+void
+ganv_edge_select(GanvEdge* edge);
+
+void
+ganv_edge_unselect(GanvEdge* edge);
+
+void
+ganv_edge_highlight(GanvEdge* edge);
+
+void
+ganv_edge_unhighlight(GanvEdge* edge);
+
+void
+ganv_edge_remove(GanvEdge* edge);
+
+void
+ganv_edge_tick(GanvEdge* edge,
+ double seconds);
+
+static inline GanvNode*
+ganv_edge_get_tail(const GanvEdge* edge)
+{
+ return edge->tail;
+}
+
+static inline GanvNode*
+ganv_edge_get_head(const GanvEdge* edge)
+{
+ return edge->head;
+}
+
+G_END_DECLS
+
+#endif /* GANV_EDGE_H */
diff --git a/ganv/ganv.hpp b/ganv/ganv.hpp
new file mode 100644
index 0000000..492f7c8
--- /dev/null
+++ b/ganv/ganv.hpp
@@ -0,0 +1,29 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_GANV_HPP
+#define GANV_GANV_HPP
+
+#include "ganv/Canvas.hpp"
+#include "ganv/Circle.hpp"
+#include "ganv/Edge.hpp"
+#include "ganv/Module.hpp"
+#include "ganv/Node.hpp"
+#include "ganv/Port.hpp"
+
+#endif // GANV_GANV_HPP
+
diff --git a/ganv/module.h b/ganv/module.h
new file mode 100644
index 0000000..46496d6
--- /dev/null
+++ b/ganv/module.h
@@ -0,0 +1,89 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_MODULE_H
+#define GANV_MODULE_H
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "ganv/box.h"
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_MODULE (ganv_module_get_type())
+#define GANV_MODULE(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_MODULE, GanvModule))
+#define GANV_MODULE_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_MODULE, GanvModuleClass))
+#define GANV_IS_MODULE(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_MODULE))
+#define GANV_IS_MODULE_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_MODULE))
+#define GANV_MODULE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_MODULE, GanvModuleClass))
+
+typedef struct _GanvModuleClass GanvModuleClass;
+
+typedef void (*GanvPortFunction)(GanvPort* port, void* data);
+
+struct _GanvModule
+{
+ GanvBox box;
+ GPtrArray* ports;
+ GnomeCanvasItem* icon_box;
+ GnomeCanvasItem* embed_item;
+ int embed_width;
+ int embed_height;
+ double widest_input;
+ double widest_output;
+ gboolean show_port_labels;
+ gboolean must_resize;
+ gboolean port_size_changed;
+};
+
+struct _GanvModuleClass {
+ GanvBoxClass parent_class;
+};
+
+GType ganv_module_get_type(void);
+
+void
+ganv_module_add_port(GanvModule* module,
+ GanvPort* port);
+
+double
+ganv_module_get_empty_port_breadth(const GanvModule* module);
+
+double
+ganv_module_get_empty_port_depth(const GanvModule* module);
+
+void
+ganv_module_set_icon(GanvModule* module,
+ GdkPixbuf* icon);
+
+void
+ganv_module_embed(GanvModule* module,
+ GtkWidget* widget);
+
+/**
+ * ganv_module_for_each_port:
+ * @f: (scope call): A function to call on every port on @module.
+ */
+void
+ganv_module_for_each_port(GanvModule* module,
+ GanvPortFunction f,
+ void* data);
+
+G_END_DECLS
+
+#endif /* GANV_MODULE_H */
diff --git a/ganv/node.h b/ganv/node.h
new file mode 100644
index 0000000..539ef63
--- /dev/null
+++ b/ganv/node.h
@@ -0,0 +1,209 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_NODE_H
+#define GANV_NODE_H
+
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include "ganv/types.h"
+#include "ganv/text.h"
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_NODE (ganv_node_get_type())
+#define GANV_NODE(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_NODE, GanvNode))
+#define GANV_NODE_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_NODE, GanvNodeClass))
+#define GANV_IS_NODE(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_NODE))
+#define GANV_IS_NODE_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_NODE))
+#define GANV_NODE_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_NODE, GanvNodeClass))
+
+typedef struct _GanvNodeClass GanvNodeClass;
+
+struct _GanvNode {
+ GnomeCanvasGroup group;
+ struct _GanvNode* partner;
+ GanvText* label;
+ double dash_length;
+ double dash_offset;
+ double border_width;
+ guint fill_color;
+ guint border_color;
+ gboolean can_tail;
+ gboolean can_head;
+ gboolean selected;
+ gboolean highlighted;
+ gboolean draggable;
+};
+
+struct _GanvNodeClass {
+ GnomeCanvasGroupClass parent_class;
+
+ void (* tick)(GanvNode* self,
+ double seconds);
+
+ void (* move)(GanvNode* node,
+ double dx,
+ double dy);
+
+ void (* move_to)(GanvNode* node,
+ double x,
+ double y);
+
+ void (* resize)(GanvNode* node);
+
+ void (* disconnect)(GanvNode* node);
+
+ gboolean (* is_within)(const GanvNode* self,
+ double x1,
+ double y1,
+ double x2,
+ double y2);
+
+
+ void (* tail_vector)(const GanvNode* self,
+ const GanvNode* head,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy);
+
+ void (* head_vector)(const GanvNode* self,
+ const GanvNode* tail,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy);
+
+ gboolean (* on_event)(GanvNode* node,
+ GdkEvent* event);
+};
+
+GType ganv_node_get_type(void);
+
+static inline gboolean
+ganv_node_can_tail(const GanvNode* self)
+{
+ return self->can_tail;
+}
+
+static inline gboolean
+ganv_node_can_head(const GanvNode* self)
+{
+ return self->can_head;
+}
+
+static inline gboolean
+ganv_node_is_within(const GanvNode* self,
+ double x1,
+ double y1,
+ double x2,
+ double y2)
+{
+ return GANV_NODE_GET_CLASS(self)->is_within(
+ self, x1, y1, x2, y2);
+}
+
+static inline void
+ganv_node_tick(GanvNode* self,
+ double seconds)
+{
+ GanvNodeClass* klass = GANV_NODE_GET_CLASS(self);
+ if (klass->tick) {
+ klass->tick(self, seconds);
+ }
+}
+
+static inline void
+ganv_node_tail_vector(const GanvNode* self,
+ const GanvNode* head,
+ double* x1,
+ double* y1,
+ double* x2,
+ double* y2)
+{
+ GANV_NODE_GET_CLASS(self)->tail_vector(
+ self, head, x1, y1, x2, y2);
+}
+
+static inline void
+ganv_node_head_vector(const GanvNode* self,
+ const GanvNode* tail,
+ double* x1,
+ double* y1,
+ double* x2,
+ double* y2)
+{
+ GANV_NODE_GET_CLASS(self)->head_vector(
+ self, tail, x1, y1, x2, y2);
+}
+
+/**
+ Get the colours that should currently be used for drawing this node.
+ Note these may not be identical to the property values because of
+ highlighting and selection.
+*/
+void ganv_node_get_draw_properties(const GanvNode* node,
+ double* dash_length,
+ double* border_color,
+ double* fill_color);
+
+const char* ganv_node_get_label(const GanvNode* node);
+
+static inline GanvNode*
+ganv_node_get_partner(const GanvNode* node)
+{
+ return node->partner;
+}
+
+void ganv_node_set_label(GanvNode* node,
+ const char* str);
+
+static inline void
+ganv_node_move(GanvNode* node,
+ double dx,
+ double dy)
+{
+ GANV_NODE_GET_CLASS(node)->move(node, dx, dy);
+}
+
+static inline void
+ganv_node_move_to(GanvNode* node,
+ double x,
+ double y)
+{
+ GANV_NODE_GET_CLASS(node)->move_to(node, x, y);
+}
+
+static inline void
+ganv_node_resize(GanvNode* node)
+{
+ GanvNodeClass* klass = GANV_NODE_GET_CLASS(node);
+ if (klass->resize) {
+ klass->resize(node);
+ }
+}
+
+static inline void
+ganv_node_disconnect(GanvNode* node)
+{
+ GANV_NODE_GET_CLASS(node)->disconnect(node);
+}
+
+G_END_DECLS
+
+#endif /* GANV_NODE_H */
diff --git a/ganv/port.h b/ganv/port.h
new file mode 100644
index 0000000..433eadd
--- /dev/null
+++ b/ganv/port.h
@@ -0,0 +1,126 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_PORT_H
+#define GANV_PORT_H
+
+#include "ganv/box.h"
+
+struct _GanvModule;
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_PORT (ganv_port_get_type())
+#define GANV_PORT(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_PORT, GanvPort))
+#define GANV_PORT_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_PORT, GanvPortClass))
+#define GANV_IS_PORT(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_PORT))
+#define GANV_IS_PORT_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_PORT))
+#define GANV_PORT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_PORT, GanvPortClass))
+
+typedef struct _GanvPortClass GanvPortClass;
+
+typedef struct {
+ GanvBox* rect;
+ float value;
+ float min;
+ float max;
+ gboolean is_toggle;
+} GanvPortControl;
+
+struct _GanvPort
+{
+ GanvBox box;
+ GanvPortControl* control;
+ gboolean is_input;
+};
+
+struct _GanvPortClass {
+ GanvBoxClass parent_class;
+};
+
+GType ganv_port_get_type(void);
+
+GanvPort*
+ganv_port_new(GanvModule* module,
+ gboolean is_input,
+ const char* first_prop_name, ...);
+
+void
+ganv_port_show_control(GanvPort* port);
+
+void
+ganv_port_hide_control(GanvPort* port);
+
+void
+ganv_port_set_control_is_toggle(GanvPort* port,
+ gboolean is_toggle);
+
+void
+ganv_port_set_control_value(GanvPort* port,
+ float value);
+
+void
+ganv_port_set_control_min(GanvPort* port,
+ float min);
+
+void
+ganv_port_set_control_max(GanvPort* port,
+ float max);
+
+double
+ganv_port_get_natural_width(const GanvPort* port);
+
+/**
+ * ganv_port_get_module:
+ * Return value: (transfer none): The module @a port is on.
+ */
+GanvModule*
+ganv_port_get_module(const GanvPort* port);
+
+static inline float
+ganv_port_get_control_value(const GanvPort* port)
+{
+ return port->control ? port->control->value : 0.0f;
+}
+
+static inline float
+ganv_port_get_control_min(const GanvPort* port)
+{
+ return port->control ? port->control->min : 0.0f;
+}
+
+static inline float
+ganv_port_get_control_max(const GanvPort* port)
+{
+ return port->control ? port->control->max : 0.0f;
+}
+
+static inline gboolean
+ganv_port_is_input(const GanvPort* port)
+{
+ return port->is_input;
+}
+
+static inline gboolean
+ganv_port_is_output(const GanvPort* port)
+{
+ return !port->is_input;
+}
+
+G_END_DECLS
+
+#endif /* GANV_PORT_H */
diff --git a/ganv/text.h b/ganv/text.h
new file mode 100644
index 0000000..3c312aa
--- /dev/null
+++ b/ganv/text.h
@@ -0,0 +1,63 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_TEXT_H
+#define GANV_TEXT_H
+
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include <cairo.h>
+
+G_BEGIN_DECLS
+
+#define GANV_TYPE_TEXT (ganv_text_get_type())
+#define GANV_TEXT(obj) (GTK_CHECK_CAST((obj), GANV_TYPE_TEXT, GanvText))
+#define GANV_TEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GANV_TYPE_TEXT, GanvTextClass))
+#define GANV_IS_TEXT(obj) (GTK_CHECK_TYPE((obj), GANV_TYPE_TEXT))
+#define GANV_IS_TEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GANV_TYPE_TEXT))
+#define GANV_TEXT_GET_CLASS(obj) (GTK_CHECK_GET_CLASS((obj), GANV_TYPE_TEXT, GanvTextClass))
+
+typedef struct _GanvText GanvText;
+typedef struct _GanvTextClass GanvTextClass;
+
+typedef struct
+{
+ double x;
+ double y;
+ double width;
+ double height;
+} GanvTextCoords;
+
+struct _GanvText
+{
+ GnomeCanvasItem item;
+ cairo_surface_t* surface;
+ char* text;
+ GanvTextCoords coords;
+ GanvTextCoords old_coords;
+ guint color;
+};
+
+struct _GanvTextClass {
+ GnomeCanvasItemClass parent_class;
+};
+
+GType ganv_text_get_type(void);
+
+G_END_DECLS
+
+#endif /* GANV_TEXT_H */
diff --git a/ganv/types.h b/ganv/types.h
new file mode 100644
index 0000000..6566f06
--- /dev/null
+++ b/ganv/types.h
@@ -0,0 +1,29 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_TYPES_H
+#define GANV_TYPES_H
+
+typedef struct _GanvCanvas GanvCanvas;
+typedef struct _GanvEdge GanvEdge;
+typedef struct _GanvItem GanvItem;
+typedef struct _GanvModule GanvModule;
+typedef struct _GanvNode GanvNode;
+typedef struct _GanvPort GanvPort;
+
+#endif // GANV_TYPES_H
+
diff --git a/ganv/types.hpp b/ganv/types.hpp
new file mode 100644
index 0000000..c164d72
--- /dev/null
+++ b/ganv/types.hpp
@@ -0,0 +1,33 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_TYPES_HPP
+#define GANV_TYPES_HPP
+
+namespace Ganv {
+
+class Canvas;
+class Edge;
+class Item;
+class Module;
+class Node;
+class Port;
+
+}; // namespace Ganv
+
+#endif // GANV_TYPES_HPP
+
diff --git a/ganv/wrap.hpp b/ganv/wrap.hpp
new file mode 100644
index 0000000..40c2d13
--- /dev/null
+++ b/ganv/wrap.hpp
@@ -0,0 +1,112 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_WRAP_HPP
+#define GANV_WRAP_HPP
+
+#include <glib.h>
+#define RW_PROPERTY(type, name) \
+ virtual type get_##name() const { \
+ type value; \
+ g_object_get(G_OBJECT(_gobj), #name, &value, NULL); \
+ return value; \
+ } \
+ virtual void set_##name(type value) { \
+ g_object_set(G_OBJECT(_gobj), #name, value, NULL); \
+ }
+
+#define RW_OBJECT_PROPERTY(type, name) \
+ type get_##name() const { \
+ if (!_gobj) return NULL; \
+ Ganv##type ptr; \
+ g_object_get(G_OBJECT(_gobj), #name, &ptr, NULL); \
+ return Glib::wrap(ptr); \
+ } \
+ void set_##name(type value) { \
+ if (!_gobj) return; \
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(_gobj), \
+ #name, value->gobj(), \
+ NULL); \
+ }
+
+#define METHOD0(prefix, name) \
+ virtual void name() { \
+ prefix##_##name(gobj()); \
+ }
+
+#define METHOD1(prefix, name, t1, a1) \
+ virtual void name(t1 a1) { \
+ prefix##_##name(gobj(), a1); \
+ }
+
+#define METHODRET0(prefix, ret, name) \
+ virtual ret name() const { \
+ return prefix##_##name(gobj()); \
+ }
+
+#define METHODRETWRAP0(prefix, ret, name) \
+ virtual ret name() const { \
+ if (gobj()) { \
+ return Glib::wrap(prefix##_##name(gobj())); \
+ } else { \
+ return NULL; \
+ } \
+ }
+
+#define METHOD2(prefix, name, t1, a1, t2, a2) \
+ virtual void name(t1 a1, t2 a2) { \
+ prefix##_##name(gobj(), a1, a2); \
+ }
+
+#define SIGNAL(name, argtype) \
+public: \
+ virtual bool on_##name(argtype arg) { \
+ return _signal_##name.emit(arg); \
+ } \
+ sigc::signal<bool, argtype>& signal_##name() { return _signal_##name; } \
+private: \
+ sigc::signal<bool, argtype> _signal_##name;
+
+#define GANV_GLIB_WRAP(Name) \
+ namespace Ganv { \
+ class Name; \
+ } \
+ namespace Glib { \
+ /** Return a Ganv::CPPType wrapper for a CType. */ \
+ static inline Ganv::Name* \
+ wrap(Ganv##Name* gobj) \
+ { \
+ if (gobj) { \
+ GQuark key = g_quark_from_string("ganvmm"); \
+ return (Ganv::Name*)g_object_get_qdata(G_OBJECT(gobj), key); \
+ } else { \
+ return NULL; \
+ } \
+ } \
+ static inline const Ganv::Name* \
+ wrap(const Ganv##Name* gobj) \
+ { \
+ if (gobj) { \
+ GQuark key = g_quark_from_string("ganvmm"); \
+ return (const Ganv::Name*)g_object_get_qdata(G_OBJECT(gobj), key); \
+ } else { \
+ return NULL; \
+ } \
+ } \
+ }
+
+#endif // GANV_WRAP_HPP
diff --git a/gtkdoc.sh b/gtkdoc.sh
new file mode 100755
index 0000000..7dddde6
--- /dev/null
+++ b/gtkdoc.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+DOC_MODULE=ganv
+
+mkdir -p docs
+cd docs
+
+export CFLAGS="`pkg-config --cflags ganv-1`"
+export LDFLAGS="`pkg-config --libs ganv-1`"
+
+# Sources have changed
+gtkdoc-scan --module=$DOC_MODULE --source-dir=../ganv
+gtkdoc-scangobj --module=$DOC_MODULE
+gtkdoc-mkdb --module=$DOC_MODULE --output-format=xml
+
+# XML files have changed
+mkdir -p html
+cd html && gtkdoc-mkhtml $DOC_MODULE ../ganv-docs.xml && cd -
+gtkdoc-fixxref --module=$DOC_MODULE --module-dir=html
+
+cd - \ No newline at end of file
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
new file mode 100644
index 0000000..a401283
--- /dev/null
+++ b/src/Canvas.cpp
@@ -0,0 +1,1953 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#define _POSIX_C_SOURCE 200809L // strdup
+
+#include <algorithm>
+#include <cassert>
+#include <cmath>
+#include <iostream>
+#include <list>
+#include <map>
+#include <sstream>
+#include <string>
+#include <vector>
+#include <set>
+
+#include <gdk/gdkkeysyms.h>
+#include <gtk/gtkstyle.h>
+
+#include <gtkmm/widget.h>
+
+#include <libgnomecanvas/gnome-canvas-pixbuf.h>
+
+#include "ganv-config.h"
+#include "ganv/Canvas.hpp"
+#include "ganv/Edge.hpp"
+#include "ganv/Circle.hpp"
+#include "ganv/Module.hpp"
+#include "ganv/Port.hpp"
+#include "ganv/box.h"
+#include "ganv/canvas.h"
+#include "ganv/edge.h"
+#include "ganv/node.h"
+
+#include "./color.h"
+
+#ifdef HAVE_AGRAPH
+# include <gvc.h>
+#endif
+
+using std::cerr;
+using std::endl;
+using std::list;
+using std::string;
+using std::vector;
+
+typedef std::set<GanvNode*> Items;
+
+#define FOREACH_ITEM(items, i) \
+ for (Items::const_iterator i = items.begin(); i != items.end(); ++i)
+
+#define FOREACH_ITEM_MUT(items, i) \
+ for (Items::iterator i = items.begin(); i != items.end(); ++i)
+
+#define FOREACH_EDGE(edges, i) \
+ for (GanvCanvasImpl::Edges::const_iterator i = edges.begin(); \
+ i != edges.end(); \
+ ++i)
+
+#define FOREACH_EDGE_MUT(edges, i) \
+ for (GanvCanvasImpl::Edges::iterator i = edges.begin(); \
+ i != edges.end(); \
+ ++i)
+
+#define FOREACH_SELECTED_EDGE(edges, i) \
+ for (GanvCanvasImpl::SelectedEdges::const_iterator i = edges.begin(); \
+ i != edges.end(); \
+ ++i)
+
+#define FOREACH_SELECTED_PORT(p) \
+ for (SelectedPorts::iterator p = _selected_ports.begin(); \
+ p != _selected_ports.end(); ++p)
+
+#ifdef HAVE_AGRAPH
+class GVNodes : public std::map<GanvNode*, Agnode_t*> {
+public:
+ GVNodes() : gvc(0), G(0) {}
+
+ void cleanup() {
+ gvFreeLayout(gvc, G);
+ agclose (G);
+ gvc = 0;
+ G = 0;
+ }
+
+ GVC_t* gvc;
+ Agraph_t* G;
+};
+#endif
+
+static const uint32_t SELECT_RECT_FILL_COLOUR = 0x0E2425FF;
+static const uint32_t SELECT_RECT_BORDER_COLOUR = 0x2E4445FF;
+
+/** Order edges by (tail, head) */
+struct TailHeadOrder {
+ inline bool operator()(const GanvEdge* a, const GanvEdge* b) const {
+ return ((a->tail < b->tail)
+ || (a->tail == b->tail && a->head < b->head));
+ }
+};
+
+/** Order edges by (head, tail) */
+struct HeadTailOrder {
+ inline bool operator()(const GanvEdge* a, const GanvEdge* b) const {
+ return ((a->head < b->head)
+ || (a->head == b->head && a->tail < b->tail));
+ }
+};
+
+static gboolean
+on_canvas_event(GnomeCanvasItem* canvasitem,
+ GdkEvent* ev,
+ void* canvas)
+{
+ return ((Ganv::Canvas*)canvas)->on_event(ev);
+}
+
+struct GanvCanvasImpl {
+ GanvCanvasImpl(Ganv::Canvas& canvas, GanvCanvas* gobj, double width, double height)
+ : _canvas(canvas)
+ , _gcanvas(gobj)
+ , _layout(Glib::wrap(GTK_LAYOUT(_gcanvas)))
+ , _connect_port(NULL)
+ , _last_selected_port(NULL)
+ , _base_rect(gnome_canvas_item_new(
+ gnome_canvas_root(GNOME_CANVAS(_gcanvas)),
+ gnome_canvas_rect_get_type(),
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", width,
+ "y2", height,
+ "fill-color-rgba", 0x000000FF,
+ NULL))
+ , _select_rect(NULL)
+ , _zoom(1.0)
+ , _font_size(0.0)
+ , _width(width)
+ , _height(height)
+ , _drag_state(NOT_DRAGGING)
+ , _direction(Ganv::Canvas::HORIZONTAL)
+ {
+ _wrapper_key = g_quark_from_string("ganvmm");
+ _move_cursor = gdk_cursor_new(GDK_FLEUR);
+
+ gnome_canvas_set_scroll_region(GNOME_CANVAS(_gcanvas), 0.0, 0.0, width, height);
+
+ g_signal_connect(G_OBJECT(gnome_canvas_root(GNOME_CANVAS(_gcanvas))),
+ "event", G_CALLBACK(on_canvas_event), &_canvas);
+ }
+
+ ~GanvCanvasImpl()
+ {
+ gdk_cursor_unref(_move_cursor);
+ }
+
+ void for_each_edge_from(const GanvNode* tail, GanvEdgeFunction f);
+ void for_each_edge_to(const GanvNode* head, GanvEdgeFunction f);
+ void for_each_edge_on(const GanvNode* node, GanvEdgeFunction f);
+
+ void add_item(GanvNode* i);
+ bool remove_item(GanvNode* i);
+
+ void select_edge(GanvEdge* edge);
+ void unselect_edge(GanvEdge* edge);
+ void select_item(GanvNode* item);
+ void unselect_item(GanvNode* item);
+
+ void move_selected_items(double dx, double dy);
+ void selection_move_finished();
+
+#ifdef HAVE_AGRAPH
+ GVNodes layout_dot(bool use_length_hints, const std::string& filename);
+#endif
+
+ void remove_edge(GanvEdge* c);
+ bool are_connected(const GanvNode* tail,
+ const GanvNode* head);
+
+ typedef std::set<GanvEdge*, TailHeadOrder> Edges;
+ typedef std::set<GanvEdge*, HeadTailOrder> DstEdges;
+ typedef std::set<GanvEdge*> SelectedEdges;
+ typedef std::list<GanvPort*> SelectedPorts;
+
+ Edges::const_iterator first_edge_from(const GanvNode* src);
+ DstEdges::const_iterator first_edge_to(const GanvNode* dst);
+
+ void select_port(GanvPort* p, bool unique=false);
+ void select_port_toggle(GanvPort* p, int mod_state);
+ void unselect_port(GanvPort* p);
+ void selection_joined_with(GanvPort* port);
+ void join_selection();
+
+ GanvNode* get_node_at(double x, double y);
+
+ bool scroll_drag_handler(GdkEvent* event);
+ bool select_drag_handler(GdkEvent* event);
+ bool connect_drag_handler(GdkEvent* event);
+
+ /**
+ Event handler for ports.
+
+ This must be implemented as a Canvas method since port event handling
+ depends on shared data (for selection and connecting). This function
+ should only be used by Port implementations.
+ */
+ bool port_event(GdkEvent* event, GanvPort* port);
+
+ void ports_joined(GanvPort* port1, GanvPort* port2);
+ bool animate_selected();
+
+ void move_contents_to_internal(double x, double y, double min_x, double min_y);
+
+ Ganv::Canvas& _canvas;
+ GanvCanvas* _gcanvas;
+ Gtk::Layout* _layout;
+
+ Items _items; ///< Items on this canvas
+ Edges _edges; ///< Edges ordered (src, dst)
+ DstEdges _dst_edges; ///< Edges ordered (dst, src)
+ Items _selected_items; ///< Currently selected items
+ SelectedEdges _selected_edges; ///< Currently selected edges
+
+ SelectedPorts _selected_ports; ///< Selected ports (hilited red)
+ GanvPort* _connect_port; ///< Port for which a edge is being made
+ GanvPort* _last_selected_port;
+
+ GnomeCanvasItem* _base_rect; ///< Background
+ GanvBox* _select_rect; ///< Rectangle for drag selection
+
+ double _zoom; ///< Current zoom level
+ double _font_size; ///< Current font size in points
+ double _width;
+ double _height;
+
+ enum DragState { NOT_DRAGGING, EDGE, SCROLL, SELECT };
+ DragState _drag_state;
+
+ GQuark _wrapper_key;
+ GdkCursor* _move_cursor;
+
+ Ganv::Canvas::FlowDirection _direction;
+};
+
+static GanvEdge
+make_edge_search_key(const GanvNode* tail, const GanvNode* head)
+{
+ GanvEdge key;
+ memset(&key, '\0', sizeof(GanvEdge));
+ key.tail = const_cast<GanvNode*>(tail);
+ key.head = const_cast<GanvNode*>(head);
+ return key;
+}
+
+GanvCanvasImpl::Edges::const_iterator
+GanvCanvasImpl::first_edge_from(const GanvNode* tail)
+{
+ GanvEdge key = make_edge_search_key(tail, NULL);
+ return _edges.lower_bound(&key);
+}
+
+GanvCanvasImpl::DstEdges::const_iterator
+GanvCanvasImpl::first_edge_to(const GanvNode* head)
+{
+ GanvEdge key = make_edge_search_key(NULL, head);
+ return _dst_edges.lower_bound(&key);
+}
+
+void
+GanvCanvasImpl::select_edge(GanvEdge* edge)
+{
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(edge), "selected", TRUE, NULL);
+ _selected_edges.insert(edge);
+}
+
+void
+GanvCanvasImpl::unselect_edge(GanvEdge* edge)
+{
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(edge), "selected", FALSE, NULL);
+ _selected_edges.erase(edge);
+}
+
+void
+GanvCanvasImpl::move_selected_items(double dx, double dy)
+{
+ FOREACH_ITEM(_selected_items, i) {
+ ganv_node_move(*i, dx, dy);
+ }
+}
+
+void
+GanvCanvasImpl::selection_move_finished()
+{
+ FOREACH_ITEM(_selected_items, i) {
+ std::cerr << "FIXME: selection move finished" << std::endl;
+ Glib::wrap(*i)->signal_moved.emit();
+ }
+}
+
+static void
+select_if_tail_is_selected(GanvEdge* edge)
+{
+ gboolean selected;
+ g_object_get(edge->tail, "selected", &selected, NULL);
+ if (!selected && GANV_IS_PORT(edge->tail)) {
+ g_object_get(ganv_port_get_module(GANV_PORT(edge->tail)),
+ "selected", &selected, NULL);
+ }
+
+ if (selected) {
+ ganv_edge_select(edge);
+ }
+}
+
+static void
+select_if_head_is_selected(GanvEdge* edge)
+{
+ gboolean selected;
+ g_object_get(edge->head, "selected", &selected, NULL);
+ if (!selected && GANV_IS_PORT(edge->head)) {
+ g_object_get(ganv_port_get_module(GANV_PORT(edge->head)),
+ "selected", &selected, NULL);
+ }
+
+ if (selected) {
+ ganv_edge_select(edge);
+ }
+}
+
+static void
+select_edges(GanvPort* port, void* data)
+{
+ GanvCanvasImpl* impl = (GanvCanvasImpl*)data;
+ if (port->is_input) {
+ impl->for_each_edge_to(GANV_NODE(port),
+ select_if_tail_is_selected);
+ } else {
+ impl->for_each_edge_from(GANV_NODE(port),
+ select_if_head_is_selected);
+ }
+}
+
+void
+GanvCanvasImpl::add_item(GanvNode* n)
+{
+ if (GNOME_CANVAS_ITEM(n)->parent == GNOME_CANVAS_ITEM(_canvas.root())) {
+ _items.insert(n);
+ }
+}
+
+/** Remove an item from the canvas, cutting all references.
+ * Returns true if item was found (and removed).
+ */
+bool
+GanvCanvasImpl::remove_item(GanvNode* item)
+{
+ bool ret = false;
+
+ // Remove from selection
+ _selected_items.erase(item);
+
+ // Remove children ports from selection if item is a module
+ if (GANV_IS_MODULE(item)) {
+ GanvModule* const module = GANV_MODULE(item);
+ for (unsigned i = 0; i < module->ports->len; ++i) {
+ unselect_port((GanvPort*)g_ptr_array_index(
+ module->ports, i));
+ }
+ }
+
+ // Remove from items
+ _items.erase(item);
+
+ return ret;
+}
+
+void
+GanvCanvasImpl::select_item(GanvNode* m)
+{
+ _selected_items.insert(m);
+
+ // Select any connections to or from this node
+ if (GANV_IS_MODULE(m)) {
+ Ganv::Module* module = Glib::wrap(GANV_MODULE(m));
+ module->for_each_port(select_edges, this);
+ } else {
+ for_each_edge_on(m, ganv_edge_select);
+ }
+
+ g_object_set(m, "selected", TRUE, NULL);
+}
+
+static void
+unselect_edges(GanvPort* port, void* data)
+{
+ GanvCanvasImpl* impl = (GanvCanvasImpl*)data;
+ if (port->is_input) {
+ impl->for_each_edge_to(GANV_NODE(port),
+ ganv_edge_unselect);
+ } else {
+ impl->for_each_edge_from(GANV_NODE(port),
+ ganv_edge_unselect);
+ }
+}
+
+void
+GanvCanvasImpl::unselect_item(GanvNode* m)
+{
+ // Unselect any connections to or from this node
+ if (GANV_IS_MODULE(m)) {
+ Ganv::Module* module = Glib::wrap(GANV_MODULE(m));
+ module->for_each_port(unselect_edges, this);
+ } else {
+ for_each_edge_on(m, ganv_edge_unselect);
+ }
+
+ // Unselect item
+ _selected_items.erase(m);
+ g_object_set(m, "selected", FALSE, NULL);
+}
+
+#ifdef HAVE_AGRAPH
+static void
+gv_set(void* subject, const char* key, double value)
+{
+ std::ostringstream ss;
+ ss << value;
+ agsafeset(subject, (char*)key, (char*)ss.str().c_str(), NULL);
+}
+
+GVNodes
+GanvCanvasImpl::layout_dot(bool use_length_hints, const std::string& filename)
+{
+ GVNodes nodes;
+
+ const double dpi = gdk_screen_get_resolution(gdk_screen_get_default());
+
+ GVC_t* gvc = gvContext();
+ Agraph_t* G = agopen((char*)"g", AGDIGRAPH);
+ agsafeset(G, (char*)"splines", (char*)"false", NULL);
+ agsafeset(G, (char*)"compound", (char*)"true", NULL);
+ agsafeset(G, (char*)"remincross", (char*)"true", NULL);
+ agsafeset(G, (char*)"overlap", (char*)"scale", NULL);
+ agsafeset(G, (char*)"nodesep", (char*)"0.0", NULL);
+ gv_set(G, "fontsize", ganv_canvas_get_font_size(_canvas.gobj()));
+ gv_set(G, "dpi", dpi);
+
+ nodes.gvc = gvc;
+ nodes.G = G;
+
+ if (_direction == Ganv::Canvas::HORIZONTAL) {
+ agraphattr(G, (char*)"rankdir", (char*)"LR");
+ } else {
+ agraphattr(G, (char*)"rankdir", (char*)"TD");
+ }
+
+ unsigned id = 0;
+ std::ostringstream ss;
+ FOREACH_ITEM(_items, i) {
+ if (GANV_IS_MODULE(*i)) {
+ // Create a subgraph for this node
+ ss.str("");
+ ss << "cluster" << id++;
+ Agraph_t* subg = agsubg(G, (char*)ss.str().c_str());
+ agsafeset(subg, (char*)"shape", (char*)"box", NULL);
+ agsafeset(subg, (char*)"pad", (char*)"0", NULL);
+ gv_set(subg, "width",
+ ganv_box_get_width(GANV_BOX(*i)) / dpi);
+ gv_set(subg, "height",
+ ganv_box_get_height(GANV_BOX(*i)) / dpi);
+
+ // Make a borderless node for the title (instead of simply setting
+ // a title on the subgraph, so partners can be connected)
+ ss.str("");
+ ss << "n" << id++;
+ Agnode_t* node = agnode(subg, strdup(ss.str().c_str()));
+ agsafeset(node, (char*)"pos", (char*)"0,0", NULL);
+ agsafeset(node, (char*)"shape", (char*)"box", NULL);
+ agsafeset(node, (char*)"penwidth", (char*)"0", NULL);
+ agsafeset(node, (char*)"margin", (char*)"0", NULL);
+ agsafeset(node, (char*)"pad", (char*)"0", NULL);
+ const char* label = ganv_node_get_label(GANV_NODE(*i));
+ if (label) {
+ agsafeset(node, (char*)"label", (char*)label, NULL);
+ double width, height;
+ g_object_get((*i)->label, "width", &width, "height", &height, NULL);
+ gv_set(node, "width", width / dpi);
+ gv_set(node, "height", height / dpi);
+ }
+ nodes.insert(std::make_pair(*i, (Agnode_t*)node));
+
+ // Make a node in the subgraph for each port on this module
+ GanvModule* const m = GANV_MODULE(*i);
+ for (size_t i = 0; i < m->ports->len; ++i) {
+ GanvPort* port = (GanvPort*)g_ptr_array_index(m->ports, i);
+ ss.str("");
+ ss << "p" << id++;
+ Agnode_t* pnode = agnode(subg, (char*)ss.str().c_str());
+ agsafeset(pnode, (char*)"shape", (char*)"box", NULL);
+ agsafeset(pnode, (char*)"margin", (char*)"0", NULL);
+ agsafeset(pnode, (char*)"pin", (char*)"true", NULL);
+ agsafeset(pnode, (char*)"label",
+ (char*)ganv_node_get_label(GANV_NODE(port)),
+ NULL);
+
+ // Fix position (we don't want ports to be arranged)
+ // (TODO: I don't think dot actually supports this...)
+ double x, y;
+ g_object_get(G_OBJECT(port), "x", &x, "y", &y, NULL);
+ ss.str("");
+ ss << (x / dpi) << "," << (-y / dpi);
+ agsafeset(pnode, (char*)"pos", (char*)ss.str().c_str(), NULL);
+ gv_set(pnode, "width",
+ ganv_box_get_width(GANV_BOX(port)) / dpi);
+ gv_set(pnode, "height",
+ ganv_box_get_height(GANV_BOX(port)) / dpi);
+ nodes.insert(std::make_pair(GANV_NODE(port), pnode));
+ }
+ } else if (GANV_IS_CIRCLE(*i)) {
+ ss.str("");
+ ss << "n" << id++;
+ Agnode_t* node = agnode(G, strdup(ss.str().c_str()));
+ agsafeset(node, (char*)"width", (char*)"1.0", NULL);
+ agsafeset(node, (char*)"height", (char*)"1.0", NULL);
+ agsafeset(node, (char*)"shape", (char*)"ellipse", NULL);
+ agsafeset(node, (char*)"label",
+ (char*)ganv_node_get_label(GANV_NODE(*i)),
+ NULL);
+ nodes.insert(std::make_pair(*i, node));
+ } else {
+ std::cerr << "Unable to arrange item of unknown type" << std::endl;
+ }
+ }
+
+ FOREACH_EDGE(_edges, i) {
+ const GanvEdge* const edge = *i;
+
+ GVNodes::iterator tail_i = nodes.find(edge->tail);
+ GVNodes::iterator head_i = nodes.find(edge->head);
+
+ if (tail_i != nodes.end() && head_i != nodes.end()) {
+ agedge(G, tail_i->second, head_i->second);
+ } else {
+ std::cerr << "Unable to find graphviz node" << std::endl;
+ }
+ }
+
+ // Add edges between partners to have them lined up as if they are
+ // connected
+ for (GVNodes::iterator i = nodes.begin(); i != nodes.end(); ++i) {
+ GanvNode* partner = ganv_node_get_partner(i->first);
+ if (partner) {
+ GVNodes::iterator p = nodes.find(partner);
+ if (p != nodes.end()) {
+ Agedge_t* e = agedge(G, i->second, p->second);
+ agsafeset(e, (char*)"style", (char*)"dotted", NULL);
+ }
+ }
+ }
+
+ gvLayout(gvc, G, (char*)"dot");
+ FILE* tmp = fopen("/dev/null", "w");
+ gvRender(gvc, G, (char*)"dot", tmp);
+ fclose(tmp);
+
+ if (filename != "") {
+ FILE* fd = fopen(filename.c_str(), "w");
+ gvRender(gvc, G, (char*)"dot", fd);
+ fclose(fd);
+ }
+
+ return nodes;
+}
+#endif
+
+void
+GanvCanvasImpl::remove_edge(GanvEdge* edge)
+{
+ if (edge) {
+ _selected_edges.erase(edge);
+ _edges.erase(edge);
+ _dst_edges.erase(edge);
+ gtk_object_destroy(GTK_OBJECT(edge));
+ }
+}
+
+/** Return whether there is a edge between item1 and item2.
+ *
+ * Note that edges are directed, so this may return false when there
+ * is a edge between the two items (in the opposite direction).
+ */
+bool
+GanvCanvasImpl::are_connected(const GanvNode* tail,
+ const GanvNode* head)
+{
+ GanvEdge key = make_edge_search_key(tail, head);
+ return (_edges.find(&key) != _edges.end());
+}
+
+void
+GanvCanvasImpl::select_port(GanvPort* p, bool unique)
+{
+ if (unique)
+ _canvas.unselect_ports();
+ g_object_set(G_OBJECT(p), "selected", TRUE, NULL);
+ SelectedPorts::iterator i = find(_selected_ports.begin(), _selected_ports.end(), p);
+ if (i == _selected_ports.end())
+ _selected_ports.push_back(p);
+ _last_selected_port = p;
+}
+
+void
+GanvCanvasImpl::select_port_toggle(GanvPort* port, int mod_state)
+{
+ gboolean selected;
+ g_object_get(G_OBJECT(port), "selected", &selected, NULL);
+ if ((mod_state & GDK_CONTROL_MASK)) {
+ if (selected)
+ unselect_port(port);
+ else
+ select_port(port);
+ } else if ((mod_state & GDK_SHIFT_MASK)) {
+ GanvModule* const m = ganv_port_get_module(port);
+ if (_last_selected_port && m
+ && ganv_port_get_module(_last_selected_port) == m) {
+ // Pivot around _last_selected_port in a single pass over module ports each click
+ GanvPort* old_last_selected = _last_selected_port;
+ GanvPort* first = NULL;
+ bool done = false;
+ for (size_t i = 0; i < m->ports->len; ++i) {
+ GanvPort* const p = (GanvPort*)g_ptr_array_index(m->ports, i);
+ if (!first && !done && (p == _last_selected_port || p == port)) {
+ first = p;
+ }
+
+ if (first && !done && p->is_input == first->is_input) {
+ select_port(p, false);
+ } else {
+ unselect_port(p);
+ }
+
+ if (p != first && (p == old_last_selected || p == port)) {
+ done = true;
+ }
+ }
+ _last_selected_port = old_last_selected;
+ } else {
+ if (selected) {
+ unselect_port(port);
+ } else {
+ select_port(port);
+ }
+ }
+ } else {
+ if (selected) {
+ _canvas.unselect_ports();
+ } else {
+ select_port(port, true);
+ }
+ }
+}
+
+void
+GanvCanvasImpl::unselect_port(GanvPort* p)
+{
+ SelectedPorts::iterator i = find(_selected_ports.begin(), _selected_ports.end(), p);
+ if (i != _selected_ports.end())
+ _selected_ports.erase(i);
+ g_object_set(G_OBJECT(p), "selected", FALSE, NULL);
+ if (_last_selected_port == p) {
+ _last_selected_port = NULL;
+ }
+}
+
+void
+GanvCanvasImpl::selection_joined_with(GanvPort* port)
+{
+ FOREACH_SELECTED_PORT(i)
+ ports_joined(*i, port);
+}
+
+void
+GanvCanvasImpl::join_selection()
+{
+ vector<GanvPort*> inputs;
+ vector<GanvPort*> outputs;
+ FOREACH_SELECTED_PORT(i) {
+ if ((*i)->is_input) {
+ inputs.push_back(*i);
+ } else {
+ outputs.push_back(*i);
+ }
+ }
+
+ if (inputs.size() == 1) { // 1 -> n
+ for (size_t i = 0; i < outputs.size(); ++i)
+ ports_joined(inputs[0], outputs[i]);
+ } else if (outputs.size() == 1) { // n -> 1
+ for (size_t i = 0; i < inputs.size(); ++i)
+ ports_joined(inputs[i], outputs[0]);
+ } else { // n -> m
+ size_t num_to_connect = std::min(inputs.size(), outputs.size());
+ for (size_t i = 0; i < num_to_connect; ++i) {
+ ports_joined(inputs[i], outputs[i]);
+ }
+ }
+}
+
+GanvNode*
+GanvCanvasImpl::get_node_at(double x, double y)
+{
+ GnomeCanvasItem* item = gnome_canvas_get_item_at(GNOME_CANVAS(_gcanvas), x, y);
+ while (item) {
+ if (GANV_IS_NODE(item)) {
+ return GANV_NODE(item);
+ } else {
+ item = item->parent;
+ }
+ }
+
+ return NULL;
+}
+
+bool
+GanvCanvasImpl::scroll_drag_handler(GdkEvent* event)
+{
+ bool handled = true;
+
+ static int original_scroll_x = 0;
+ static int original_scroll_y = 0;
+ static double origin_x = 0;
+ static double origin_y = 0;
+ static double scroll_offset_x = 0;
+ static double scroll_offset_y = 0;
+ static double last_x = 0;
+ static double last_y = 0;
+
+ if (event->type == GDK_BUTTON_PRESS && event->button.button == 2) {
+ gnome_canvas_item_grab(
+ GNOME_CANVAS_ITEM(_base_rect),
+ GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK,
+ NULL, event->button.time);
+ gnome_canvas_get_scroll_offsets(GNOME_CANVAS(_gcanvas), &original_scroll_x, &original_scroll_y);
+ scroll_offset_x = 0;
+ scroll_offset_y = 0;
+ origin_x = event->button.x_root;
+ origin_y = event->button.y_root;
+ //cerr << "Origin: (" << origin_x << "," << origin_y << ")\n";
+ last_x = origin_x;
+ last_y = origin_y;
+ _drag_state = SCROLL;
+
+ } else if (event->type == GDK_MOTION_NOTIFY && _drag_state == SCROLL) {
+ const double x = event->motion.x_root;
+ const double y = event->motion.y_root;
+ const double x_offset = last_x - x;
+ const double y_offset = last_y - y;
+
+ //cerr << "Coord: (" << x << "," << y << ")\n";
+ //cerr << "Offset: (" << x_offset << "," << y_offset << ")\n";
+
+ scroll_offset_x += x_offset;
+ scroll_offset_y += y_offset;
+ gnome_canvas_scroll_to(GNOME_CANVAS(_gcanvas),
+ lrint(original_scroll_x + scroll_offset_x),
+ lrint(original_scroll_y + scroll_offset_y));
+ last_x = x;
+ last_y = y;
+ } else if (event->type == GDK_BUTTON_RELEASE && _drag_state == SCROLL) {
+ gnome_canvas_item_ungrab(GNOME_CANVAS_ITEM(_base_rect), event->button.time);
+ _drag_state = NOT_DRAGGING;
+ } else {
+ handled = false;
+ }
+
+ return handled;
+}
+
+static void
+get_motion_coords(GdkEventMotion* motion, double* x, double* y)
+{
+ if (motion->is_hint) {
+ gint px;
+ gint py;
+ GdkModifierType state;
+ gdk_window_get_pointer(motion->window, &px, &py, &state);
+ *x = px;
+ *y = py;
+ } else {
+ *x = motion->x;
+ *y = motion->y;
+ }
+}
+
+bool
+GanvCanvasImpl::select_drag_handler(GdkEvent* event)
+{
+ if (event->type == GDK_BUTTON_PRESS && event->button.button == 1) {
+ assert(_select_rect == NULL);
+ _drag_state = SELECT;
+ if ( !(event->button.state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) )
+ _canvas.clear_selection();
+ _select_rect = GANV_BOX(
+ gnome_canvas_item_new(
+ _canvas.root(),
+ ganv_box_get_type(),
+ "x1", event->button.x,
+ "y1", event->button.y,
+ "x2", event->button.x,
+ "y2", event->button.y,
+ "fill-color", SELECT_RECT_FILL_COLOUR,
+ "border-color", SELECT_RECT_BORDER_COLOUR,
+ NULL));
+ gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(_select_rect));
+ gnome_canvas_item_lower_to_bottom(GNOME_CANVAS_ITEM(_base_rect));
+ gnome_canvas_item_grab(
+ GNOME_CANVAS_ITEM(_base_rect), GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK,
+ NULL, event->button.time);
+ return true;
+ } else if (event->type == GDK_MOTION_NOTIFY && _drag_state == SELECT) {
+ assert(_select_rect);
+ double x, y;
+ get_motion_coords(&event->motion, &x, &y);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(_select_rect),
+ "x2", x,
+ "y2", y,
+ NULL);
+ return true;
+ } else if (event->type == GDK_BUTTON_RELEASE && _drag_state == SELECT) {
+ // Normalize select rect
+ ganv_box_normalize(_select_rect);
+
+ // Select all modules within rect
+ FOREACH_ITEM(_items, i) {
+ GanvNode* node = *i;
+ if (ganv_node_is_within(
+ node,
+ ganv_box_get_x1(_select_rect),
+ ganv_box_get_y1(_select_rect),
+ ganv_box_get_x2(_select_rect),
+ ganv_box_get_y2(_select_rect))) {
+ gboolean selected;
+ g_object_get(G_OBJECT(node), "selected", &selected, NULL);
+ if (selected) {
+ unselect_item(node);
+ } else {
+ select_item(node);
+ }
+ }
+ }
+
+ // Select all edges with handles within rect
+ FOREACH_EDGE(_edges, i) {
+ if (ganv_edge_is_within(
+ (*i),
+ ganv_box_get_x1(_select_rect),
+ ganv_box_get_y1(_select_rect),
+ ganv_box_get_x2(_select_rect),
+ ganv_box_get_y2(_select_rect))) {
+ select_edge(*i);
+ }
+ }
+
+ gnome_canvas_item_ungrab(GNOME_CANVAS_ITEM(_base_rect), event->button.time);
+
+ gtk_object_destroy(GTK_OBJECT(_select_rect));
+ _select_rect = NULL;
+ _drag_state = NOT_DRAGGING;
+ return true;
+ }
+ return false;
+}
+
+bool
+GanvCanvasImpl::connect_drag_handler(GdkEvent* event)
+{
+ static GanvEdge* drag_edge = NULL;
+ static GanvNode* drag_node = NULL;
+ static bool snapped = false;
+
+ if (_drag_state != EDGE) {
+ return false;
+ }
+
+ if (event->type == GDK_MOTION_NOTIFY) {
+ double x, y;
+ get_motion_coords(&event->motion, &x, &y);
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(_base_rect), &x, &y);
+
+ if (!drag_edge) {
+ // Create drag edge
+ assert(!drag_node);
+ assert(_connect_port);
+
+ drag_node = GANV_NODE(
+ gnome_canvas_item_new(gnome_canvas_root(GNOME_CANVAS(_gcanvas)),
+ ganv_node_get_type(),
+ "x", x,
+ "y", y,
+ NULL));
+
+ drag_edge = ganv_edge_new(
+ _canvas.gobj(),
+ GANV_NODE(_connect_port),
+ drag_node,
+ "color", GANV_NODE(_connect_port)->fill_color,
+ "curved", TRUE,
+ "ghost", TRUE,
+ NULL);
+ }
+
+ GanvNode* joinee = get_node_at(x, y);
+ if (joinee && ganv_node_can_head(joinee) && joinee != drag_node) {
+ // Snap to item
+ snapped = true;
+ gnome_canvas_item_set(&drag_edge->item,
+ "head", joinee,
+ NULL);
+ } else if (snapped) {
+ // Unsnap from item
+ snapped = false;
+ gnome_canvas_item_set(&drag_edge->item,
+ "head", drag_node,
+ NULL);
+ }
+
+ // Update drag edge for pointer position
+ ganv_node_move_to(drag_node, x, y);
+ gnome_canvas_item_request_update(&drag_node->group.item);
+ gnome_canvas_item_request_update(&drag_edge->item);
+
+ return true;
+
+ } else if (event->type == GDK_BUTTON_RELEASE) {
+ gnome_canvas_item_ungrab(GNOME_CANVAS_ITEM(_base_rect), event->button.time);
+
+ double x = event->button.x;
+ double y = event->button.y;
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(_base_rect), &x, &y);
+
+ GanvNode* joinee = get_node_at(x, y);
+
+ if (joinee) {
+ if (joinee == GANV_NODE(_connect_port)) {
+ // Drag ended on the same port it started on, port clicked
+ if (_selected_ports.empty()) {
+ // No selected ports, port clicked
+ select_port(_connect_port);
+ } else {
+ // Connect to selected ports
+ selection_joined_with(_connect_port);
+ _canvas.unselect_ports();
+ _connect_port = NULL;
+ }
+ } else { // drag ended on different port
+ ports_joined(_connect_port, GANV_PORT(joinee));
+ _canvas.unselect_ports();
+ _connect_port = NULL;
+ }
+ }
+
+ // Clean up dragging stuff
+
+ if (_connect_port) {
+ g_object_set(G_OBJECT(_connect_port), "highlighted", FALSE, NULL);
+ }
+
+ _canvas.unselect_ports();
+ _drag_state = NOT_DRAGGING;
+ _connect_port = NULL;
+
+ gtk_object_destroy(GTK_OBJECT(drag_edge));
+ gtk_object_destroy(GTK_OBJECT(drag_node));
+ drag_edge = NULL;
+ drag_node = NULL;
+
+ return true;
+ }
+
+ return false;
+}
+
+bool
+GanvCanvasImpl::port_event(GdkEvent* event, GanvPort* port)
+{
+ static bool port_dragging = false;
+ static bool control_dragging = false;
+ static bool ignore_button_release = false;
+
+ bool handled = true;
+
+ switch (event->type) {
+
+ case GDK_BUTTON_PRESS:
+ if (event->button.button == 1) {
+ GanvModule* const module = ganv_port_get_module(port);
+ if (module && _canvas.get_locked() && port->is_input) {
+#if 0
+ if (port->is_toggled()) {
+ port->toggle();
+ ignore_button_release = true;
+ } else {
+ control_dragging = true;
+ const double port_x = module->get_x() + port->get_x();
+ float new_control = ((event->button.x - port_x) / (double)port->get_width());
+ if (new_control < 0.0)
+ new_control = 0.0;
+ else if (new_control > 1.0)
+ new_control = 1.0;
+
+ new_control *= (port->control_max() - port->control_min());
+ new_control += port->control_min();
+ if (new_control < port->control_min())
+ new_control = port->control_min();
+ if (new_control > port->control_max())
+ new_control = port->control_max();
+ if (new_control != port->control_value())
+ port->set_control(new_control);
+ }
+#endif
+ } else {
+ port_dragging = true;
+ }
+ } else {
+ // FIXME
+ //return Glib::wrap(port)->on_click(&event->button);
+ }
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ if (control_dragging) {
+ GanvModule* const module = ganv_port_get_module(port);
+ if (module) {
+ const double port_x = ganv_box_get_x1(GANV_BOX(module))
+ + ganv_box_get_x1(GANV_BOX(port));
+ float new_control = ((event->button.x - port_x)
+ / ganv_box_get_width(GANV_BOX(port)));
+ if (new_control < 0.0)
+ new_control = 0.0;
+ else if (new_control > 1.0)
+ new_control = 1.0;
+
+ new_control *= (port->control->max - port->control->min);
+ new_control += port->control->min;
+ assert(new_control >= port->control->min);
+ assert(new_control <= port->control->max);
+
+ if (new_control != port->control->value) {
+ ganv_port_set_control_value(port, new_control);
+ }
+ }
+ }
+ break;
+
+ case GDK_BUTTON_RELEASE:
+ if (port_dragging) {
+ if (_connect_port) { // dragging
+ ports_joined(port, _connect_port);
+ _canvas.unselect_ports();
+ } else {
+ bool modded = event->button.state & (GDK_SHIFT_MASK|GDK_CONTROL_MASK);
+ if (!modded && _last_selected_port && _last_selected_port->is_input != port->is_input) {
+ selection_joined_with(port);
+ _canvas.unselect_ports();
+ } else {
+ select_port_toggle(port, event->button.state);
+ }
+ }
+ port_dragging = false;
+ } else if (control_dragging) {
+ control_dragging = false;
+ } else if (ignore_button_release) {
+ ignore_button_release = false;
+ } else {
+ handled = false;
+ }
+ break;
+
+ case GDK_ENTER_NOTIFY:
+ //signal_item_entered.emit(port);
+ gboolean selected;
+ g_object_get(G_OBJECT(port), "selected", &selected, NULL);
+ if (!control_dragging && !selected) {
+ g_object_set(G_OBJECT(port), "highlighted", TRUE, NULL);
+ return true;
+ }
+ break;
+
+ case GDK_LEAVE_NOTIFY:
+ if (port_dragging) {
+ _drag_state = GanvCanvasImpl::EDGE;
+ _connect_port = port;
+ port_dragging = false;
+ gnome_canvas_item_grab(
+ GNOME_CANVAS_ITEM(_base_rect),
+ GDK_BUTTON_PRESS_MASK|GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK,
+ NULL, event->crossing.time);
+ } else if (!control_dragging) {
+ g_object_set(G_OBJECT(port), "highlighted", FALSE, NULL);
+ }
+ //signal_item_left.emit(port);
+ break;
+
+ default:
+ handled = false;
+ }
+
+ return handled;
+}
+
+/** Called when two ports are 'toggled' (connected or disconnected)
+ */
+void
+GanvCanvasImpl::ports_joined(GanvPort* port1, GanvPort* port2)
+{
+ if (port1 == port2 || !port1 || !port2) {
+ return;
+ }
+
+ g_object_set(G_OBJECT(port1), "highlighted", FALSE, NULL);
+ g_object_set(G_OBJECT(port2), "highlighted", FALSE, NULL);
+
+ GanvNode* src_node;
+ GanvNode* dst_node;
+
+ if (port2->is_input && !port1->is_input) {
+ src_node = GANV_NODE(port1);
+ dst_node = GANV_NODE(port2);
+ } else if (!port2->is_input && port1->is_input) {
+ src_node = GANV_NODE(port2);
+ dst_node = GANV_NODE(port1);
+ } else {
+ return;
+ }
+
+ if (are_connected(GANV_NODE(src_node), GANV_NODE(dst_node)))
+ _canvas.disconnect(Glib::wrap(src_node), Glib::wrap(dst_node));
+ else
+ _canvas.connect(Glib::wrap(src_node), Glib::wrap(dst_node));
+}
+
+/** Update animated "rubber band" selection effect. */
+bool
+GanvCanvasImpl::animate_selected()
+{
+ const double seconds = g_get_monotonic_time() / 1000000.0;
+
+ FOREACH_ITEM(_selected_items, s) {
+ ganv_node_tick(*s, seconds);
+ }
+
+ FOREACH_SELECTED_PORT(p) {
+ ganv_node_tick(GANV_NODE(*p), seconds);
+ }
+
+ FOREACH_EDGE(_selected_edges, c) {
+ ganv_edge_tick(*c, seconds);
+ }
+
+ return true;
+}
+
+void
+GanvCanvasImpl::move_contents_to_internal(double x, double y, double min_x, double min_y)
+{
+ FOREACH_ITEM(_items, i) {
+ ganv_node_move(*i,
+ x - min_x,
+ y - min_y);
+ }
+}
+
+void
+GanvCanvasImpl::for_each_edge_from(const GanvNode* tail,
+ GanvEdgeFunction f)
+{
+ for (GanvCanvasImpl::Edges::const_iterator i = first_edge_from(tail);
+ i != _edges.end() && (*i)->tail == tail;) {
+ GanvCanvasImpl::Edges::const_iterator next = i;
+ ++next;
+ f((*i));
+ i = next;
+ }
+}
+
+void
+GanvCanvasImpl::for_each_edge_to(const GanvNode* head,
+ GanvEdgeFunction f)
+{
+ for (GanvCanvasImpl::Edges::const_iterator i = first_edge_to(head);
+ i != _dst_edges.end() && (*i)->head == head;) {
+ GanvCanvasImpl::Edges::const_iterator next = i;
+ ++next;
+ f((*i));
+ i = next;
+ }
+}
+
+void
+GanvCanvasImpl::for_each_edge_on(const GanvNode* node,
+ GanvEdgeFunction f)
+{
+ for_each_edge_from(node, f);
+ for_each_edge_to(node, f);
+}
+
+namespace Ganv {
+
+Canvas::Canvas(double width, double height)
+ : _gobj(GANV_CANVAS(ganv_canvas_new()))
+{
+ _gobj->impl = new GanvCanvasImpl(*this, _gobj, width, height);
+
+ impl()->_font_size = get_default_font_size();
+
+ g_object_set_qdata(G_OBJECT(impl()->_gcanvas), wrapper_key(), this);
+
+ Glib::signal_timeout().connect(
+ sigc::mem_fun(impl(), &GanvCanvasImpl::animate_selected), 120);
+}
+
+Canvas::~Canvas()
+{
+ destroy();
+ delete impl();
+}
+
+void
+Canvas::set_zoom(double pix_per_unit)
+{
+ set_zoom_and_font_size(pix_per_unit, impl()->_font_size);
+}
+
+void
+Canvas::set_font_size(double points)
+{
+ set_zoom_and_font_size(impl()->_zoom, points);
+}
+
+void
+Canvas::set_zoom_and_font_size(double zoom, double points)
+{
+ points = std::max(points, 1.0);
+ zoom = std::max(zoom, 0.01);
+
+ if (zoom == impl()->_zoom && points == impl()->_font_size)
+ return;
+
+ if (zoom != impl()->_zoom) {
+ impl()->_zoom = zoom;
+ gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(impl()->_gcanvas), zoom);
+ }
+
+ impl()->_font_size = points;
+
+#if 0
+ FOREACH_ITEM(impl()->_items, i) {
+ (*i)->redraw_text();
+ }
+#endif
+}
+
+void
+Canvas::zoom_full()
+{
+#if 0
+ if (impl()->_items.empty())
+ return;
+
+ int win_width, win_height;
+ Glib::RefPtr<Gdk::Window> win = GNOME_CANVAS(impl()->_gcanvas)->get_window();
+ win->get_size(win_width, win_height);
+
+ // Box containing all canvas items
+ double left = DBL_MAX;
+ double right = DBL_MIN;
+ double top = DBL_MIN;
+ double bottom = DBL_MAX;
+
+ FOREACH_ITEM(impl()->_items, i) {
+ if ((*i)->get_x() < left)
+ left = (*i)->get_x();
+ if ((*i)->get_x() + (*i)->width() > right)
+ right = (*i)->get_x() + (*i)->width();
+ if ((*i)->get_y() < bottom)
+ bottom = (*i)->get_y();
+ if ((*i)->get_y() + (*i)->height() > top)
+ top = (*i)->get_y() + (*i)->height();
+ }
+
+ static const double pad = 8.0;
+
+ const double new_zoom = std::min(
+ ((double)win_width / (double)(right - left + pad*2.0)),
+ ((double)win_height / (double)(top - bottom + pad*2.0)));
+
+ set_zoom(new_zoom);
+
+ int scroll_x, scroll_y;
+ GNOME_CANVAS(impl()->_gcanvas)->w2c(lrintf(left - pad), lrintf(bottom - pad), scroll_x, scroll_y);
+
+ GNOME_CANVAS(impl()->_gcanvas)->scroll_to(scroll_x, scroll_y);
+#endif
+}
+
+void
+Canvas::clear_selection()
+{
+ unselect_ports();
+
+ FOREACH_ITEM(impl()->_selected_items, i) {
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(*i), "selected", FALSE, NULL);
+ }
+
+ FOREACH_SELECTED_EDGE(impl()->_selected_edges, c) {
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(*c), "selected", FALSE, NULL);
+ }
+
+ impl()->_selected_items.clear();
+ impl()->_selected_edges.clear();
+}
+
+void
+Canvas::select_edge(Edge* edge)
+{
+ impl()->select_edge(edge->gobj());
+}
+
+void
+Canvas::unselect_edge(Edge* edge)
+{
+ impl()->unselect_edge(edge->gobj());
+}
+
+double
+Canvas::get_zoom()
+{
+ return impl()->_zoom;
+}
+
+double
+Canvas::width() const
+{
+ return impl()->_width;
+}
+
+double
+Canvas::height() const
+{
+ return impl()->_height;
+}
+
+void
+Canvas::set_direction(FlowDirection d)
+{
+ impl()->_direction = d;
+ std::cerr << "FIXME: set direction" << std::endl;
+#if 0
+ FOREACH_ITEM(impl()->_items, i) {
+ Module* mod = dynamic_cast<Module*>(*i);
+ if (mod) {
+ mod->set_show_port_labels(d == Canvas::HORIZONTAL);
+ }
+ }
+#endif
+}
+
+Canvas::FlowDirection
+Canvas::direction() const
+{
+ return impl()->_direction;
+}
+
+void
+Canvas::select_all()
+{
+ clear_selection();
+ FOREACH_ITEM(impl()->_items, m) {
+ impl()->select_item(*m);
+ }
+}
+
+void
+Canvas::select_item(Ganv::Node* m)
+{
+ impl()->select_item(m->gobj());
+}
+
+void
+Canvas::unselect_item(Ganv::Node* m)
+{
+ impl()->unselect_item(m->gobj());
+}
+
+void
+Canvas::destroy()
+{
+ impl()->_selected_items.clear();
+ impl()->_selected_edges.clear();
+
+ Items items = impl()->_items; // copy
+ FOREACH_ITEM(items, i) {
+ gtk_object_destroy(GTK_OBJECT(*i));
+ }
+
+ impl()->_edges.clear();
+
+ impl()->_selected_ports.clear();
+ impl()->_connect_port = NULL;
+
+ impl()->_items.clear();
+}
+
+void
+Canvas::unselect_ports()
+{
+ for (GanvCanvasImpl::SelectedPorts::iterator i = impl()->_selected_ports.begin();
+ i != impl()->_selected_ports.end(); ++i)
+ g_object_set(G_OBJECT(*i), "selected", FALSE, NULL);
+
+ impl()->_selected_ports.clear();
+ impl()->_last_selected_port = NULL;
+}
+
+void
+Canvas::set_default_placement(Node* i)
+{
+ // Simple cascade. This will get more clever in the future.
+ double x = ((impl()->_width / 2.0) + (impl()->_items.size() * 25));
+ double y = ((impl()->_height / 2.0) + (impl()->_items.size() * 25));
+
+ i->move_to(x, y);
+}
+
+void
+Canvas::remove_edge(Node* item1,
+ Node* item2)
+{
+ Edge* edge = get_edge(item1, item2);
+ if (edge) {
+ impl()->remove_edge(edge->gobj());
+ }
+}
+
+/** Get the edge between two items.
+ *
+ * Note that edges are directed.
+ * This will only return a edge from @a tail to @a head.
+ */
+Edge*
+Canvas::get_edge(Node* tail, Node* head) const
+{
+ FOREACH_EDGE(impl()->_edges, i) {
+ const GanvNode* const t = (*i)->tail;
+ const GanvNode* const h = (*i)->head;
+
+ if (t == tail->gobj() && h == head->gobj())
+ return Glib::wrap(*i);
+ }
+
+ return NULL;
+}
+
+bool
+Canvas::on_event(GdkEvent* event)
+{
+ static const int scroll_increment = 10;
+ int scroll_x, scroll_y;
+ gnome_canvas_get_scroll_offsets(GNOME_CANVAS(impl()->_gcanvas), &scroll_x, &scroll_y);
+
+ switch (event->type) {
+ case GDK_KEY_PRESS:
+ switch (event->key.keyval) {
+ case GDK_Up:
+ scroll_y -= scroll_increment;
+ break;
+ case GDK_Down:
+ scroll_y += scroll_increment;
+ break;
+ case GDK_Left:
+ scroll_x -= scroll_increment;
+ break;
+ case GDK_Right:
+ scroll_x += scroll_increment;
+ break;
+ case GDK_Return:
+ if (impl()->_selected_ports.size() > 1) {
+ impl()->join_selection();
+ clear_selection();
+ }
+ return true;
+ default:
+ return false;
+ }
+ gnome_canvas_scroll_to(GNOME_CANVAS(impl()->_gcanvas), scroll_x, scroll_y);
+ return true;
+
+ case GDK_SCROLL:
+ if ((event->scroll.state & GDK_CONTROL_MASK)) {
+ if (event->scroll.direction == GDK_SCROLL_UP) {
+ set_font_size(get_font_size() * 1.25);
+ return true;
+ } else if (event->scroll.direction == GDK_SCROLL_DOWN) {
+ set_font_size(get_font_size() * 0.75);
+ return true;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return impl()->scroll_drag_handler(event)
+ || impl()->select_drag_handler(event)
+ || impl()->connect_drag_handler(event);
+}
+
+void
+Canvas::render_to_dot(const string& dot_output_filename)
+{
+#ifdef HAVE_AGRAPH
+ GVNodes nodes = impl()->layout_dot(false, dot_output_filename);
+ nodes.cleanup();
+#endif
+}
+
+void
+Canvas::arrange(bool use_length_hints)
+{
+#ifdef HAVE_AGRAPH
+ GVNodes nodes = impl()->layout_dot(use_length_hints, "");
+
+ double least_x=HUGE_VAL, least_y=HUGE_VAL, most_x=0, most_y=0;
+
+ // Set numeric locale to POSIX for reading graphviz output with strtod
+ char* locale = strdup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "POSIX");
+
+ // Arrange to graphviz coordinates
+ for (GVNodes::iterator i = nodes.begin(); i != nodes.end(); ++i) {
+ if (GNOME_CANVAS_ITEM(i->first)->parent != GNOME_CANVAS_ITEM(root())) {
+ continue;
+ }
+ const string pos = agget(i->second, (char*)"pos");
+ const string x_str = pos.substr(0, pos.find(","));
+ const string y_str = pos.substr(pos.find(",") + 1);
+ const double cx = strtod(x_str.c_str(), NULL) * 1.1;
+ const double cy = strtod(y_str.c_str(), NULL) * 1.1;
+ const double w = ganv_box_get_width(GANV_BOX(i->first));
+
+ /* Dot node positions are supposedly node centers, but things only
+ match up if x is interpreted as center and y as top...
+ */
+ const double x = cx - (w / 2.0);
+ const double y = -cy;
+
+ ganv_node_move_to(i->first, x, y);
+
+ least_x = std::min(least_x, x);
+ least_y = std::min(least_y, y);
+ most_x = std::max(most_x, x);
+ most_y = std::max(most_y, y);
+ }
+
+ // Reset numeric locale to original value
+ setlocale(LC_NUMERIC, locale);
+ free(locale);
+
+ const double graph_width = most_x - least_x;
+ const double graph_height = most_y - least_y;
+
+ //cerr << "CWH: " << _width << ", " << _height << endl;
+ //cerr << "GWH: " << graph_width << ", " << graph_height << endl;
+
+ if (graph_width + 10 > impl()->_width)
+ resize(graph_width + 10, impl()->_height);
+
+ if (graph_height + 10 > impl()->_height)
+ resize(impl()->_width, graph_height + 10);
+
+ nodes.cleanup();
+
+ static const double border_width = impl()->_font_size;
+ impl()->move_contents_to_internal(border_width, border_width, least_x, least_y);
+ gnome_canvas_scroll_to(GNOME_CANVAS(impl()->_gcanvas), 0, 0);
+
+ FOREACH_ITEM(impl()->_items, i) {
+ std::cerr << "FIXME: arrange moved" << std::endl;
+ Glib::wrap((*i))->signal_moved.emit();
+ }
+#endif
+}
+
+void
+Canvas::move_contents_to(double x, double y)
+{
+ double min_x=HUGE_VAL, min_y=HUGE_VAL;
+ FOREACH_ITEM(impl()->_items, i) {
+ double x, y;
+ g_object_get(*i, "x", &x, "y", &y, NULL);
+ min_x = std::min(min_x, x);
+ min_y = std::min(min_y, y);
+ }
+ impl()->move_contents_to_internal(x, y, min_x, min_y);
+}
+
+void
+Canvas::resize(double width, double height)
+{
+ if (width != impl()->_width || height != impl()->_height) {
+ gnome_canvas_item_set(
+ GNOME_CANVAS_ITEM(impl()->_base_rect),
+ "x2", width,
+ "y2", height,
+ NULL);
+ impl()->_width = width;
+ impl()->_height = height;
+ gnome_canvas_set_scroll_region(GNOME_CANVAS(impl()->_gcanvas), 0.0, 0.0, width, height);
+ }
+}
+
+void
+Canvas::for_each_node(NodeFunction f, void* data)
+{
+ FOREACH_ITEM(impl()->_items, i) {
+ f(*i, data);
+ }
+}
+
+void
+Canvas::for_each_selected_node(NodeFunction f, void* data)
+{
+ FOREACH_ITEM(impl()->_selected_items, i) {
+ f(*i, data);
+ }
+}
+
+void
+Canvas::for_each_edge(EdgePtrFunction f, void* data)
+{
+ FOREACH_EDGE(impl()->_edges, i) {
+ f((*i), data);
+ }
+}
+
+void
+Canvas::for_each_selected_edge(EdgePtrFunction f, void* data)
+{
+ FOREACH_EDGE(impl()->_selected_edges, i) {
+ f((*i), data);
+ }
+}
+
+GnomeCanvasGroup*
+Canvas::root()
+{
+ return gnome_canvas_root(GNOME_CANVAS(impl()->_gcanvas));
+}
+
+Gtk::Layout&
+Canvas::widget()
+{
+ return *impl()->_layout;
+}
+
+void
+Canvas::get_scroll_offsets(int& cx, int& cy) const
+{
+ gnome_canvas_get_scroll_offsets(GNOME_CANVAS(impl()->_gcanvas), &cx, &cy);
+}
+
+void
+Canvas::scroll_to(int x, int y)
+{
+ gnome_canvas_scroll_to(GNOME_CANVAS(impl()->_gcanvas), x, y);
+}
+
+GQuark
+Canvas::wrapper_key()
+{
+ return impl()->_wrapper_key;
+}
+
+GdkCursor*
+Canvas::move_cursor()
+{
+ return impl()->_move_cursor;
+}
+
+GanvCanvas*
+Canvas::gobj()
+{
+ return impl()->_gcanvas;
+}
+
+const GanvCanvas*
+Canvas::gobj() const
+{
+ return impl()->_gcanvas;
+}
+
+} // namespace Ganv
+
+
+extern "C" {
+
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include "ganv/canvas.h"
+
+#include "./boilerplate.h"
+#include "./color.h"
+#include "./gettext.h"
+
+G_DEFINE_TYPE(GanvCanvas, ganv_canvas, GNOME_TYPE_CANVAS)
+
+static GnomeCanvasClass* parent_class;
+
+enum {
+ PROP_0,
+ PROP_LOCKED
+};
+
+static void
+ganv_canvas_init(GanvCanvas* canvas)
+{
+ canvas->direction = GANV_HORIZONTAL;
+}
+
+static void
+ganv_canvas_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_CANVAS(object));
+
+ GanvCanvas* canvas = GANV_CANVAS(object);
+
+ switch (prop_id) {
+ case PROP_LOCKED: {
+ const gboolean tmp = g_value_get_boolean(value);
+ if (canvas->locked != tmp) {
+ GnomeCanvasItem* base = GNOME_CANVAS_ITEM(canvas->impl->_base_rect);
+ gnome_canvas_item_set(base,
+ "fill-color", tmp ? 0x131415FF : 0x000000FF,
+ NULL);
+ canvas->locked = tmp;
+ gnome_canvas_item_request_update(base);
+ }
+ break;
+ }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_canvas_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_CANVAS(object));
+
+ GanvCanvas* canvas = GANV_CANVAS(object);
+
+ switch (prop_id) {
+ GET_CASE(LOCKED, boolean, canvas->locked);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_canvas_class_init(GanvCanvasClass* klass)
+{
+ GObjectClass* gobject_class = (GObjectClass*)klass;
+
+ parent_class = GNOME_CANVAS_CLASS(g_type_class_peek_parent(klass));
+
+ gobject_class->set_property = ganv_canvas_set_property;
+ gobject_class->get_property = ganv_canvas_get_property;
+
+ g_object_class_install_property(
+ gobject_class, PROP_LOCKED, g_param_spec_boolean(
+ "locked",
+ _("locked"),
+ _("whether canvas items are movable"),
+ FALSE,
+ (GParamFlags)G_PARAM_READWRITE));
+}
+
+GanvCanvas*
+ganv_canvas_new(void)
+{
+ return (GanvCanvas*)g_object_new(ganv_canvas_get_type(), NULL);
+}
+
+GnomeCanvasGroup*
+ganv_canvas_get_root(const GanvCanvas* canvas)
+{
+ return gnome_canvas_root(GNOME_CANVAS(canvas->impl->_gcanvas));
+}
+
+double
+ganv_canvas_get_default_font_size(const GanvCanvas* canvas)
+{
+ GtkStyle* style = gtk_rc_get_style(GTK_WIDGET(canvas));
+ const PangoFontDescription* font = style->font_desc;
+ return pango_font_description_get_size(font) / (double)PANGO_SCALE;
+}
+
+double
+ganv_canvas_get_font_size(const GanvCanvas* canvas)
+{
+ return ganv_canvas_get_default_font_size(canvas);
+}
+
+void
+ganv_canvas_clear_selection(GanvCanvas* canvas)
+{
+ canvas->impl->_canvas.clear_selection();
+}
+
+void
+ganv_canvas_move_selected_items(GanvCanvas* canvas,
+ double dx,
+ double dy)
+{
+ return canvas->impl->move_selected_items(dx, dy);
+}
+
+void
+ganv_canvas_selection_move_finished(GanvCanvas* canvas)
+{
+ return canvas->impl->selection_move_finished();
+}
+
+void
+ganv_canvas_select_node(GanvCanvas* canvas,
+ GanvNode* node)
+{
+ canvas->impl->select_item(node);
+}
+
+void
+ganv_canvas_unselect_node(GanvCanvas* canvas,
+ GanvNode* node)
+{
+ canvas->impl->unselect_item(node);
+}
+
+void
+ganv_canvas_add_node(GanvCanvas* canvas,
+ GanvNode* node)
+{
+ canvas->impl->add_item(node);
+}
+
+void
+ganv_canvas_remove_node(GanvCanvas* canvas,
+ GanvNode* node)
+{
+ canvas->impl->remove_item(node);
+}
+
+void
+ganv_canvas_add_edge(GanvCanvas* canvas,
+ GanvEdge* edge)
+{
+ canvas->impl->_edges.insert(edge);
+ canvas->impl->_dst_edges.insert(edge);
+}
+
+void
+ganv_canvas_remove_edge(GanvCanvas* canvas,
+ GanvEdge* edge)
+{
+ canvas->impl->remove_edge(edge);
+}
+
+void
+ganv_canvas_select_edge(GanvCanvas* canvas,
+ GanvEdge* edge)
+{
+ canvas->impl->select_edge(edge);
+}
+
+void
+ganv_canvas_unselect_edge(GanvCanvas* canvas,
+ GanvEdge* edge)
+{
+ canvas->impl->unselect_edge(edge);
+}
+
+void
+ganv_canvas_for_each_edge_from(GanvCanvas* canvas,
+ const GanvNode* tail,
+ GanvEdgeFunction f)
+{
+ canvas->impl->for_each_edge_from(tail, f);
+}
+
+void
+ganv_canvas_for_each_edge_to(GanvCanvas* canvas,
+ const GanvNode* head,
+ GanvEdgeFunction f)
+{
+ canvas->impl->for_each_edge_to(head, f);
+}
+
+void
+ganv_canvas_for_each_edge_on(GanvCanvas* canvas,
+ const GanvNode* node,
+ GanvEdgeFunction f)
+{
+ canvas->impl->for_each_edge_on(node, f);
+}
+
+GdkCursor*
+ganv_canvas_get_move_cursor(const GanvCanvas* canvas)
+{
+ return canvas->impl->_move_cursor;
+}
+
+gboolean
+ganv_canvas_port_event(GanvCanvas* canvas,
+ GanvPort* port,
+ GdkEvent* event)
+{
+ return canvas->impl->port_event(event, port);
+}
+
+} // extern "C"
diff --git a/src/Port.cpp b/src/Port.cpp
new file mode 100644
index 0000000..1a48740
--- /dev/null
+++ b/src/Port.cpp
@@ -0,0 +1,52 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string>
+
+#include <glib.h>
+
+#include "ganv/Canvas.hpp"
+#include "ganv/Module.hpp"
+#include "ganv/Port.hpp"
+
+#include "./color.h"
+
+namespace Ganv {
+
+/** Contruct a Port on an existing module.
+ */
+Port::Port(Module& module,
+ const std::string& name,
+ bool is_input,
+ uint32_t color)
+ : Box(module.canvas(),
+ GANV_BOX(
+ ganv_port_new(module.gobj(), is_input,
+ "fill-color", color,
+ "border-color", highlight_color(color, 0x20),
+ "label", name.c_str(),
+ NULL)))
+{
+}
+
+Module*
+Port::get_module() const
+{
+ return Glib::wrap(ganv_port_get_module(gobj()));
+}
+
+} // namespace Ganv
diff --git a/src/boilerplate.h b/src/boilerplate.h
new file mode 100644
index 0000000..413c48d
--- /dev/null
+++ b/src/boilerplate.h
@@ -0,0 +1,45 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+typedef gpointer gobject;
+
+/**
+ A case in a switch statement in a set_properties implementation.
+ @prop: Property enumeration ID.
+ @type: Name of the value type, e.g. uint for guint.
+ @field: Field to set to the new value.
+*/
+#define SET_CASE(prop, type, field) \
+ case PROP_##prop: { \
+ const g##type tmp = g_value_get_##type(value); \
+ if (field != tmp) { \
+ field = tmp; \
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(object)); \
+ } \
+ break; \
+ }
+
+/**
+ A case in a switch statement in a get_properties implementation.
+ @prop: Property enumeration ID.
+ @type: Name of the value type, e.g. uint for guint.
+ @field: Field to set to the new value.
+*/
+#define GET_CASE(prop, type, field) \
+ case PROP_##prop: \
+ g_value_set_##type(value, field); \
+ break;
diff --git a/src/box.c b/src/box.c
new file mode 100644
index 0000000..2a542bf
--- /dev/null
+++ b/src/box.c
@@ -0,0 +1,504 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <math.h>
+#include <string.h>
+
+#include <cairo.h>
+
+#include "ganv/box.h"
+
+#include "./boilerplate.h"
+#include "./color.h"
+#include "./gettext.h"
+
+static const double STACKED_OFFSET = 4.0;
+
+G_DEFINE_TYPE(GanvBox, ganv_box, GANV_TYPE_NODE)
+
+static GanvNodeClass* parent_class;
+
+enum {
+ PROP_0,
+ PROP_X1,
+ PROP_Y1,
+ PROP_X2,
+ PROP_Y2,
+ PROP_RADIUS_TL,
+ PROP_RADIUS_TR,
+ PROP_RADIUS_BR,
+ PROP_RADIUS_BL,
+ PROP_STACKED
+};
+
+static void
+ganv_box_init(GanvBox* box)
+{
+ memset(&box->coords, '\0', sizeof(GanvBoxCoords));
+ box->coords.border_width = box->node.border_width;
+
+ box->old_coords = box->coords;
+ box->radius_tl = 0.0;
+ box->radius_tr = 0.0;
+ box->radius_br = 0.0;
+ box->radius_bl = 0.0;
+}
+
+static void
+ganv_box_destroy(GtkObject* object)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_BOX(object));
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ }
+}
+
+static void
+ganv_box_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_BOX(object));
+
+ GanvBox* box = GANV_BOX(object);
+ GanvBoxCoords* coords = &box->coords;
+
+ switch (prop_id) {
+ SET_CASE(X1, double, coords->x1);
+ SET_CASE(Y1, double, coords->y1);
+ SET_CASE(X2, double, coords->x2);
+ SET_CASE(Y2, double, coords->y2);
+ SET_CASE(RADIUS_TL, double, box->radius_tl);
+ SET_CASE(RADIUS_TR, double, box->radius_tr);
+ SET_CASE(RADIUS_BR, double, box->radius_br);
+ SET_CASE(RADIUS_BL, double, box->radius_bl);
+ SET_CASE(STACKED, boolean, coords->stacked);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_box_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_BOX(object));
+
+ GanvBox* box = GANV_BOX(object);
+
+ switch (prop_id) {
+ GET_CASE(X1, double, box->coords.x1);
+ GET_CASE(X2, double, box->coords.x2);
+ GET_CASE(Y1, double, box->coords.y1);
+ GET_CASE(Y2, double, box->coords.y2);
+ GET_CASE(RADIUS_TL, double, box->radius_tl);
+ GET_CASE(RADIUS_TR, double, box->radius_tr);
+ GET_CASE(RADIUS_BR, double, box->radius_br);
+ GET_CASE(RADIUS_BL, double, box->radius_bl);
+ GET_CASE(STACKED, boolean, box->coords.stacked);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_box_bounds_item(const GanvBoxCoords* coords,
+ double* x1, double* y1,
+ double* x2, double* y2)
+{
+ *x1 = MIN(coords->x1, coords->x2) - coords->border_width;
+ *y1 = MIN(coords->y1, coords->y2) - coords->border_width;
+ *x2 = MAX(coords->x1, coords->x2) + coords->border_width;
+ *y2 = MAX(coords->y1, coords->y2) + coords->border_width;
+
+ if (coords->stacked) {
+ *x2 += STACKED_OFFSET;
+ *y2 += STACKED_OFFSET;
+ }
+}
+
+
+static void
+request_redraw(GnomeCanvasItem* item,
+ const GanvBoxCoords* coords,
+ gboolean world)
+{
+ double x1, y1, x2, y2;
+ ganv_box_bounds_item(coords, &x1, &y1, &x2, &y2);
+
+ if (!world) {
+ // Convert from parent-relative coordinates to world coordinates
+ gnome_canvas_item_i2w(item, &x1, &y1);
+ gnome_canvas_item_i2w(item, &x2, &y2);
+ }
+
+ gnome_canvas_request_redraw(item->canvas, x1, y1, x2, y2);
+}
+
+static void
+coords_i2w(GnomeCanvasItem* item, GanvBoxCoords* coords)
+{
+ gnome_canvas_item_i2w(item, &coords->x1, &coords->y1);
+ gnome_canvas_item_i2w(item, &coords->x2, &coords->y2);
+}
+
+static void
+ganv_box_bounds(GnomeCanvasItem* item,
+ double* x1, double* y1,
+ double* x2, double* y2)
+{
+ // Note this will not be correct if children are outside the box bounds
+ GanvBox* box = GANV_BOX(item);
+ ganv_box_bounds_item(&box->coords, x1, y1, x2, y2);
+ gnome_canvas_item_i2w(item, x1, y1);
+ gnome_canvas_item_i2w(item, x2, y2);
+}
+
+static void
+ganv_box_update(GnomeCanvasItem* item,
+ double* affine,
+ ArtSVP* clip_path,
+ int flags)
+{
+ GanvBox* box = GANV_BOX(item);
+ box->coords.border_width = box->node.border_width;
+
+ // Request redraw of old location
+ request_redraw(item, &box->old_coords, TRUE);
+
+ GnomeCanvasItemClass* item_class = GNOME_CANVAS_ITEM_CLASS(parent_class);
+ item_class->update(item, affine, clip_path, flags);
+
+ // Store old coordinates in world relative coordinates in case the
+ // group we are in moves between now and the next update
+ box->old_coords = box->coords;
+ coords_i2w(item, &box->old_coords);
+
+ // Get bounding box
+ double x1, x2, y1, y2;
+ ganv_box_bounds(item, &x1, &y1, &x2, &y2);
+
+ // Update item canvas coordinates
+ gnome_canvas_w2c_d(GNOME_CANVAS(item->canvas), x1, y1, &item->x1, &item->y1);
+ gnome_canvas_w2c_d(GNOME_CANVAS(item->canvas), x2, y2, &item->x2, &item->y2);
+
+ // Request redraw of new location
+ request_redraw(item, &box->coords, FALSE);
+
+}
+
+static void
+ganv_box_render(GnomeCanvasItem* item,
+ GnomeCanvasBuf* buf)
+{
+ // Not implemented
+}
+
+static void
+ganv_box_draw(GnomeCanvasItem* item,
+ GdkDrawable* drawable,
+ int cx, int cy,
+ int width, int height)
+{
+ GanvBox* me = GANV_BOX(item);
+ cairo_t* cr = gdk_cairo_create(drawable);
+
+ double x1 = me->coords.x1;
+ double y1 = me->coords.y1;
+ double x2 = me->coords.x2;
+ double y2 = me->coords.y2;
+ gnome_canvas_item_i2w(item, &x1, &y1);
+ gnome_canvas_item_i2w(item, &x2, &y2);
+
+ double dash_length, border_color, fill_color;
+ ganv_node_get_draw_properties(
+ &me->node, &dash_length, &border_color, &fill_color);
+
+ double r, g, b, a;
+
+ double degrees = M_PI / 180.0;
+
+ for (int i = (me->coords.stacked ? 1 : 0); i >= 0; --i) {
+ const int x = cx - (STACKED_OFFSET * i);
+ const int y = cy - (STACKED_OFFSET * i);
+
+ if (me->radius_tl == 0.0 && me->radius_tr == 0.0
+ && me->radius_br == 0.0 && me->radius_bl == 0.0) {
+ // Simple rectangle
+ cairo_rectangle(cr, x1 - x, y1 - y, x2 - x1, y2 - y1);
+ } else {
+ // Rounded rectangle
+ cairo_new_sub_path(cr);
+ cairo_arc(cr,
+ x2 - x - me->radius_tr,
+ y1 - y + me->radius_tr,
+ me->radius_tr, -90 * degrees, 0 * degrees);
+ cairo_arc(cr,
+ x2 - x - me->radius_br, y2 - y - me->radius_br,
+ me->radius_br, 0 * degrees, 90 * degrees);
+ cairo_arc(cr,
+ x1 - x + me->radius_bl, y2 - y - me->radius_bl,
+ me->radius_bl, 90 * degrees, 180 * degrees);
+ cairo_arc(cr,
+ x1 - x + me->radius_tl, y1 - y + me->radius_tl,
+ me->radius_tl, 180 * degrees, 270 * degrees);
+ cairo_close_path(cr);
+ }
+
+ // Fill
+ color_to_rgba(fill_color, &r, &g, &b, &a);
+ cairo_set_source_rgba(cr, r, g, b, a);
+ cairo_fill_preserve(cr);
+
+ // Border
+ if (me->coords.border_width > 0.0) {
+ color_to_rgba(border_color, &r, &g, &b, &a);
+ cairo_set_source_rgba(cr, r, g, b, a);
+ cairo_set_line_width(cr, me->coords.border_width);
+ if (dash_length > 0) {
+ cairo_set_dash(cr, &dash_length, 1, me->node.dash_offset);
+ }
+ }
+ cairo_stroke(cr);
+ }
+
+ GnomeCanvasItemClass* item_class = GNOME_CANVAS_ITEM_CLASS(parent_class);
+ item_class->draw(item, drawable, cx, cy, width, height);
+
+ cairo_destroy(cr);
+}
+
+static double
+ganv_box_point(GnomeCanvasItem* item,
+ double x, double y,
+ int cx, int cy,
+ GnomeCanvasItem** actual_item)
+{
+ GanvBox* box = GANV_BOX(item);
+
+ *actual_item = NULL;
+
+ double x1, y1, x2, y2;
+ ganv_box_bounds_item(&box->coords, &x1, &y1, &x2, &y2);
+
+ // Point is inside the box (distance 0)
+ if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2)) {
+ GnomeCanvasItemClass* item_class = GNOME_CANVAS_ITEM_CLASS(parent_class);
+ double d = item_class->point(item, x, y, cx, cy, actual_item);
+ if (*actual_item) {
+ return d;
+ } else {
+ *actual_item = item;
+ return 0.0;
+ }
+ }
+
+ // Point is outside the box
+ double dx, dy;
+
+ // Find horizontal distance to nearest edge
+ if (x < x1) {
+ dx = x1 - x;
+ } else if (x > x2) {
+ dx = x - x2;
+ } else {
+ dx = 0.0;
+ }
+
+ // Find vertical distance to nearest edge
+ if (y < y1) {
+ dy = y1 - y;
+ } else if (y > y2) {
+ dy = y - y2;
+ } else {
+ dy = 0.0;
+ }
+
+ return sqrt((dx * dx) + (dy * dy));
+}
+
+static gboolean
+ganv_box_is_within(const GanvNode* self,
+ double x1,
+ double y1,
+ double x2,
+ double y2)
+{
+ double bx1, by1, bx2, by2;
+ g_object_get(G_OBJECT(self),
+ "x1", &bx1,
+ "y1", &by1,
+ "x2", &bx2,
+ "y2", &by2,
+ NULL);
+
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self), &bx1, &by1);
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self), &bx2, &by2);
+
+ return ( bx1 >= x1
+ && by2 >= y1
+ && bx2 <= x2
+ && by2 <= y2);
+}
+
+static void
+ganv_box_default_set_width(GanvBox* box,
+ double width)
+{
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(box),
+ "x2", ganv_box_get_x1(box) + width,
+ NULL);
+}
+
+static void
+ganv_box_default_set_height(GanvBox* box,
+ double height)
+{
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(box),
+ "y2", ganv_box_get_y1(box) + height,
+ NULL);
+}
+
+static void
+ganv_box_class_init(GanvBoxClass* class)
+{
+ GObjectClass* gobject_class = (GObjectClass*)class;
+ GtkObjectClass* object_class = (GtkObjectClass*)class;
+ GnomeCanvasItemClass* item_class = (GnomeCanvasItemClass*)class;
+ GanvNodeClass* node_class = (GanvNodeClass*)class;
+
+ parent_class = GANV_NODE_CLASS(g_type_class_peek_parent(class));
+
+ gobject_class->set_property = ganv_box_set_property;
+ gobject_class->get_property = ganv_box_get_property;
+
+ g_object_class_install_property(
+ gobject_class, PROP_X1, g_param_spec_double(
+ "x1",
+ _("x1"),
+ _("top left x coordinate"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_Y1, g_param_spec_double(
+ "y1",
+ _("y1"),
+ _("top left y coordinate"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_X2, g_param_spec_double(
+ "x2",
+ _("x2"),
+ _("bottom right x coordinate"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_Y2, g_param_spec_double(
+ "y2",
+ _("y2"),
+ _("bottom right y coordinate"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_RADIUS_TL, g_param_spec_double(
+ "radius-tl",
+ _("top left corner radius"),
+ _("top left corner radius"),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_RADIUS_TR, g_param_spec_double(
+ "radius-tr",
+ _("top right corner radius"),
+ _("top right corner radius"),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_RADIUS_BR, g_param_spec_double(
+ "radius-br",
+ _("bottom right corner radius"),
+ _("bottom right corner radius"),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_RADIUS_BL, g_param_spec_double(
+ "radius-bl",
+ _("bottom left corner radius"),
+ _("bottom left corner radius"),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_STACKED, g_param_spec_boolean(
+ "stacked",
+ _("stacked"),
+ _("Show the box with a stacked appearance."),
+ FALSE,
+ G_PARAM_READWRITE));
+
+ object_class->destroy = ganv_box_destroy;
+
+ item_class->update = ganv_box_update;
+ item_class->bounds = ganv_box_bounds;
+ item_class->point = ganv_box_point;
+ item_class->render = ganv_box_render;
+ item_class->draw = ganv_box_draw;
+
+ node_class->is_within = ganv_box_is_within;
+
+ class->set_width = ganv_box_default_set_width;
+ class->set_height = ganv_box_default_set_height;
+}
+
+void
+ganv_box_normalize(GanvBox* box)
+{
+ const double x1 = box->coords.x1;
+ const double y1 = box->coords.y1;
+ const double x2 = box->coords.x2;
+ const double y2 = box->coords.y2;
+
+ box->coords.x1 = MIN(x1, x2);
+ box->coords.y1 = MIN(y1, y2);
+ box->coords.x2 = MAX(x1, x2);
+ box->coords.y2 = MAX(y1, y2);
+}
diff --git a/src/circle.c b/src/circle.c
new file mode 100644
index 0000000..5452417
--- /dev/null
+++ b/src/circle.c
@@ -0,0 +1,351 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <math.h>
+#include <string.h>
+
+#include "ganv/circle.h"
+
+#include "./color.h"
+#include "./boilerplate.h"
+#include "./gettext.h"
+
+G_DEFINE_TYPE(GanvCircle, ganv_circle, GANV_TYPE_NODE)
+
+static GanvNodeClass* parent_class;
+
+enum {
+ PROP_0,
+ PROP_RADIUS
+};
+
+static void
+ganv_circle_init(GanvCircle* circle)
+{
+ memset(&circle->coords, '\0', sizeof(GanvCircleCoords));
+ circle->coords.radius = 8.0;
+ circle->coords.width = 2.0;
+ circle->old_coords = circle->coords;
+}
+
+static void
+ganv_circle_destroy(GtkObject* object)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_CIRCLE(object));
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ }
+}
+
+static void
+ganv_circle_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_CIRCLE(object));
+
+ GanvCircle* circle = GANV_CIRCLE(object);
+
+ switch (prop_id) {
+ SET_CASE(RADIUS, double, circle->coords.radius);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_circle_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_CIRCLE(object));
+
+ GanvCircle* circle = GANV_CIRCLE(object);
+
+ switch (prop_id) {
+ GET_CASE(RADIUS, double, circle->coords.radius);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static gboolean
+ganv_circle_is_within(const GanvNode* self,
+ double x1,
+ double y1,
+ double x2,
+ double y2)
+{
+ double x, y;
+ g_object_get(G_OBJECT(self), "x", &x, "y", &y, NULL);
+
+ return x >= x1
+ && x <= x2
+ && y >= y1
+ && y <= y2;
+}
+
+static void
+ganv_circle_tail_vector(const GanvNode* self,
+ const GanvNode* head,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy)
+{
+ g_object_get(G_OBJECT(self), "x", x, "y", y, NULL);
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self)->parent, x, y);
+ *dx = 0.0;
+ *dy = 0.0;
+}
+
+static void
+ganv_circle_head_vector(const GanvNode* self,
+ const GanvNode* tail,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy)
+{
+ GanvCircle* circle = GANV_CIRCLE(self);
+
+ double cx, cy;
+ g_object_get(G_OBJECT(self), "x", &cx, "y", &cy, NULL);
+
+ // FIXME: Not quite right, should be the connect point
+ double tail_x, tail_y;
+ g_object_get(G_OBJECT(tail),
+ "x", &tail_x,
+ "y", &tail_y,
+ NULL);
+
+ const double xdist = tail_x - cx;
+ const double ydist = tail_y - cy;
+ const double h = sqrt((xdist * xdist) + (ydist * ydist));
+ const double theta = asin(xdist / (h + DBL_EPSILON));
+ const double y_mod = (cy < tail_y) ? 1 : -1;
+ const double ret_h = h - circle->coords.radius;
+ const double ret_x = tail_x - sin(theta) * ret_h;
+ const double ret_y = tail_y - cos(theta) * ret_h * y_mod;
+
+ *x = ret_x;
+ *y = ret_y;
+ *dx = 0.0;
+ *dy = 0.0;
+
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self)->parent, x, y);
+}
+
+static void
+request_redraw(GnomeCanvasItem* item,
+ const GanvCircleCoords* coords,
+ gboolean world)
+{
+ const double w = coords->width;
+
+ double x1 = coords->x - coords->radius - w;
+ double y1 = coords->y - coords->radius - w;
+ double x2 = coords->x + coords->radius + w;
+ double y2 = coords->y + coords->radius + w;
+
+ if (!world) {
+ // Convert from parent-relative coordinates to world coordinates
+ gnome_canvas_item_i2w(item, &x1, &y1);
+ gnome_canvas_item_i2w(item, &x2, &y2);
+ }
+
+ gnome_canvas_request_redraw(item->canvas, x1, y1, x2, y2);
+ gnome_canvas_request_redraw(item->canvas, 0, 0, 10000, 10000);
+}
+
+static void
+coords_i2w(GnomeCanvasItem* item, GanvCircleCoords* coords)
+{
+ gnome_canvas_item_i2w(item, &coords->x, &coords->y);
+}
+
+static void
+ganv_circle_bounds_item(GnomeCanvasItem* item,
+ double* x1, double* y1,
+ double* x2, double* y2)
+{
+ const GanvCircle* circle = GANV_CIRCLE(item);
+ const GanvCircleCoords* coords = &circle->coords;
+ *x1 = coords->x - coords->radius - coords->width;
+ *y1 = coords->y - coords->radius - coords->width;
+ *x2 = coords->x + coords->radius + coords->width;
+ *y2 = coords->y + coords->radius + coords->width;
+}
+
+static void
+ganv_circle_bounds(GnomeCanvasItem* item,
+ double* x1, double* y1,
+ double* x2, double* y2)
+{
+ ganv_circle_bounds_item(item, x1, y1, x2, y2);
+ gnome_canvas_item_i2w(item, x1, y1);
+ gnome_canvas_item_i2w(item, x2, y2);
+}
+
+static void
+ganv_circle_update(GnomeCanvasItem* item,
+ double* affine,
+ ArtSVP* clip_path,
+ int flags)
+{
+ GanvCircle* circle = GANV_CIRCLE(item);
+
+ GnomeCanvasItemClass* item_class = GNOME_CANVAS_ITEM_CLASS(parent_class);
+ if (item_class->update) {
+ (*item_class->update)(item, affine, clip_path, flags);
+ }
+
+ // Request redraw of old location
+ request_redraw(item, &circle->old_coords, TRUE);
+
+ // Store old coordinates in world relative coordinates in case the
+ // group we are in moves between now and the next update
+ circle->old_coords = circle->coords;
+ coords_i2w(item, &circle->old_coords);
+
+ // Get bounding circle
+ double x1, x2, y1, y2;
+ ganv_circle_bounds(item, &x1, &y1, &x2, &y2);
+
+ // Update item canvas coordinates
+ gnome_canvas_w2c_d(GNOME_CANVAS(item->canvas), x1, y1, &item->x1, &item->y1);
+ gnome_canvas_w2c_d(GNOME_CANVAS(item->canvas), x2, y2, &item->x2, &item->y2);
+
+ // Request redraw of new location
+ request_redraw(item, &circle->coords, FALSE);
+}
+
+static void
+ganv_circle_render(GnomeCanvasItem* item,
+ GnomeCanvasBuf* buf)
+{
+ // Not implemented
+}
+
+static void
+ganv_circle_draw(GnomeCanvasItem* item,
+ GdkDrawable* drawable,
+ int x, int y,
+ int width, int height)
+{
+ GanvCircle* me = GANV_CIRCLE(item);
+ cairo_t* cr = gdk_cairo_create(drawable);
+
+ double r, g, b, a;
+
+ double cx = me->coords.x;
+ double cy = me->coords.y;
+ gnome_canvas_item_i2w(item, &cx, &cy);
+
+ double dash_length, border_color, fill_color;
+ ganv_node_get_draw_properties(
+ &me->node, &dash_length, &border_color, &fill_color);
+
+ cairo_arc(cr,
+ cx - x,
+ cy - y,
+ me->coords.radius,
+ 0, 2 * M_PI);
+
+ // Fill
+ color_to_rgba(fill_color, &r, &g, &b, &a);
+ cairo_set_source_rgba(cr, r, g, b, a);
+ cairo_fill_preserve(cr);
+
+ // Border
+ color_to_rgba(border_color, &r, &g, &b, &a);
+ cairo_set_source_rgba(cr, r, g, b, a);
+ cairo_set_line_width(cr, me->coords.width);
+ if (dash_length > 0) {
+ cairo_set_dash(cr, &dash_length, 1, me->node.dash_offset);
+ }
+ cairo_stroke(cr);
+
+ cairo_destroy(cr);
+}
+
+static double
+ganv_circle_point(GnomeCanvasItem* item,
+ double x, double y,
+ int cx, int cy,
+ GnomeCanvasItem** actual_item)
+{
+ const GanvCircle* circle = GANV_CIRCLE(item);
+ const GanvCircleCoords* coords = &circle->coords;
+
+ *actual_item = item;
+
+ const double dx = fabs(x - coords->x);
+ const double dy = fabs(y - coords->y);
+ const double d = sqrt((dx * dx) + (dy * dy));
+
+ if (d <= coords->radius + coords->width) {
+ // Point is inside the circle
+ return 0.0;
+ } else {
+ // Distance from the edge of the circle
+ return d - (coords->radius + coords->width);
+ }
+}
+
+static void
+ganv_circle_class_init(GanvCircleClass* class)
+{
+ GObjectClass* gobject_class = (GObjectClass*)class;
+ GtkObjectClass* object_class = (GtkObjectClass*)class;
+ GnomeCanvasItemClass* item_class = (GnomeCanvasItemClass*)class;
+ GanvNodeClass* node_class = (GanvNodeClass*)class;
+
+ parent_class = GANV_NODE_CLASS(g_type_class_peek_parent(class));
+
+ gobject_class->set_property = ganv_circle_set_property;
+ gobject_class->get_property = ganv_circle_get_property;
+
+ g_object_class_install_property(
+ gobject_class, PROP_RADIUS, g_param_spec_double(
+ "radius",
+ _("radius"),
+ _("radius of circle"),
+ 0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ object_class->destroy = ganv_circle_destroy;
+
+ node_class->is_within = ganv_circle_is_within;
+ node_class->tail_vector = ganv_circle_tail_vector;
+ node_class->head_vector = ganv_circle_head_vector;
+
+ item_class->update = ganv_circle_update;
+ item_class->bounds = ganv_circle_bounds;
+ item_class->point = ganv_circle_point;
+ item_class->render = ganv_circle_render;
+ item_class->draw = ganv_circle_draw;
+}
diff --git a/src/color.h b/src/color.h
new file mode 100644
index 0000000..03a390b
--- /dev/null
+++ b/src/color.h
@@ -0,0 +1,51 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_UTIL_H
+#define GANV_UTIL_H
+
+#include <glib/gmacros.h>
+
+#define DEFAULT_TEXT_COLOR 0xFFFFFFFF
+#define DEFAULT_FILL_COLOR 0x1E2224FF
+#define DEFAULT_BORDER_COLOR 0x3E4244FF
+
+static inline void
+color_to_rgba(guint color, double* r, double* g, double* b, double* a)
+{
+ *r = ((color >> 24) & 0xFF) / 255.0;
+ *g = ((color >> 16) & 0xFF) / 255.0;
+ *b = ((color >> 8) & 0xFF) / 255.0;
+ *a = ((color) & 0xFF) / 255.0;
+}
+
+static inline guint
+highlight_color(guint c, guint delta)
+{
+ const guint max_char = 255;
+ const guint r = MIN((c >> 24) + delta, max_char);
+ const guint g = MIN(((c >> 16) & 0xFF) + delta, max_char);
+ const guint b = MIN(((c >> 8) & 0xFF) + delta, max_char);
+ const guint a = c & 0xFF;
+
+ return ((((guint)(r)) << 24) |
+ (((guint)(g)) << 16) |
+ (((guint)(b)) << 8) |
+ (((guint)(a))));
+}
+
+#endif // GANV_UTIL_H
diff --git a/src/edge.c b/src/edge.c
new file mode 100644
index 0000000..7d5b48c
--- /dev/null
+++ b/src/edge.c
@@ -0,0 +1,658 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <math.h>
+#include <string.h>
+
+#include <cairo.h>
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include "ganv/canvas.h"
+#include "ganv/edge.h"
+#include "ganv/node.h"
+
+#include "./boilerplate.h"
+#include "./color.h"
+#include "./gettext.h"
+
+#include "ganv-private.h"
+
+// TODO: Very sloppy clipping for arrow heads
+#define ARROW_DEPTH 32
+#define ARROW_BREADTH 32
+
+// Uncomment to see control point path as straight lines
+//#define GANV_DEBUG_CURVES 1
+
+enum {
+ PROP_0,
+ PROP_TAIL,
+ PROP_HEAD,
+ PROP_WIDTH,
+ PROP_HANDLE_RADIUS,
+ PROP_DASH_LENGTH,
+ PROP_DASH_OFFSET,
+ PROP_COLOR,
+ PROP_CURVED,
+ PROP_ARROWHEAD,
+ PROP_SELECTED,
+ PROP_HIGHLIGHTED,
+ PROP_GHOST
+};
+
+G_DEFINE_TYPE(GanvEdge, ganv_edge, GNOME_TYPE_CANVAS_ITEM)
+
+static GnomeCanvasItemClass* parent_class;
+
+static void
+ganv_edge_init(GanvEdge* edge)
+{
+ edge->tail = NULL;
+ edge->head = NULL;
+
+ memset(&edge->coords, '\0', sizeof(GanvEdgeCoords));
+ edge->coords.width = 2.0;
+ edge->coords.handle_radius = 4.0;
+ edge->coords.curved = FALSE;
+ edge->coords.arrowhead = FALSE;
+
+ edge->old_coords = edge->coords;
+ edge->dash_length = 0.0;
+ edge->dash_offset = 0.0;
+ edge->color = 0xA0A0A0FF;
+}
+
+static void
+ganv_edge_destroy(GtkObject* object)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_EDGE(object));
+
+ GanvEdge* edge = GANV_EDGE(object);
+ GanvCanvas* canvas = GANV_CANVAS(edge->item.canvas);
+ if (canvas && !edge->ghost) {
+ ganv_canvas_remove_edge(canvas, edge);
+ edge->item.canvas = NULL;
+ }
+ edge->item.parent = NULL;
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ }
+}
+
+static void
+ganv_edge_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_EDGE(object));
+
+ GanvEdge* edge = GANV_EDGE(object);
+ GanvEdgeCoords* coords = &edge->coords;
+
+ switch (prop_id) {
+ SET_CASE(TAIL, object, edge->tail);
+ SET_CASE(HEAD, object, edge->head);
+ SET_CASE(WIDTH, double, coords->width);
+ SET_CASE(HANDLE_RADIUS, double, coords->handle_radius);
+ SET_CASE(DASH_LENGTH, double, edge->dash_length);
+ SET_CASE(DASH_OFFSET, double, edge->dash_offset);
+ SET_CASE(COLOR, uint, edge->color);
+ SET_CASE(CURVED, boolean, edge->coords.curved);
+ SET_CASE(ARROWHEAD, boolean, edge->coords.arrowhead);
+ SET_CASE(SELECTED, boolean, edge->selected);
+ SET_CASE(HIGHLIGHTED, boolean, edge->highlighted);
+ SET_CASE(GHOST, boolean, edge->ghost);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_edge_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_EDGE(object));
+
+ GanvEdge* edge = GANV_EDGE(object);
+
+ switch (prop_id) {
+ GET_CASE(TAIL, object, edge->tail);
+ GET_CASE(HEAD, object, edge->head);
+ GET_CASE(WIDTH, double, edge->coords.width);
+ SET_CASE(HANDLE_RADIUS, double, edge->coords.handle_radius);
+ GET_CASE(DASH_LENGTH, double, edge->dash_length);
+ GET_CASE(DASH_OFFSET, double, edge->dash_offset);
+ GET_CASE(COLOR, uint, edge->color);
+ GET_CASE(CURVED, boolean, edge->coords.curved);
+ GET_CASE(ARROWHEAD, boolean, edge->coords.arrowhead);
+ GET_CASE(SELECTED, boolean, edge->selected);
+ GET_CASE(HIGHLIGHTED, boolean, edge->highlighted);
+ SET_CASE(GHOST, boolean, edge->ghost);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+request_redraw(GnomeCanvas* canvas,
+ const GanvEdgeCoords* coords)
+{
+ const double w = coords->width;
+ if (coords->curved) {
+ const double src_x = coords->x1;
+ const double src_y = coords->y1;
+ const double dst_x = coords->x2;
+ const double dst_y = coords->y2;
+ const double join_x = (src_x + dst_x) / 2.0;
+ const double join_y = (src_y + dst_y) / 2.0;
+ const double src_x1 = coords->cx1;
+ const double src_y1 = coords->cy1;
+ const double dst_x1 = coords->cx2;
+ const double dst_y1 = coords->cy2;
+
+ const double r1x1 = MIN(MIN(src_x, join_x), src_x1);
+ const double r1y1 = MIN(MIN(src_y, join_y), src_y1);
+ const double r1x2 = MAX(MAX(src_x, join_x), src_x1);
+ const double r1y2 = MAX(MAX(src_y, join_y), src_y1);
+ gnome_canvas_request_redraw(canvas,
+ r1x1 - w, r1y1 - w,
+ r1x2 + w, r1y2 + w);
+
+ const double r2x1 = MIN(MIN(dst_x, join_x), dst_x1);
+ const double r2y1 = MIN(MIN(dst_y, join_y), dst_y1);
+ const double r2x2 = MAX(MAX(dst_x, join_x), dst_x1);
+ const double r2y2 = MAX(MAX(dst_y, join_y), dst_y1);
+ gnome_canvas_request_redraw(canvas,
+ r2x1 - w, r2y1 - w,
+ r2x2 + w, r2y2 + w);
+
+ } else {
+ const double x1 = MIN(coords->x1, coords->x2);
+ const double y1 = MIN(coords->y1, coords->y2);
+ const double x2 = MAX(coords->x1, coords->x2);
+ const double y2 = MAX(coords->y1, coords->y2);
+
+ gnome_canvas_request_redraw(canvas,
+ x1 - w, y1 - w,
+ x2 + w, y2 + w);
+ }
+
+ gnome_canvas_request_redraw(canvas,
+ coords->handle_x - coords->handle_radius,
+ coords->handle_y - coords->handle_radius,
+ coords->handle_x + coords->handle_radius,
+ coords->handle_y + coords->handle_radius);
+
+ if (coords->arrowhead) {
+ gnome_canvas_request_redraw(
+ canvas,
+ coords->x2 - ARROW_DEPTH,
+ coords->y2 - ARROW_BREADTH,
+ coords->x2 + ARROW_DEPTH,
+ coords->y2 + ARROW_BREADTH);
+ }
+}
+
+static void
+ganv_edge_bounds(GnomeCanvasItem* item,
+ double* x1, double* y1,
+ double* x2, double* y2)
+{
+ GanvEdge* edge = GANV_EDGE(item);
+
+ // TODO: This is not correct for curved edges
+ *x1 = MIN(edge->coords.x1, edge->coords.x2);
+ *y1 = MIN(edge->coords.y1, edge->coords.y2);
+ *x2 = MAX(edge->coords.x1, edge->coords.x2);
+ *y2 = MAX(edge->coords.y1, edge->coords.y2);
+}
+
+static void
+ganv_edge_update(GnomeCanvasItem* item,
+ double* affine,
+ ArtSVP* clip_path,
+ int flags)
+{
+ GanvEdge* edge = GANV_EDGE(item);
+
+ if (parent_class->update) {
+ (*parent_class->update)(item, affine, clip_path, flags);
+ }
+
+ // Request redraw of old location
+ request_redraw(item->canvas, &edge->old_coords);
+
+ // Calculate new coordinates from tail and head
+ GanvEdgeCoords* coords = &edge->coords;
+ GANV_NODE_GET_CLASS(edge->tail)->tail_vector(
+ edge->tail, edge->head,
+ &coords->x1, &coords->y1, &coords->cx1, &coords->cy1);
+ GANV_NODE_GET_CLASS(edge->head)->head_vector(
+ edge->head, edge->tail,
+ &coords->x2, &coords->y2, &coords->cx2, &coords->cy2);
+
+ const double dx = coords->x2 - coords->x1;
+ const double dy = coords->y2 - coords->y1;
+ coords->handle_x = coords->x1 + (dx / 2.0);
+ coords->handle_y = coords->y1 + (dy / 2.0);
+
+ coords->cx1 = coords->x1 + (coords->cx1 * (ceilf(fabs(dx)) / 4.0));
+ coords->cy1 += coords->y1;
+ coords->cx2 = coords->x2 + (coords->cx2 * (ceilf(fabs(dx)) / 4.0));
+ coords->cy2 += coords->y2;
+
+ // Update old coordinates
+ edge->old_coords = edge->coords;
+
+ // Get bounding box
+ double x1, x2, y1, y2;
+ ganv_edge_bounds(item, &x1, &y1, &x2, &y2);
+
+ // Ensure bounding box has non-zero area
+ if (x1 == x2) {
+ x2 += 1.0;
+ }
+ if (y1 == y2) {
+ y2 += 1.0;
+ }
+
+ // Update item canvas coordinates
+ gnome_canvas_w2c_d(GNOME_CANVAS(item->canvas), x1, y1, &item->x1, &item->y1);
+ gnome_canvas_w2c_d(GNOME_CANVAS(item->canvas), x2, y2, &item->x2, &item->y2);
+
+ // Request redraw of new location
+ request_redraw(item->canvas, &edge->coords);
+}
+
+static void
+ganv_edge_render(GnomeCanvasItem* item,
+ GnomeCanvasBuf* buf)
+{
+ // Not implemented
+}
+
+static void
+ganv_edge_draw(GnomeCanvasItem* item,
+ GdkDrawable* drawable,
+ int x, int y,
+ int width, int height)
+{
+ GanvEdge* me = GANV_EDGE(item);
+ cairo_t* cr = gdk_cairo_create(drawable);
+
+ double src_x = me->coords.x1 - x;
+ double src_y = me->coords.y1 - y;
+ //double src_cx = me->coords.cx1 - x;
+ //double src_cy = me->coords.cy1 - y;
+ double dst_x = me->coords.x2 - x;
+ double dst_y = me->coords.y2 - y;
+ //double dst_cx = me->coords.cx2 - x;
+ //double dst_cy = me->coords.cy2 - y;
+
+ double dx = src_x - dst_x;
+ double dy = src_y - dst_y;
+
+ double r, g, b, a;
+ if (me->highlighted) {
+ color_to_rgba(highlight_color(me->color, 0x20), &r, &g, &b, &a);
+ } else {
+ color_to_rgba(me->color, &r, &g, &b, &a);
+ }
+ cairo_set_source_rgba(cr, r, g, b, a);
+
+ cairo_set_line_width(cr, me->coords.width);
+ cairo_move_to(cr, src_x, src_y);
+
+ const double dash_length = (me->selected ? 4.0 : me->dash_length);
+ if (dash_length > 0.0) {
+ double dashed[2] = { dash_length, dash_length };
+ cairo_set_dash(cr, dashed, 2, me->dash_offset);
+ }
+
+ const double join_x = (src_x + dst_x) / 2.0;
+ const double join_y = (src_y + dst_y) / 2.0;
+
+ if (me->coords.curved) {
+ // Curved line as 2 paths which join at the middle point
+
+ // Path 1 (src_x, src_y) -> (join_x, join_y)
+ // Control point 1
+ const double src_x1 = me->coords.cx1 - x;
+ const double src_y1 = me->coords.cy1 - y;
+ // Control point 2
+ const double src_x2 = (join_x + src_x1) / 2.0;
+ const double src_y2 = (join_y + src_y1) / 2.0;
+
+ // Path 2, (join_x, join_y) -> (dst_x, dst_y)
+ // Control point 1
+ const double dst_x1 = me->coords.cx2 - x;
+ const double dst_y1 = me->coords.cy2 - y;
+ // Control point 2
+ const double dst_x2 = (join_x + dst_x1) / 2.0;
+ const double dst_y2 = (join_y + dst_y1) / 2.0;
+
+ cairo_move_to(cr, src_x, src_y);
+ cairo_curve_to(cr, src_x1, src_y1, src_x2, src_y2, join_x, join_y);
+ cairo_curve_to(cr, dst_x2, dst_y2, dst_x1, dst_y1, dst_x, dst_y);
+
+ if (me->coords.arrowhead) {
+ cairo_line_to(cr, dst_x - 12, dst_y - 4);
+ cairo_move_to(cr, dst_x, dst_y);
+ cairo_line_to(cr, dst_x - 12, dst_y + 4);
+ }
+
+#ifdef GANV_DEBUG_CURVES
+ cairo_stroke(cr);
+ cairo_save(cr);
+ cairo_set_source_rgba(cr, 1.0, 0, 0, 0.5);
+
+ cairo_move_to(cr, src_x, src_y);
+ cairo_line_to(cr, src_x1, src_y1);
+ cairo_stroke(cr);
+
+ cairo_move_to(cr, join_x, join_y);
+ cairo_line_to(cr, src_x2, src_y2);
+ cairo_stroke(cr);
+
+ cairo_move_to(cr, join_x, join_y);
+ cairo_line_to(cr, dst_x2, dst_y2);
+ cairo_stroke(cr);
+
+ cairo_move_to(cr, dst_x, dst_y);
+ cairo_line_to(cr, dst_x1, dst_y1);
+ cairo_stroke(cr);
+ cairo_restore(cr);
+#endif
+
+ } else {
+ // Straight line from (x1, y1) to (x2, y2)
+ cairo_move_to(cr, src_x, src_y);
+ cairo_line_to(cr, dst_x, dst_y);
+
+ if (me->coords.arrowhead) {
+ const double ah = sqrt(dx * dx + dy * dy);
+ const double adx = dx / ah * 10.0;
+ const double ady = dy / ah * 10.0;
+
+ cairo_line_to(cr,
+ dst_x + adx - ady/1.5,
+ dst_y + ady + adx/1.5);
+ cairo_move_to(cr, dst_x, dst_y);
+ cairo_line_to(cr,
+ dst_x + adx + ady/1.5,
+ dst_y + ady - adx/1.5);
+ }
+ }
+
+ cairo_stroke(cr);
+
+ cairo_move_to(cr, join_x, join_y);
+ cairo_arc(cr, join_x, join_y, me->coords.handle_radius, 0, 2 * M_PI);
+ cairo_fill(cr);
+
+ cairo_destroy(cr);
+}
+
+static double
+ganv_edge_point(GnomeCanvasItem* item,
+ double x, double y,
+ int cx, int cy,
+ GnomeCanvasItem** actual_item)
+{
+ const GanvEdge* edge = GANV_EDGE(item);
+ const GanvEdgeCoords* coords = &edge->coords;
+
+ const double dx = fabs(x - coords->handle_x);
+ const double dy = fabs(y - coords->handle_y);
+ const double d = sqrt((dx * dx) + (dy * dy));
+
+ *actual_item = item;
+
+ if (d <= coords->handle_radius) {
+ // Point is inside the handle
+ return 0.0;
+ } else {
+ // Distance from the edge of the handle
+ return d - (coords->handle_radius + coords->width);
+ }
+}
+
+gboolean
+ganv_edge_is_within(const GanvEdge* edge,
+ double x1,
+ double y1,
+ double x2,
+ double y2)
+{
+ const double handle_x = edge->coords.handle_x;
+ const double handle_y = edge->coords.handle_y;
+
+ return handle_x >= x1
+ && handle_x <= x2
+ && handle_y >= y1
+ && handle_y <= y2;
+}
+
+static void
+ganv_edge_class_init(GanvEdgeClass* class)
+{
+ GObjectClass* gobject_class = (GObjectClass*)class;
+ GtkObjectClass* object_class = (GtkObjectClass*)class;
+ GnomeCanvasItemClass* item_class = (GnomeCanvasItemClass*)class;
+
+ parent_class = GNOME_CANVAS_ITEM_CLASS(g_type_class_peek_parent(class));
+
+ gobject_class->set_property = ganv_edge_set_property;
+ gobject_class->get_property = ganv_edge_get_property;
+
+ g_object_class_install_property(
+ gobject_class, PROP_TAIL, g_param_spec_object(
+ "tail",
+ _("tail"),
+ _("node this edge starts from"),
+ GANV_TYPE_NODE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_HEAD, g_param_spec_object(
+ "head",
+ _("head"),
+ _("node this edge ends at"),
+ GANV_TYPE_NODE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_WIDTH, g_param_spec_double(
+ "width",
+ _("line width"),
+ _("width of line in canvas units"),
+ 0.0, G_MAXDOUBLE,
+ 2.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_HANDLE_RADIUS, g_param_spec_double(
+ "handle-radius",
+ _("handle radius"),
+ _("radius of handle in canvas units"),
+ 0.0, G_MAXDOUBLE,
+ 4.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_DASH_LENGTH, g_param_spec_double(
+ "dash-length",
+ _("line dash length"),
+ _("length of dashes, or zero for no dashing"),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_DASH_OFFSET, g_param_spec_double(
+ "dash-offset",
+ _("line dash offset"),
+ _("offset for dashes (useful for 'rubber band' animation)."),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_COLOR, g_param_spec_uint(
+ "color",
+ _("color"),
+ _("color as an RGBA integer"),
+ 0, G_MAXUINT,
+ 0xA0A0A0FF,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_CURVED, g_param_spec_boolean(
+ "curved",
+ _("curved"),
+ _("whether line should be curved, not straight"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_ARROWHEAD, g_param_spec_boolean(
+ "arrowhead",
+ _("arrowhead"),
+ _("whether to show an arrowhead at the end point"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_SELECTED, g_param_spec_boolean(
+ "selected",
+ _("selected"),
+ _("whether this edge is selected"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_HIGHLIGHTED, g_param_spec_boolean(
+ "highlighted",
+ _("highlighted"),
+ _("whether to highlight the edge"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_GHOST, g_param_spec_boolean(
+ "ghost",
+ _("ghost"),
+ _("whether to highlight the edge"),
+ 0,
+ G_PARAM_READWRITE));
+
+ object_class->destroy = ganv_edge_destroy;
+
+ item_class->update = ganv_edge_update;
+ item_class->bounds = ganv_edge_bounds;
+ item_class->point = ganv_edge_point;
+ item_class->render = ganv_edge_render;
+ item_class->draw = ganv_edge_draw;
+}
+
+GanvEdge*
+ganv_edge_new(GanvCanvas* canvas,
+ GanvNode* tail,
+ GanvNode* head,
+ const char* first_prop_name, ...)
+{
+ GanvEdge* edge = GANV_EDGE(
+ g_object_new(ganv_edge_get_type(), NULL));
+
+ va_list args;
+ va_start(args, first_prop_name);
+ gnome_canvas_item_construct(&edge->item,
+ ganv_canvas_get_root(canvas),
+ first_prop_name, args);
+ va_end(args);
+
+ edge->tail = tail;
+ edge->head = head;
+
+ if (!edge->ghost) {
+ ganv_canvas_add_edge(canvas, edge);
+ }
+ return edge;
+}
+
+void
+ganv_edge_update_location(GanvEdge* edge)
+{
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(edge));
+}
+
+void
+ganv_edge_select(GanvEdge* edge)
+{
+ GanvCanvas* canvas = GANV_CANVAS(edge->item.canvas);
+ ganv_canvas_select_edge(canvas, edge);
+}
+
+void
+ganv_edge_unselect(GanvEdge* edge)
+{
+ GanvCanvas* canvas = GANV_CANVAS(edge->item.canvas);
+ ganv_canvas_unselect_edge(canvas, edge);
+}
+
+void
+ganv_edge_highlight(GanvEdge* edge)
+{
+ edge->highlighted = TRUE;
+ gnome_canvas_item_raise_to_top(GNOME_CANVAS_ITEM(edge));
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(edge));
+}
+
+void
+ganv_edge_unhighlight(GanvEdge* edge)
+{
+ edge->highlighted = FALSE;
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(edge));
+}
+
+void
+ganv_edge_tick(GanvEdge* edge,
+ double seconds)
+{
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(edge),
+ "dash-offset", seconds * 8.0,
+ NULL);
+}
+
+void
+ganv_edge_remove(GanvEdge* edge)
+{
+ if (!edge->ghost) {
+ ganv_canvas_remove_edge(
+ GANV_CANVAS(edge->item.canvas),
+ edge);
+ }
+}
diff --git a/src/ganv-private.h b/src/ganv-private.h
new file mode 100644
index 0000000..d44dc02
--- /dev/null
+++ b/src/ganv-private.h
@@ -0,0 +1,69 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_PRIVATE_H
+#define GANV_PRIVATE_H
+
+void
+ganv_canvas_add_node(GanvCanvas* canvas,
+ GanvNode* node);
+
+void
+ganv_canvas_remove_node(GanvCanvas* canvas,
+ GanvNode* node);
+
+void
+ganv_canvas_move_selected_items(GanvCanvas* canvas,
+ double dx,
+ double dy);
+
+void
+ganv_canvas_selection_move_finished(GanvCanvas* canvas);
+
+void
+ganv_canvas_select_node(GanvCanvas* canvas,
+ GanvNode* node);
+
+void
+ganv_canvas_unselect_node(GanvCanvas* canvas,
+ GanvNode* node);
+
+void
+ganv_canvas_add_edge(GanvCanvas* canvas,
+ GanvEdge* edge);
+
+void
+ganv_canvas_remove_edge(GanvCanvas* canvas,
+ GanvEdge* edge);
+
+void
+ganv_canvas_select_edge(GanvCanvas* canvas,
+ GanvEdge* edge);
+
+void
+ganv_canvas_unselect_edge(GanvCanvas* canvas,
+ GanvEdge* edge);
+
+GdkCursor*
+ganv_canvas_get_move_cursor(const GanvCanvas* canvas);
+
+gboolean
+ganv_canvas_port_event(GanvCanvas* canvas,
+ GanvPort* port,
+ GdkEvent* event);
+
+#endif /* GANV_PRIVATE_H */
diff --git a/src/ganv_bench.cpp b/src/ganv_bench.cpp
new file mode 100644
index 0000000..693882d
--- /dev/null
+++ b/src/ganv_bench.cpp
@@ -0,0 +1,182 @@
+/* This file is part of Ganv.
+ * Copyright 2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <gtkmm/main.h>
+#include <gtkmm/scrolledwindow.h>
+#include <gtkmm/window.h>
+
+#include "ganv/ganv.hpp"
+
+using namespace std;
+using namespace Ganv;
+
+static const int MAX_NUM_PORTS = 16;
+
+vector<Node*> ins;
+vector<Node*> outs;
+
+Module*
+make_module(Canvas* canvas)
+{
+ char name[8];
+
+ snprintf(name, 8, "mod%d", rand() % 10000);
+ Module* m(new Module(*canvas, name,
+ rand() % (int)canvas->width(),
+ rand() % (int)canvas->height(),
+ true,
+ true));
+
+ int n_ins = rand() % MAX_NUM_PORTS;
+ for (int i = 0; i < n_ins; ++i) {
+ snprintf(name, 8, "in%d", rand() % 10000);
+ Port* p(new Port(*m, name, true,
+ ((rand() % 0xFFFFFF) << 8) | 0xFF));
+ ins.push_back(p);
+ }
+
+ int n_outs = rand() % MAX_NUM_PORTS;
+ for (int i = 0; i < n_outs; ++i) {
+ snprintf(name, 8, "out%d", rand() % 10000);
+ Port* p(new Port(*m, name, false,
+ ((rand() % 0xFFFFFF) << 8) | 0xFF));
+ outs.push_back(p);
+ }
+
+ m->show();
+ return m;
+}
+
+Circle*
+make_circle(Canvas* canvas)
+{
+ char name[8];
+
+ snprintf(name, 8, "%d", rand() % 10000);
+ Circle* e(new Circle(*canvas, name,
+ rand() % (int)canvas->width(),
+ rand() % (int)canvas->height(),
+ 32.0,
+ 32.0));
+
+ ins.push_back(e);
+ outs.push_back(e);
+
+ return e;
+}
+
+bool
+quit()
+{
+ Gtk::Main::quit();
+ return true;
+}
+
+int
+print_usage(const char* name)
+{
+ fprintf(stderr,
+ "USAGE: %s [OPTIONS] CANVAS_W CANVAS_H N_MODULES N_CIRCLES N_EDGES\n\n"
+ "Options:\n"
+ " -o Remain open (do not close immediately)\n"
+ " -a Arrange canvas\n"
+ " -s Straight edges\n",
+ name);
+ return 1;
+}
+
+int
+main(int argc, char** argv)
+{
+ if (argc < 5) {
+ return print_usage(argv[0]);
+ }
+
+ int arg = 1;
+
+ bool remain_open = false;
+ bool arrange = false;
+ bool straight = false;
+ for (; arg < argc && argv[arg][0] == '-'; ++arg) {
+ if (argv[arg][1] == 'o') {
+ remain_open = true;
+ } else if (argv[arg][1] == 'a') {
+ arrange = true;
+ } else if (argv[arg][1] == 's') {
+ straight = true;
+ } else {
+ return print_usage(argv[0]);
+ }
+ }
+
+ const int canvas_w = atoi(argv[arg++]);
+ const int canvas_h = atoi(argv[arg++]);
+
+ if (argc - arg < 3) {
+ return print_usage(argv[0]);
+ }
+
+ const int n_modules = atoi(argv[arg++]);
+ const int n_circles = atoi(argv[arg++]);
+ const int n_edges = atoi(argv[arg++]);
+
+ srand(time(NULL));
+
+ Gtk::Main kit(argc, argv);
+
+ Gtk::Window window;
+ Gtk::ScrolledWindow* scroller = Gtk::manage(new Gtk::ScrolledWindow());
+
+ Canvas* canvas = new Canvas(canvas_w, canvas_h);
+ scroller->add(canvas->widget());
+ window.add(*scroller);
+
+ window.show_all();
+
+ for (int i = 0; i < n_modules; ++i) {
+ make_module(canvas);
+ }
+
+ for (int i = 0; i < n_circles; ++i) {
+ make_circle(canvas);
+ }
+
+ for (int i = 0; i < n_edges; ++i) {
+ Node* src = outs[rand() % outs.size()];
+ Node* dst = ins[rand() % ins.size()];
+ Edge* c = new Edge(*canvas, src, dst, 0x808080FF);
+ if (straight) {
+ c->set_curved(false);
+ }
+ }
+
+ if (arrange) {
+ canvas->arrange();
+ }
+
+ if (!remain_open) {
+ Glib::signal_idle().connect(sigc::ptr_fun(quit));
+ }
+
+ Gtk::Main::run(window);
+
+ return 0;
+}
diff --git a/src/gettext.h b/src/gettext.h
new file mode 100644
index 0000000..ff66f1f
--- /dev/null
+++ b/src/gettext.h
@@ -0,0 +1,28 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GANV_GETTEXT_H
+#define GANV_GETTEXT_H
+
+#ifdef ENABLE_NLS
+# include <libintl.h>
+# define _(str) dgettext("ganv", str)
+#else
+# define _(str) str
+#endif
+
+#endif /* GANV_GETTEXT_H */
diff --git a/src/module.c b/src/module.c
new file mode 100644
index 0000000..66eb486
--- /dev/null
+++ b/src/module.c
@@ -0,0 +1,792 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h>
+
+#include "ganv/canvas.h"
+#include "ganv/module.h"
+#include "ganv/port.h"
+
+#include "./color.h"
+#include "./boilerplate.h"
+#include "./gettext.h"
+
+#define FOREACH_PORT(ports, i) \
+ for (GanvPort** i = (GanvPort**)ports->pdata; \
+ i != (GanvPort**)ports->pdata + ports->len; ++i)
+
+#define FOREACH_PORT_CONST(ports, i) \
+ for (const GanvPort** i = (const GanvPort**)ports->pdata; \
+ i != (const GanvPort**)ports->pdata + ports->len; ++i)
+
+static const double MODULE_LABEL_PAD = 2.0;
+static const double MODULE_ICON_SIZE = 16;
+
+G_DEFINE_TYPE(GanvModule, ganv_module, GANV_TYPE_BOX)
+
+static GanvBoxClass* parent_class;
+
+enum {
+ PROP_0,
+ PROP_SHOW_PORT_LABELS
+};
+
+static void
+ganv_module_init(GanvModule* module)
+{
+ GANV_NODE(module)->can_head = FALSE;
+ GANV_NODE(module)->can_tail = FALSE;
+
+ module->ports = g_ptr_array_new();
+ module->icon_box = NULL;
+ module->embed_item = NULL;
+ module->embed_width = 0;
+ module->embed_height = 0;
+ module->widest_input = 0.0;
+ module->widest_output = 0.0;
+ module->show_port_labels = FALSE;
+ module->must_resize = FALSE;
+ module->port_size_changed = FALSE;
+}
+
+static void
+ganv_module_destroy(GtkObject* object)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_MODULE(object));
+
+ g_ptr_array_free(GANV_MODULE(object)->ports, TRUE);
+
+ GanvModule* module = GANV_MODULE(object);
+ FOREACH_PORT(module->ports, p) {
+ gtk_object_destroy(GTK_OBJECT(*p));
+ }
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ }
+}
+
+static void
+ganv_module_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_MODULE(object));
+
+ GanvModule* module = GANV_MODULE(object);
+
+ switch (prop_id) {
+ case PROP_SHOW_PORT_LABELS: {
+ const gboolean tmp = g_value_get_boolean(value);
+ if (module->show_port_labels != tmp) {
+ module->show_port_labels = tmp;
+ module->port_size_changed = TRUE;
+ module->must_resize = TRUE;
+ /* FIXME
+ FOREACH_PORT_CONST(gobj()->ports, p) {
+ (*p)->show_label(b);
+ }*/
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(object));
+ }
+ break;
+ }
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_module_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_MODULE(object));
+
+ GanvModule* module = GANV_MODULE(object);
+
+ switch (prop_id) {
+ GET_CASE(SHOW_PORT_LABELS, boolean, module->show_port_labels);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+typedef struct {
+ double embed_x;
+ double width;
+ double input_width;
+ double output_width;
+ gboolean horiz;
+ gboolean embed_between;
+} Metrics;
+
+static void
+title_size(GanvModule* module, double* w, double* h)
+{
+ if (module->box.node.label) {
+ g_object_get(G_OBJECT(module->box.node.label),
+ "width", w,
+ "height", h,
+ NULL);
+ } else {
+ *w = *h = 0.0;
+ }
+}
+
+static void
+measure(GanvModule* module, Metrics* m)
+{
+ memset(m, '\0', sizeof(Metrics));
+
+ double title_w, title_h;
+ title_size(module, &title_w, &title_h);
+
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(module)->canvas);
+ GanvText* canvas_title = module->box.node.label;
+
+ GanvDirection direction = canvas->direction;
+
+ if (direction == GANV_VERTICAL) {
+ static const double PAD = 2.0;
+
+ double contents_width = PAD;
+ if (canvas_title) {
+ contents_width += title_w;
+ }
+ if (module->icon_box) {
+ contents_width += MODULE_ICON_SIZE + PAD;
+ }
+
+ m->embed_x = 0;
+ m->input_width = ganv_module_get_empty_port_breadth(module);
+ m->output_width = ganv_module_get_empty_port_breadth(module);
+
+ const double ports_width = PAD + ((m->input_width + PAD) * module->ports->len);
+
+ m->width = MAX(contents_width, ports_width);
+ m->width = MAX(m->width, module->embed_width);
+ return;
+ }
+
+ // The amount of space between a port edge and the module edge (on the
+ // side that the port isn't right on the edge).
+ const double hor_pad = (canvas_title ? 10.0 : 20.0);
+
+ m->width = (canvas_title)
+ ? title_w + 10.0
+ : 1.0;
+
+ if (module->icon_box)
+ m->width += MODULE_ICON_SIZE + 2;
+
+ // Title is wide, put inputs and outputs beside each other
+ m->horiz = (module->widest_input + module->widest_output + 10.0
+ < MAX(m->width, module->embed_width));
+
+ // Fit ports to module (or vice-versa)
+ m->input_width = module->widest_input;
+ m->output_width = module->widest_output;
+ double expand_w = (m->horiz ? (m->width / 2.0) : m->width) - hor_pad;
+ if (module->show_port_labels && !module->embed_item) {
+ m->input_width = MAX(module->widest_input, expand_w);
+ m->output_width = MAX(module->widest_output, expand_w);
+ }
+
+ const double widest = MAX(m->input_width, m->output_width);
+
+ if (module->embed_item) {
+ double above_w = MAX(m->width, widest + hor_pad);
+ double between_w = MAX(m->width,
+ (m->input_width
+ + m->output_width
+ + module->embed_width));
+
+ above_w = MAX(above_w, module->embed_width);
+
+ // Decide where to place embedded widget if necessary)
+ if (module->embed_width < module->embed_height * 2.0) {
+ m->embed_between = TRUE;
+ m->width = between_w;
+ m->embed_x = m->input_width;
+ } else {
+ m->width = above_w;
+ m->embed_x = 2.0;
+ }
+ }
+
+ if (!canvas_title && (module->widest_input == 0.0
+ || module->widest_output == 0.0)) {
+ m->width += 10.0;
+ }
+
+ m->width += 4.0;
+ m->width = MAX(m->width, widest + hor_pad);
+}
+
+static void
+place_title(GanvModule* module, GanvDirection dir)
+{
+ GanvBox* box = GANV_BOX(module);
+
+ double title_w, title_h;
+ title_size(module, &title_w, &title_h);
+
+ GanvText* canvas_title = module->box.node.label;
+
+ if (!canvas_title) {
+ return;
+ } else if (dir == GANV_HORIZONTAL) {
+ if (module->icon_box) {
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(canvas_title),
+ "x", MODULE_ICON_SIZE + 1.0,
+ NULL);
+ } else {
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(canvas_title),
+ "x", ((ganv_box_get_width(box) / 2.0)
+ - (title_w / 2.0)),
+ NULL);
+ }
+ } else {
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(canvas_title),
+ "x", ((ganv_box_get_width(box) / 2.0)
+ - (title_w / 2.0)),
+ "y", ganv_module_get_empty_port_depth(module) + 2.0,
+ NULL);
+ }
+}
+
+static void
+resize_horiz(GanvModule* module)
+{
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(module)->canvas);
+
+ Metrics m;
+ measure(module, &m);
+
+ double title_w, title_h;
+ title_size(module, &title_w, &title_h);
+
+ // Basic height contains title, icon
+ double header_height = 2.0 + title_h;
+
+ double height = header_height;
+
+ if (module->embed_item) {
+ gnome_canvas_item_set(module->embed_item,
+ "x", (double)m.embed_x,
+ NULL);
+ }
+
+ // Actually set width and height
+ ganv_box_set_width(GANV_BOX(module), m.width);
+
+ // Offset ports below embedded widget
+ if (!m.embed_between) {
+ header_height += module->embed_height;
+ }
+
+ // Move ports to appropriate locations
+ int i = 0;
+ gboolean last_was_input = FALSE;
+ double y = 0.0;
+ double h = 0.0;
+ FOREACH_PORT(module->ports, pi) {
+ GanvPort* const p = (*pi);
+ GanvBox* const pbox = GANV_BOX(p);
+ GanvNode* const pnode = GANV_NODE(p);
+ h = ganv_box_get_height(pbox);
+
+ if (p->is_input) {
+ y = header_height + (i * (h + 1.0));
+ ++i;
+ ganv_box_set_width(pbox, m.input_width);
+ ganv_node_move_to(pnode, 0.0, y);
+ last_was_input = TRUE;
+
+ ganv_canvas_for_each_edge_to(
+ canvas, pnode, ganv_edge_update_location);
+ } else {
+ if (!m.horiz || !last_was_input) {
+ y = header_height + (i * (h + 1.0));
+ ++i;
+ }
+ ganv_box_set_width(pbox, m.output_width);
+ ganv_node_move_to(pnode,
+ m.width - ganv_box_get_width(pbox),
+ y);
+ last_was_input = FALSE;
+
+ ganv_canvas_for_each_edge_from(
+ canvas, pnode, ganv_edge_update_location);
+ }
+ }
+
+ if (module->ports->len == 0) {
+ h += header_height;
+ }
+
+ height = y + h + 4.0;
+ if (module->embed_item && m.embed_between)
+ height = MAX(height, module->embed_height + header_height + 2.0);
+
+ ganv_box_set_height(&module->box, height);
+
+ place_title(module, GANV_HORIZONTAL);
+}
+
+static void
+resize_vert(GanvModule* module)
+{
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(module)->canvas);
+
+ Metrics m;
+ measure(module, &m);
+
+ double title_w, title_h;
+ title_size(module, &title_w, &title_h);
+
+ static const double PAD = 2.0;
+
+ const double port_depth = ganv_module_get_empty_port_depth(module);
+ const double port_breadth = ganv_module_get_empty_port_breadth(module);
+
+ if (module->embed_item) {
+ gnome_canvas_item_set(module->embed_item,
+ "x", (double)m.embed_x,
+ "y", port_depth + title_h,
+ NULL);
+ }
+
+ const double height = PAD + title_h
+ + module->embed_height + (port_depth * 2.0);
+
+ // Move ports to appropriate locations
+ int i = 0;
+ gboolean last_was_input = FALSE;
+ double x = 0.0;
+ FOREACH_PORT(module->ports, pi) {
+ GanvPort* const p = (*pi);
+ GanvBox* const pbox = GANV_BOX(p);
+ GanvNode* const pnode = GANV_NODE(p);
+ ganv_box_set_width(pbox, port_breadth);
+ ganv_box_set_height(pbox, port_depth);
+ if (p->is_input) {
+ x = PAD + (i * (port_breadth + PAD));
+ ++i;
+ ganv_node_move_to(pnode, x, 0);
+ last_was_input = TRUE;
+
+ ganv_canvas_for_each_edge_to(canvas, pnode,
+ ganv_edge_update_location);
+ } else {
+ if (!last_was_input) {
+ x = PAD + (i * (port_breadth + PAD));
+ ++i;
+ }
+ ganv_node_move_to(pnode,
+ x,
+ height - ganv_box_get_height(pbox));
+ last_was_input = FALSE;
+
+ ganv_canvas_for_each_edge_from(canvas, pnode,
+ ganv_edge_update_location);
+ }
+ }
+
+ ganv_box_set_width(GANV_BOX(module), m.width);
+ ganv_box_set_height(GANV_BOX(module), height);
+
+ place_title(module, GANV_VERTICAL);
+}
+
+static void
+measure_ports(GanvModule* module)
+{
+ module->widest_input = 0.0;
+ module->widest_output = 0.0;
+ FOREACH_PORT_CONST(module->ports, pi) {
+ const GanvPort* const p = (*pi);
+ const double w = ganv_port_get_natural_width(p);
+ if (p->is_input) {
+ if (w > module->widest_input) {
+ module->widest_input = w;
+ }
+ } else {
+ if (w > module->widest_output) {
+ module->widest_output = w;
+ }
+ }
+ }
+}
+
+static void
+layout(GanvNode* self)
+{
+ GanvModule* module = GANV_MODULE(self);
+ GanvNode* node = GANV_NODE(self);
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(module)->canvas);
+
+ double label_w = 0.0;
+ double label_h = 0.0;
+ if (node->label) {
+ g_object_get(node->label,
+ "width", &label_w,
+ "height", &label_h,
+ NULL);
+ }
+
+ ganv_box_set_width(&module->box, label_w + (MODULE_LABEL_PAD * 2.0));
+ ganv_box_set_height(&module->box, label_h);
+
+ if (module->port_size_changed) {
+ measure_ports(module);
+ module->port_size_changed = FALSE;
+ }
+
+ switch (canvas->direction) {
+ case GANV_HORIZONTAL:
+ resize_horiz(module);
+ break;
+ case GANV_VERTICAL:
+ resize_vert(module);
+ break;
+ }
+
+ module->must_resize = FALSE;
+}
+
+static void
+ganv_module_resize(GanvNode* self)
+{
+ GanvModule* module = GANV_MODULE(self);
+
+ if (module->must_resize) {
+ layout(self);
+ }
+
+ if (parent_class->parent_class.resize) {
+ parent_class->parent_class.resize(self);
+ }
+}
+
+static void
+ganv_module_update(GnomeCanvasItem* item,
+ double* affine,
+ ArtSVP* clip_path,
+ int flags)
+{
+ GanvNode* node = GANV_NODE(item);
+ GanvModule* module = GANV_MODULE(item);
+ if (module->must_resize) {
+ layout(node);
+ }
+
+ GnomeCanvasItemClass* item_class = GNOME_CANVAS_ITEM_CLASS(parent_class);
+ item_class->update(item, affine, clip_path, flags);
+}
+
+static void
+ganv_module_move_to(GanvNode* node,
+ double x,
+ double y)
+{
+ GanvModule* module = GANV_MODULE(node);
+ GANV_NODE_CLASS(parent_class)->move_to(node, x, y);
+ FOREACH_PORT(module->ports, p) {
+ ganv_node_move(GANV_NODE(*p), 0.0, 0.0);
+ }
+}
+
+static void
+ganv_module_move(GanvNode* node,
+ double dx,
+ double dy)
+{
+ GanvModule* module = GANV_MODULE(node);
+ GANV_NODE_CLASS(parent_class)->move(node, dx, dy);
+ FOREACH_PORT(module->ports, p) {
+ ganv_node_move(GANV_NODE(*p), 0.0, 0.0);
+ }
+}
+
+static void
+ganv_module_class_init(GanvModuleClass* class)
+{
+ GObjectClass* gobject_class = (GObjectClass*)class;
+ GtkObjectClass* object_class = (GtkObjectClass*)class;
+ GnomeCanvasItemClass* item_class = (GnomeCanvasItemClass*)class;
+ GanvNodeClass* node_class = (GanvNodeClass*)class;
+
+ parent_class = GANV_BOX_CLASS(g_type_class_peek_parent(class));
+
+ gobject_class->set_property = ganv_module_set_property;
+ gobject_class->get_property = ganv_module_get_property;
+
+ object_class->destroy = ganv_module_destroy;
+
+ item_class->update = ganv_module_update;
+
+ node_class->move = ganv_module_move;
+ node_class->move_to = ganv_module_move_to;
+ node_class->resize = ganv_module_resize;
+}
+
+void
+ganv_module_add_port(GanvModule* module,
+ GanvPort* port)
+{
+ const double width = ganv_port_get_natural_width(port);
+ if (port->is_input && width > module->widest_input) {
+ module->widest_input = width;
+ module->must_resize = TRUE;
+ } else if (!port->is_input && width > module->widest_output) {
+ module->widest_output = width;
+ module->must_resize = TRUE;
+ }
+
+#if 0
+
+ double port_x, port_y;
+
+ // Place vertically
+ if (canvas()->direction() == Canvas::HORIZONTAL) {
+ if (gobj()->ports->len != 0) {
+ const Port* const last_port = *back();
+ port_y = last_port->get_y() + last_port->get_height() + 1;
+ } else {
+ port_y = 2.0 + title_height();
+ }
+ } else {
+ if (p->is_input()) {
+ port_y = 0.0;
+ } else {
+ port_y = get_height() - get_empty_port_depth();
+ }
+ }
+
+ // Place horizontally
+ Metrics m;
+ calculate_metrics(m);
+
+ set_width(m.width);
+ if (p->is_input()) {
+ p->set_width(m.input_width);
+ port_x = 0;
+ } else {
+ p->set_width(m.output_width);
+ port_x = m.width - p->get_width();
+ }
+
+ p->move_to(port_x, port_y);
+
+ g_ptr_array_add(gobj()->ports, p->gobj());
+ if (canvas()->direction() == Canvas::HORIZONTAL) {
+ set_height(p->get_y() + p->get_height() + 1);
+ }
+
+ place_title();
+#endif
+ module->must_resize = TRUE;
+
+ g_ptr_array_add(module->ports, port);
+ //if (canvas()->direction() == Canvas::HORIZONTAL) {
+ // set_height(p->get_y() + p->get_height() + 1);
+ //}
+
+ GanvCanvas* canvas = GANV_CANVAS(
+ GNOME_CANVAS_ITEM(module)->canvas);
+
+ place_title(module, canvas->direction);
+
+}
+
+void
+ganv_module_remove_port(GanvModule* module,
+ GanvPort* port)
+{
+#if 0
+ gboolean removed = g_ptr_array_remove(gobj()->ports, port->gobj());
+ if (removed) {
+ // Find new widest input or output, if necessary
+ if (port->is_input() && port->get_width() >= _widest_input) {
+ _widest_input = 0;
+ FOREACH_PORT_CONST(gobj()->ports, i) {
+ const Port* const p = (*i);
+ if (p->is_input() && p->get_width() >= _widest_input) {
+ _widest_input = p->get_width();
+ }
+ }
+ } else if (port->is_output() && port->get_width() >= _widest_output) {
+ _widest_output = 0;
+ FOREACH_PORT_CONST(gobj()->ports, i) {
+ const Port* const p = (*i);
+ if (p->is_output() && p->get_width() >= _widest_output) {
+ _widest_output = p->get_width();
+ }
+ }
+ }
+
+ _must_resize = true;
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(_gobj));
+ } else {
+ std::cerr << "Failed to find port to remove" << std::endl;
+ }
+#endif
+}
+
+double
+ganv_module_get_empty_port_breadth(const GanvModule* module)
+{
+ return ganv_module_get_empty_port_depth(module) * 2.0;
+}
+
+double
+ganv_module_get_empty_port_depth(const GanvModule* module)
+{
+ GanvCanvas* canvas = GANV_CANVAS(
+ GNOME_CANVAS_ITEM(module)->canvas);
+
+ return ganv_canvas_get_font_size(canvas);
+}
+
+void
+ganv_module_set_icon(GanvModule* module,
+ GdkPixbuf* icon)
+{
+ if (module->icon_box) {
+ gtk_object_destroy(GTK_OBJECT(module->icon_box));
+ module->icon_box = NULL;
+ }
+
+ if (icon) {
+ module->icon_box = gnome_canvas_item_new(
+ GNOME_CANVAS_GROUP(module),
+ gnome_canvas_pixbuf_get_type(),
+ "x", 8.0,
+ "y", 10.0,
+ "pixbuf", icon,
+ NULL);
+
+ const double icon_w = gdk_pixbuf_get_width(icon);
+ const double icon_h = gdk_pixbuf_get_height(icon);
+ const double scale = MODULE_ICON_SIZE / ((icon_w > icon_h)
+ ? icon_w : icon_h);
+ const double scale_trans[6] = {
+ scale, 0.0, 0.0,
+ scale, 0.0, 0.0
+ };
+
+ gnome_canvas_item_affine_relative(module->icon_box, scale_trans);
+ gnome_canvas_item_raise_to_top(module->icon_box);
+ gnome_canvas_item_show(module->icon_box);
+ }
+ module->must_resize = TRUE;
+}
+
+static void
+on_embed_size_request(GtkWidget* widget,
+ GtkRequisition* r,
+ void* user_data)
+{
+ GanvModule* module = GANV_MODULE(user_data);
+ if (module->embed_width == r->width && module->embed_height == r->height) {
+ return;
+ }
+
+ module->embed_width = r->width;
+ module->embed_height = r->height;
+
+ module->must_resize = TRUE;
+
+ GtkAllocation allocation;
+ allocation.width = r->width;
+ allocation.height = r->width;
+
+ gtk_widget_size_allocate(widget, &allocation);
+ gnome_canvas_item_set(module->embed_item,
+ "width", (double)r->width,
+ "height", (double)r->height,
+ NULL);
+}
+
+void
+ganv_module_embed(GanvModule* module,
+ GtkWidget* widget)
+{
+ if (module->embed_item) {
+ gtk_object_destroy(GTK_OBJECT(module->embed_item));
+ module->embed_item = NULL;
+ }
+
+ if (!widget) {
+ module->embed_width = 0;
+ module->embed_height = 0;
+ module->must_resize = TRUE;
+ return;
+ }
+
+ double title_w, title_h;
+ title_size(module, &title_w, &title_h);
+
+ const double y = 4.0 + title_h;
+ module->embed_item = gnome_canvas_item_new(
+ GNOME_CANVAS_GROUP(module),
+ gnome_canvas_widget_get_type(),
+ "x", 2.0,
+ "y", y,
+ "widget", widget,
+ NULL);
+
+ gtk_widget_show_all(widget);
+
+ GtkRequisition r;
+ gtk_widget_size_request(widget, &r);
+ on_embed_size_request(widget, &r, module);
+
+ gnome_canvas_item_show(module->embed_item);
+ gnome_canvas_item_raise_to_top(module->embed_item);
+
+ g_signal_connect(widget, "size-request",
+ G_CALLBACK(on_embed_size_request), module);
+
+ layout(GANV_NODE(module));
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(module));
+}
+
+void
+ganv_module_for_each_port(GanvModule* module,
+ GanvPortFunction f,
+ void* data)
+{
+ const int len = module->ports->len;
+ GanvPort** copy = (GanvPort**)malloc(sizeof(GanvPort*) * len);
+ memcpy(copy, module->ports->pdata, sizeof(GanvPort*) * len);
+
+ for (int i = 0; i < len; ++i) {
+ f(copy[i], data);
+ }
+
+ free(copy);
+}
+
diff --git a/src/node.c b/src/node.c
new file mode 100644
index 0000000..e7c3931
--- /dev/null
+++ b/src/node.c
@@ -0,0 +1,546 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include "ganv/canvas.h"
+#include "ganv/node.h"
+
+#include "./boilerplate.h"
+#include "./color.h"
+#include "./ganv-private.h"
+#include "./gettext.h"
+
+G_DEFINE_TYPE(GanvNode, ganv_node, GNOME_TYPE_CANVAS_GROUP)
+
+static GnomeCanvasGroupClass* parent_class;
+
+enum {
+ PROP_0,
+ PROP_PARTNER,
+ PROP_LABEL,
+ PROP_DASH_LENGTH,
+ PROP_DASH_OFFSET,
+ PROP_BORDER_WIDTH,
+ PROP_FILL_COLOR,
+ PROP_BORDER_COLOR,
+ PROP_CAN_TAIL,
+ PROP_CAN_HEAD,
+ PROP_SELECTED,
+ PROP_HIGHLIGHTED,
+ PROP_DRAGGABLE
+};
+
+static gboolean
+on_event(GanvNode* node, GdkEvent* event)
+{
+ return GANV_NODE_GET_CLASS(node)->on_event(node, event);
+}
+
+static void
+ganv_node_init(GanvNode* node)
+{
+ node->partner = NULL;
+ node->label = NULL;
+ node->dash_length = 0.0;
+ node->dash_offset = 0.0;
+ node->border_width = 2.0;
+ node->fill_color = DEFAULT_FILL_COLOR;
+ node->border_color = DEFAULT_BORDER_COLOR;
+ node->can_tail = FALSE;
+ node->can_head = FALSE;
+ node->selected = FALSE;
+ node->highlighted = FALSE;
+ node->draggable = FALSE;
+
+ g_signal_connect(G_OBJECT(node),
+ "event", G_CALLBACK(on_event), node);
+}
+
+static void
+ganv_node_realize(GnomeCanvasItem* item)
+{
+ GNOME_CANVAS_ITEM_CLASS(parent_class)->realize(item);
+ ganv_canvas_add_node(GANV_CANVAS(item->canvas),
+ GANV_NODE(item));
+}
+
+static void
+ganv_node_destroy(GtkObject* object)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_NODE(object));
+
+ GanvNode* node = GANV_NODE(object);
+ if (node->label) {
+ gtk_object_destroy(GTK_OBJECT(node->label));
+ node->label = NULL;
+ }
+
+ GnomeCanvasItem* item = GNOME_CANVAS_ITEM(object);
+ ganv_node_disconnect(node);
+ if (item->canvas) {
+ ganv_canvas_remove_node(GANV_CANVAS(item->canvas), node);
+ }
+
+ node->partner = NULL;
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ }
+}
+
+static void
+ganv_node_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_NODE(object));
+
+ GanvNode* node = GANV_NODE(object);
+
+ switch (prop_id) {
+ SET_CASE(PARTNER, object, node->partner);
+ SET_CASE(DASH_LENGTH, double, node->dash_length);
+ SET_CASE(DASH_OFFSET, double, node->dash_offset);
+ SET_CASE(BORDER_WIDTH, double, node->border_width);
+ SET_CASE(FILL_COLOR, uint, node->fill_color);
+ SET_CASE(BORDER_COLOR, uint, node->border_color);
+ SET_CASE(CAN_TAIL, boolean, node->can_tail)
+ SET_CASE(CAN_HEAD, boolean, node->can_head)
+ SET_CASE(SELECTED, boolean, node->selected)
+ SET_CASE(HIGHLIGHTED, boolean, node->highlighted)
+ SET_CASE(DRAGGABLE, boolean, node->draggable)
+ case PROP_LABEL:
+ ganv_node_set_label(node, g_value_get_string(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_node_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_NODE(object));
+
+ GanvNode* node = GANV_NODE(object);
+
+ typedef char* gstring;
+
+ switch (prop_id) {
+ GET_CASE(PARTNER, object, node->partner);
+ GET_CASE(LABEL, string, node->label->text);
+ GET_CASE(DASH_LENGTH, double, node->dash_length);
+ GET_CASE(DASH_OFFSET, double, node->dash_offset);
+ GET_CASE(BORDER_WIDTH, double, node->border_width);
+ GET_CASE(FILL_COLOR, uint, node->fill_color);
+ GET_CASE(BORDER_COLOR, uint, node->border_color);
+ GET_CASE(CAN_TAIL, boolean, node->can_tail)
+ GET_CASE(CAN_HEAD, boolean, node->can_head)
+ GET_CASE(SELECTED, boolean, node->selected)
+ GET_CASE(HIGHLIGHTED, boolean, node->highlighted)
+ GET_CASE(DRAGGABLE, boolean, node->draggable)
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_node_default_tail_vector(const GanvNode* self,
+ const GanvNode* head,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy)
+{
+ g_object_get(G_OBJECT(self),
+ "x", x,
+ "y", y,
+ NULL);
+
+ *dx = 1.0;
+ *dy = 0.0;
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self)->parent, x, y);
+}
+
+static void
+ganv_node_default_head_vector(const GanvNode* self,
+ const GanvNode* tail,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy)
+{
+ g_object_get(G_OBJECT(self),
+ "x", x,
+ "y", y,
+ NULL);
+
+ *dx = -1.0;
+ *dy = 0.0;
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self)->parent, x, y);
+}
+
+void
+ganv_node_get_draw_properties(const GanvNode* node,
+ double* dash_length,
+ double* border_color,
+ double* fill_color)
+{
+ *dash_length = node->dash_length;
+ *border_color = node->border_color;
+ *fill_color = node->fill_color;
+
+ if (node->selected) {
+ *dash_length = 4.0;
+ *border_color = highlight_color(node->border_color, 0x20);
+ }
+
+ if (node->highlighted) {
+ *fill_color = highlight_color(node->fill_color, 0x20);
+ *border_color = highlight_color(node->border_color, 0x20);
+ }
+}
+
+const char*
+ganv_node_get_label(const GanvNode* node)
+{
+ return node->label ? node->label->text : NULL;
+}
+
+void
+ganv_node_set_label(GanvNode* node, const char* str)
+{
+ if (str[0] == '\0' || !str) {
+ if (node->label) {
+ gtk_object_destroy(GTK_OBJECT(node->label));
+ node->label = NULL;
+ }
+ } else if (node->label) {
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(node->label),
+ "text", str,
+ NULL);
+ } else {
+ node->label = GANV_TEXT(gnome_canvas_item_new(
+ GNOME_CANVAS_GROUP(node),
+ ganv_text_get_type(),
+ "text", str,
+ "color", 0xFFFFFFFF,
+ NULL));
+ }
+
+ GanvNodeClass* klass = GANV_NODE_GET_CLASS(node);
+ if (klass->resize) {
+ klass->resize(node);
+ }
+}
+
+static void
+ganv_node_default_tick(GanvNode* self,
+ double seconds)
+{
+ GanvNode* node = GANV_NODE(self);
+ node->dash_offset = seconds * 8.0;
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(self));
+}
+
+static void
+ganv_node_default_disconnect(GanvNode* node)
+{
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(node)->canvas);
+ if (canvas) {
+ ganv_canvas_for_each_edge_on(canvas, node, ganv_edge_remove);
+ }
+}
+
+static void
+ganv_node_default_move(GanvNode* node,
+ double dx,
+ double dy)
+{
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(node)->canvas);
+ gnome_canvas_item_move(GNOME_CANVAS_ITEM(node), dx, dy);
+ ganv_canvas_for_each_edge_on(canvas, node,
+ ganv_edge_update_location);
+
+}
+
+static void
+ganv_node_default_move_to(GanvNode* node,
+ double x,
+ double y)
+{
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(node)->canvas);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(node),
+ "x", x,
+ "y", y,
+ NULL);
+ if (node->can_tail) {
+ ganv_canvas_for_each_edge_from(
+ canvas, node, ganv_edge_update_location);
+ } else if (node->can_head) {
+ ganv_canvas_for_each_edge_to(
+ canvas, node, ganv_edge_update_location);
+ }
+}
+
+static gboolean
+ganv_node_default_on_event(GanvNode* node,
+ GdkEvent* event)
+{
+ GanvCanvas* canvas = GANV_CANVAS(GNOME_CANVAS_ITEM(node)->canvas);
+
+ // FIXME: put these somewhere better
+ static double last_x, last_y;
+ static double drag_start_x, drag_start_y;
+ static gboolean dragging = FALSE;
+
+ /*
+ double click_x,
+ gnome_canvas_item_w2i(GNOME_CANVAS_ITEM(GNOME_CANVAS_ITEM(node)->parent),
+ &click_x, &click_y);
+ */
+
+ switch (event->type) {
+ case GDK_ENTER_NOTIFY:
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(node),
+ "highlighted", TRUE, NULL);
+ return TRUE;
+
+ case GDK_LEAVE_NOTIFY:
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(node),
+ "highlighted", FALSE, NULL);
+ return TRUE;
+
+ case GDK_BUTTON_PRESS:
+ drag_start_x = event->button.x;
+ drag_start_y = event->button.y;
+ last_x = event->button.x;
+ last_y = event->button.y;
+ if (!canvas->locked && node->draggable && event->button.button == 1) {
+ gnome_canvas_item_grab(
+ GNOME_CANVAS_ITEM(node),
+ GDK_POINTER_MOTION_MASK|GDK_BUTTON_RELEASE_MASK|GDK_BUTTON_PRESS_MASK,
+ ganv_canvas_get_move_cursor(canvas),
+ event->button.time);
+ dragging = TRUE;
+ return TRUE;
+ }
+ break;
+
+ case GDK_BUTTON_RELEASE:
+ if (dragging) {
+ gboolean selected;
+ g_object_get(G_OBJECT(node), "selected", &selected, NULL);
+ gnome_canvas_item_ungrab(GNOME_CANVAS_ITEM(node), event->button.time);
+ dragging = FALSE;
+ if (event->button.x != drag_start_x || event->button.y != drag_start_y) {
+ // Dragged
+ // FIXME: emit moved signal
+ ganv_canvas_selection_move_finished(canvas);
+ } else {
+ // Clicked
+ if (selected) {
+ ganv_canvas_unselect_node(canvas, node);
+ } else {
+ if (!(event->button.state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK))) {
+ ganv_canvas_clear_selection(canvas);
+ }
+ ganv_canvas_select_node(canvas, node);
+ }
+
+ }
+ return TRUE;
+ }
+ break;
+
+ case GDK_MOTION_NOTIFY:
+ if ((dragging && (event->motion.state & GDK_BUTTON1_MASK))) {
+ gboolean selected;
+ g_object_get(G_OBJECT(node), "selected", &selected, NULL);
+
+ double new_x = event->motion.x;
+ double new_y = event->motion.y;
+
+ if (event->motion.is_hint) {
+ int t_x;
+ int t_y;
+ GdkModifierType state;
+ gdk_window_get_pointer(event->motion.window, &t_x, &t_y, &state);
+ new_x = t_x;
+ new_y = t_y;
+ }
+
+ const double dx = new_x - last_x;
+ const double dy = new_y - last_y;
+ if (selected) {
+ ganv_canvas_move_selected_items(canvas, dx, dy);
+ } else {
+ ganv_node_move(node, dx, dy);
+ }
+
+ last_x = new_x;
+ last_y = new_y;
+ return TRUE;
+ }
+
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static void
+ganv_node_class_init(GanvNodeClass* class)
+{
+ GObjectClass* gobject_class = (GObjectClass*)class;
+ GtkObjectClass* object_class = (GtkObjectClass*)class;
+ GnomeCanvasItemClass* item_class = (GnomeCanvasItemClass*)class;
+
+ parent_class = GNOME_CANVAS_GROUP_CLASS(g_type_class_peek_parent(class));
+
+ gobject_class->set_property = ganv_node_set_property;
+ gobject_class->get_property = ganv_node_get_property;
+
+ g_object_class_install_property(
+ gobject_class, PROP_PARTNER, g_param_spec_object(
+ "partner",
+ _("partner"),
+ _("\
+Partners are nodes that should be visually aligned to correspond to each \
+other, even if they are not necessarily connected (e.g. for separate modules \
+representing the inputs and outputs of a single thing). When the canvas is \
+arranged, the partner will be aligned as if there was an edge from this node \
+to its partner."),
+ GANV_TYPE_NODE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_LABEL, g_param_spec_string(
+ "label",
+ _("label"),
+ _("the text to display"),
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_DASH_LENGTH, g_param_spec_double(
+ "dash-length",
+ _("border dash length"),
+ _("length of dashes, or zero for no dashing"),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_DASH_OFFSET, g_param_spec_double(
+ "dash-offset",
+ _("border dash offset"),
+ _("offset for dashes (useful for 'rubber band' animation)."),
+ 0.0, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_BORDER_WIDTH, g_param_spec_double(
+ "border-width",
+ _("border width"),
+ _("width of the border around this node."),
+ 0.0, G_MAXDOUBLE,
+ 2.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_FILL_COLOR, g_param_spec_uint(
+ "fill-color",
+ _("fill color"),
+ _("color of internal area"),
+ 0, G_MAXUINT,
+ DEFAULT_FILL_COLOR,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_BORDER_COLOR, g_param_spec_uint(
+ "border-color",
+ _("border color"),
+ _("color of border area"),
+ 0, G_MAXUINT,
+ DEFAULT_BORDER_COLOR,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_CAN_TAIL, g_param_spec_boolean(
+ "can-tail",
+ _("can tail"),
+ _("whether this object can be the tail of an edge"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_CAN_HEAD, g_param_spec_boolean(
+ "can-head",
+ _("can head"),
+ _("whether this object can be the head of an edge"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_SELECTED, g_param_spec_boolean(
+ "selected",
+ _("selected"),
+ _("whether this object is selected"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_HIGHLIGHTED, g_param_spec_boolean(
+ "highlighted",
+ _("highlighted"),
+ _("whether this object is highlighted"),
+ 0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_DRAGGABLE, g_param_spec_boolean(
+ "draggable",
+ _("draggable"),
+ _("whether this object is draggable"),
+ 0,
+ G_PARAM_READWRITE));
+
+ object_class->destroy = ganv_node_destroy;
+
+ item_class->realize = ganv_node_realize;
+
+ class->disconnect = ganv_node_default_disconnect;
+ class->move = ganv_node_default_move;
+ class->move_to = ganv_node_default_move_to;
+ class->tick = ganv_node_default_tick;
+ class->tail_vector = ganv_node_default_tail_vector;
+ class->head_vector = ganv_node_default_head_vector;
+ class->on_event = ganv_node_default_on_event;
+}
diff --git a/src/port.c b/src/port.c
new file mode 100644
index 0000000..7316846
--- /dev/null
+++ b/src/port.c
@@ -0,0 +1,420 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <math.h>
+
+#include "ganv/canvas.h"
+#include "ganv/port.h"
+#include "ganv/module.h"
+
+#include "./boilerplate.h"
+#include "./ganv-private.h"
+#include "./gettext.h"
+
+static const double PORT_LABEL_HPAD = 4.0;
+static const double PORT_LABEL_VPAD = 1.0;
+
+G_DEFINE_TYPE(GanvPort, ganv_port, GANV_TYPE_BOX)
+
+static GanvBoxClass* parent_class;
+
+enum {
+ PROP_0,
+ PROP_IS_INPUT
+};
+
+static void
+ganv_port_init(GanvPort* port)
+{
+ port->is_input = TRUE;
+}
+
+static void
+ganv_port_destroy(GtkObject* object)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_PORT(object));
+
+ GnomeCanvasItem* item = GNOME_CANVAS_ITEM(object);
+ GanvPort* port = GANV_PORT(object);
+ GanvCanvas* canvas = GANV_CANVAS(item->canvas);
+ if (port->is_input) {
+ ganv_canvas_for_each_edge_to(canvas,
+ &port->box.node,
+ ganv_edge_remove);
+ } else {
+ ganv_canvas_for_each_edge_from(canvas,
+ &port->box.node,
+ ganv_edge_remove);
+ }
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ }
+}
+
+static void
+ganv_port_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_PORT(object));
+
+ GanvPort* port = GANV_PORT(object);
+
+ switch (prop_id) {
+ SET_CASE(IS_INPUT, boolean, port->is_input);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_port_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_PORT(object));
+
+ GanvPort* port = GANV_PORT(object);
+
+ switch (prop_id) {
+ GET_CASE(IS_INPUT, boolean, port->is_input);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_port_tail_vector(const GanvNode* self,
+ const GanvNode* head,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy)
+{
+ GanvPort* port = GANV_PORT(self);
+
+ double px, py;
+ g_object_get(G_OBJECT(self), "x", &px, "y", &py, NULL);
+
+ *x = px + ganv_box_get_width(&port->box);
+ *y = py + ganv_box_get_height(&port->box) / 2.0;
+ *dx = 1.0;
+ *dy = 0.0;
+
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self)->parent, x, y);
+}
+
+static void
+ganv_port_head_vector(const GanvNode* self,
+ const GanvNode* tail,
+ double* x,
+ double* y,
+ double* dx,
+ double* dy)
+{
+ GanvPort* port = GANV_PORT(self);
+
+ double px, py;
+ g_object_get(G_OBJECT(self), "x", &px, "y", &py, NULL);
+
+ *x = px;
+ *y = py + ganv_box_get_height(&port->box) / 2.0;
+ *dx = -1.0;
+ *dy = 0.0;
+
+ gnome_canvas_item_i2w(GNOME_CANVAS_ITEM(self)->parent, x, y);
+}
+
+static void
+ganv_port_resize(GanvNode* self)
+{
+ GanvPort* port = GANV_PORT(self);
+ GanvNode* node = GANV_NODE(self);
+
+ double label_w, label_h;
+ g_object_get(node->label,
+ "width", &label_w,
+ "height", &label_h,
+ NULL);
+
+ ganv_box_set_width(&port->box, label_w + (PORT_LABEL_HPAD * 2.0));
+ ganv_box_set_height(&port->box, label_h + (PORT_LABEL_VPAD * 2.0));
+
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(node->label),
+ "x", PORT_LABEL_HPAD,
+ "y", PORT_LABEL_VPAD,
+ NULL);
+
+ if (parent_class->parent_class.resize) {
+ parent_class->parent_class.resize(self);
+ }
+}
+
+static void
+ganv_port_set_width(GanvBox* box,
+ double width)
+{
+ GanvPort* port = GANV_PORT(box);
+ parent_class->set_width(box, width);
+ if (port->control) {
+ ganv_port_set_control_value(port, port->control->value);
+ }
+}
+
+static void
+ganv_port_set_height(GanvBox* box,
+ double height)
+{
+ GanvPort* port = GANV_PORT(box);
+ parent_class->set_height(box, height);
+ if (port->control) {
+ double control_y1;
+ g_object_get(port->control->rect, "y1", &control_y1, NULL);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(port->control->rect),
+ "y2", control_y1 + height,
+ NULL);
+ }
+}
+
+static gboolean
+on_event(GanvNode* node, GdkEvent* event)
+{
+ GnomeCanvasItem* item = GNOME_CANVAS_ITEM(node);
+ GanvCanvas* canvas = GANV_CANVAS(item->canvas);
+
+ return ganv_canvas_port_event(canvas, GANV_PORT(node), event);
+}
+
+static void
+ganv_port_class_init(GanvPortClass* class)
+{
+ GObjectClass* gobject_class = (GObjectClass*)class;
+ GtkObjectClass* object_class = (GtkObjectClass*)class;
+ GanvNodeClass* node_class = (GanvNodeClass*)class;
+ GanvBoxClass* box_class = (GanvBoxClass*)class;
+
+ parent_class = GANV_BOX_CLASS(g_type_class_peek_parent(class));
+
+ gobject_class->set_property = ganv_port_set_property;
+ gobject_class->get_property = ganv_port_get_property;
+
+ g_object_class_install_property(
+ gobject_class, PROP_IS_INPUT, g_param_spec_boolean(
+ "is-input",
+ _("is input"),
+ _("whether this port is an input (or an output, if false)"),
+ 0,
+ G_PARAM_READWRITE));
+
+ object_class->destroy = ganv_port_destroy;
+
+ node_class->on_event = on_event;
+ node_class->tail_vector = ganv_port_tail_vector;
+ node_class->head_vector = ganv_port_head_vector;
+ node_class->resize = ganv_port_resize;
+
+ box_class->set_width = ganv_port_set_width;
+ box_class->set_height = ganv_port_set_height;
+}
+
+GanvPort*
+ganv_port_new(GanvModule* module,
+ gboolean is_input,
+ const char* first_prop_name, ...)
+{
+ GanvPort* port = GANV_PORT(
+ g_object_new(ganv_port_get_type(), NULL));
+
+ GnomeCanvasItem* item = GNOME_CANVAS_ITEM(port);
+ va_list args;
+ va_start(args, first_prop_name);
+ gnome_canvas_item_construct(item,
+ GNOME_CANVAS_GROUP(module),
+ first_prop_name, args);
+ va_end(args);
+
+ port->is_input = is_input;
+
+ GanvBox* box = GANV_BOX(port);
+ box->radius_tl = (is_input ? 0.0 : 4.0);
+ box->radius_tr = (is_input ? 4.0 : 0.0);
+ box->radius_br = (is_input ? 4.0 : 0.0);
+ box->radius_bl = (is_input ? 0.0 : 4.0);
+
+ GanvNode* node = GANV_NODE(port);
+ node->can_tail = !is_input;
+ node->can_head = is_input;
+ node->draggable = FALSE;
+
+ GanvCanvas* canvas = GANV_CANVAS(item->canvas);
+ if (!node->label) {
+ const double depth = ganv_module_get_empty_port_depth(module);
+ const double breadth = ganv_module_get_empty_port_breadth(module);
+ if (canvas->direction == GANV_HORIZONTAL) {
+ ganv_box_set_width(box, depth);
+ ganv_box_set_height(box, breadth);
+ } else {
+ ganv_box_set_width(box, breadth);
+ ganv_box_set_height(box, depth);
+ }
+ }
+
+ ganv_module_add_port(module, port);
+ return port;
+}
+
+void
+ganv_port_show_control(GanvPort* port)
+{
+ port->control = (GanvPortControl*)malloc(sizeof(GanvPortControl));
+ port->control->value = 0.0f;
+ port->control->min = 0.0f;
+ port->control->max = 0.0f;
+ port->control->is_toggle = FALSE;
+ port->control->rect = GANV_BOX(gnome_canvas_item_new(
+ GNOME_CANVAS_GROUP(port),
+ ganv_box_get_type(),
+ "x1", 0.0,
+ "y1", 0.0,
+ "x2", 0.0,
+ "y2", ganv_box_get_height(&port->box),
+ "fill-color", 0xFFFFFF80,
+ "border-width", 0.0,
+ NULL));
+ gnome_canvas_item_show(GNOME_CANVAS_ITEM(port->control->rect));
+}
+
+void
+ganv_port_hide_control(GanvPort* port)
+{
+ gtk_object_destroy(GTK_OBJECT(port->control->rect));
+ free(port->control);
+ port->control = NULL;
+}
+
+void
+ganv_port_set_control_is_toggle(GanvPort* port,
+ gboolean is_toggle)
+{
+ if (port->control) {
+ port->control->is_toggle = is_toggle;
+ ganv_port_set_control_value(port, port->control->value);
+ }
+}
+
+void
+ganv_port_set_control_value(GanvPort* port,
+ float value)
+{
+ if (!port->control) {
+ return;
+ }
+
+ if (port->control->is_toggle) {
+ if (value != 0.0) {
+ value = port->control->max;
+ } else {
+ value = port->control->min;
+ }
+ }
+
+ if (value < port->control->min) {
+ port->control->min = value;
+ }
+ if (value > port->control->max) {
+ port->control->max = value;
+ }
+
+ if (port->control->max == port->control->min) {
+ port->control->max = port->control->min + 1.0;
+ }
+
+ const int inf = isinf(value);
+ if (inf == -1) {
+ value = port->control->min;
+ } else if (inf == 1) {
+ value = port->control->max;
+ }
+
+ const double w = (value - port->control->min)
+ / (port->control->max - port->control->min)
+ * ganv_box_get_width(&port->box);
+
+ if (isnan(w)) {
+ return;
+ }
+
+ ganv_box_set_width(port->control->rect, MAX(0.0, w - 1.0));
+#if 0
+ if (signal && _control->value == value)
+ signal = false;
+#endif
+
+ port->control->value = value;
+}
+
+void
+ganv_port_set_control_min(GanvPort* port,
+ float min)
+{
+ if (port->control) {
+ port->control->min = min;
+ ganv_port_set_control_value(port, port->control->value);
+ }
+}
+
+void
+ganv_port_set_control_max(GanvPort* port,
+ float max)
+{
+ if (port->control) {
+ port->control->max = max;
+ ganv_port_set_control_value(port, port->control->value);
+ }
+}
+
+double
+ganv_port_get_natural_width(const GanvPort* port)
+{
+ /*
+ Canvas* const canvas = _module->canvas();
+ if (canvas->direction() == Canvas::VERTICAL) {
+ return _module->empty_port_breadth();
+ } else*/
+ if (port->box.node.label) {
+ double label_w;
+ g_object_get(port->box.node.label, "width", &label_w, NULL);
+ return label_w + (PORT_LABEL_HPAD * 2.0);
+ } else {
+ //return _module->empty_port_depth();
+ return 4.0;
+ }
+}
+
+GanvModule*
+ganv_port_get_module(const GanvPort* port)
+{
+ return GANV_MODULE(GNOME_CANVAS_ITEM(port)->parent);
+}
diff --git a/src/text.c b/src/text.c
new file mode 100644
index 0000000..b239775
--- /dev/null
+++ b/src/text.c
@@ -0,0 +1,371 @@
+/* This file is part of Ganv.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * Ganv is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * Ganv is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Ganv. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <stdint.h>
+#include <string.h>
+#include <math.h>
+
+#include <gtk/gtkstyle.h>
+#include <libgnomecanvas/libgnomecanvas.h>
+
+#include "ganv/canvas.h"
+#include "ganv/text.h"
+
+#include "./color.h"
+#include "./boilerplate.h"
+#include "./gettext.h"
+
+G_DEFINE_TYPE(GanvText, ganv_text, GNOME_TYPE_CANVAS_ITEM)
+
+static GnomeCanvasItemClass* parent_class;
+
+enum {
+ PROP_0,
+ PROP_TEXT,
+ PROP_X,
+ PROP_Y,
+ PROP_WIDTH,
+ PROP_HEIGHT,
+ PROP_COLOR
+};
+
+static void
+ganv_text_init(GanvText* text)
+{
+ memset(&text->coords, '\0', sizeof(GanvTextCoords));
+ text->coords.width = 1.0;
+ text->coords.height = 1.0;
+ text->old_coords = text->coords;
+
+ text->surface = NULL;
+ text->text = NULL;
+ text->color = 0xFFFFFFFF;
+}
+
+static void
+ganv_text_destroy(GtkObject* object)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_TEXT(object));
+
+ GanvText* text = GANV_TEXT(object);
+
+ if (text->text) {
+ g_free(text->text);
+ text->text = NULL;
+ }
+
+ if (text->surface) {
+ cairo_surface_destroy(text->surface);
+ text->surface = NULL;
+ }
+
+ if (GTK_OBJECT_CLASS(parent_class)->destroy) {
+ (*GTK_OBJECT_CLASS(parent_class)->destroy)(object);
+ }
+}
+
+static void
+ganv_text_layout(GanvText* text)
+{
+ GnomeCanvasItem* item = GNOME_CANVAS_ITEM(text);
+ GanvCanvas* canvas = GANV_CANVAS(item->canvas);
+ GtkWidget* widget = GTK_WIDGET(canvas);
+ double font_size = ganv_canvas_get_font_size(canvas);
+ guint color = 0xFFFFFFFF;
+
+ GtkStyle* style = gtk_rc_get_style(widget);
+ PangoFontDescription* font = pango_font_description_copy(style->font_desc);
+ PangoLayout* layout = gtk_widget_create_pango_layout(widget, text->text);
+ PangoContext* context = pango_layout_get_context(layout);
+ cairo_font_options_t* options = cairo_font_options_copy(
+ pango_cairo_context_get_font_options(context));
+
+ pango_font_description_set_size(font, font_size * (double)PANGO_SCALE);
+ pango_layout_set_font_description(layout, font);
+
+ if (cairo_font_options_get_antialias(options) == CAIRO_ANTIALIAS_SUBPIXEL) {
+ cairo_font_options_set_antialias(options, CAIRO_ANTIALIAS_GRAY);
+ }
+
+ pango_cairo_context_set_font_options(context, options);
+ cairo_font_options_destroy(options);
+
+ int width, height;
+ pango_layout_get_pixel_size(layout, &width, &height);
+
+ text->coords.width = width;
+ text->coords.height = height;
+
+ if (text->surface) {
+ cairo_surface_destroy(text->surface);
+ }
+
+ text->surface = cairo_image_surface_create(
+ CAIRO_FORMAT_ARGB32, width, height);
+
+ cairo_t* cr = cairo_create(text->surface);
+
+ double r, g, b, a;
+ color_to_rgba(color, &r, &g, &b, &a);
+
+ cairo_set_source_rgba(cr, r, g, b, a);
+ cairo_move_to(cr, 0, 0);
+ pango_cairo_show_layout(cr, layout);
+
+ cairo_destroy(cr);
+ g_object_unref(layout);
+ pango_font_description_free(font);
+
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(text));
+}
+
+static void
+ganv_text_set_property(GObject* object,
+ guint prop_id,
+ const GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_TEXT(object));
+
+ GanvText* text = GANV_TEXT(object);
+
+ switch (prop_id) {
+ SET_CASE(X, double, text->coords.x);
+ SET_CASE(Y, double, text->coords.y);
+ SET_CASE(WIDTH, double, text->coords.width);
+ SET_CASE(HEIGHT, double, text->coords.height);
+ SET_CASE(COLOR, uint, text->color)
+ case PROP_TEXT:
+ free(text->text);
+ text->text = g_value_dup_string(value);
+ ganv_text_layout(text);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_text_get_property(GObject* object,
+ guint prop_id,
+ GValue* value,
+ GParamSpec* pspec)
+{
+ g_return_if_fail(object != NULL);
+ g_return_if_fail(GANV_IS_TEXT(object));
+
+ GanvText* text = GANV_TEXT(object);
+
+ switch (prop_id) {
+ GET_CASE(TEXT, string, text->text)
+ GET_CASE(X, double, text->coords.x);
+ GET_CASE(Y, double, text->coords.y);
+ GET_CASE(WIDTH, double, text->coords.width);
+ GET_CASE(HEIGHT, double, text->coords.height);
+ GET_CASE(COLOR, uint, text->color)
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+ganv_text_bounds_item(GnomeCanvasItem* item,
+ double* x1, double* y1,
+ double* x2, double* y2)
+{
+ GanvText* text = GANV_TEXT(item);
+
+ *x1 = MIN(text->coords.x, text->coords.x + text->coords.width);
+ *y1 = MIN(text->coords.y, text->coords.y + text->coords.height);
+ *x2 = MAX(text->coords.x, text->coords.x + text->coords.width);
+ *y2 = MAX(text->coords.y, text->coords.y + text->coords.height);
+}
+
+static void
+ganv_text_bounds(GnomeCanvasItem* item,
+ double* x1, double* y1,
+ double* x2, double* y2)
+{
+ ganv_text_bounds_item(item, x1, y1, x2, y2);
+ gnome_canvas_item_i2w(item->parent, x1, y1);
+ gnome_canvas_item_i2w(item->parent, x2, y2);
+}
+
+static void
+ganv_text_update(GnomeCanvasItem* item,
+ double* affine,
+ ArtSVP* clip_path,
+ int flags)
+{
+ double x1, y1, x2, y2;
+ ganv_text_bounds(item, &x1, &y1, &x2, &y2);
+ gnome_canvas_request_redraw(item->canvas, x1, y1, x2, y2);
+
+ // I have no idea why this is necessary
+ item->x1 = x1;
+ item->y1 = y1;
+ item->x2 = x2;
+ item->y2 = y2;
+
+ parent_class->update(item, affine, clip_path, flags);
+}
+
+static double
+ganv_text_point(GnomeCanvasItem* item,
+ double x, double y,
+ int cx, int cy,
+ GnomeCanvasItem** actual_item)
+{
+ *actual_item = NULL;
+
+ double x1, y1, x2, y2;
+ ganv_text_bounds_item(item, &x1, &y1, &x2, &y2);
+ if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2)) {
+ return 0.0;
+ }
+
+ // Point is outside the box
+ double dx, dy;
+
+ // Find horizontal distance to nearest edge
+ if (x < x1) {
+ dx = x1 - x;
+ } else if (x > x2) {
+ dx = x - x2;
+ } else {
+ dx = 0.0;
+ }
+
+ // Find vertical distance to nearest edge
+ if (y < y1) {
+ dy = y1 - y;
+ } else if (y > y2) {
+ dy = y - y2;
+ } else {
+ dy = 0.0;
+ }
+
+ return sqrt((dx * dx) + (dy * dy));
+}
+
+static void
+ganv_text_render(GnomeCanvasItem* item,
+ GnomeCanvasBuf* buf)
+{
+ // Not implemented
+}
+
+static void
+ganv_text_draw(GnomeCanvasItem* item,
+ GdkDrawable* drawable,
+ int x, int y,
+ int width, int height)
+{
+ GanvText* text = GANV_TEXT(item);
+ cairo_t* cr = gdk_cairo_create(drawable);
+
+ double wx = text->coords.x;
+ double wy = text->coords.y;
+ gnome_canvas_item_i2w(item, &wx, &wy);
+
+ // Round to the nearest pixel so text isn't blurry
+ wx = lrint(wx - x);
+ wy = lrint(wy - y);
+
+ cairo_set_source_surface(cr, text->surface, wx, wy);
+ cairo_paint(cr);
+
+ cairo_destroy(cr);
+}
+
+static void
+ganv_text_class_init(GanvTextClass* class)
+{
+ GObjectClass* gobject_class = (GObjectClass*)class;
+ GtkObjectClass* object_class = (GtkObjectClass*)class;
+ GnomeCanvasItemClass* item_class = (GnomeCanvasItemClass*)class;
+
+ parent_class = GNOME_CANVAS_ITEM_CLASS(g_type_class_peek_parent(class));
+
+ gobject_class->set_property = ganv_text_set_property;
+ gobject_class->get_property = ganv_text_get_property;
+
+ g_object_class_install_property(
+ gobject_class, PROP_TEXT, g_param_spec_string(
+ "text",
+ _("text"),
+ _("the text to display"),
+ NULL,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_X, g_param_spec_double(
+ "x",
+ _("x"),
+ _("x coordinate"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_Y, g_param_spec_double(
+ "y",
+ _("y"),
+ _("y coordinate"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_WIDTH, g_param_spec_double(
+ "width",
+ _("width"),
+ _("width"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 1.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_HEIGHT, g_param_spec_double(
+ "height",
+ _("height"),
+ _("height"),
+ -G_MAXDOUBLE, G_MAXDOUBLE,
+ 1.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property(
+ gobject_class, PROP_COLOR, g_param_spec_uint(
+ "color",
+ _("color"),
+ _("the color of the text"),
+ 0, G_MAXUINT,
+ DEFAULT_TEXT_COLOR,
+ G_PARAM_READWRITE));
+
+ object_class->destroy = ganv_text_destroy;
+
+ item_class->update = ganv_text_update;
+ item_class->bounds = ganv_text_bounds;
+ item_class->point = ganv_text_point;
+ item_class->render = ganv_text_render;
+ item_class->draw = ganv_text_draw;
+}
diff --git a/waf b/waf
new file mode 100755
index 0000000..d121e23
--- /dev/null
+++ b/waf
Binary files differ
diff --git a/wscript b/wscript
new file mode 100644
index 0000000..81c578e
--- /dev/null
+++ b/wscript
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+import os
+import waflib.Options as Options
+from waflib.extras import autowaf as autowaf
+
+# Version of this package (even if built as a child)
+GANV_VERSION = '1.2.0'
+GANV_MAJOR_VERSION = '1'
+
+# Library version (UNIX style major, minor, micro)
+# major increment <=> incompatible changes
+# minor increment <=> compatible changes (additions)
+# micro increment <=> no interface changes
+# Ganv as of 1.0.0 uses the same version number for both library and package
+GANV_LIB_VERSION = GANV_VERSION
+
+# Variables for 'waf dist'
+APPNAME = 'ganv'
+VERSION = GANV_VERSION
+
+# Mandatory variables
+top = '.'
+out = 'build'
+
+def options(opt):
+ opt.load('compiler_c')
+ opt.load('compiler_cxx')
+ autowaf.set_options(opt)
+ opt.add_option('--no-graphviz', action='store_true', default=False,
+ dest='no_graphviz',
+ help='Do not compile with graphviz support')
+ opt.add_option('--no-nls', action='store_true', default=False, dest='no_nls',
+ help='Disable i18n (native language support)')
+ opt.add_option('--gir', action='store_true', default=False, dest='gir',
+ help='Build GObject introspection data')
+
+def configure(conf):
+ conf.load('compiler_c')
+ conf.load('compiler_cxx')
+ autowaf.configure(conf)
+ conf.line_just = 44
+ autowaf.display_header('Ganv Configuration')
+
+ conf.env.append_unique('CFLAGS', '-std=c99')
+
+ autowaf.check_pkg(conf, 'gtkmm-2.4', uselib_store='GTKMM',
+ atleast_version='2.10.0', mandatory=True)
+ autowaf.check_pkg(conf, 'libgnomecanvas-2.0', uselib_store='GNOMECANVAS',
+ atleast_version='2.0.0', mandatory=True)
+
+ if Options.options.gir:
+ autowaf.check_pkg(conf, 'gobject-introspection-1.0',
+ uselib_store='GIR', mandatory=False)
+
+ if not Options.options.no_graphviz:
+ autowaf.check_pkg(conf, 'libgvc', uselib_store='AGRAPH',
+ atleast_version='2.8', mandatory=False)
+
+ if not Options.options.no_nls:
+ autowaf.check_header(conf, 'c', 'libintl.h', 'ENABLE_NLS', mandatory=False)
+
+ conf.env['LIB_GANV'] = ['ganv-%s' % GANV_MAJOR_VERSION]
+
+ conf.write_config_header('ganv-config.h', remove=False)
+
+ autowaf.display_msg(conf, "Auto-arrange", conf.is_defined('HAVE_AGRAPH'))
+ autowaf.display_msg(conf, "Native language support", conf.is_defined('ENABLE_NLS'))
+ autowaf.display_msg(conf, "GObject introspection", conf.is_defined('HAVE_GIR'))
+ print('')
+
+ganv_source = [
+ 'src/Canvas.cpp',
+ 'src/Port.cpp',
+ 'src/box.c',
+ 'src/circle.c',
+ 'src/edge.c',
+ 'src/module.c',
+ 'src/node.c',
+ 'src/port.c',
+ 'src/text.c'
+]
+
+def build(bld):
+ # Headers
+ includedir = '${INCLUDEDIR}/ganv-%s/ganv' % GANV_MAJOR_VERSION
+ bld.install_files(includedir, bld.path.ant_glob('ganv/*.h*'))
+
+ # Pkgconfig file
+ autowaf.build_pc(bld, 'GANV', GANV_VERSION, GANV_MAJOR_VERSION,
+ 'AGRAPH GLIBMM GNOMECANVAS',
+ {'GANV_MAJOR_VERSION' : GANV_MAJOR_VERSION})
+
+ # Library
+ obj = bld(features = 'c cshlib cxx cxxshlib')
+ obj.export_includes = ['.']
+ obj.source = ganv_source
+ obj.includes = ['.', './src']
+ obj.name = 'libganv'
+ obj.target = 'ganv-%s' % GANV_MAJOR_VERSION
+ obj.uselib = 'GTKMM GNOMECANVAS AGRAPH'
+ obj.vnum = GANV_LIB_VERSION
+ obj.install_path = '${LIBDIR}'
+
+ # Benchmark program
+ obj = bld(features = 'cxx cxxprogram',
+ source = 'src/ganv_bench.cpp',
+ includes = ['.', './src'],
+ use = 'libganv',
+ use_lib = 'GTKMM',
+ target = 'src/ganv_bench')
+
+ # Documentation
+ autowaf.build_dox(bld, 'GANV', GANV_VERSION, top, out)
+
+ if bld.is_defined('HAVE_GIR'):
+ bld.add_group()
+
+ top_level = (len(bld.stack_path) > 1)
+ bld_dir = os.path.join(out, APPNAME) if top_level else out
+ pc_path = os.path.abspath(os.path.join(bld_dir, 'ganv-1.pc'))
+
+ gir = bld(
+ name = 'ganv-gir',
+ source = ganv_source + bld.path.ant_glob('ganv/*.h'),
+ target = 'Ganv-1.0.gir',
+ install_path = '${LIBDIR}/girepository-1.0',
+ rule = 'g-ir-scanner --warn-all -n Ganv --nsversion=1.0'
+ ' --no-libtool ' +
+ ('--pkg=%s' % pc_path) +
+ (' -I%s' % bld.path.bldpath()) +
+ (' -L%s' % bld_dir) +
+ ' --library=ganv-1'
+ ' --include=GObject-2.0 --include=Gdk-2.0 --include Gtk-2.0'
+ ' -o ${TGT} ${SRC}')
+
+ typelib = bld(
+ name = 'ganv-typelib',
+ after = 'ganv-gir',
+ source = 'Ganv-1.0.gir',
+ target = 'Ganv-1.0.typelib',
+ install_path = '${LIBDIR}/girepository-1.0',
+ rule = 'g-ir-compiler ${SRC} -o ${TGT}')
+
+ bld.add_post_fun(autowaf.run_ldconfig)
+
+def i18n(bld):
+ autowaf.build_i18n(bld, '..', 'ganv', APPNAME, ganv_source,
+ 'David Robillard')