Icons for Radium and Shellplayer.
[AROS-Contrib.git] / MultiMedia / radium / common / gfx_subtrack.c
blobeded376ccaf38c68a793d4e27b8359318dd9e03b
1 /* Copyright 2000 Kjetil S. Matheussen
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public License
5 as published by the Free Software Foundation; either version 2
6 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19 #include "nsmtracker.h"
20 #include "list_proc.h"
22 #include "gfx_subtrack_proc.h"
27 /************************************************************************
28 FUNCTION
29 Returns the left X coordinate relative to track->fx.y for the subtrack
30 'subtrack'.
31 ************************************************************************/
32 int GetRelXSubTrack1(
33 struct WTracks *wtrack,
34 int subtrack
36 return (wtrack->fxwidth*subtrack/wtrack->num_vel) + (subtrack>0 ? 1 : 0 ) ;
39 /************************************************************************
40 FUNCTION
41 Returns the absolute left X coordinate to track->fx.y for the subtrack
42 'subtrack'.
43 ************************************************************************/
44 int GetXSubTrack1(
45 struct WTracks *wtrack,
46 int subtrack
48 if(subtrack==-1) return wtrack->notearea.x;
49 return wtrack->fxarea.x + GetRelXSubTrack1(wtrack,subtrack);
52 /************************************************************************
53 FUNCTION
54 Returns the right X coordinate relative to track->fx.y for the subtrack
55 'subtrack'.
56 ************************************************************************/
57 int GetRelXSubTrack2(
58 struct WTracks *wtrack,
59 int subtrack
61 return
62 (wtrack->fxwidth*(subtrack+1)/wtrack->num_vel) -
63 (subtrack == wtrack->num_vel-1 ? 0 : 1)
67 /************************************************************************
68 FUNCTION
69 Returns the absolute right X coordinate to track->fx.y for the subtrack
70 'subtrack'.
71 ************************************************************************/
72 int GetXSubTrack2(
73 struct WTracks *wtrack,
74 int subtrack
76 if(subtrack==-1) return wtrack->notearea.x2;
77 return wtrack->fxarea.x + GetRelXSubTrack2(wtrack,subtrack);
80 /************************************************************************
81 FUNCTION
82 These two functions works just like GetXSubTrack1 and 2, except
83 that they allso accept the tracks that contains to the block. Which
84 is the lpb-track, tempo-track, and the temponode-track.
85 ************************************************************************/
86 int GetXSubTrack_B1(
87 struct WBlocks *wblock,
88 NInt track,
89 int subtrack
91 if(track>=0) return GetXSubTrack1(ListFindElement1(&wblock->wtracks->l,track),subtrack);
92 switch(track){
93 case LPBTRACK:
94 return wblock->lpbarea.x;
95 break;
96 case TEMPOTRACK:
97 return wblock->tempoarea.x;
98 break;
99 case TEMPONODETRACK:
100 return wblock->temponodearea.x;
101 break;
103 RError("Error in function GetXSubTrack_B1 in file gfx_subtrack.c\n");
104 return 0;
107 int GetXSubTrack_B2(
108 struct WBlocks *wblock,
109 NInt track,
110 int subtrack
112 if(track>=0) return GetXSubTrack2(ListFindElement1(&wblock->wtracks->l,track),subtrack);
113 switch(track){
114 case LPBTRACK:
115 return wblock->lpbarea.x2;
116 break;
117 case TEMPOTRACK:
118 return wblock->tempoarea.x2;
119 break;
120 case TEMPONODETRACK:
121 return wblock->temponodearea.x2;
122 break;
124 RError("Error in function GetXSubTrack_B2 in file gfx_subtrack.c\n");
125 return 0;
128 /************************************************************************
129 FUNCTION
130 Make shure that x is placed within the boundaries of the subtrack.
131 ************************************************************************/
132 int SubtrackBoundaries(struct WTracks *wtrack,int subtrack,int x){
133 int x1=GetRelXSubTrack1(wtrack,subtrack);
134 int x2=GetRelXSubTrack2(wtrack,subtrack);
135 if(x<x1) return x1;
136 if(x>x2) return x2;
137 if(x==2000) printf("2000\n");
138 return x;
142 int GetSubTrackWidth(struct WTracks *wtrack,int subtrack){
143 return GetXSubTrack2(wtrack,subtrack)-GetXSubTrack1(wtrack,subtrack);
147 /**************************************************************
148 FUNCTION
149 Returns the relative X position according to X1 value
150 of the wtrack 'wtrack', calculated from the vector (x,maxx).
151 INPUTS
152 subtrack - Start at zero.
153 **************************************************************/
154 int GetSubTrackPos(
155 struct WTracks *wtrack,
156 float x,
157 int maxx,
158 int subtrack
160 float x2;
162 x2=x*GetSubTrackWidth(wtrack,subtrack)/maxx;
163 x2=x2+GetRelXSubTrack1(wtrack,subtrack);
165 return (int) (x2+0.5);
168 /**************************************************************
169 FUNCTION
170 Returns the subtrack 'x' belongs to in the wtrack 'wtrack'.
171 If it doesn't belong to a subtrack. Returns -2;
172 **************************************************************/
173 int GetSubTrack(
174 struct WTracks *wtrack,
175 int x
177 int lokke;
178 int num_vel=wtrack->num_vel;
180 for(lokke= -1;lokke<num_vel;lokke++){
181 if(x==SubtrackBoundaries(wtrack,lokke,x)) return lokke;
184 return -2;