Mercurial > mplayer.hg
annotate gui/app.c @ 32761:3ceeb62a1125
Improve the readability of dynamic labels which scroll.
If the text of a dynamic label to be displayed is wider than the given
length, it will be scrolled. Currently such a label starts scrolling
immediately after it is placed and - even more unpleasant - the start of the
text is randomly somewhere within the specified space of the label. Both
makes it hard to track and to read.
Now such a dynamic label starts left-aligned and begins scrolling through the
specified space only after a short delay (2.5 seconds). Every time the start
of the text nears the left margin again during the scrolling process it will
stop and everything starts all over again, i.e. scrolling after a short
delay.
author | ib |
---|---|
date | Thu, 03 Feb 2011 14:44:46 +0000 |
parents | 8fa2f43cb760 |
children | 12ae3b893c59 |
rev | line source |
---|---|
26458 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer 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 * MPlayer 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 along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
23077 | 18 |
19 #include <stdlib.h> | |
20 #include <stdio.h> | |
21 #include <string.h> | |
22 | |
23 #include "config.h" | |
24 #include "mp_msg.h" | |
25 #include "help_mp.h" | |
26 | |
27 #include "app.h" | |
28 #include "wm/wskeys.h" | |
29 #include "skin/skin.h" | |
30 #include "mplayer/gmplayer.h" | |
31 #include "interface.h" | |
32 | |
25243 | 33 static const evName evNames[] = |
23077 | 34 { |
35 { evNone, "evNone" }, | |
36 { evPlay, "evPlay" }, | |
37 { evStop, "evStop" }, | |
38 { evPause, "evPause" }, | |
39 { evPrev, "evPrev" }, | |
40 { evNext, "evNext" }, | |
41 { evLoad, "evLoad" }, | |
42 { evEqualizer, "evEqualizer" }, | |
43 { evEqualizer, "evEqualeaser" }, | |
44 { evPlayList, "evPlaylist" }, | |
45 { evExit, "evExit" }, | |
46 { evIconify, "evIconify" }, | |
47 { evIncBalance, "evIncBalance" }, | |
48 { evDecBalance, "evDecBalance" }, | |
49 { evFullScreen, "evFullScreen" }, | |
50 { evFName, "evFName" }, | |
51 { evMovieTime, "evMovieTime" }, | |
52 { evAbout, "evAbout" }, | |
53 { evLoadPlay, "evLoadPlay" }, | |
54 { evPreferences, "evPreferences" }, | |
55 { evSkinBrowser, "evSkinBrowser" }, | |
56 { evBackward10sec, "evBackward10sec" }, | |
57 { evForward10sec, "evForward10sec" }, | |
58 { evBackward1min, "evBackward1min" }, | |
59 { evForward1min, "evForward1min" }, | |
60 { evBackward10min, "evBackward10min" }, | |
61 { evForward10min, "evForward10min" }, | |
62 { evIncVolume, "evIncVolume" }, | |
63 { evDecVolume, "evDecVolume" }, | |
64 { evMute, "evMute" }, | |
65 { evIncAudioBufDelay, "evIncAudioBufDelay" }, | |
66 { evDecAudioBufDelay, "evDecAudioBufDelay" }, | |
67 { evPlaySwitchToPause, "evPlaySwitchToPause" }, | |
68 { evPauseSwitchToPlay, "evPauseSwitchToPlay" }, | |
69 { evNormalSize, "evHalfSize" }, | |
70 { evNormalSize, "evNormalSize" }, | |
71 { evDoubleSize, "evDoubleSize" }, | |
72 { evSetMoviePosition, "evSetMoviePosition" }, | |
73 { evSetVolume, "evSetVolume" }, | |
74 { evSetBalance, "evSetBalance" }, | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
75 { evHelp, "evHelp" }, |
23077 | 76 { evLoadSubtitle, "evLoadSubtitle" }, |
77 { evPlayDVD, "evPlayDVD" }, | |
78 { evPlayVCD, "evPlayVCD" }, | |
79 { evSetURL, "evSetURL" }, | |
80 { evLoadAudioFile, "evLoadAudioFile" }, | |
81 { evDropSubtitle, "evDropSubtitle" }, | |
82 { evSetAspect, "evSetAspect" } | |
83 }; | |
84 | |
25243 | 85 static const int evBoxs = sizeof( evNames ) / sizeof( evName ); |
23077 | 86 |
87 // --- | |
88 | |
89 listItems appMPlayer; | |
90 | |
91 /* FIXME: Eventually remove the obsolete directory names. */ | |
92 char * skinDirInHome=NULL; | |
93 char * skinDirInHome_obsolete=NULL; | |
94 char * skinMPlayerDir=NULL; | |
95 char * skinMPlayerDir_obsolete=NULL; | |
96 char * skinName = NULL; | |
97 | |
98 void appClearItem( wItem * item ) | |
99 { | |
100 item->type=0; | |
101 // --- | |
102 item->x=0; item->y=0; item->width=0; item->height=0; | |
103 // --- | |
104 item->px=0; item->py=0; item->psx=0; item->psy=0; | |
105 // --- | |
106 item->msg=0; item->msg2=0; | |
107 item->pressed=btnReleased; | |
108 item->tmp=0; | |
109 item->key=0; item->key2=0; | |
110 item->Bitmap.Width=0; item->Bitmap.Height=0; item->Bitmap.BPP=0; item->Bitmap.ImageSize=0; | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
29263
diff
changeset
|
111 free(item->Bitmap.Image); |
23077 | 112 item->Bitmap.Image=NULL; |
113 // --- | |
114 item->fontid=0; | |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
29263
diff
changeset
|
115 free(item->label); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
29263
diff
changeset
|
116 item->label=NULL; |
32761
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32537
diff
changeset
|
117 free(item->text); |
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32537
diff
changeset
|
118 item->text=NULL; |
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32537
diff
changeset
|
119 item->textwidth=0; |
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32537
diff
changeset
|
120 item->starttime=0; |
3ceeb62a1125
Improve the readability of dynamic labels which scroll.
ib
parents:
32537
diff
changeset
|
121 item->last_x=0; |
23077 | 122 item->event=0; |
123 } | |
124 | |
125 void appCopy( listItems * dest,listItems * source ) | |
126 { | |
127 dest->NumberOfItems=source->NumberOfItems; | |
128 memcpy( &dest->Items,&source->Items,128 * sizeof( wItem ) ); | |
129 | |
130 dest->NumberOfMenuItems=source->NumberOfMenuItems; | |
131 memcpy( &dest->MenuItems,&source->MenuItems,32 * sizeof( wItem ) ); | |
132 | |
133 memcpy( &dest->main,&source->main,sizeof( wItem ) ); | |
134 memcpy( &dest->sub,&source->sub,sizeof( wItem ) ); | |
135 memcpy( &dest->menuBase,&source->menuBase,sizeof( wItem ) ); | |
136 memcpy( &dest->menuSelected,&source->menuSelected,sizeof( wItem ) ); | |
137 } | |
138 | |
139 void appInitStruct( listItems * item ) | |
140 { | |
141 int i; | |
142 for ( i=0;i<item->NumberOfItems;i++ ) | |
143 appClearItem( &item->Items[i] ); | |
144 for ( i=0;i<item->NumberOfMenuItems;i++ ) | |
145 appClearItem( &item->MenuItems[i] ); | |
146 for ( i=0;i<item->NumberOfBarItems;i++ ) | |
147 appClearItem( &item->barItems[i] ); | |
148 | |
149 item->NumberOfItems=-1; | |
150 memset( item->Items,0,256 * sizeof( wItem ) ); | |
151 item->NumberOfMenuItems=-1; | |
152 memset( item->MenuItems,0,64 * sizeof( wItem ) ); | |
153 item->NumberOfBarItems=-1; | |
154 memset( item->barItems,0,256 * sizeof( wItem ) ); | |
155 | |
156 appClearItem( &item->main ); | |
157 item->mainDecoration=0; | |
158 appClearItem( &item->sub ); | |
159 item->sub.width=0; item->sub.height=0; | |
160 item->sub.x=-1; item->sub.y=-1; | |
161 appClearItem( &item->menuBase ); | |
162 appClearItem( &item->menuSelected ); | |
163 item->sub.R=item->sub.G=item->sub.B=0; | |
164 item->bar.R=item->bar.G=item->bar.B=0; | |
165 item->main.R=item->main.G=item->main.B=0; | |
166 item->barIsPresent=0; | |
167 item->menuIsPresent=0; | |
168 } | |
169 | |
170 int appFindKey( unsigned char * name ) | |
171 { | |
172 int i; | |
173 for ( i=0;i<wsKeyNumber;i++ ) | |
174 if ( !strcmp( wsKeyNames[i].name,name ) ) return wsKeyNames[i].code; | |
175 return -1; | |
176 } | |
177 | |
178 int appFindMessage( unsigned char * str ) | |
179 { | |
180 int i; | |
181 for ( i=0;i<evBoxs;i++ ) | |
182 if ( !strcmp( evNames[i].name,str ) ) return evNames[i].msg; | |
183 return -1; | |
184 } | |
185 | |
186 void btnModify( int event,float state ) | |
187 { | |
188 int j; | |
189 for ( j=0;j < appMPlayer.NumberOfItems + 1;j++ ) | |
190 if ( appMPlayer.Items[j].msg == event ) | |
191 { | |
192 switch ( appMPlayer.Items[j].type ) | |
193 { | |
194 case itButton: | |
195 appMPlayer.Items[j].pressed=(int)state; | |
196 appMPlayer.Items[j].tmp=(int)state; | |
197 break; | |
198 case itPotmeter: | |
199 case itVPotmeter: | |
200 case itHPotmeter: | |
201 if ( state < 0.0f ) state=0.0f; | |
202 if ( state > 100.f ) state=100.0f; | |
203 appMPlayer.Items[j].value=state; | |
204 break; | |
205 } | |
206 } | |
207 | |
208 for ( j=0;j < appMPlayer.NumberOfBarItems + 1;j++ ) | |
209 if ( appMPlayer.barItems[j].msg == event ) | |
210 { | |
211 switch ( appMPlayer.barItems[j].type ) | |
212 { | |
213 case itButton: | |
214 appMPlayer.barItems[j].pressed=(int)state; | |
215 appMPlayer.barItems[j].tmp=(int)state; | |
216 break; | |
217 case itPotmeter: | |
218 case itVPotmeter: | |
219 case itHPotmeter: | |
220 if ( state < 0.0f ) state=0.0f; | |
221 if ( state > 100.f ) state=100.0f; | |
222 appMPlayer.barItems[j].value=state; | |
223 break; | |
224 } | |
225 } | |
226 } | |
227 | |
228 float btnGetValue( int event ) | |
229 { | |
230 int j; | |
231 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ ) | |
232 if ( appMPlayer.Items[j].msg == event ) return appMPlayer.Items[j].value; | |
233 return 0; | |
234 } | |
235 | |
236 void btnSet( int event,int set ) | |
237 { | |
238 int j; | |
239 for ( j=0;j<appMPlayer.NumberOfItems + 1;j++ ) | |
240 if ( appMPlayer.Items[j].msg == event ) | |
241 { appMPlayer.Items[j].pressed=set; appMPlayer.barItems[j].tmp=0; } | |
242 for ( j=0;j<appMPlayer.NumberOfBarItems + 1;j++ ) | |
243 if ( appMPlayer.barItems[j].msg == event ) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
26458
diff
changeset
|
244 { appMPlayer.barItems[j].pressed=set; appMPlayer.barItems[j].tmp=0; } |
23077 | 245 } |