Import
git-svn-id: file:///home/vcs/svn/jsweeper/trunk@1 6611ac79-6612-48ef-a1e9-b906f853523emaster
commit
8b10f1bc33
|
@ -0,0 +1,43 @@
|
||||||
|
cmake_minimum_required(VERSION 2.0)
|
||||||
|
|
||||||
|
PROJECT(jsweeper)
|
||||||
|
|
||||||
|
INCLUDE( ${CMAKE_ROOT}/Modules/FindPkgConfig.cmake )
|
||||||
|
INCLUDE( ${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake )
|
||||||
|
|
||||||
|
pkg_check_modules(JACK jack>=0.118)
|
||||||
|
pkg_check_modules(GTKMM gtkmm-2.4>=2.4)
|
||||||
|
pkg_check_modules(CAIROMM cairomm-1.0>=1.0)
|
||||||
|
|
||||||
|
SET(SOURCES
|
||||||
|
src/gui.cpp
|
||||||
|
src/gui.h
|
||||||
|
src/jack.cpp
|
||||||
|
src/jack.h
|
||||||
|
src/jsweeper.cpp
|
||||||
|
src/port.cpp
|
||||||
|
src/port.h
|
||||||
|
src/portmanager.cpp
|
||||||
|
src/portmanager.h
|
||||||
|
)
|
||||||
|
|
||||||
|
LINK_DIRECTORIES(
|
||||||
|
${JACK_LIBRARY_DIRS}
|
||||||
|
${GTKMM_LIBRARY_DIRS}
|
||||||
|
${CAIROMM_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
INCLUDE_DIRECTORIES(
|
||||||
|
${JACK_INCLUDE_DIRS}
|
||||||
|
${GTKMM_INCLUDE_DIRS}
|
||||||
|
${CAIROMM_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-g -Wall -Wextra -ansi -pedantic)
|
||||||
|
ADD_EXECUTABLE(jsweeper ${SOURCES})
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(jsweeper
|
||||||
|
${JACK_LIBRARIES}
|
||||||
|
${GTKMM_LIBRARIES}
|
||||||
|
${CAIROMM_LIBRARIES}
|
||||||
|
)
|
|
@ -0,0 +1,4 @@
|
||||||
|
mplex is copyright (c) 2009 Peter Nelson.
|
||||||
|
|
||||||
|
This software is licensed under the GNU General Public License version 2.
|
||||||
|
Please see the included file GPL-2 for full license terms.
|
|
@ -0,0 +1,339 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 2, June 1991
|
||||||
|
|
||||||
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The licenses for most software are designed to take away your
|
||||||
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
License is intended to guarantee your freedom to share and change free
|
||||||
|
software--to make sure the software is free for all its users. This
|
||||||
|
General Public License applies to most of the Free Software
|
||||||
|
Foundation's software and to any other program whose authors commit to
|
||||||
|
using it. (Some other Free Software Foundation software is covered by
|
||||||
|
the GNU Lesser General Public License instead.) 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
|
||||||
|
this service 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 make restrictions that forbid
|
||||||
|
anyone to deny you these rights or to ask you to surrender the rights.
|
||||||
|
These restrictions translate to certain responsibilities for you if you
|
||||||
|
distribute copies of the software, or if you modify it.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must give the recipients all the rights that
|
||||||
|
you have. 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.
|
||||||
|
|
||||||
|
We protect your rights with two steps: (1) copyright the software, and
|
||||||
|
(2) offer you this license which gives you legal permission to copy,
|
||||||
|
distribute and/or modify the software.
|
||||||
|
|
||||||
|
Also, for each author's protection and ours, we want to make certain
|
||||||
|
that everyone understands that there is no warranty for this free
|
||||||
|
software. If the software is modified by someone else and passed on, we
|
||||||
|
want its recipients to know that what they have is not the original, so
|
||||||
|
that any problems introduced by others will not reflect on the original
|
||||||
|
authors' reputations.
|
||||||
|
|
||||||
|
Finally, any free program is threatened constantly by software
|
||||||
|
patents. We wish to avoid the danger that redistributors of a free
|
||||||
|
program will individually obtain patent licenses, in effect making the
|
||||||
|
program proprietary. To prevent this, we have made it clear that any
|
||||||
|
patent must be licensed for everyone's free use or not licensed at all.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
|
0. This License applies to any program or other work which contains
|
||||||
|
a notice placed by the copyright holder saying it may be distributed
|
||||||
|
under the terms of this General Public License. The "Program", below,
|
||||||
|
refers to any such program or work, and a "work based on the Program"
|
||||||
|
means either the Program or any derivative work under copyright law:
|
||||||
|
that is to say, a work containing the Program or a portion of it,
|
||||||
|
either verbatim or with modifications and/or translated into another
|
||||||
|
language. (Hereinafter, translation is included without limitation in
|
||||||
|
the term "modification".) Each licensee is addressed as "you".
|
||||||
|
|
||||||
|
Activities other than copying, distribution and modification are not
|
||||||
|
covered by this License; they are outside its scope. The act of
|
||||||
|
running the Program is not restricted, and the output from the Program
|
||||||
|
is covered only if its contents constitute a work based on the
|
||||||
|
Program (independent of having been made by running the Program).
|
||||||
|
Whether that is true depends on what the Program does.
|
||||||
|
|
||||||
|
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
|
||||||
|
notices that refer to this License and to the absence of any warranty;
|
||||||
|
and give any other recipients of the Program a copy of this License
|
||||||
|
along with the Program.
|
||||||
|
|
||||||
|
You may charge a fee for the physical act of transferring a copy, and
|
||||||
|
you may at your option offer warranty protection in exchange for a fee.
|
||||||
|
|
||||||
|
2. You may modify your copy or copies of the Program or any portion
|
||||||
|
of it, thus forming a work based on the Program, and copy and
|
||||||
|
distribute such modifications or work under the terms of Section 1
|
||||||
|
above, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) You must cause the modified files to carry prominent notices
|
||||||
|
stating that you changed the files and the date of any change.
|
||||||
|
|
||||||
|
b) You must cause any work that you distribute or publish, that in
|
||||||
|
whole or in part contains or is derived from the Program or any
|
||||||
|
part thereof, to be licensed as a whole at no charge to all third
|
||||||
|
parties under the terms of this License.
|
||||||
|
|
||||||
|
c) If the modified program normally reads commands interactively
|
||||||
|
when run, you must cause it, when started running for such
|
||||||
|
interactive use in the most ordinary way, to print or display an
|
||||||
|
announcement including an appropriate copyright notice and a
|
||||||
|
notice that there is no warranty (or else, saying that you provide
|
||||||
|
a warranty) and that users may redistribute the program under
|
||||||
|
these conditions, and telling the user how to view a copy of this
|
||||||
|
License. (Exception: if the Program itself is interactive but
|
||||||
|
does not normally print such an announcement, your work based on
|
||||||
|
the Program is not required to print an announcement.)
|
||||||
|
|
||||||
|
These requirements apply to the modified work as a whole. If
|
||||||
|
identifiable sections of that work are not derived from the Program,
|
||||||
|
and can be reasonably considered independent and separate works in
|
||||||
|
themselves, then this License, and its terms, do not apply to those
|
||||||
|
sections when you distribute them as separate works. But when you
|
||||||
|
distribute the same sections as part of a whole which is a work based
|
||||||
|
on the Program, the distribution of the whole must be on the terms of
|
||||||
|
this License, whose permissions for other licensees extend to the
|
||||||
|
entire whole, and thus to each and every part regardless of who wrote it.
|
||||||
|
|
||||||
|
Thus, it is not the intent of this section to claim rights or contest
|
||||||
|
your rights to work written entirely by you; rather, the intent is to
|
||||||
|
exercise the right to control the distribution of derivative or
|
||||||
|
collective works based on the Program.
|
||||||
|
|
||||||
|
In addition, mere aggregation of another work not based on the Program
|
||||||
|
with the Program (or with a work based on the Program) on a volume of
|
||||||
|
a storage or distribution medium does not bring the other work under
|
||||||
|
the scope of this License.
|
||||||
|
|
||||||
|
3. You may copy and distribute the Program (or a work based on it,
|
||||||
|
under Section 2) in object code or executable form under the terms of
|
||||||
|
Sections 1 and 2 above provided that you also do one of the following:
|
||||||
|
|
||||||
|
a) Accompany it with the complete corresponding machine-readable
|
||||||
|
source code, which must be distributed under the terms of Sections
|
||||||
|
1 and 2 above on a medium customarily used for software interchange; or,
|
||||||
|
|
||||||
|
b) Accompany it with a written offer, valid for at least three
|
||||||
|
years, to give any third party, for a charge no more than your
|
||||||
|
cost of physically performing source distribution, a complete
|
||||||
|
machine-readable copy of the corresponding source code, to be
|
||||||
|
distributed under the terms of Sections 1 and 2 above on a medium
|
||||||
|
customarily used for software interchange; or,
|
||||||
|
|
||||||
|
c) Accompany it with the information you received as to the offer
|
||||||
|
to distribute corresponding source code. (This alternative is
|
||||||
|
allowed only for noncommercial distribution and only if you
|
||||||
|
received the program in object code or executable form with such
|
||||||
|
an offer, in accord with Subsection b above.)
|
||||||
|
|
||||||
|
The source code for a work means the preferred form of the work for
|
||||||
|
making modifications to it. For an executable work, complete source
|
||||||
|
code means all the source code for all modules it contains, plus any
|
||||||
|
associated interface definition files, plus the scripts used to
|
||||||
|
control compilation and installation of the executable. However, as a
|
||||||
|
special exception, the source code distributed need not include
|
||||||
|
anything that is normally distributed (in either source or binary
|
||||||
|
form) with the major components (compiler, kernel, and so on) of the
|
||||||
|
operating system on which the executable runs, unless that component
|
||||||
|
itself accompanies the executable.
|
||||||
|
|
||||||
|
If distribution of executable or object code is made by offering
|
||||||
|
access to copy from a designated place, then offering equivalent
|
||||||
|
access to copy the source code from the same place counts as
|
||||||
|
distribution of the source code, even though third parties are not
|
||||||
|
compelled to copy the source along with the object code.
|
||||||
|
|
||||||
|
4. You may not copy, modify, sublicense, or distribute the Program
|
||||||
|
except as expressly provided under this License. Any attempt
|
||||||
|
otherwise to copy, modify, sublicense or distribute the Program is
|
||||||
|
void, and will automatically terminate your rights under this License.
|
||||||
|
However, parties who have received copies, or rights, from you under
|
||||||
|
this License will not have their licenses terminated so long as such
|
||||||
|
parties remain in full compliance.
|
||||||
|
|
||||||
|
5. You are not required to accept this License, since you have not
|
||||||
|
signed it. However, nothing else grants you permission to modify or
|
||||||
|
distribute the Program or its derivative works. These actions are
|
||||||
|
prohibited by law if you do not accept this License. Therefore, by
|
||||||
|
modifying or distributing the Program (or any work based on the
|
||||||
|
Program), you indicate your acceptance of this License to do so, and
|
||||||
|
all its terms and conditions for copying, distributing or modifying
|
||||||
|
the Program or works based on it.
|
||||||
|
|
||||||
|
6. Each time you redistribute the Program (or any work based on the
|
||||||
|
Program), the recipient automatically receives a license from the
|
||||||
|
original licensor to copy, distribute or modify the Program subject to
|
||||||
|
these terms and conditions. You may not impose any further
|
||||||
|
restrictions on the recipients' exercise of the rights granted herein.
|
||||||
|
You are not responsible for enforcing compliance by third parties to
|
||||||
|
this License.
|
||||||
|
|
||||||
|
7. If, as a consequence of a court judgment or allegation of patent
|
||||||
|
infringement or for any other reason (not limited to patent issues),
|
||||||
|
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
|
||||||
|
distribute so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you
|
||||||
|
may not distribute the Program at all. For example, if a patent
|
||||||
|
license would not permit royalty-free redistribution of the Program by
|
||||||
|
all those who receive copies directly or indirectly through you, then
|
||||||
|
the only way you could satisfy both it and this License would be to
|
||||||
|
refrain entirely from distribution of the Program.
|
||||||
|
|
||||||
|
If any portion of this section is held invalid or unenforceable under
|
||||||
|
any particular circumstance, the balance of the section is intended to
|
||||||
|
apply and the section as a whole is intended to apply in other
|
||||||
|
circumstances.
|
||||||
|
|
||||||
|
It is not the purpose of this section to induce you to infringe any
|
||||||
|
patents or other property right claims or to contest validity of any
|
||||||
|
such claims; this section has the sole purpose of protecting the
|
||||||
|
integrity of the free software distribution system, which is
|
||||||
|
implemented by public license practices. Many people have made
|
||||||
|
generous contributions to the wide range of software distributed
|
||||||
|
through that system in reliance on consistent application of that
|
||||||
|
system; it is up to the author/donor to decide if he or she is willing
|
||||||
|
to distribute software through any other system and a licensee cannot
|
||||||
|
impose that choice.
|
||||||
|
|
||||||
|
This section is intended to make thoroughly clear what is believed to
|
||||||
|
be a consequence of the rest of this License.
|
||||||
|
|
||||||
|
8. If the distribution and/or use of the Program is restricted in
|
||||||
|
certain countries either by patents or by copyrighted interfaces, the
|
||||||
|
original copyright holder who places the Program under this License
|
||||||
|
may add an explicit geographical distribution limitation excluding
|
||||||
|
those countries, so that distribution is permitted only in or among
|
||||||
|
countries not thus excluded. In such case, this License incorporates
|
||||||
|
the limitation as if written in the body of this License.
|
||||||
|
|
||||||
|
9. The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the 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 a version number of this License which applies to it and "any
|
||||||
|
later version", you have the option of following the terms and conditions
|
||||||
|
either of that version or of any later version published by the Free
|
||||||
|
Software Foundation. If the Program does not specify a version number of
|
||||||
|
this License, you may choose any version ever published by the Free Software
|
||||||
|
Foundation.
|
||||||
|
|
||||||
|
10. If you wish to incorporate parts of the Program into other free
|
||||||
|
programs whose distribution conditions are different, write to the author
|
||||||
|
to ask for permission. For software which is copyrighted by the Free
|
||||||
|
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||||
|
make exceptions for this. Our decision will be guided by the two goals
|
||||||
|
of preserving the free status of all derivatives of our free software and
|
||||||
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
|
NO WARRANTY
|
||||||
|
|
||||||
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
|
||||||
|
|
||||||
|
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||||
|
REDISTRIBUTE 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.
|
||||||
|
|
||||||
|
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
|
||||||
|
convey 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 2 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, write to the Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program is interactive, make it output a short notice like this
|
||||||
|
when it starts in an interactive mode:
|
||||||
|
|
||||||
|
Gnomovision version 69, Copyright (C) year name of author
|
||||||
|
Gnomovision 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, the commands you use may
|
||||||
|
be called something other than `show w' and `show c'; they could even be
|
||||||
|
mouse-clicks or menu items--whatever suits your program.
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or your
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. Here is a sample; alter the names:
|
||||||
|
|
||||||
|
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||||
|
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||||
|
|
||||||
|
<signature of Ty Coon>, 1 April 1989
|
||||||
|
Ty Coon, President of Vice
|
||||||
|
|
||||||
|
This 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.
|
|
@ -0,0 +1,11 @@
|
||||||
|
system:capture_1 system:record.L
|
||||||
|
system:capture_2 system:record.R
|
||||||
|
system:playback_1 system:playback.L
|
||||||
|
system:playback_2 system:playback.R
|
||||||
|
Rhythmbox:out_1 Rhythmbox:out.L
|
||||||
|
Rhythmbox:out_2 Rhythmbox:out.R
|
||||||
|
jack_rack:out_1 jack_rack:out.L
|
||||||
|
jack_rack:out_2 jack_rack:out.R
|
||||||
|
jack_rack:in_1 jack_rack:in.L
|
||||||
|
jack_rack:in_2 jack_rack:in.R
|
||||||
|
hexter\ DX7\ emulation(v0.6.1):hexter\ DX7\ emulation\ (v0.6.1)\ out_1 hexter:out
|
|
@ -0,0 +1,681 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <cmath>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include "jack.h"
|
||||||
|
#include "portmanager.h"
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
|
const Rect Rect::None = Rect(0, 0, -1, -1);
|
||||||
|
|
||||||
|
Matrix::Matrix() :
|
||||||
|
m_client_width(0), m_client_height(0), m_port_width(0), m_port_height(0), m_separation(0), m_padding(3),
|
||||||
|
m_font_size(10), m_typeface("Liberation Sans Bold")
|
||||||
|
{
|
||||||
|
set_size_request(0, 0);
|
||||||
|
show();
|
||||||
|
|
||||||
|
add_events(Gdk::BUTTON_PRESS_MASK);
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix::~Matrix()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Matrix::Refresh()
|
||||||
|
{
|
||||||
|
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||||
|
if (!window) return;
|
||||||
|
|
||||||
|
m_client_width = 0;
|
||||||
|
m_client_height = 0;
|
||||||
|
m_port_width = 0;
|
||||||
|
m_port_height = 0;
|
||||||
|
|
||||||
|
m_separation = 0;
|
||||||
|
|
||||||
|
pm.Sort();
|
||||||
|
|
||||||
|
int cols = 0;
|
||||||
|
int rows = 0;
|
||||||
|
|
||||||
|
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
|
||||||
|
cr->select_font_face(m_typeface, Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL);
|
||||||
|
cr->set_font_size(m_font_size);
|
||||||
|
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pm.m_ports.begin(); plit != pm.m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
p->rect = Rect::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClientList::iterator clit;
|
||||||
|
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||||
|
Client *c = *clit;
|
||||||
|
|
||||||
|
cr->get_text_extents(c->m_name, c->extents);
|
||||||
|
|
||||||
|
int width = c->extents.width + m_padding * 2;
|
||||||
|
if (c->m_is_input) {
|
||||||
|
if (width > m_client_height) m_client_height = width;
|
||||||
|
} else {
|
||||||
|
if (width > m_client_width) m_client_width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->extents.height > m_separation) m_separation = c->extents.height;
|
||||||
|
|
||||||
|
if (!c->m_expanded) {
|
||||||
|
if (c->m_is_input) {
|
||||||
|
cols++;
|
||||||
|
} else {
|
||||||
|
rows++;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
pg->rect = Rect::None;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
|
||||||
|
cr->get_text_extents(pg->m_name, pg->extents);
|
||||||
|
if (pg->extents.height > m_separation) m_separation = pg->extents.height;
|
||||||
|
|
||||||
|
if (!pg->m_expanded && pg->m_name != "") {
|
||||||
|
int width = pg->extents.width + m_padding * 2;
|
||||||
|
if (c->m_is_input) {
|
||||||
|
if (width > m_port_height) m_port_height = width;
|
||||||
|
cols++;
|
||||||
|
} else {
|
||||||
|
if (width > m_port_width) m_port_width = width;
|
||||||
|
rows++;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pg->m_ports.begin(); plit != pg->m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
|
||||||
|
cr->get_text_extents(p->m_name, p->extents);
|
||||||
|
|
||||||
|
int width = pg->extents.width + p->extents.width + m_padding * (pg->extents.width > 0 ? 4 : 2);
|
||||||
|
if (p->m_flags & JackPortIsInput) {
|
||||||
|
if (width > m_port_height) m_port_height = width;
|
||||||
|
cols++;
|
||||||
|
} else {
|
||||||
|
if (width > m_port_width) m_port_width = width;
|
||||||
|
rows++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->extents.height > m_separation) m_separation = p->extents.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pm.m_ports.begin(); plit != pm.m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
|
||||||
|
cr->get_text_extents(p->m_name, p->extents);
|
||||||
|
|
||||||
|
if (p->m_flags & JackPortIsInput) {
|
||||||
|
if (p->extents.width > m_port_height) m_port_height = p->extents.width;
|
||||||
|
} else {
|
||||||
|
if (p->extents.width > m_port_width) m_port_width = p->extents.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->extents.height > m_separation) m_separation = p->extents.height;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
m_separation += m_padding * 2;
|
||||||
|
|
||||||
|
// if (m_port_width > m_separation * 5) m_port_width = m_separation * 5;
|
||||||
|
// if (m_port_height > m_separation * 5) m_port_height = m_separation * 5;
|
||||||
|
|
||||||
|
int y = m_client_height + m_port_height + m_padding;
|
||||||
|
int x = m_client_width + m_port_width + m_padding;
|
||||||
|
|
||||||
|
across.clear();
|
||||||
|
down.clear();
|
||||||
|
|
||||||
|
Rect r;
|
||||||
|
|
||||||
|
// ClientList::iterator clit;
|
||||||
|
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||||
|
Client *c = *clit;
|
||||||
|
|
||||||
|
if (c->m_is_input) {
|
||||||
|
r.left = x;
|
||||||
|
r.top = m_padding;
|
||||||
|
r.width = -1;
|
||||||
|
r.height = m_client_height;
|
||||||
|
c->rect = r;
|
||||||
|
|
||||||
|
if (!c->m_expanded) {
|
||||||
|
c->rect.width = m_separation;
|
||||||
|
c->rect.height = m_client_height + m_port_height;
|
||||||
|
across.push_back(c);
|
||||||
|
x += m_separation;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
|
||||||
|
if (pg->m_name != "") {
|
||||||
|
r.left = x;
|
||||||
|
r.top = m_padding + m_client_height;
|
||||||
|
r.width = pg->m_expanded ? m_separation * pg->m_ports.size() : m_separation;
|
||||||
|
r.height = pg->m_expanded ? pg->extents.width + m_padding * 2 : m_port_height;
|
||||||
|
pg->rect = r;
|
||||||
|
|
||||||
|
if (!pg->m_expanded) {
|
||||||
|
c->rect.width = pg->rect.left - c->rect.left + m_separation;
|
||||||
|
across.push_back(pg);
|
||||||
|
x += m_separation;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
r.top += r.height;
|
||||||
|
r.width = m_separation;
|
||||||
|
r.height = m_port_height - r.height;
|
||||||
|
} else {
|
||||||
|
pg->rect = Rect::None;
|
||||||
|
|
||||||
|
r.top = m_padding + m_client_height;
|
||||||
|
r.width = m_separation;
|
||||||
|
r.height = m_port_height;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pg->m_ports.begin(); plit != pg->m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
|
||||||
|
r.left = x;
|
||||||
|
p->rect = r;
|
||||||
|
|
||||||
|
c->rect.width = p->rect.left - c->rect.left + m_separation;
|
||||||
|
if (pg->rect != Rect::None) {
|
||||||
|
pg->rect.width = p->rect.left - pg->rect.left + m_separation;
|
||||||
|
}
|
||||||
|
|
||||||
|
across.push_back(p);
|
||||||
|
x += m_separation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
r.left = m_padding;
|
||||||
|
r.top = y;
|
||||||
|
r.width = m_client_width;
|
||||||
|
r.height = -1;
|
||||||
|
c->rect = r;
|
||||||
|
|
||||||
|
if (!c->m_expanded) {
|
||||||
|
c->rect.width = m_client_width + m_port_width;
|
||||||
|
c->rect.height = m_separation;
|
||||||
|
down.push_back(c);
|
||||||
|
y += m_separation;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
|
||||||
|
if (pg->m_name != "") {
|
||||||
|
r.left = m_padding + m_client_width;
|
||||||
|
r.top = y;
|
||||||
|
r.width = pg->m_expanded ? pg->extents.width + m_padding * 2 : m_port_width;
|
||||||
|
r.height = pg->m_expanded ? m_separation * pg->m_ports.size() : m_separation;
|
||||||
|
pg->rect = r;
|
||||||
|
|
||||||
|
if (!pg->m_expanded) {
|
||||||
|
c->rect.height = pg->rect.top - c->rect.top + m_separation;
|
||||||
|
down.push_back(pg);
|
||||||
|
y += m_separation;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
r.left += r.width;
|
||||||
|
r.width = m_port_width - r.width;
|
||||||
|
r.height = m_separation;
|
||||||
|
} else {
|
||||||
|
pg->rect = Rect::None;
|
||||||
|
|
||||||
|
r.left = m_padding + m_client_width;
|
||||||
|
r.width = m_port_width;
|
||||||
|
r.height = m_separation;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pg->m_ports.begin(); plit != pg->m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
|
||||||
|
r.top = y;
|
||||||
|
p->rect = r;
|
||||||
|
|
||||||
|
c->rect.height = p->rect.top - c->rect.top + m_separation;
|
||||||
|
if (pg->rect != Rect::None) {
|
||||||
|
pg->rect.height = p->rect.top - pg->rect.top + m_separation;
|
||||||
|
}
|
||||||
|
|
||||||
|
down.push_back(p);
|
||||||
|
y += m_separation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int w = m_padding * 2 + m_client_width + m_port_width;
|
||||||
|
int h = m_padding * 2 + m_client_height + m_port_height;
|
||||||
|
|
||||||
|
w += cols * m_separation;
|
||||||
|
h += rows * m_separation;
|
||||||
|
|
||||||
|
m_width = w;
|
||||||
|
m_height = h;
|
||||||
|
|
||||||
|
set_size_request(w, h);
|
||||||
|
parent->set_size_request(w + 20, h + 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Matrix::Box(Cairo::RefPtr<Cairo::Context> cr, float r, float g, float b, Rect &rect)
|
||||||
|
{
|
||||||
|
cr->set_source_rgb(r, g, b);
|
||||||
|
cr->rectangle(rect.left, rect.top, rect.width, rect.height);
|
||||||
|
cr->fill();
|
||||||
|
|
||||||
|
cr->set_source_rgb(0.75, 0.75, 0.75);
|
||||||
|
cr->rectangle(rect.left, rect.top, rect.width, rect.height);
|
||||||
|
cr->stroke();
|
||||||
|
|
||||||
|
cr->set_source_rgb(1, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Matrix::on_expose_event(GdkEventExpose *event)
|
||||||
|
{
|
||||||
|
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||||
|
if (!window) return true;
|
||||||
|
|
||||||
|
if (m_client_width == 0) Refresh();
|
||||||
|
|
||||||
|
Gtk::Allocation allocation = get_allocation();
|
||||||
|
const int alloc_width = allocation.get_width();
|
||||||
|
const int alloc_height = allocation.get_height();
|
||||||
|
|
||||||
|
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
|
||||||
|
cr->set_line_width(1.0);
|
||||||
|
cr->set_antialias(Cairo::ANTIALIAS_NONE);
|
||||||
|
|
||||||
|
// Set clipping area
|
||||||
|
cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
|
||||||
|
cr->clip();
|
||||||
|
|
||||||
|
// Clear background
|
||||||
|
cr->set_source_rgb(0.25, 0.25, 0.25);
|
||||||
|
cr->rectangle(0, 0, alloc_width, alloc_height);
|
||||||
|
cr->fill();
|
||||||
|
|
||||||
|
cr->set_source_rgb(1, 1, 1);
|
||||||
|
cr->select_font_face(m_typeface, Cairo::FONT_SLANT_NORMAL, Cairo::FONT_WEIGHT_NORMAL);
|
||||||
|
cr->set_font_size(m_font_size);
|
||||||
|
|
||||||
|
Rect tr;
|
||||||
|
Rect &r = tr;
|
||||||
|
|
||||||
|
ClientList::iterator clit;
|
||||||
|
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||||
|
Client *c = *clit;
|
||||||
|
r = c->rect;
|
||||||
|
|
||||||
|
if (c->m_is_input) {
|
||||||
|
Box(cr, BACK_COLOUR, r);
|
||||||
|
|
||||||
|
cr->save();
|
||||||
|
cr->move_to(r.left + m_padding - c->extents.y_bearing, r.top + r.height - m_padding - c->extents.x_bearing);
|
||||||
|
cr->rotate(2 * M_PI * 0.75);
|
||||||
|
cr->show_text(c->m_name);
|
||||||
|
cr->restore();
|
||||||
|
|
||||||
|
if (!c->m_expanded) {
|
||||||
|
cr->set_source_rgb(GRID_CLIENT);
|
||||||
|
cr->move_to(r.left + r.width, r.top + r.height);
|
||||||
|
cr->line_to(r.left + r.width, m_height - m_padding);
|
||||||
|
cr->stroke();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroupList::iterator pglast = c->m_groups.end();
|
||||||
|
--pglast;
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
r = pg->rect;
|
||||||
|
|
||||||
|
if (pg->m_name != "") {
|
||||||
|
Box(cr, GROUP_COLOUR, r);
|
||||||
|
|
||||||
|
cr->save();
|
||||||
|
cr->move_to(r.left + m_padding - pg->extents.y_bearing, r.top + r.height - m_padding - pg->extents.x_bearing);
|
||||||
|
cr->rotate(2 * M_PI * 0.75);
|
||||||
|
cr->show_text(pg->m_name);
|
||||||
|
cr->restore();
|
||||||
|
|
||||||
|
if (!pg->m_expanded) {
|
||||||
|
if (pglit == pglast) {
|
||||||
|
cr->set_source_rgb(GRID_CLIENT);
|
||||||
|
} else {
|
||||||
|
cr->set_source_rgb(GRID_GROUP);
|
||||||
|
}
|
||||||
|
cr->move_to(r.left + r.width, r.top + r.height);
|
||||||
|
cr->line_to(r.left + r.width, m_height - m_padding);
|
||||||
|
cr->stroke();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PortList::iterator plast = pg->m_ports.end();
|
||||||
|
--plast;
|
||||||
|
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pg->m_ports.begin(); plit != pg->m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
r = p->rect;
|
||||||
|
|
||||||
|
if (p->m_is_midi) {
|
||||||
|
Box(cr, MIDI_COLOUR, r);
|
||||||
|
} else {
|
||||||
|
Box(cr, AUDIO_COLOUR, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
cr->save();
|
||||||
|
cr->move_to(r.left + m_padding - p->extents.y_bearing, r.top + r.height - m_padding - p->extents.x_bearing);
|
||||||
|
cr->rotate(2 * M_PI * 0.75);
|
||||||
|
cr->show_text(p->m_name);
|
||||||
|
cr->restore();
|
||||||
|
|
||||||
|
if (pglit == pglast && plit == plast) {
|
||||||
|
cr->set_source_rgb(GRID_CLIENT);
|
||||||
|
} else if (plit == plast) {
|
||||||
|
cr->set_source_rgb(GRID_GROUP);
|
||||||
|
} else {
|
||||||
|
cr->set_source_rgb(GRID_PORT);
|
||||||
|
}
|
||||||
|
cr->move_to(r.left + r.width, r.top + r.height);
|
||||||
|
cr->line_to(r.left + r.width, m_height - m_padding);
|
||||||
|
cr->stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Box(cr, BACK_COLOUR, r);
|
||||||
|
|
||||||
|
cr->move_to(r.left + m_padding - c->extents.x_bearing, r.top + m_padding - c->extents.y_bearing);
|
||||||
|
cr->show_text(c->m_name);
|
||||||
|
|
||||||
|
if (!c->m_expanded) {
|
||||||
|
cr->set_source_rgb(GRID_CLIENT);
|
||||||
|
cr->move_to(r.left + r.width, r.top + r.height);
|
||||||
|
cr->line_to(m_width - m_padding, r.top + r.height);
|
||||||
|
cr->stroke();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroupList::iterator pglast = c->m_groups.end();
|
||||||
|
--pglast;
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
r = pg->rect;
|
||||||
|
|
||||||
|
if (pg->m_name != "") {
|
||||||
|
Box(cr, GROUP_COLOUR, r);
|
||||||
|
cr->move_to(r.left + m_padding - pg->extents.x_bearing, r.top + m_padding - pg->extents.y_bearing);
|
||||||
|
cr->show_text(pg->m_name);
|
||||||
|
|
||||||
|
if (!pg->m_expanded) {
|
||||||
|
if (pglit == pglast) {
|
||||||
|
cr->set_source_rgb(GRID_CLIENT);
|
||||||
|
} else {
|
||||||
|
cr->set_source_rgb(GRID_GROUP);
|
||||||
|
}
|
||||||
|
cr->move_to(r.left + r.width, r.top + r.height);
|
||||||
|
cr->line_to(m_width - m_padding, r.top + r.height);
|
||||||
|
cr->stroke();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PortList::iterator plast = pg->m_ports.end();
|
||||||
|
--plast;
|
||||||
|
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pg->m_ports.begin(); plit != pg->m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
r = p->rect;
|
||||||
|
|
||||||
|
if (p->m_is_midi) {
|
||||||
|
Box(cr, MIDI_COLOUR, r);
|
||||||
|
} else {
|
||||||
|
Box(cr, AUDIO_COLOUR, r);
|
||||||
|
}
|
||||||
|
|
||||||
|
cr->move_to(r.left + m_padding - p->extents.x_bearing, r.top + m_padding - p->extents.y_bearing);
|
||||||
|
cr->show_text(p->m_name);
|
||||||
|
|
||||||
|
if (pglit == pglast && plit == plast) {
|
||||||
|
cr->set_source_rgb(GRID_CLIENT);
|
||||||
|
} else if (plit == plast) {
|
||||||
|
cr->set_source_rgb(GRID_GROUP);
|
||||||
|
} else {
|
||||||
|
cr->set_source_rgb(GRID_PORT);
|
||||||
|
}
|
||||||
|
cr->move_to(r.left + r.width, r.top + r.height);
|
||||||
|
cr->line_to(m_width - m_padding, r.top + r.height);
|
||||||
|
cr->stroke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int x = m_client_width + m_port_width + m_padding;
|
||||||
|
BaseList::iterator bit1;
|
||||||
|
for (bit1 = across.begin(); bit1 != across.end(); ++bit1) {
|
||||||
|
BaseList::iterator bit2;
|
||||||
|
Base *b1 = *bit1;
|
||||||
|
|
||||||
|
int y = m_client_height + m_port_height + m_padding;
|
||||||
|
for (bit2 = down.begin(); bit2 != down.end(); ++bit2) {
|
||||||
|
Base *b2 = *bit2;
|
||||||
|
|
||||||
|
ConnectionMode cm = b1->ConnectedTo(b2);
|
||||||
|
|
||||||
|
if (cm != CM_NONE) {
|
||||||
|
// if (p1->m_is_midi) {
|
||||||
|
// cr->set_source_rgb(MIDI_COLOUR);
|
||||||
|
// } else {
|
||||||
|
cr->set_source_rgb(AUDIO_COLOUR);
|
||||||
|
// }
|
||||||
|
cr->rectangle(x + 1, y + 1, m_separation - 1, m_separation - 1);
|
||||||
|
cr->fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
y += m_separation;
|
||||||
|
}
|
||||||
|
|
||||||
|
x += m_separation;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
PortList::iterator plit1;
|
||||||
|
for (plit1 = pm.m_ports.begin(); plit1 != pm.m_ports.end(); ++plit1) {
|
||||||
|
Port *p1 = *plit1;
|
||||||
|
if (p1->pos == 0) continue;
|
||||||
|
PortList::iterator plit2;
|
||||||
|
for (plit2 = p1->m_connections.begin(); plit2 != p1->m_connections.end(); ++plit2) {
|
||||||
|
Port *p2 = *plit2;
|
||||||
|
if (p2->pos == 0) continue;
|
||||||
|
// cr->imove_to(p2->pos, p1->pos);
|
||||||
|
// cr->arc(p1->pos, p2->pos, (m_separation - m_padding * 2) / 2.0, 0, 2 * M_PI);
|
||||||
|
if (p1->m_is_midi) {
|
||||||
|
cr->set_source_rgb(MIDI_COLOUR);
|
||||||
|
} else {
|
||||||
|
cr->set_source_rgb(AUDIO_COLOUR);
|
||||||
|
}
|
||||||
|
cr->rectangle(p1->pos + 1, p2->pos + 1, m_separation - 1, m_separation - 1);
|
||||||
|
cr->fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Matrix::on_button_press_event(GdkEventButton *event)
|
||||||
|
{
|
||||||
|
// Check expandable boxes
|
||||||
|
ClientList::iterator clit;
|
||||||
|
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||||
|
Client *c = *clit;
|
||||||
|
if (c->rect.Hit(event->x, event->y)) {
|
||||||
|
c->m_expanded = !c->m_expanded;
|
||||||
|
Refresh();
|
||||||
|
queue_draw();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
if (pg->rect.Hit(event->x, event->y)) {
|
||||||
|
pg->m_expanded = !pg->m_expanded;
|
||||||
|
Refresh();
|
||||||
|
queue_draw();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Port *p1 = NULL;
|
||||||
|
Port *p2 = NULL;
|
||||||
|
|
||||||
|
// Check port hit
|
||||||
|
PortList::iterator plit;
|
||||||
|
for (plit = pm.m_ports.begin(); plit != pm.m_ports.end(); ++plit) {
|
||||||
|
Port *p = *plit;
|
||||||
|
|
||||||
|
if (p->rect.HitX(event->x)) p1 = p;
|
||||||
|
if (p->rect.HitY(event->y)) p2 = p;
|
||||||
|
|
||||||
|
if (p1 != NULL && p2 != NULL) {
|
||||||
|
pm.ToggleConnect(p1, p2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroup *pg1 = NULL;
|
||||||
|
PortGroup *pg2 = NULL;
|
||||||
|
|
||||||
|
for (clit = pm.m_clients.begin(); clit != pm.m_clients.end(); ++clit) {
|
||||||
|
Client *c = *clit;
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
|
||||||
|
if (pg->rect.HitX(event->x)) pg1 = pg;
|
||||||
|
if (pg->rect.HitY(event->y)) pg2 = pg;
|
||||||
|
|
||||||
|
if (p1 != NULL && pg2 != NULL) {
|
||||||
|
pm.ToggleConnect(p1, pg2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pg1 != NULL && p2 != NULL) {
|
||||||
|
pm.ToggleConnect(pg1, p2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (pg1 != NULL && pg2 != NULL) {
|
||||||
|
pm.ToggleConnect(pg1, pg2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << event->x << ", " << event->y << std::endl;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Gui::Gui()
|
||||||
|
{
|
||||||
|
set_title("JACK Sweeper");
|
||||||
|
set_border_width(0);
|
||||||
|
set_size_request(100, 100);
|
||||||
|
|
||||||
|
add(m_box);
|
||||||
|
|
||||||
|
m_scrolledwindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
||||||
|
m_scrolledwindow.set_border_width(0);
|
||||||
|
|
||||||
|
m_scrolledwindow.add(m_matrix);
|
||||||
|
m_matrix.parent = this;
|
||||||
|
|
||||||
|
Refresh();
|
||||||
|
|
||||||
|
Glib::signal_idle().connect(sigc::mem_fun(*this, &Gui::on_idle));
|
||||||
|
|
||||||
|
m_actiongroup = Gtk::ActionGroup::create();
|
||||||
|
m_actiongroup->add(Gtk::Action::create("MenuFile", "_File"));
|
||||||
|
m_actiongroup->add(Gtk::Action::create("Connect", "Connect"));
|
||||||
|
m_actiongroup->add(Gtk::Action::create("Disconnect", "Disconnect"));
|
||||||
|
m_actiongroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT));
|
||||||
|
|
||||||
|
m_uimanager = Gtk::UIManager::create();
|
||||||
|
m_uimanager->insert_action_group(m_actiongroup);
|
||||||
|
add_accel_group(m_uimanager->get_accel_group());
|
||||||
|
|
||||||
|
std::string ui_info =
|
||||||
|
"<ui>"
|
||||||
|
" <menubar name='MenuBar'>"
|
||||||
|
" <menu action='MenuFile'>"
|
||||||
|
" <menuitem action='Connect'/>"
|
||||||
|
" <menuitem action='Disconnect'/>"
|
||||||
|
" <separator/>"
|
||||||
|
" <menuitem action='Quit'/>"
|
||||||
|
" </menu>"
|
||||||
|
" </menubar>"
|
||||||
|
"</ui>";
|
||||||
|
m_uimanager->add_ui_from_string(ui_info);
|
||||||
|
|
||||||
|
Gtk::Widget *menubar = m_uimanager->get_widget("/MenuBar");
|
||||||
|
m_box.pack_start(*menubar, Gtk::PACK_SHRINK);
|
||||||
|
m_box.pack_start(m_scrolledwindow);
|
||||||
|
|
||||||
|
show_all_children();
|
||||||
|
}
|
||||||
|
|
||||||
|
Gui::~Gui()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void Gui::Refresh()
|
||||||
|
{
|
||||||
|
m_matrix.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Gui::on_idle()
|
||||||
|
{
|
||||||
|
if (jack.ProcessEvents()) {
|
||||||
|
Refresh();
|
||||||
|
queue_draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep(1000);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
#ifndef GUI_H
|
||||||
|
#define GUI_H
|
||||||
|
|
||||||
|
#include <gtkmm.h>
|
||||||
|
#include <list>
|
||||||
|
#include "rect.h"
|
||||||
|
|
||||||
|
#define BACK_COLOUR 0.1020, 0.1059, 0.1059
|
||||||
|
#define MIDI_COLOUR 0.3098, 0.1882, 0.1882
|
||||||
|
#define AUDIO_COLOUR 0.1608, 0.2510, 0.3373
|
||||||
|
#define GROUP_COLOUR 0.1608, 0.3373, 0.1647
|
||||||
|
|
||||||
|
#define GRID_CLIENT 0.00, 0.00, 0.00
|
||||||
|
#define GRID_GROUP 0.10, 0.10, 0.10
|
||||||
|
#define GRID_PORT 0.20, 0.20, 0.20
|
||||||
|
|
||||||
|
typedef std::list<Base *> BaseList;
|
||||||
|
|
||||||
|
class Matrix : public Gtk::DrawingArea
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
int m_client_width;
|
||||||
|
int m_client_height;
|
||||||
|
int m_port_width;
|
||||||
|
int m_port_height;
|
||||||
|
int m_separation;
|
||||||
|
int m_padding;
|
||||||
|
int m_width;
|
||||||
|
int m_height;
|
||||||
|
|
||||||
|
int m_font_size;
|
||||||
|
std::string m_typeface;
|
||||||
|
|
||||||
|
BaseList across;
|
||||||
|
BaseList down;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Matrix();
|
||||||
|
virtual ~Matrix();
|
||||||
|
|
||||||
|
void Refresh();
|
||||||
|
|
||||||
|
Gtk::Window *parent;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void Box(Cairo::RefPtr<Cairo::Context> cr, float r, float g, float b, Rect &rect);
|
||||||
|
virtual bool on_expose_event(GdkEventExpose *event);
|
||||||
|
virtual bool on_button_press_event(GdkEventButton *event);
|
||||||
|
};
|
||||||
|
|
||||||
|
class Gui : public Gtk::Window
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
Glib::RefPtr<Gtk::ActionGroup> m_actiongroup;
|
||||||
|
Glib::RefPtr<Gtk::UIManager> m_uimanager;
|
||||||
|
Gtk::ScrolledWindow m_scrolledwindow;
|
||||||
|
Gtk::VBox m_box;
|
||||||
|
Matrix m_matrix;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Gui();
|
||||||
|
virtual ~Gui();
|
||||||
|
|
||||||
|
void Refresh();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool on_idle();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // GUI_H
|
|
@ -0,0 +1,153 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "jack.h"
|
||||||
|
#include "portmanager.h"
|
||||||
|
|
||||||
|
JackDriver::JackDriver()
|
||||||
|
{
|
||||||
|
m_connected = false;
|
||||||
|
m_client = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
JackDriver::~JackDriver()
|
||||||
|
{
|
||||||
|
Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void JackDriver::Connect()
|
||||||
|
{
|
||||||
|
if (m_connected) return;
|
||||||
|
|
||||||
|
jack_status_t status;
|
||||||
|
m_client = jack_client_open("jsweeper", JackNoStartServer, &status);
|
||||||
|
if (m_client == NULL) {
|
||||||
|
if (status & JackServerFailed) {
|
||||||
|
std::cerr << "JACK server not running" << std::endl;
|
||||||
|
} else {
|
||||||
|
std::cerr << "jack_client_open() failed, status = " << status << std::endl;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_buffer = jack_ringbuffer_create(4096);
|
||||||
|
|
||||||
|
m_connected = true;
|
||||||
|
|
||||||
|
jack_on_shutdown(m_client, &ShutdownCallbackHandler, this);
|
||||||
|
jack_set_port_registration_callback(m_client, &PortRegistrationCallbackHandler, this);
|
||||||
|
jack_set_port_connect_callback(m_client, &PortConnectCallbackHandler, this);
|
||||||
|
|
||||||
|
jack_activate(m_client);
|
||||||
|
|
||||||
|
const char **ports = jack_get_ports(m_client, NULL, NULL, 0);
|
||||||
|
|
||||||
|
for (int i = 0; ports[i] != NULL; ++i) {
|
||||||
|
pm.Add(jack_port_by_name(m_client, ports[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; ports[i] != NULL; ++i) {
|
||||||
|
jack_port_t *port = jack_port_by_name(m_client, ports[i]);
|
||||||
|
if (jack_port_flags(port) & JackPortIsInput) {
|
||||||
|
const char **connections = jack_port_get_all_connections(m_client, port);
|
||||||
|
if (connections != NULL) {
|
||||||
|
for (int j = 0; connections[j] != NULL; ++j) {
|
||||||
|
pm.Connect(port, jack_port_by_name(m_client, connections[j]));
|
||||||
|
}
|
||||||
|
free(connections);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
free(ports);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JackDriver::Disconnect()
|
||||||
|
{
|
||||||
|
if (!m_connected) return;
|
||||||
|
|
||||||
|
m_connected = false;
|
||||||
|
|
||||||
|
jack_deactivate(m_client);
|
||||||
|
jack_client_close(m_client);
|
||||||
|
|
||||||
|
jack_ringbuffer_free(m_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JackDriver::ShutdownCallback()
|
||||||
|
{
|
||||||
|
m_connected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JackDriver::PortRegistrationCallback(jack_port_id_t port_id, int reg)
|
||||||
|
{
|
||||||
|
PortEvent pe;
|
||||||
|
pe.type = reg ? PET_REGISTER : PET_UNREGISTER;
|
||||||
|
pe.port_id_a = port_id;
|
||||||
|
|
||||||
|
if (jack_ringbuffer_write_space(m_buffer) < sizeof pe) {
|
||||||
|
std::cerr << "Ringbuffer full!" << std::endl;
|
||||||
|
} else {
|
||||||
|
jack_ringbuffer_write(m_buffer, (const char *)&pe, sizeof pe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void JackDriver::PortConnectCallback(jack_port_id_t port_id_a, jack_port_id_t port_id_b, int connect)
|
||||||
|
{
|
||||||
|
PortEvent pe;
|
||||||
|
pe.type = connect ? PET_CONNECT : PET_DISCONNECT;
|
||||||
|
pe.port_id_a = port_id_a;
|
||||||
|
pe.port_id_b = port_id_b;
|
||||||
|
|
||||||
|
if (jack_ringbuffer_write_space(m_buffer) < sizeof pe) {
|
||||||
|
std::cerr << "Ringbuffer full!" << std::endl;
|
||||||
|
} else {
|
||||||
|
jack_ringbuffer_write(m_buffer, (const char *)&pe, sizeof pe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool JackDriver::ProcessEvents()
|
||||||
|
{
|
||||||
|
bool ret = false;
|
||||||
|
if (!m_connected) return false;
|
||||||
|
|
||||||
|
PortEvent pe;
|
||||||
|
while (jack_ringbuffer_read_space(m_buffer) >= sizeof pe) {
|
||||||
|
jack_ringbuffer_read(m_buffer, (char *)&pe, sizeof pe);
|
||||||
|
|
||||||
|
switch (pe.type) {
|
||||||
|
case PET_REGISTER:
|
||||||
|
pm.Add(jack_port_by_id(m_client, pe.port_id_a));
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PET_UNREGISTER:
|
||||||
|
pm.Delete(jack_port_by_id(m_client, pe.port_id_a));
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PET_CONNECT:
|
||||||
|
pm.Connect(jack_port_by_id(m_client, pe.port_id_a), jack_port_by_id(m_client, pe.port_id_b));
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PET_DISCONNECT:
|
||||||
|
pm.Disconnect(jack_port_by_id(m_client, pe.port_id_a), jack_port_by_id(m_client, pe.port_id_b));
|
||||||
|
ret = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void JackDriver::Connect(jack_port_t *a, jack_port_t *b)
|
||||||
|
{
|
||||||
|
jack_connect(m_client, jack_port_name(a), jack_port_name(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
void JackDriver::Disconnect(jack_port_t *a, jack_port_t *b)
|
||||||
|
{
|
||||||
|
jack_disconnect(m_client, jack_port_name(a), jack_port_name(b));
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
|
||||||
|
#ifndef JACK_H
|
||||||
|
#define JACK_H
|
||||||
|
|
||||||
|
#include <jack/jack.h>
|
||||||
|
#include <jack/ringbuffer.h>
|
||||||
|
|
||||||
|
enum PortEventType
|
||||||
|
{
|
||||||
|
PET_REGISTER,
|
||||||
|
PET_UNREGISTER,
|
||||||
|
PET_CONNECT,
|
||||||
|
PET_DISCONNECT
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PortEvent
|
||||||
|
{
|
||||||
|
PortEventType type;
|
||||||
|
jack_port_id_t port_id_a;
|
||||||
|
jack_port_id_t port_id_b;
|
||||||
|
};
|
||||||
|
|
||||||
|
class JackDriver
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
bool m_connected;
|
||||||
|
jack_client_t *m_client;
|
||||||
|
jack_ringbuffer_t *m_buffer;
|
||||||
|
|
||||||
|
static void ShutdownCallbackHandler(void *arg)
|
||||||
|
{
|
||||||
|
((JackDriver *)arg)->ShutdownCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PortRegistrationCallbackHandler(jack_port_id_t port_id, int reg, void *arg)
|
||||||
|
{
|
||||||
|
((JackDriver *)arg)->PortRegistrationCallback(port_id, reg);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PortConnectCallbackHandler(jack_port_id_t port_id_a, jack_port_id_t port_id_b, int connect, void *arg)
|
||||||
|
{
|
||||||
|
((JackDriver *)arg)->PortConnectCallback(port_id_a, port_id_b, connect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ShutdownCallback();
|
||||||
|
void PortRegistrationCallback(jack_port_id_t port, int reg);
|
||||||
|
void PortConnectCallback(jack_port_id_t a, jack_port_id_t b, int connect);
|
||||||
|
|
||||||
|
public:
|
||||||
|
JackDriver();
|
||||||
|
~JackDriver();
|
||||||
|
|
||||||
|
void Connect();
|
||||||
|
void Disconnect();
|
||||||
|
|
||||||
|
bool IsConnected() const
|
||||||
|
{
|
||||||
|
return m_connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProcessEvents();
|
||||||
|
|
||||||
|
void Connect(jack_port_t *a, jack_port_t *b);
|
||||||
|
void Disconnect(jack_port_t *a, jack_port_t *b);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern JackDriver jack;
|
||||||
|
|
||||||
|
#endif // JACK_H
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include "jack.h"
|
||||||
|
#include "portmanager.h"
|
||||||
|
#include "gui.h"
|
||||||
|
|
||||||
|
PortManager pm;
|
||||||
|
JackDriver jack;
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
Gtk::Main kit(argc, argv);
|
||||||
|
|
||||||
|
pm.AliasLoad("hurr.jsa");
|
||||||
|
|
||||||
|
jack.Connect();
|
||||||
|
|
||||||
|
Gui *g = new Gui();
|
||||||
|
kit.run(*g);
|
||||||
|
|
||||||
|
delete g;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,174 @@
|
||||||
|
#include "port.h"
|
||||||
|
|
||||||
|
ConnectionMode Client::ConnectedTo(Port *port)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = m_ports.begin(); it != m_ports.end(); ++it) {
|
||||||
|
Port *p = *it;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = p->ConnectedTo(port);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode Client::ConnectedTo(PortGroup *group)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = group->m_ports.begin(); it != group->m_ports.end(); ++it) {
|
||||||
|
Port *port = *it;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = this->ConnectedTo(port);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode Client::ConnectedTo(Client *client)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = client->m_ports.begin(); it != client->m_ports.end(); ++it) {
|
||||||
|
Port *port = *it;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = this->ConnectedTo(port);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode PortGroup::ConnectedTo(Port *port)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = m_ports.begin(); it != m_ports.end(); ++it) {
|
||||||
|
Port *p = *it;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = p->ConnectedTo(port);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode PortGroup::ConnectedTo(PortGroup *group)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator plita;
|
||||||
|
PortList::iterator plitb;
|
||||||
|
for (plita = m_ports.begin(), plitb = group->m_ports.begin(); plita != m_ports.end() && plitb != group->m_ports.end(); ++plita, ++plitb) {
|
||||||
|
Port *pa = *plita;
|
||||||
|
Port *pb = *plitb;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = pa->ConnectedTo(pb);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode PortGroup::ConnectedTo(Client *client)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = client->m_ports.begin(); it != client->m_ports.end(); ++it) {
|
||||||
|
Port *port = *it;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = this->ConnectedTo(port);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode Port::ConnectedTo(Port *port)
|
||||||
|
{
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = m_connections.begin(); it != m_connections.end(); ++it) {
|
||||||
|
Port *p = *it;
|
||||||
|
if (p == port) return CM_FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return CM_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode Port::ConnectedTo(PortGroup *group)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = group->m_ports.begin(); it != group->m_ports.end(); ++it) {
|
||||||
|
Port *port = *it;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = this->ConnectedTo(port);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionMode Port::ConnectedTo(Client *client)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = CM_UNKNOWN;
|
||||||
|
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = client->m_ports.begin(); it != client->m_ports.end(); ++it) {
|
||||||
|
Port *port = *it;
|
||||||
|
|
||||||
|
ConnectionMode cm2 = this->ConnectedTo(port);
|
||||||
|
if (cm == CM_UNKNOWN) {
|
||||||
|
cm = cm2;
|
||||||
|
} else if (cm != cm2) {
|
||||||
|
// If connected types aren't the same, we're partially connected.
|
||||||
|
return CM_PARTIAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cm;
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
#ifndef PORT_H
|
||||||
|
#define PORT_H
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <string>
|
||||||
|
#include <gtkmm.h>
|
||||||
|
#include <jack/jack.h>
|
||||||
|
#include "rect.h"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Jack port names look like client_name:port_name
|
||||||
|
// A proposal is to add groups by separating the port_name with a period
|
||||||
|
// resulting in client_name:port_group.port_suffix.
|
||||||
|
// e.g. system:main_out.L
|
||||||
|
// system:main_out.R
|
||||||
|
//
|
||||||
|
|
||||||
|
struct Client;
|
||||||
|
struct PortGroup;
|
||||||
|
struct Port;
|
||||||
|
|
||||||
|
typedef std::list<Client *> ClientList;
|
||||||
|
typedef std::list<PortGroup *> PortGroupList;
|
||||||
|
typedef std::list<Port *> PortList;
|
||||||
|
|
||||||
|
enum ConnectionMode
|
||||||
|
{
|
||||||
|
CM_UNKNOWN,
|
||||||
|
CM_NONE,
|
||||||
|
CM_PARTIAL,
|
||||||
|
CM_FULL
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Client;
|
||||||
|
struct PortGroup;
|
||||||
|
struct Port;
|
||||||
|
|
||||||
|
struct Base {
|
||||||
|
virtual int get_type() const = 0;
|
||||||
|
|
||||||
|
ConnectionMode ConnectedTo(Base *b)
|
||||||
|
{
|
||||||
|
switch (b->get_type()) {
|
||||||
|
case 0: return ConnectedTo((Client *)b);
|
||||||
|
case 1: return ConnectedTo((PortGroup *)b);
|
||||||
|
case 2: return ConnectedTo((Port *)b);
|
||||||
|
default: return CM_UNKNOWN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ConnectionMode ConnectedTo(Client *client) = 0;
|
||||||
|
virtual ConnectionMode ConnectedTo(PortGroup *group) = 0;
|
||||||
|
virtual ConnectionMode ConnectedTo(Port *port) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Client : Base
|
||||||
|
{
|
||||||
|
std::string m_name;
|
||||||
|
bool m_is_input;
|
||||||
|
bool m_is_midi;
|
||||||
|
PortGroupList m_groups;
|
||||||
|
PortList m_ports;
|
||||||
|
Cairo::TextExtents extents;
|
||||||
|
bool m_expanded;
|
||||||
|
Rect rect;
|
||||||
|
|
||||||
|
virtual ConnectionMode ConnectedTo(Port *port);
|
||||||
|
virtual ConnectionMode ConnectedTo(PortGroup *group);
|
||||||
|
virtual ConnectionMode ConnectedTo(Client *client);
|
||||||
|
|
||||||
|
virtual int get_type() const { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PortGroup : Base
|
||||||
|
{
|
||||||
|
std::string m_name;
|
||||||
|
JackPortFlags m_flags;
|
||||||
|
PortList m_ports;
|
||||||
|
Cairo::TextExtents extents;
|
||||||
|
bool m_expanded;
|
||||||
|
Rect rect;
|
||||||
|
|
||||||
|
virtual ConnectionMode ConnectedTo(Port *port);
|
||||||
|
virtual ConnectionMode ConnectedTo(PortGroup *group);
|
||||||
|
virtual ConnectionMode ConnectedTo(Client *client);
|
||||||
|
|
||||||
|
virtual int get_type() const { return 1; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Port : Base
|
||||||
|
{
|
||||||
|
jack_port_t *m_port;
|
||||||
|
JackPortFlags m_flags;
|
||||||
|
std::string m_name;
|
||||||
|
bool m_is_midi;
|
||||||
|
Client *m_client;
|
||||||
|
PortGroup *m_group;
|
||||||
|
PortList m_connections;
|
||||||
|
Cairo::TextExtents extents;
|
||||||
|
Rect rect;
|
||||||
|
|
||||||
|
virtual ConnectionMode ConnectedTo(Port *port);
|
||||||
|
virtual ConnectionMode ConnectedTo(PortGroup *group);
|
||||||
|
virtual ConnectionMode ConnectedTo(Client *client);
|
||||||
|
|
||||||
|
virtual int get_type() const { return 2; }
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PORT_H
|
|
@ -0,0 +1,323 @@
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <cstring>
|
||||||
|
#include "jack.h"
|
||||||
|
#include "portmanager.h"
|
||||||
|
|
||||||
|
void PortManager::Add(jack_port_t *port)
|
||||||
|
{
|
||||||
|
std::string jack_name = jack_port_name(port);
|
||||||
|
std::string client_name;
|
||||||
|
std::string group_name;
|
||||||
|
std::string port_name;
|
||||||
|
|
||||||
|
char *aliases[2];
|
||||||
|
aliases[0] = new char[jack_port_name_size()];
|
||||||
|
aliases[1] = new char[jack_port_name_size()];
|
||||||
|
int num_aliases = jack_port_get_aliases(port, aliases);
|
||||||
|
|
||||||
|
if (num_aliases < 2) {
|
||||||
|
pm.AliasBay(port, num_aliases, aliases);
|
||||||
|
num_aliases = jack_port_get_aliases(port, aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (num_aliases == 2) {
|
||||||
|
jack_name = aliases[1];
|
||||||
|
} else if (num_aliases == 1) {
|
||||||
|
jack_name = aliases[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete aliases[0];
|
||||||
|
delete aliases[1];
|
||||||
|
|
||||||
|
size_t pos1 = jack_name.find(':');
|
||||||
|
size_t pos2 = jack_name.find('.', pos1);
|
||||||
|
|
||||||
|
// All ports must have a client part
|
||||||
|
if (pos1 == std::string::npos) return;
|
||||||
|
|
||||||
|
Port *p = new Port();
|
||||||
|
p->m_port = port;
|
||||||
|
p->m_flags = (JackPortFlags)jack_port_flags(port);
|
||||||
|
|
||||||
|
std::string type = jack_port_type(port);
|
||||||
|
p->m_is_midi = type == JACK_DEFAULT_MIDI_TYPE;
|
||||||
|
|
||||||
|
// Client
|
||||||
|
client_name = jack_name.substr(0, pos1);
|
||||||
|
p->m_client = FindOrMakeClient(client_name, p->m_flags & JackPortIsInput, p->m_is_midi);
|
||||||
|
|
||||||
|
if (pos2 != std::string::npos) {
|
||||||
|
// Group
|
||||||
|
group_name = jack_name.substr(pos1 + 1, pos2 - pos1 - 1);
|
||||||
|
port_name = jack_name.substr(pos2 + 1);
|
||||||
|
} else {
|
||||||
|
group_name = "";
|
||||||
|
port_name = jack_name.substr(pos1 + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
p->m_group = FindOrMakeGroup(p->m_client, p->m_flags, group_name);
|
||||||
|
p->m_group->m_ports.push_back(p);
|
||||||
|
|
||||||
|
p->m_name = port_name;
|
||||||
|
|
||||||
|
//std::clog << "New port (" << client_name << ") " << port_name << std::endl;
|
||||||
|
|
||||||
|
p->m_client->m_ports.push_back(p);
|
||||||
|
|
||||||
|
m_ports.push_back(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::Delete(jack_port_t *port)
|
||||||
|
{
|
||||||
|
Port *p = FindPort(port);
|
||||||
|
if (p == NULL) {
|
||||||
|
std::cerr << "Deleting unknown port!" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->m_group != NULL) {
|
||||||
|
// Clean up groups
|
||||||
|
p->m_group->m_ports.remove(p);
|
||||||
|
if (p->m_group->m_ports.size() == 0) {
|
||||||
|
p->m_client->m_groups.remove(p->m_group);
|
||||||
|
delete p->m_group;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up clients
|
||||||
|
p->m_client->m_ports.remove(p);
|
||||||
|
if (p->m_client->m_ports.size() == 0) {
|
||||||
|
m_clients.remove(p->m_client);
|
||||||
|
delete p->m_client;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove port
|
||||||
|
m_ports.remove(p);
|
||||||
|
|
||||||
|
//std::clog << "Port '" << p->m_name << "' removed" << std::endl;
|
||||||
|
|
||||||
|
delete p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::Connect(jack_port_t *port_a, jack_port_t *port_b)
|
||||||
|
{
|
||||||
|
Port *p1 = FindPort(port_a);
|
||||||
|
Port *p2 = FindPort(port_b);
|
||||||
|
|
||||||
|
if (p1 == NULL || p2 == NULL) {
|
||||||
|
std::cerr << "Connecting unknown ports!" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p1->m_flags & JackPortIsInput) {
|
||||||
|
p1->m_connections.push_back(p2);
|
||||||
|
} else {
|
||||||
|
p2->m_connections.push_back(p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::clog << "Connecting '" << jack_port_name(port_a) << "' to '" << jack_port_name(port_b) << "'" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::Disconnect(jack_port_t *port_a, jack_port_t *port_b)
|
||||||
|
{
|
||||||
|
Port *p1 = FindPort(port_a);
|
||||||
|
Port *p2 = FindPort(port_b);
|
||||||
|
|
||||||
|
if (p1 == NULL || p2 == NULL) {
|
||||||
|
std::cerr << "Disconnecting unknown ports!" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p1->m_flags & JackPortIsInput) {
|
||||||
|
p1->m_connections.remove(p2);
|
||||||
|
} else {
|
||||||
|
p2->m_connections.remove(p1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//std::clog << "Disconnecting '" << jack_port_name(port_a) << "' from '" << jack_port_name(port_b) << "'" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *PortManager::FindOrMakeClient(std::string name, bool is_input, bool is_midi)
|
||||||
|
{
|
||||||
|
ClientList::iterator it;
|
||||||
|
for (it = m_clients.begin(); it != m_clients.end(); ++it) {
|
||||||
|
Client *c = *it;
|
||||||
|
if (c->m_is_input == is_input && c->m_is_midi == is_midi && c->m_name == name) return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
Client *c = new Client();
|
||||||
|
c->m_name = name;
|
||||||
|
c->m_is_input = is_input;
|
||||||
|
c->m_is_midi = is_midi;
|
||||||
|
c->m_expanded = true;
|
||||||
|
|
||||||
|
m_clients.push_back(c);
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroup *PortManager::FindOrMakeGroup(Client *client, JackPortFlags flags, std::string name)
|
||||||
|
{
|
||||||
|
PortGroupList::iterator it;
|
||||||
|
for (it = client->m_groups.begin(); it != client->m_groups.end(); ++it) {
|
||||||
|
PortGroup *pg = *it;
|
||||||
|
if (pg->m_flags == flags && pg->m_name == name) return pg;
|
||||||
|
}
|
||||||
|
|
||||||
|
PortGroup *pg = new PortGroup();
|
||||||
|
pg->m_name = name;
|
||||||
|
pg->m_flags = flags;
|
||||||
|
pg->m_expanded = false;
|
||||||
|
|
||||||
|
client->m_groups.push_back(pg);
|
||||||
|
|
||||||
|
return pg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Port *PortManager::FindPort(jack_port_t *port)
|
||||||
|
{
|
||||||
|
PortList::iterator it;
|
||||||
|
for (it = m_ports.begin(); it != m_ports.end(); ++it) {
|
||||||
|
Port *p = *it;
|
||||||
|
if (p->m_port == port) return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool ClientSortPredicate(const Client *lhs, const Client *rhs)
|
||||||
|
{
|
||||||
|
return lhs->m_name < rhs->m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool PortGroupSortPredicate(const PortGroup *lhs, const PortGroup *rhs)
|
||||||
|
{
|
||||||
|
return lhs->m_name < rhs->m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool PortSortPredicate(const Port *lhs, const Port *rhs)
|
||||||
|
{
|
||||||
|
return lhs->m_name < rhs->m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::Sort()
|
||||||
|
{
|
||||||
|
m_clients.sort(&ClientSortPredicate);
|
||||||
|
|
||||||
|
ClientList::iterator clit;
|
||||||
|
for (clit = m_clients.begin(); clit != m_clients.end(); ++clit) {
|
||||||
|
Client *c = *clit;
|
||||||
|
|
||||||
|
c->m_groups.sort(&PortGroupSortPredicate);
|
||||||
|
|
||||||
|
PortGroupList::iterator pglit;
|
||||||
|
for (pglit = c->m_groups.begin(); pglit != c->m_groups.end(); ++pglit) {
|
||||||
|
PortGroup *pg = *pglit;
|
||||||
|
|
||||||
|
pg->m_ports.sort(&PortSortPredicate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::ToggleConnect(Port *a, Port *b)
|
||||||
|
{
|
||||||
|
ConnectionMode cm = a->ConnectedTo(b);
|
||||||
|
|
||||||
|
if (cm == CM_NONE) {
|
||||||
|
jack.Connect(b->m_port, a->m_port);
|
||||||
|
} else {
|
||||||
|
jack.Disconnect(b->m_port, a->m_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::ToggleConnect(Port *a, PortGroup *b)
|
||||||
|
{
|
||||||
|
PortList::iterator plitb;
|
||||||
|
ConnectionMode cm = a->ConnectedTo(b);
|
||||||
|
|
||||||
|
for (plitb = b->m_ports.begin(); plitb != b->m_ports.end(); ++plitb) {
|
||||||
|
Port *pb = *plitb;
|
||||||
|
|
||||||
|
// if (connect == 0) {
|
||||||
|
// connect = a->ConnectedTo(pb) ? -1 : 1;
|
||||||
|
// }
|
||||||
|
if (cm == CM_NONE) {
|
||||||
|
jack.Connect(pb->m_port, a->m_port);
|
||||||
|
} else {
|
||||||
|
jack.Disconnect(pb->m_port, a->m_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::ToggleConnect(PortGroup *a, Port *b)
|
||||||
|
{
|
||||||
|
PortList::iterator plita;
|
||||||
|
ConnectionMode cm = a->ConnectedTo(b);
|
||||||
|
|
||||||
|
for (plita = a->m_ports.begin(); plita != a->m_ports.end(); ++plita) {
|
||||||
|
Port *pa = *plita;
|
||||||
|
|
||||||
|
// if (connect == 0) {
|
||||||
|
// connect = pa->ConnectedTo(b) ? -1 : 1;
|
||||||
|
// }
|
||||||
|
if (cm == CM_NONE) {
|
||||||
|
jack.Connect(b->m_port, pa->m_port);
|
||||||
|
} else {
|
||||||
|
jack.Disconnect(b->m_port, pa->m_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::ToggleConnect(PortGroup *a, PortGroup *b)
|
||||||
|
{
|
||||||
|
PortList::iterator plita;
|
||||||
|
PortList::iterator plitb;
|
||||||
|
ConnectionMode cm = a->ConnectedTo(b);
|
||||||
|
|
||||||
|
for (plita = a->m_ports.begin(), plitb = b->m_ports.begin(); plita != a->m_ports.end() && plitb != b->m_ports.end(); ++plita, ++plitb) {
|
||||||
|
Port *pa = *plita;
|
||||||
|
Port *pb = *plitb;
|
||||||
|
|
||||||
|
if (cm == CM_NONE) {
|
||||||
|
jack.Connect(pb->m_port, pa->m_port);
|
||||||
|
} else {
|
||||||
|
jack.Disconnect(pb->m_port, pa->m_port);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::AliasBay(jack_port_t *port, int num_aliases, char *aliases[2])
|
||||||
|
{
|
||||||
|
std::string port_name = jack_port_name(port);
|
||||||
|
|
||||||
|
AliasList::iterator it;
|
||||||
|
for (it = m_aliases.begin(); it != m_aliases.end(); ++it) {
|
||||||
|
Alias &a = *it;
|
||||||
|
if (a.name == port_name) {
|
||||||
|
bool got = false;
|
||||||
|
for (int i = 0; i < num_aliases; i++) {
|
||||||
|
if (a.alias == aliases[i]) got = true;
|
||||||
|
}
|
||||||
|
if (!got) {
|
||||||
|
jack_port_set_alias(port, a.alias.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PortManager::AliasLoad(std::string filename)
|
||||||
|
{
|
||||||
|
std::ifstream file;
|
||||||
|
file.open(filename.c_str());
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
char line[1024];
|
||||||
|
while (file.getline(line, sizeof line)) {
|
||||||
|
std::istringstream iss(line);
|
||||||
|
Alias a;
|
||||||
|
iss >> a.name;
|
||||||
|
iss >> a.alias;
|
||||||
|
m_aliases.push_back(a);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
#ifndef PORTMANAGER_H
|
||||||
|
#define PORTMANAGER_H
|
||||||
|
|
||||||
|
#include <jack/jack.h>
|
||||||
|
#include "port.h"
|
||||||
|
|
||||||
|
struct Alias
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
std::string alias;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::list<Alias> AliasList;
|
||||||
|
|
||||||
|
class PortManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ClientList m_clients;
|
||||||
|
PortList m_ports;
|
||||||
|
AliasList m_aliases;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Add(jack_port_t *port);
|
||||||
|
void Delete(jack_port_t *port);
|
||||||
|
|
||||||
|
void Connect(jack_port_t *port_a, jack_port_t *port_b);
|
||||||
|
void Disconnect(jack_port_t *port_a, jack_port_t *port_b);
|
||||||
|
|
||||||
|
Client *FindOrMakeClient(std::string name, bool is_input, bool is_midi);
|
||||||
|
PortGroup *FindOrMakeGroup(Client *client, JackPortFlags flags, std::string name);
|
||||||
|
Port *FindPort(jack_port_t *port);
|
||||||
|
|
||||||
|
void Sort();
|
||||||
|
|
||||||
|
void ToggleConnect(Port *a, Port *b);
|
||||||
|
void ToggleConnect(Port *a, PortGroup *b);
|
||||||
|
void ToggleConnect(PortGroup *a, Port *b);
|
||||||
|
void ToggleConnect(PortGroup *a, PortGroup *b);
|
||||||
|
|
||||||
|
void AliasBay(jack_port_t *port, int num_aliases, char *aliases[2]);
|
||||||
|
void AliasLoad(std::string filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern PortManager pm;
|
||||||
|
|
||||||
|
#endif // PORTMANAGER_H
|
|
@ -0,0 +1,42 @@
|
||||||
|
#ifndef RECT_H
|
||||||
|
#define RECT_H
|
||||||
|
|
||||||
|
struct Rect
|
||||||
|
{
|
||||||
|
int left;
|
||||||
|
int top;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
|
||||||
|
static const Rect None;
|
||||||
|
|
||||||
|
Rect() { }
|
||||||
|
Rect(int _left, int _top, int _width, int _height) : left(_left), top(_top), width(_width), height(_height) { }
|
||||||
|
|
||||||
|
bool operator ==(const Rect &other) const
|
||||||
|
{
|
||||||
|
return left == other.left && top == other.top && width == other.width && height == other.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator !=(const Rect &other) const
|
||||||
|
{
|
||||||
|
return !(*this == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HitX(int x) const
|
||||||
|
{
|
||||||
|
return x >= left && x < left + width;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HitY(int y) const
|
||||||
|
{
|
||||||
|
return y >= top && y < top + height;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Hit(int x, int y) const
|
||||||
|
{
|
||||||
|
return HitX(x) && HitY(y);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // RECT_H
|
Loading…
Reference in New Issue