~ubuntu-branches/ubuntu/vivid/ardour/vivid-proposed

« back to all changes in this revision

Viewing changes to libs/surfaces/mackie/scripts/surface-cc-template.erb

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Jaromír Mikeš, Felipe Sateler
  • Date: 2014-05-22 14:39:25 UTC
  • mfrom: (29 sid)
  • mto: This revision was merged to the branch mainline in revision 30.
  • Revision ID: package-import@ubuntu.com-20140522143925-vwqfo9287pmkrroe
Tags: 1:2.8.16+git20131003-3
* Team upload

[ Jaromír Mikeš ]
* Add -dbg package

[ Felipe Sateler ]
* Upload to experimental

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<%#
 
2
        Copyright (C) 2006,2007 John Anderson
 
3
 
 
4
        This program is free software; you can redistribute it and/or modify
 
5
        it under the terms of the GNU General Public License as published by
 
6
        the Free Software Foundation; either version 2 of the License, or
 
7
        (at your option) any later version.
 
8
 
 
9
        This program is distributed in the hope that it will be useful,
 
10
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
        GNU General Public License for more details.
 
13
 
 
14
        You should have received a copy of the GNU General Public License
 
15
        along with this program; if not, write to the Free Software
 
16
        Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
-%>
 
18
/*
 
19
        Generated by scripts/generate-surface.rb
 
20
*/
 
21
 
 
22
#include "<%= sf.name.downcase %>_surface.h"
 
23
 
 
24
#include "controls.h"
 
25
#include "mackie_button_handler.h"
 
26
 
 
27
using namespace Mackie;
 
28
 
 
29
void Mackie::<%= sf.name %>Surface::init_controls()
 
30
{
 
31
        // intialise groups and strips
 
32
        Group * group = 0;
 
33
        
 
34
        // make sure there are enough strips
 
35
        strips.resize( <%= sf.groups.values.find_all{|x| x.name =~ /strip/}.size %> );
 
36
        
 
37
% sf.groups.values.each do |group|
 
38
        <%- if group.class == Strip -%>
 
39
                <%- if group.name == 'master' -%>
 
40
        group = new MasterStrip ( "<%=group.name%>", 0 );
 
41
                <%- else -%>
 
42
        group = new <%= group.class.name %> ( "<%=group.name%>", <%=group.ordinal - 1%> );
 
43
                <%- end -%>
 
44
        <%- else -%>
 
45
        group = new <%= group.class.name %> ( "<%=group.name%>" );
 
46
        <%- end -%>
 
47
        groups["<%=group.name%>"] = group;
 
48
        <%- if group.class == Strip -%>
 
49
        strips[<%=group.ordinal - 1%>] = dynamic_cast<Strip*>( group );
 
50
        <%- end -%>
 
51
        
 
52
% end
 
53
 
 
54
        // initialise controls
 
55
        Fader * fader = 0;
 
56
        Pot * pot = 0;
 
57
        Button * button = 0;
 
58
        Led * led = 0;
 
59
 
 
60
% sf.controls.each do |control|
 
61
        <%-
 
62
                variable_name = control.class.name.downcase
 
63
                class_name =
 
64
                if control.name == 'jog'
 
65
                        'Jog'
 
66
                else
 
67
                        control.class.name
 
68
                end
 
69
        -%>
 
70
        group = groups["<%=control.group.name%>"];
 
71
        <%= variable_name %> = new <%= class_name %> ( <%= control.id %>, <%= control.ordinal %>, "<%=control.name%>", *group );
 
72
        <%= variable_name %>s[0x<%=control.id.to_hex %>] = <%= variable_name %>;
 
73
        controls.push_back( <%= variable_name %> );
 
74
        <%- if control.group.class != Strip -%>
 
75
        controls_by_name["<%= control.name %>"] = <%= variable_name %>;
 
76
        <%- end -%>
 
77
        group->add( *<%= variable_name %> );
 
78
 
 
79
% end
 
80
}
 
81
 
 
82
void Mackie::<%= sf.name %>Surface::handle_button( MackieButtonHandler & mbh, ButtonState bs, Button & button )
 
83
{
 
84
        if ( bs != press && bs != release )
 
85
        {
 
86
                mbh.update_led( button, none );
 
87
                return;
 
88
        }
 
89
        
 
90
        LedState ls;
 
91
        switch ( button.id() )
 
92
        {
 
93
<%-
 
94
buttons = sf.controls.find_all{|x| x.class == Button && x.group.class != Strip}
 
95
buttons.each do |button|
 
96
%>
 
97
                case 0x<%= ( button.class.midi_zero_byte << 8 | button.id ).to_hex %>: // <%= button.name %>
 
98
                        switch ( bs ) {
 
99
                                case press: ls = mbh.<%= button.name %>_press( button ); break;
 
100
                                case release: ls = mbh.<%= button.name %>_release( button ); break;
 
101
                                case neither: break;
 
102
                        }
 
103
                        break;
 
104
<% end %>
 
105
        }
 
106
        mbh.update_led( button, ls );
 
107
}