~ubuntu-branches/ubuntu/maverick/vlc/maverick

« back to all changes in this revision

Viewing changes to modules/gui/beos/MediaControlView.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-09-17 21:56:14 UTC
  • mfrom: (1.1.17 upstream)
  • Revision ID: james.westby@ubuntu.com-20080917215614-tj0vx8xzd57e52t8
Tags: 0.9.2-1ubuntu1
* New Upstream Release, exception granted by
    - dktrkranz, norsetto, Hobbsee (via irc). LP: #270404

Changes done in ubuntu:

* add libxul-dev to build-depends
* make sure that vlc is build against libxul in configure. This doesn't
  change anything in the package, but makes it more robust if building
  in an 'unclean' chroot or when modifying the package.
* debian/control: make Vcs-* fields point to the motumedia branch
* add libx264-dev and libass-dev to build-depends
  LP: #210354, #199870
* actually enable libass support by passing --enable-libass to configure
* enable libdca: add libdca-dev to build depends and --enable-libdca
* install the x264 plugin.

Changes already in the pkg-multimedia branch in debian:

* don't install usr/share/vlc/mozilla in debian/mozilla-plugin-vlc.install  
* new upstream .desktop file now registers flash video mimetype LP: #261567
* add Xb-Npp-Applications to mozilla-plugin-vlc
* remove duplicate entries in debian/vlc-nox.install

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * MediaControlView.cpp: beos interface
3
3
 *****************************************************************************
4
4
 * Copyright (C) 1999, 2000, 2001 the VideoLAN team
5
 
 * $Id: 9989b088d347bb68af11050067f487c630c79547 $
 
5
 * $Id$
6
6
 *
7
7
 * Authors: Tony Castley <tony@castley.net>
8
8
 *          Stephan Aßmus <stippi@yellowbites.com>
26
26
#include <InterfaceKit.h>
27
27
#include <AppKit.h>
28
28
#include <String.h>
29
 
#include <string.h>
30
29
 
31
30
/* VLC headers */
32
 
#include <vlc/vlc.h>
33
 
#include <vlc/intf.h>
34
 
#include <vlc/input.h>
 
31
#ifdef HAVE_CONFIG_H
 
32
# include "config.h"
 
33
#endif
 
34
 
 
35
#include <vlc_common.h>
 
36
#include <vlc_interface.h>
35
37
extern "C"
36
38
{
37
39
  #include <audio_output.h>
70
72
 
71
73
enum
72
74
{
73
 
        MSG_REWIND                              = 'rwnd',
74
 
        MSG_FORWARD                             = 'frwd',
75
 
        MSG_SKIP_BACKWARDS              = 'skpb',
76
 
        MSG_SKIP_FORWARD                = 'skpf',
 
75
    MSG_REWIND                = 'rwnd',
 
76
    MSG_FORWARD                = 'frwd',
 
77
    MSG_SKIP_BACKWARDS        = 'skpb',
 
78
    MSG_SKIP_FORWARD        = 'skpf',
77
79
};
78
80
 
79
81
// constructor
80
82
MediaControlView::MediaControlView( intf_thread_t * _p_intf, BRect frame)
81
 
        : BBox(frame, NULL, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED,
82
 
                   B_PLAIN_BORDER),
 
83
    : BBox(frame, NULL, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED,
 
84
           B_PLAIN_BORDER),
83
85
      p_intf( _p_intf ),
84
86
      fCurrentRate(INPUT_RATE_DEFAULT),
85
87
      fCurrentStatus(-1),
86
88
      fBottomControlHeight(0.0),
87
89
      fIsEnabled( true )
88
90
{
89
 
        BRect frame(0.0, 0.0, 10.0, 10.0);
90
 
        
 
91
    BRect frame(0.0, 0.0, 10.0, 10.0);
 
92
    
91
93
    // Seek Slider
92
94
    fSeekSlider = new SeekSlider( p_intf, frame, "seek slider", this );
93
95
    fSeekSlider->SetValue(0);
97
99
    // Buttons
98
100
    // Skip Back
99
101
    frame.SetRightBottom(kSkipButtonSize);
100
 
        fBottomControlHeight = kRewindBitmapHeight - 1.0;
 
102
    fBottomControlHeight = kRewindBitmapHeight - 1.0;
101
103
    fSkipBack = new TransportButton(frame, B_EMPTY_STRING,
102
104
                                    kSkipBackBitmapBits,
103
105
                                    kPressedSkipBackBitmapBits,
105
107
                                    new BMessage(MSG_SKIP_BACKWARDS));
106
108
    AddChild( fSkipBack );
107
109
 
108
 
        // Play Pause
 
110
    // Play Pause
109
111
    frame.SetRightBottom(kPlayButtonSize);
110
 
        if (fBottomControlHeight < kPlayPauseBitmapHeight - 1.0)
111
 
                fBottomControlHeight = kPlayPauseBitmapHeight - 1.0;
 
112
    if (fBottomControlHeight < kPlayPauseBitmapHeight - 1.0)
 
113
        fBottomControlHeight = kPlayPauseBitmapHeight - 1.0;
112
114
    fPlayPause = new PlayPauseButton(frame, B_EMPTY_STRING,
113
115
                                     kPlayButtonBitmapBits,
114
116
                                     kPressedPlayButtonBitmapBits,
130
132
                                       new BMessage(MSG_SKIP_FORWARD));
131
133
    AddChild( fSkipForward );
132
134
 
133
 
        // Forward
134
 
        fForward = new TransportButton(frame, B_EMPTY_STRING,
135
 
                                                                   kForwardBitmapBits,
136
 
                                                                   kPressedForwardBitmapBits,
137
 
                                                                   kDisabledForwardBitmapBits,
138
 
                                                                   new BMessage(MSG_FORWARD));
139
 
//      AddChild( fForward );
 
135
    // Forward
 
136
    fForward = new TransportButton(frame, B_EMPTY_STRING,
 
137
                                   kForwardBitmapBits,
 
138
                                   kPressedForwardBitmapBits,
 
139
                                   kDisabledForwardBitmapBits,
 
140
                                   new BMessage(MSG_FORWARD));
 
141
//    AddChild( fForward );
140
142
 
141
 
        // Rewind
142
 
        fRewind = new TransportButton(frame, B_EMPTY_STRING,
143
 
                                                                  kRewindBitmapBits,
144
 
                                                                  kPressedRewindBitmapBits,
145
 
                                                                  kDisabledRewindBitmapBits,
146
 
                                                                  new BMessage(MSG_REWIND));
147
 
//      AddChild( fRewind );
 
143
    // Rewind
 
144
    fRewind = new TransportButton(frame, B_EMPTY_STRING,
 
145
                                  kRewindBitmapBits,
 
146
                                  kPressedRewindBitmapBits,
 
147
                                  kDisabledRewindBitmapBits,
 
148
                                  new BMessage(MSG_REWIND));
 
149
//    AddChild( fRewind );
148
150
 
149
151
    // Stop
150
152
    frame.SetRightBottom(kStopButtonSize);
151
 
        if (fBottomControlHeight < kStopBitmapHeight - 1.0)
152
 
                fBottomControlHeight = kStopBitmapHeight - 1.0;
 
153
    if (fBottomControlHeight < kStopBitmapHeight - 1.0)
 
154
        fBottomControlHeight = kStopBitmapHeight - 1.0;
153
155
    fStop = new TransportButton(frame, B_EMPTY_STRING,
154
156
                                kStopButtonBitmapBits,
155
157
                                kPressedStopButtonBitmapBits,
156
158
                                kDisabledStopButtonBitmapBits,
157
159
                                new BMessage(STOP_PLAYBACK));
158
 
        AddChild( fStop );
 
160
    AddChild( fStop );
159
161
 
160
 
        // Mute
 
162
    // Mute
161
163
    frame.SetRightBottom(kSpeakerButtonSize);
162
 
        if (fBottomControlHeight < kSpeakerIconBitmapHeight - 1.0)
163
 
                fBottomControlHeight = kSpeakerIconBitmapHeight - 1.0;
 
164
    if (fBottomControlHeight < kSpeakerIconBitmapHeight - 1.0)
 
165
        fBottomControlHeight = kSpeakerIconBitmapHeight - 1.0;
164
166
    fMute = new TransportButton(frame, B_EMPTY_STRING,
165
167
                                kSpeakerIconBits,
166
168
                                kPressedSpeakerIconBits,
167
169
                                kSpeakerIconBits,
168
170
                                new BMessage(VOLUME_MUTE));
169
171
 
170
 
        AddChild( fMute );
 
172
    AddChild( fMute );
171
173
 
172
174
    // Volume Slider
173
 
        fVolumeSlider = new VolumeSlider(BRect(0.0, 0.0, VOLUME_MIN_WIDTH,
174
 
                                                                                   kVolumeSliderBitmapHeight - 1.0),
175
 
                                                                         "volume slider", 1, AOUT_VOLUME_MAX,
176
 
                                                                         new BMessage(VOLUME_CHG));
177
 
        fVolumeSlider->SetValue( config_GetInt( p_intf, "volume" ) );
178
 
        AddChild( fVolumeSlider );
179
 
        
180
 
        // Position Info View
 
175
    fVolumeSlider = new VolumeSlider(BRect(0.0, 0.0, VOLUME_MIN_WIDTH,
 
176
                                           kVolumeSliderBitmapHeight - 1.0),
 
177
                                     "volume slider", 1, AOUT_VOLUME_MAX,
 
178
                                     new BMessage(VOLUME_CHG));
 
179
    fVolumeSlider->SetValue( config_GetInt( p_intf, "volume" ) );
 
180
    AddChild( fVolumeSlider );
 
181
    
 
182
    // Position Info View
181
183
    fPositionInfo = new PositionInfoView(BRect(0.0, 0.0, 10.0, 10.0), "led",
182
184
                                         p_intf);
183
185
    fPositionInfo->ResizeToPreferred();
193
195
void
194
196
MediaControlView::AttachedToWindow()
195
197
{
196
 
        // we are now a valid BHandler
197
 
        fRewind->SetTarget(this);
198
 
        fForward->SetTarget(this);
199
 
        fSkipBack->SetTarget(this);
200
 
        fSkipForward->SetTarget(this);
201
 
        fVolumeSlider->SetTarget(Window());
202
 
 
203
 
        BRect r(_MinFrame());
204
 
        if (BMenuBar* menuBar = Window()->KeyMenuBar()) {
205
 
                float width, height;
206
 
                menuBar->GetPreferredSize(&width, &height);
207
 
//              r.bottom += menuBar->Bounds().Height();
208
 
                r.bottom += height;
209
 
                // see that our calculated minimal width is not smaller than what
210
 
                // the menubar can be
211
 
                width -= r.Width();
212
 
                if (width > 0.0)
213
 
                        r.right += width;
214
 
        }
215
 
 
216
 
        Window()->SetSizeLimits(r.Width(), r.Width() * 1.8, r.Height(), r.Height() * 1.3);
217
 
        if (!Window()->Bounds().Contains(r))
218
 
                Window()->ResizeTo(r.Width(), r.Height());
219
 
        else
220
 
                FrameResized(Bounds().Width(), Bounds().Height());
221
 
 
222
 
        // get pulse message every two frames
223
 
        Window()->SetPulseRate(80000);
 
198
    // we are now a valid BHandler
 
199
    fRewind->SetTarget(this);
 
200
    fForward->SetTarget(this);
 
201
    fSkipBack->SetTarget(this);
 
202
    fSkipForward->SetTarget(this);
 
203
    fVolumeSlider->SetTarget(Window());
 
204
 
 
205
    BRect r(_MinFrame());
 
206
    if (BMenuBar* menuBar = Window()->KeyMenuBar()) {
 
207
        float width, height;
 
208
        menuBar->GetPreferredSize(&width, &height);
 
209
//        r.bottom += menuBar->Bounds().Height();
 
210
        r.bottom += height;
 
211
        // see that our calculated minimal width is not smaller than what
 
212
        // the menubar can be
 
213
        width -= r.Width();
 
214
        if (width > 0.0)
 
215
            r.right += width;
 
216
    }
 
217
 
 
218
    Window()->SetSizeLimits(r.Width(), r.Width() * 1.8, r.Height(), r.Height() * 1.3);
 
219
    if (!Window()->Bounds().Contains(r))
 
220
        Window()->ResizeTo(r.Width(), r.Height());
 
221
    else
 
222
        FrameResized(Bounds().Width(), Bounds().Height());
 
223
 
 
224
    // get pulse message every two frames
 
225
    Window()->SetPulseRate(80000);
224
226
}
225
227
 
226
228
// FrameResized
227
229
void
228
230
MediaControlView::FrameResized(float width, float height)
229
231
{
230
 
        BRect r(Bounds());
231
 
        // make sure we don't leave dirty pixels
232
 
        // (B_FULL_UPDATE_ON_RESIZE == annoying flicker -> this is smarter)
233
 
        if (fOldBounds.Width() < r.Width())
234
 
                Invalidate(BRect(fOldBounds.right, fOldBounds.top + 1.0,
235
 
                                                 fOldBounds.right, fOldBounds.bottom - 1.0));
236
 
        else
237
 
                Invalidate(BRect(r.right, r.top + 1.0,
238
 
                                                 r.right, r.bottom - 1.0));
239
 
        if (fOldBounds.Height() < r.Height())
240
 
                Invalidate(BRect(fOldBounds.left + 1.0, fOldBounds.bottom,
241
 
                                                 fOldBounds.right - 1.0, fOldBounds.bottom));
242
 
        else
243
 
                Invalidate(BRect(r.left + 1.0, r.bottom,
244
 
                                                 r.right - 1.0, r.bottom));
245
 
        // remember for next time
246
 
        fOldBounds = r;
247
 
        // layout controls
248
 
        r.InsetBy(BORDER_INSET, BORDER_INSET);
249
 
        _LayoutControls(r);
 
232
    BRect r(Bounds());
 
233
    // make sure we don't leave dirty pixels
 
234
    // (B_FULL_UPDATE_ON_RESIZE == annoying flicker -> this is smarter)
 
235
    if (fOldBounds.Width() < r.Width())
 
236
        Invalidate(BRect(fOldBounds.right, fOldBounds.top + 1.0,
 
237
                         fOldBounds.right, fOldBounds.bottom - 1.0));
 
238
    else
 
239
        Invalidate(BRect(r.right, r.top + 1.0,
 
240
                         r.right, r.bottom - 1.0));
 
241
    if (fOldBounds.Height() < r.Height())
 
242
        Invalidate(BRect(fOldBounds.left + 1.0, fOldBounds.bottom,
 
243
                         fOldBounds.right - 1.0, fOldBounds.bottom));
 
244
    else
 
245
        Invalidate(BRect(r.left + 1.0, r.bottom,
 
246
                         r.right - 1.0, r.bottom));
 
247
    // remember for next time
 
248
    fOldBounds = r;
 
249
    // layout controls
 
250
    r.InsetBy(BORDER_INSET, BORDER_INSET);
 
251
    _LayoutControls(r);
250
252
}
251
253
 
252
254
// GetPreferredSize
253
255
void
254
256
MediaControlView::GetPreferredSize(float* width, float* height)
255
257
{
256
 
        if (width && height)
257
 
        {
258
 
                BRect r(_MinFrame());
259
 
                *width = r.Width();
260
 
                *height = r.Height();
261
 
        }
 
258
    if (width && height)
 
259
    {
 
260
        BRect r(_MinFrame());
 
261
        *width = r.Width();
 
262
        *height = r.Height();
 
263
    }
262
264
}
263
265
 
264
266
// MessageReceived
265
267
void
266
268
MediaControlView::MessageReceived(BMessage* message)
267
269
{
268
 
        switch (message->what)
269
 
        {
270
 
                case MSG_REWIND:
271
 
                        break;
272
 
                case MSG_FORWARD:
273
 
                        break;
274
 
                case MSG_SKIP_BACKWARDS:
275
 
                        Window()->PostMessage(NAVIGATE_PREV);
276
 
                        break;
277
 
                case MSG_SKIP_FORWARD:
278
 
                        Window()->PostMessage(NAVIGATE_NEXT);
279
 
                        break;
280
 
                default:
281
 
                    BBox::MessageReceived(message);
282
 
                    break;
283
 
        }
 
270
    switch (message->what)
 
271
    {
 
272
        case MSG_REWIND:
 
273
            break;
 
274
        case MSG_FORWARD:
 
275
            break;
 
276
        case MSG_SKIP_BACKWARDS:
 
277
            Window()->PostMessage(NAVIGATE_PREV);
 
278
            break;
 
279
        case MSG_SKIP_FORWARD:
 
280
            Window()->PostMessage(NAVIGATE_NEXT);
 
281
            break;
 
282
        default:
 
283
            BBox::MessageReceived(message);
 
284
            break;
 
285
    }
284
286
}
285
287
 
286
288
// Pulse
287
289
void
288
290
MediaControlView::Pulse()
289
291
{
290
 
        InterfaceWindow* window = dynamic_cast<InterfaceWindow*>(Window());
291
 
        if (window && window->IsStopped())
292
 
                        fPlayPause->SetStopped();
 
292
    InterfaceWindow* window = dynamic_cast<InterfaceWindow*>(Window());
 
293
    if (window && window->IsStopped())
 
294
            fPlayPause->SetStopped();
293
295
 
294
296
    unsigned short i_volume;
295
297
    aout_VolumeGet( p_intf, (audio_volume_t*)&i_volume );
300
302
void
301
303
MediaControlView::SetProgress( float position )
302
304
{
303
 
        fSeekSlider->SetPosition( position );
 
305
    fSeekSlider->SetPosition( position );
304
306
}
305
307
 
306
308
// SetStatus
307
309
void
308
310
MediaControlView::SetStatus(int status, int rate)
309
311
{
310
 
        // we need to set the button status periodically
311
 
        // (even if it is the same) to get a blinking button
312
 
        fCurrentStatus = status;
 
312
    // we need to set the button status periodically
 
313
    // (even if it is the same) to get a blinking button
 
314
    fCurrentStatus = status;
313
315
    switch( status )
314
316
    {
315
317
        case PLAYING_S:
 
318
        case OPENNING_S:
 
319
        case BUFFERING_S:
316
320
            fPlayPause->SetPlaying();
317
321
            break;
318
322
        case PAUSE_S:
322
326
            fPlayPause->SetStopped();
323
327
            break;
324
328
    }
325
 
        if (rate != fCurrentRate)
326
 
        {
327
 
                fCurrentRate = rate;
328
 
            if ( rate < INPUT_RATE_DEFAULT )
329
 
            {
330
 
                // TODO: ...
331
 
            }
332
 
        }
 
329
    if (rate != fCurrentRate)
 
330
    {
 
331
        fCurrentRate = rate;
 
332
        if ( rate < INPUT_RATE_DEFAULT )
 
333
        {
 
334
            // TODO: ...
 
335
        }
 
336
    }
333
337
}
334
338
 
335
339
// SetEnabled
342
346
        /* do not redraw if it is not necessary */
343
347
        return;
344
348
    }
345
 
    
346
 
        if( LockLooper() )
347
 
        {
348
 
                fSkipBack->SetEnabled( enabled );
349
 
                fPlayPause->SetEnabled( enabled );
350
 
                fSkipForward->SetEnabled( enabled );
351
 
                fStop->SetEnabled( enabled );
352
 
                fMute->SetEnabled( enabled );
353
 
                fVolumeSlider->SetEnabled( enabled );
354
 
                fSeekSlider->SetEnabled( enabled );
355
 
                fRewind->SetEnabled( enabled );
356
 
                fForward->SetEnabled( enabled );
357
 
                UnlockLooper();
358
 
                fIsEnabled = enabled;
359
 
        }
 
349
 
 
350
    if( LockLooper() )
 
351
    {
 
352
        fSkipBack->SetEnabled( enabled );
 
353
        fPlayPause->SetEnabled( enabled );
 
354
        fSkipForward->SetEnabled( enabled );
 
355
        fStop->SetEnabled( enabled );
 
356
        fMute->SetEnabled( enabled );
 
357
        fVolumeSlider->SetEnabled( enabled );
 
358
        fSeekSlider->SetEnabled( enabled );
 
359
        fRewind->SetEnabled( enabled );
 
360
        fForward->SetEnabled( enabled );
 
361
        UnlockLooper();
 
362
        fIsEnabled = enabled;
 
363
    }
360
364
}
361
365
 
362
366
// SetAudioEnabled
363
367
void
364
368
MediaControlView::SetAudioEnabled(bool enabled)
365
369
{
366
 
        fMute->SetEnabled(enabled);
367
 
        fVolumeSlider->SetEnabled(enabled);
 
370
    fMute->SetEnabled(enabled);
 
371
    fVolumeSlider->SetEnabled(enabled);
368
372
}
369
373
 
370
374
// GetVolume
371
375
uint32
372
376
MediaControlView::GetVolume() const
373
377
{
374
 
        return fVolumeSlider->Value();
 
378
    return fVolumeSlider->Value();
375
379
}
376
380
 
377
381
// SetSkippable
378
382
void
379
383
MediaControlView::SetSkippable(bool backward, bool forward)
380
384
{
381
 
        fSkipBack->SetEnabled(backward);
382
 
        fSkipForward->SetEnabled(forward);
 
385
    fSkipBack->SetEnabled(backward);
 
386
    fSkipForward->SetEnabled(forward);
383
387
}
384
388
 
385
389
// SetMuted
386
390
void
387
391
MediaControlView::SetMuted(bool mute)
388
392
{
389
 
        fVolumeSlider->SetMuted(mute);
 
393
    fVolumeSlider->SetMuted(mute);
390
394
}
391
395
 
392
396
// _LayoutControls
393
397
void
394
398
MediaControlView::_LayoutControls(BRect frame) const
395
399
{
396
 
        // seek slider
397
 
        BRect r(frame);
398
 
        // calculate absolutly minimal width
399
 
        float minWidth = fSkipBack->Bounds().Width();
400
 
//      minWidth += fRewind->Bounds().Width();
401
 
        minWidth += fStop->Bounds().Width();
402
 
        minWidth += fPlayPause->Bounds().Width();
403
 
//      minWidth += fForward->Bounds().Width();
404
 
        minWidth += fSkipForward->Bounds().Width();
405
 
        minWidth += fMute->Bounds().Width();
406
 
        minWidth += VOLUME_MIN_WIDTH;
407
 
        
408
 
        // layout time slider and info view
 
400
    // seek slider
 
401
    BRect r(frame);
 
402
    // calculate absolutly minimal width
 
403
    float minWidth = fSkipBack->Bounds().Width();
 
404
//    minWidth += fRewind->Bounds().Width();
 
405
    minWidth += fStop->Bounds().Width();
 
406
    minWidth += fPlayPause->Bounds().Width();
 
407
//    minWidth += fForward->Bounds().Width();
 
408
    minWidth += fSkipForward->Bounds().Width();
 
409
    minWidth += fMute->Bounds().Width();
 
410
    minWidth += VOLUME_MIN_WIDTH;
 
411
    
 
412
    // layout time slider and info view
409
413
    float width, height;
410
414
    fPositionInfo->GetBigPreferredSize( &width, &height );
411
415
    float ratio = width / height;
435
439
        r.right = frame.right;
436
440
        _LayoutControl(fSeekSlider, r, true);
437
441
    }
438
 
        float currentWidth = frame.Width();
439
 
        float space = (currentWidth - minWidth) / 6.0;//8.0;
440
 
        // apply weighting
441
 
        space = MIN_SPACE + (space - MIN_SPACE) / VOLUME_SLIDER_LAYOUT_WEIGHT;
442
 
        // layout controls with "space" inbetween
443
 
        r.left = frame.left;
444
 
        r.top = r.bottom + MIN_SPACE + 1.0;
445
 
        r.bottom = frame.bottom;
446
 
        // skip back
447
 
        r.right = r.left + fSkipBack->Bounds().Width();
448
 
        _LayoutControl(fSkipBack, r);
449
 
        // rewind
450
 
//      r.left = r.right + space;
451
 
//      r.right = r.left + fRewind->Bounds().Width();
452
 
//      _LayoutControl(fRewind, r);
453
 
        // stop
454
 
        r.left = r.right + space;
455
 
        r.right = r.left + fStop->Bounds().Width();
456
 
        _LayoutControl(fStop, r);
457
 
        // play/pause
458
 
        r.left = r.right + space;
459
 
        r.right = r.left + fPlayPause->Bounds().Width();
460
 
        _LayoutControl(fPlayPause, r);
461
 
        // forward
462
 
//      r.left = r.right + space;
463
 
//      r.right = r.left + fForward->Bounds().Width();
464
 
//      _LayoutControl(fForward, r);
465
 
        // skip forward
466
 
        r.left = r.right + space;
467
 
        r.right = r.left + fSkipForward->Bounds().Width();
468
 
        _LayoutControl(fSkipForward, r);
469
 
        // speaker icon
470
 
        r.left = r.right + space + space;
471
 
        r.right = r.left + fMute->Bounds().Width();
472
 
        _LayoutControl(fMute, r);
473
 
        // volume slider
474
 
        r.left = r.right + SPEAKER_SLIDER_DIST; // keep speaker icon and volume slider attached
475
 
        r.right = frame.right;
476
 
        _LayoutControl(fVolumeSlider, r, true);
 
442
    float currentWidth = frame.Width();
 
443
    float space = (currentWidth - minWidth) / 6.0;//8.0;
 
444
    // apply weighting
 
445
    space = MIN_SPACE + (space - MIN_SPACE) / VOLUME_SLIDER_LAYOUT_WEIGHT;
 
446
    // layout controls with "space" inbetween
 
447
    r.left = frame.left;
 
448
    r.top = r.bottom + MIN_SPACE + 1.0;
 
449
    r.bottom = frame.bottom;
 
450
    // skip back
 
451
    r.right = r.left + fSkipBack->Bounds().Width();
 
452
    _LayoutControl(fSkipBack, r);
 
453
    // rewind
 
454
//    r.left = r.right + space;
 
455
//    r.right = r.left + fRewind->Bounds().Width();
 
456
//    _LayoutControl(fRewind, r);
 
457
    // stop
 
458
    r.left = r.right + space;
 
459
    r.right = r.left + fStop->Bounds().Width();
 
460
    _LayoutControl(fStop, r);
 
461
    // play/pause
 
462
    r.left = r.right + space;
 
463
    r.right = r.left + fPlayPause->Bounds().Width();
 
464
    _LayoutControl(fPlayPause, r);
 
465
    // forward
 
466
//    r.left = r.right + space;
 
467
//    r.right = r.left + fForward->Bounds().Width();
 
468
//    _LayoutControl(fForward, r);
 
469
    // skip forward
 
470
    r.left = r.right + space;
 
471
    r.right = r.left + fSkipForward->Bounds().Width();
 
472
    _LayoutControl(fSkipForward, r);
 
473
    // speaker icon
 
474
    r.left = r.right + space + space;
 
475
    r.right = r.left + fMute->Bounds().Width();
 
476
    _LayoutControl(fMute, r);
 
477
    // volume slider
 
478
    r.left = r.right + SPEAKER_SLIDER_DIST; // keep speaker icon and volume slider attached
 
479
    r.right = frame.right;
 
480
    _LayoutControl(fVolumeSlider, r, true);
477
481
}
478
482
 
479
483
// _MinFrame
480
 
BRect           
 
484
BRect
481
485
MediaControlView::_MinFrame() const
482
486
{
483
 
        // add up width of controls along bottom (seek slider will likely adopt)
484
 
        float minWidth = 2 * BORDER_INSET;
485
 
        minWidth += fSkipBack->Bounds().Width() + MIN_SPACE;
486
 
//      minWidth += fRewind->Bounds().Width() + MIN_SPACE;
487
 
        minWidth += fStop->Bounds().Width() + MIN_SPACE;
488
 
        minWidth += fPlayPause->Bounds().Width() + MIN_SPACE;
489
 
//      minWidth += fForward->Bounds().Width() + MIN_SPACE;
490
 
        minWidth += fSkipForward->Bounds().Width() + MIN_SPACE + MIN_SPACE;
491
 
        minWidth += fMute->Bounds().Width() + SPEAKER_SLIDER_DIST;
492
 
        minWidth += VOLUME_MIN_WIDTH;
 
487
    // add up width of controls along bottom (seek slider will likely adopt)
 
488
    float minWidth = 2 * BORDER_INSET;
 
489
    minWidth += fSkipBack->Bounds().Width() + MIN_SPACE;
 
490
//    minWidth += fRewind->Bounds().Width() + MIN_SPACE;
 
491
    minWidth += fStop->Bounds().Width() + MIN_SPACE;
 
492
    minWidth += fPlayPause->Bounds().Width() + MIN_SPACE;
 
493
//    minWidth += fForward->Bounds().Width() + MIN_SPACE;
 
494
    minWidth += fSkipForward->Bounds().Width() + MIN_SPACE + MIN_SPACE;
 
495
    minWidth += fMute->Bounds().Width() + SPEAKER_SLIDER_DIST;
 
496
    minWidth += VOLUME_MIN_WIDTH;
493
497
 
494
 
        // add up height of seek slider and heighest control on bottom
495
 
        float minHeight = 2 * BORDER_INSET;
496
 
        minHeight += fSeekSlider->Bounds().Height() + MIN_SPACE + MIN_SPACE / 2.0;
497
 
        minHeight += fBottomControlHeight;
498
 
        return BRect(0.0, 0.0, minWidth - 1.0, minHeight - 1.0);
 
498
    // add up height of seek slider and heighest control on bottom
 
499
    float minHeight = 2 * BORDER_INSET;
 
500
    minHeight += fSeekSlider->Bounds().Height() + MIN_SPACE + MIN_SPACE / 2.0;
 
501
    minHeight += fBottomControlHeight;
 
502
    return BRect(0.0, 0.0, minWidth - 1.0, minHeight - 1.0);
499
503
}
500
504
 
501
505
// _LayoutControl
504
508
                                 bool resizeWidth, bool resizeHeight) const
505
509
{
506
510
    if (!resizeHeight)
507
 
            // center vertically
508
 
            frame.top = (frame.top + frame.bottom) / 2.0 - view->Bounds().Height() / 2.0;
509
 
        if (!resizeWidth)
510
 
            //center horizontally
511
 
                frame.left = (frame.left + frame.right) / 2.0 - view->Bounds().Width() / 2.0;
512
 
        view->MoveTo(frame.LeftTop());
513
 
        float width = resizeWidth ? frame.Width() : view->Bounds().Width();
514
 
        float height = resizeHeight ? frame.Height() : view->Bounds().Height();
 
511
        // center vertically
 
512
        frame.top = (frame.top + frame.bottom) / 2.0 - view->Bounds().Height() / 2.0;
 
513
    if (!resizeWidth)
 
514
        //center horizontally
 
515
        frame.left = (frame.left + frame.right) / 2.0 - view->Bounds().Width() / 2.0;
 
516
    view->MoveTo(frame.LeftTop());
 
517
    float width = resizeWidth ? frame.Width() : view->Bounds().Width();
 
518
    float height = resizeHeight ? frame.Height() : view->Bounds().Height();
515
519
    if (resizeWidth || resizeHeight)
516
520
        view->ResizeTo(width, height);
517
521
}
523
527
 *****************************************************************************/
524
528
SeekSlider::SeekSlider( intf_thread_t * _p_intf,
525
529
                        BRect frame, const char* name, MediaControlView *owner )
526
 
        : BControl(frame, name, NULL, NULL, B_FOLLOW_NONE,
527
 
                           B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
528
 
          p_intf(_p_intf),
529
 
          fOwner(owner),
530
 
          fTracking(false)
 
530
    : BControl(frame, name, NULL, NULL, B_FOLLOW_NONE,
 
531
               B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
 
532
      p_intf(_p_intf),
 
533
      fOwner(owner),
 
534
      fTracking(false)
531
535
{
532
 
        BFont font(be_plain_font);
533
 
        font.SetSize(9.0);
534
 
        SetFont(&font);
 
536
    BFont font(be_plain_font);
 
537
    font.SetSize(9.0);
 
538
    SetFont(&font);
535
539
}
536
540
 
537
541
SeekSlider::~SeekSlider()
544
548
void
545
549
SeekSlider::AttachedToWindow()
546
550
{
547
 
        BControl::AttachedToWindow();
548
 
        SetViewColor(B_TRANSPARENT_32_BIT);
 
551
    BControl::AttachedToWindow();
 
552
    SetViewColor(B_TRANSPARENT_32_BIT);
549
553
}
550
554
 
551
555
/*****************************************************************************
554
558
void
555
559
SeekSlider::Draw(BRect updateRect)
556
560
{
557
 
        BRect r(Bounds());
558
 
        float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
559
 
        float sliderStart = (r.left + knobWidth2);
560
 
        float sliderEnd = (r.right - knobWidth2);
561
 
        float knobPos = sliderStart
562
 
                                        + floorf((sliderEnd - sliderStart - 1.0) * Value()
563
 
                                        / SEEKSLIDER_RANGE);
564
 
        // draw both sides (the original from Be doesn't seem
565
 
        // to make a difference for enabled/disabled state)
566
 
//      DrawBitmapAsync(fLeftSideBits, r.LeftTop());
567
 
//      DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top));
568
 
        // colors for the slider area between the two bitmaps
569
 
        rgb_color background = kBackground;//ui_color(B_PANEL_BACKGROUND_COLOR);
570
 
        rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
571
 
        rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT);
572
 
        rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);
573
 
        rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT);
574
 
        rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
575
 
        rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT);
576
 
        rgb_color green = kSeekGreen;
577
 
        rgb_color greenShadow = kSeekGreenShadow;
578
 
        rgb_color black = kBlack;
579
 
        rgb_color dotGrey = midShadow;
580
 
        rgb_color dotGreen = greenShadow;
581
 
        // draw frame
582
 
        _StrokeFrame(r, softShadow, softShadow, softLight, softLight);
583
 
        r.InsetBy(1.0, 1.0);
584
 
        _StrokeFrame(r, black, black, light, light);
585
 
        if (IsEnabled())
586
 
        {
587
 
                r.InsetBy(1.0, 1.0);
588
 
                // inner shadow
589
 
                _StrokeFrame(r, greenShadow, greenShadow, green, green);
590
 
                r.top++;
591
 
                r.left++;
592
 
                _StrokeFrame(r, greenShadow, greenShadow, green, green);
593
 
                // inside area
594
 
                r.InsetBy(1.0, 1.0);
595
 
                SetHighColor(green);
596
 
                FillRect(r);
597
 
                // dots
598
 
                int32 dotCount = (int32)(r.Width() / 6.0);
599
 
                BPoint dotPos;
600
 
                dotPos.y = r.top + 2.0;
601
 
                SetHighColor(dotGreen);
602
 
                for (int32 i = 0; i < dotCount; i++)
603
 
                {
604
 
                        dotPos.x = sliderStart + i * 6.0 + 5.0;
605
 
                        StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 6.0));
606
 
                }
607
 
                // slider handle
608
 
                r.top -= 4.0;
609
 
                r.bottom += 3.0;
610
 
                r.left = knobPos - knobWidth2;
611
 
                r.right = knobPos + knobWidth2;
612
 
                // black outline
613
 
                float handleBottomSize = 2.0;
614
 
                float handleArrowSize = 6.0;
615
 
                BeginLineArray(10);
616
 
                        // upper handle
617
 
                        AddLine(BPoint(r.left, r.top + handleBottomSize),
618
 
                                        BPoint(r.left, r.top), black);
619
 
                        AddLine(BPoint(r.left + 1.0, r.top),
620
 
                                        BPoint(r.right, r.top), black);
621
 
                        AddLine(BPoint(r.right, r.top + 1.0),
622
 
                                        BPoint(r.right, r.top + handleBottomSize), black);
623
 
                        AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
624
 
                                        BPoint(knobPos, r.top + handleArrowSize), black);
625
 
                        AddLine(BPoint(knobPos - 1.0, r.top + handleArrowSize - 1.0),
626
 
                                        BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), black);
627
 
                        // lower handle
628
 
                        AddLine(BPoint(r.left, r.bottom),
629
 
                                        BPoint(r.left, r.bottom - handleBottomSize), black);
630
 
                        AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
631
 
                                        BPoint(knobPos, r.bottom - handleArrowSize), black);
632
 
                        AddLine(BPoint(knobPos + 1.0, r.bottom - handleArrowSize + 1.0),
633
 
                                        BPoint(r.right, r.bottom - handleBottomSize), black);
634
 
                        AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
635
 
                                        BPoint(r.right, r.bottom), black);
636
 
                        AddLine(BPoint(r.right - 1.0, r.bottom),
637
 
                                        BPoint(r.left + 1.0, r.bottom), black);
638
 
                EndLineArray();
639
 
                // inner red light and shadow lines
640
 
                r.InsetBy(1.0, 1.0);
641
 
                handleBottomSize--;
642
 
                handleArrowSize -= 2.0;
643
 
                BeginLineArray(10);
644
 
                        // upper handle
645
 
                        AddLine(BPoint(r.left, r.top + handleBottomSize),
646
 
                                        BPoint(r.left, r.top), kSeekRedLight);
647
 
                        AddLine(BPoint(r.left + 1.0, r.top),
648
 
                                        BPoint(r.right, r.top), kSeekRedLight);
649
 
                        AddLine(BPoint(r.right, r.top + 1.0),
650
 
                                        BPoint(r.right, r.top + handleBottomSize), kSeekRedShadow);
651
 
                        AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
652
 
                                        BPoint(knobPos, r.top + handleArrowSize), kSeekRedShadow);
653
 
                        AddLine(BPoint(knobPos - 1.0, r.top + handleArrowSize - 1.0),
654
 
                                        BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), kSeekRedLight);
655
 
                        // lower handle
656
 
                        AddLine(BPoint(r.left, r.bottom),
657
 
                                        BPoint(r.left, r.bottom - handleBottomSize), kSeekRedLight);
658
 
                        AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
659
 
                                        BPoint(knobPos, r.bottom - handleArrowSize), kSeekRedLight);
660
 
                        AddLine(BPoint(knobPos + 1.0, r.bottom - handleArrowSize + 1.0),
661
 
                                        BPoint(r.right, r.bottom - handleBottomSize), kSeekRedShadow);
662
 
                        AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
663
 
                                        BPoint(r.right, r.bottom), kSeekRedShadow);
664
 
                        AddLine(BPoint(r.right - 1.0, r.bottom),
665
 
                                        BPoint(r.left + 1.0, r.bottom), kSeekRedShadow);
666
 
                EndLineArray();
667
 
                // fill rest of handles with red
668
 
                SetHighColor(kSeekRed);
669
 
                r.InsetBy(1.0, 1.0);
670
 
                handleArrowSize -= 2.0;
671
 
                BPoint arrow[3];
672
 
                // upper handle arrow
673
 
                arrow[0].x = r.left;
674
 
                arrow[0].y = r.top;
675
 
                arrow[1].x = r.right;
676
 
                arrow[1].y = r.top;
677
 
                arrow[2].x = knobPos;
678
 
                arrow[2].y = r.top + handleArrowSize;
679
 
                FillPolygon(arrow, 3);
680
 
                // lower handle arrow
681
 
                arrow[0].x = r.left;
682
 
                arrow[0].y = r.bottom;
683
 
                arrow[1].x = r.right;
684
 
                arrow[1].y = r.bottom;
685
 
                arrow[2].x = knobPos;
686
 
                arrow[2].y = r.bottom - handleArrowSize;
687
 
                FillPolygon(arrow, 3);
688
 
        }
689
 
        else
690
 
        {
691
 
                r.InsetBy(1.0, 1.0);
692
 
                _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
693
 
                r.InsetBy(1.0, 1.0);
694
 
                _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
695
 
                r.InsetBy(1.0, 1.0);
696
 
                SetHighColor(darkShadow);
697
 
                SetLowColor(shadow);
698
 
                // stripes
699
 
                float width = floorf(StringWidth(DISABLED_SEEK_MESSAGE));
700
 
                float textPos = r.left + r.Width() / 2.0 - width / 2.0;
701
 
                pattern stripes = {{ 0xc7, 0x8f, 0x1f, 0x3e, 0x7c, 0xf8, 0xf1, 0xe3 }};
702
 
                BRect stripesRect(r);
703
 
                stripesRect.right = textPos - 5.0;
704
 
                FillRect(stripesRect, stripes);
705
 
                stripesRect.left = textPos + width + 3.0;
706
 
                stripesRect.right = r.right;
707
 
                FillRect(stripesRect, stripes);
708
 
                // info text
709
 
                r.left = textPos - 4.0;
710
 
                r.right = textPos + width + 2.0;
711
 
                FillRect(r);
712
 
                SetHighColor(shadow);
713
 
                SetLowColor(darkShadow);
714
 
                font_height fh;
715
 
                GetFontHeight(&fh);
716
 
                DrawString(DISABLED_SEEK_MESSAGE, BPoint(textPos, r.top + ceilf(fh.ascent) - 1.0));
717
 
        }
 
561
    BRect r(Bounds());
 
562
    float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
 
563
    float sliderStart = (r.left + knobWidth2);
 
564
    float sliderEnd = (r.right - knobWidth2);
 
565
    float knobPos = sliderStart
 
566
                    + floorf((sliderEnd - sliderStart - 1.0) * Value()
 
567
                    / SEEKSLIDER_RANGE);
 
568
    // draw both sides (the original from Be doesn't seem
 
569
    // to make a difference for enabled/disabled state)
 
570
//    DrawBitmapAsync(fLeftSideBits, r.LeftTop());
 
571
//    DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top));
 
572
    // colors for the slider area between the two bitmaps
 
573
    rgb_color background = kBackground;//ui_color(B_PANEL_BACKGROUND_COLOR);
 
574
    rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
 
575
    rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT);
 
576
    rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);
 
577
    rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT);
 
578
    rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
 
579
    rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT);
 
580
    rgb_color green = kSeekGreen;
 
581
    rgb_color greenShadow = kSeekGreenShadow;
 
582
    rgb_color black = kBlack;
 
583
    rgb_color dotGrey = midShadow;
 
584
    rgb_color dotGreen = greenShadow;
 
585
    // draw frame
 
586
    _StrokeFrame(r, softShadow, softShadow, softLight, softLight);
 
587
    r.InsetBy(1.0, 1.0);
 
588
    _StrokeFrame(r, black, black, light, light);
 
589
    if (IsEnabled())
 
590
    {
 
591
        r.InsetBy(1.0, 1.0);
 
592
        // inner shadow
 
593
        _StrokeFrame(r, greenShadow, greenShadow, green, green);
 
594
        r.top++;
 
595
        r.left++;
 
596
        _StrokeFrame(r, greenShadow, greenShadow, green, green);
 
597
        // inside area
 
598
        r.InsetBy(1.0, 1.0);
 
599
        SetHighColor(green);
 
600
        FillRect(r);
 
601
        // dots
 
602
        int32 dotCount = (int32)(r.Width() / 6.0);
 
603
        BPoint dotPos;
 
604
        dotPos.y = r.top + 2.0;
 
605
        SetHighColor(dotGreen);
 
606
        for (int32 i = 0; i < dotCount; i++)
 
607
        {
 
608
            dotPos.x = sliderStart + i * 6.0 + 5.0;
 
609
            StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 6.0));
 
610
        }
 
611
        // slider handle
 
612
        r.top -= 4.0;
 
613
        r.bottom += 3.0;
 
614
        r.left = knobPos - knobWidth2;
 
615
        r.right = knobPos + knobWidth2;
 
616
        // black outline
 
617
        float handleBottomSize = 2.0;
 
618
        float handleArrowSize = 6.0;
 
619
        BeginLineArray(10);
 
620
            // upper handle
 
621
            AddLine(BPoint(r.left, r.top + handleBottomSize),
 
622
                    BPoint(r.left, r.top), black);
 
623
            AddLine(BPoint(r.left + 1.0, r.top),
 
624
                    BPoint(r.right, r.top), black);
 
625
            AddLine(BPoint(r.right, r.top + 1.0),
 
626
                    BPoint(r.right, r.top + handleBottomSize), black);
 
627
            AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
 
628
                    BPoint(knobPos, r.top + handleArrowSize), black);
 
629
            AddLine(BPoint(knobPos - 1.0, r.top + handleArrowSize - 1.0),
 
630
                    BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), black);
 
631
            // lower handle
 
632
            AddLine(BPoint(r.left, r.bottom),
 
633
                    BPoint(r.left, r.bottom - handleBottomSize), black);
 
634
            AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
 
635
                    BPoint(knobPos, r.bottom - handleArrowSize), black);
 
636
            AddLine(BPoint(knobPos + 1.0, r.bottom - handleArrowSize + 1.0),
 
637
                    BPoint(r.right, r.bottom - handleBottomSize), black);
 
638
            AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
 
639
                    BPoint(r.right, r.bottom), black);
 
640
            AddLine(BPoint(r.right - 1.0, r.bottom),
 
641
                    BPoint(r.left + 1.0, r.bottom), black);
 
642
        EndLineArray();
 
643
        // inner red light and shadow lines
 
644
        r.InsetBy(1.0, 1.0);
 
645
        handleBottomSize--;
 
646
        handleArrowSize -= 2.0;
 
647
        BeginLineArray(10);
 
648
            // upper handle
 
649
            AddLine(BPoint(r.left, r.top + handleBottomSize),
 
650
                    BPoint(r.left, r.top), kSeekRedLight);
 
651
            AddLine(BPoint(r.left + 1.0, r.top),
 
652
                    BPoint(r.right, r.top), kSeekRedLight);
 
653
            AddLine(BPoint(r.right, r.top + 1.0),
 
654
                    BPoint(r.right, r.top + handleBottomSize), kSeekRedShadow);
 
655
            AddLine(BPoint(r.right - 1.0, r.top + handleBottomSize + 1.0),
 
656
                    BPoint(knobPos, r.top + handleArrowSize), kSeekRedShadow);
 
657
            AddLine(BPoint(knobPos - 1.0, r.top + handleArrowSize - 1.0),
 
658
                    BPoint(r.left + 1.0, r.top + handleBottomSize + 1.0), kSeekRedLight);
 
659
            // lower handle
 
660
            AddLine(BPoint(r.left, r.bottom),
 
661
                    BPoint(r.left, r.bottom - handleBottomSize), kSeekRedLight);
 
662
            AddLine(BPoint(r.left + 1.0, r.bottom - handleBottomSize - 1.0),
 
663
                    BPoint(knobPos, r.bottom - handleArrowSize), kSeekRedLight);
 
664
            AddLine(BPoint(knobPos + 1.0, r.bottom - handleArrowSize + 1.0),
 
665
                    BPoint(r.right, r.bottom - handleBottomSize), kSeekRedShadow);
 
666
            AddLine(BPoint(r.right, r.bottom - handleBottomSize + 1.0),
 
667
                    BPoint(r.right, r.bottom), kSeekRedShadow);
 
668
            AddLine(BPoint(r.right - 1.0, r.bottom),
 
669
                    BPoint(r.left + 1.0, r.bottom), kSeekRedShadow);
 
670
        EndLineArray();
 
671
        // fill rest of handles with red
 
672
        SetHighColor(kSeekRed);
 
673
        r.InsetBy(1.0, 1.0);
 
674
        handleArrowSize -= 2.0;
 
675
        BPoint arrow[3];
 
676
        // upper handle arrow
 
677
        arrow[0].x = r.left;
 
678
        arrow[0].y = r.top;
 
679
        arrow[1].x = r.right;
 
680
        arrow[1].y = r.top;
 
681
        arrow[2].x = knobPos;
 
682
        arrow[2].y = r.top + handleArrowSize;
 
683
        FillPolygon(arrow, 3);
 
684
        // lower handle arrow
 
685
        arrow[0].x = r.left;
 
686
        arrow[0].y = r.bottom;
 
687
        arrow[1].x = r.right;
 
688
        arrow[1].y = r.bottom;
 
689
        arrow[2].x = knobPos;
 
690
        arrow[2].y = r.bottom - handleArrowSize;
 
691
        FillPolygon(arrow, 3);
 
692
    }
 
693
    else
 
694
    {
 
695
        r.InsetBy(1.0, 1.0);
 
696
        _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
 
697
        r.InsetBy(1.0, 1.0);
 
698
        _StrokeFrame(r, darkShadow, darkShadow, darkShadow, darkShadow);
 
699
        r.InsetBy(1.0, 1.0);
 
700
        SetHighColor(darkShadow);
 
701
        SetLowColor(shadow);
 
702
        // stripes
 
703
        float width = floorf(StringWidth(DISABLED_SEEK_MESSAGE));
 
704
        float textPos = r.left + r.Width() / 2.0 - width / 2.0;
 
705
        pattern stripes = {{ 0xc7, 0x8f, 0x1f, 0x3e, 0x7c, 0xf8, 0xf1, 0xe3 }};
 
706
        BRect stripesRect(r);
 
707
        stripesRect.right = textPos - 5.0;
 
708
        FillRect(stripesRect, stripes);
 
709
        stripesRect.left = textPos + width + 3.0;
 
710
        stripesRect.right = r.right;
 
711
        FillRect(stripesRect, stripes);
 
712
        // info text
 
713
        r.left = textPos - 4.0;
 
714
        r.right = textPos + width + 2.0;
 
715
        FillRect(r);
 
716
        SetHighColor(shadow);
 
717
        SetLowColor(darkShadow);
 
718
        font_height fh;
 
719
        GetFontHeight(&fh);
 
720
        DrawString(DISABLED_SEEK_MESSAGE, BPoint(textPos, r.top + ceilf(fh.ascent) - 1.0));
 
721
    }
718
722
}
719
723
 
720
724
/*****************************************************************************
723
727
void
724
728
SeekSlider::MouseDown(BPoint where)
725
729
{
726
 
        if (IsEnabled() && Bounds().Contains(where))
727
 
        {
728
 
                SetValue(_ValueFor(where.x));
729
 
                fTracking = true;
730
 
                SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
731
 
        }
 
730
    if (IsEnabled() && Bounds().Contains(where))
 
731
    {
 
732
        SetValue(_ValueFor(where.x));
 
733
        fTracking = true;
 
734
        SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
 
735
    }
732
736
}
733
737
 
734
738
/*****************************************************************************
737
741
void
738
742
SeekSlider::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
739
743
{
740
 
        if (fTracking)
741
 
        {
742
 
                SetValue(_ValueFor(where.x));
743
 
        }
 
744
    if (fTracking)
 
745
    {
 
746
        SetValue(_ValueFor(where.x));
 
747
    }
744
748
}
745
749
 
746
750
/*****************************************************************************
749
753
void
750
754
SeekSlider::MouseUp(BPoint where)
751
755
{
752
 
        if (fTracking)
753
 
        {
754
 
                fTracking = false;
755
 
                input_thread_t * p_input;
756
 
                p_input = (input_thread_t *)
 
756
    if (fTracking)
 
757
    {
 
758
        fTracking = false;
 
759
        input_thread_t * p_input;
 
760
        p_input = (input_thread_t *)
757
761
            vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
758
762
 
759
763
        if( p_input )
760
764
        {
761
 
                    var_SetFloat( p_input, "position",
762
 
                                  (float) Value() / SEEKSLIDER_RANGE );
763
 
                    vlc_object_release( p_input );
764
 
                }
765
 
        }
 
765
            var_SetFloat( p_input, "position",
 
766
                          (float) Value() / SEEKSLIDER_RANGE );
 
767
            vlc_object_release( p_input );
 
768
        }
 
769
    }
766
770
}
767
771
 
768
772
/*****************************************************************************
771
775
void
772
776
SeekSlider::ResizeToPreferred()
773
777
{
774
 
        float width = 15.0 + StringWidth(DISABLED_SEEK_MESSAGE) + 15.0;
775
 
        ResizeTo(width, 17.0);
 
778
    float width = 15.0 + StringWidth(DISABLED_SEEK_MESSAGE) + 15.0;
 
779
    ResizeTo(width, 17.0);
776
780
}
777
781
 
778
782
/*****************************************************************************
781
785
void
782
786
SeekSlider::SetPosition(float position)
783
787
{
784
 
        if ( LockLooper() )
785
 
        {
786
 
            if( !fTracking )
787
 
            {
788
 
                    SetValue( SEEKSLIDER_RANGE * position );
789
 
                }
790
 
                UnlockLooper();
791
 
        }
 
788
    if ( LockLooper() )
 
789
    {
 
790
        if( !fTracking )
 
791
        {
 
792
            SetValue( SEEKSLIDER_RANGE * position );
 
793
        }
 
794
        UnlockLooper();
 
795
    }
792
796
}
793
797
 
794
798
/*****************************************************************************
797
801
int32
798
802
SeekSlider::_ValueFor(float xPos) const
799
803
{
800
 
        BRect r(Bounds());
801
 
        float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
802
 
        float sliderStart = (r.left + knobWidth2);
803
 
        float sliderEnd = (r.right - knobWidth2);
804
 
        int32 value =  (int32)(((xPos - sliderStart) * SEEKSLIDER_RANGE)
805
 
                                  / (sliderEnd - sliderStart - 1.0));
806
 
        if (value < 0)
807
 
                value = 0;
808
 
        if (value > SEEKSLIDER_RANGE)
809
 
                value = SEEKSLIDER_RANGE;
810
 
        return value;
 
804
    BRect r(Bounds());
 
805
    float knobWidth2 = SEEK_SLIDER_KNOB_WIDTH / 2.0;
 
806
    float sliderStart = (r.left + knobWidth2);
 
807
    float sliderEnd = (r.right - knobWidth2);
 
808
    int32 value =  (int32)(((xPos - sliderStart) * SEEKSLIDER_RANGE)
 
809
                  / (sliderEnd - sliderStart - 1.0));
 
810
    if (value < 0)
 
811
        value = 0;
 
812
    if (value > SEEKSLIDER_RANGE)
 
813
        value = SEEKSLIDER_RANGE;
 
814
    return value;
811
815
}
812
816
 
813
817
/*****************************************************************************
815
819
 *****************************************************************************/
816
820
void
817
821
SeekSlider::_StrokeFrame(BRect r, rgb_color left, rgb_color top,
818
 
                                                 rgb_color right, rgb_color bottom)
 
822
                         rgb_color right, rgb_color bottom)
819
823
{
820
 
        BeginLineArray(4);
821
 
                AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), left);
822
 
                AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), top);
823
 
                AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), right);
824
 
                AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), bottom);
825
 
        EndLineArray();
 
824
    BeginLineArray(4);
 
825
        AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), left);
 
826
        AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), top);
 
827
        AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), right);
 
828
        AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), bottom);
 
829
    EndLineArray();
826
830
}
827
831
 
828
832
/*****************************************************************************
829
833
 * VolumeSlider
830
834
 *****************************************************************************/
831
835
VolumeSlider::VolumeSlider(BRect frame, const char* name, int32 minValue, int32 maxValue,
832
 
                                                   BMessage* message, BHandler* target)
833
 
        : BControl(frame, name, NULL, message, B_FOLLOW_NONE,
834
 
                           B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
835
 
          fLeftSideBits(NULL),
836
 
          fRightSideBits(NULL),
837
 
          fKnobBits(NULL),
838
 
          fTracking(false),
839
 
          fMuted(false),
840
 
          fMinValue(minValue),
841
 
          fMaxValue(maxValue)
 
836
                           BMessage* message, BHandler* target)
 
837
    : BControl(frame, name, NULL, message, B_FOLLOW_NONE,
 
838
               B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE),
 
839
      fLeftSideBits(NULL),
 
840
      fRightSideBits(NULL),
 
841
      fKnobBits(NULL),
 
842
      fTracking(false),
 
843
      fMuted(false),
 
844
      fMinValue(minValue),
 
845
      fMaxValue(maxValue)
842
846
{
843
 
        SetTarget(target);
844
 
 
845
 
        // create bitmaps
846
 
        BRect r(BPoint(0.0, 0.0), kVolumeSliderBitmapSize);
847
 
        fLeftSideBits = new BBitmap(r, B_CMAP8);
848
 
        fRightSideBits = new BBitmap(r, B_CMAP8);
849
 
        r.Set(0.0, 0.0, kVolumeSliderKnobBitmapSize.x, kVolumeSliderKnobBitmapSize.y);
850
 
        fKnobBits = new BBitmap(r, B_CMAP8);
851
 
 
852
 
        _MakeBitmaps();
 
847
    SetTarget(target);
 
848
 
 
849
    // create bitmaps
 
850
    BRect r(BPoint(0.0, 0.0), kVolumeSliderBitmapSize);
 
851
    fLeftSideBits = new BBitmap(r, B_CMAP8);
 
852
    fRightSideBits = new BBitmap(r, B_CMAP8);
 
853
    r.Set(0.0, 0.0, kVolumeSliderKnobBitmapSize.x, kVolumeSliderKnobBitmapSize.y);
 
854
    fKnobBits = new BBitmap(r, B_CMAP8);
 
855
 
 
856
    _MakeBitmaps();
853
857
}
854
858
 
855
859
/*****************************************************************************
857
861
 *****************************************************************************/
858
862
VolumeSlider::~VolumeSlider()
859
863
{
860
 
        delete fLeftSideBits;
861
 
        delete fRightSideBits;
862
 
        delete fKnobBits;
 
864
    delete fLeftSideBits;
 
865
    delete fRightSideBits;
 
866
    delete fKnobBits;
863
867
}
864
868
 
865
869
/*****************************************************************************
868
872
void
869
873
VolumeSlider::AttachedToWindow()
870
874
{
871
 
        BControl::AttachedToWindow();
872
 
        SetViewColor(B_TRANSPARENT_32_BIT);
 
875
    BControl::AttachedToWindow();
 
876
    SetViewColor(B_TRANSPARENT_32_BIT);
873
877
}
874
878
 
875
879
/*****************************************************************************
878
882
void
879
883
VolumeSlider::SetValue(int32 value)
880
884
{
881
 
        if (value != Value())
882
 
        {
883
 
                BControl::SetValue(value);
884
 
                Invoke();
885
 
        }
 
885
    if (value != Value())
 
886
    {
 
887
        BControl::SetValue(value);
 
888
        Invoke();
 
889
    }
886
890
}
887
891
 
888
892
/*****************************************************************************
891
895
void
892
896
VolumeSlider::SetEnabled(bool enable)
893
897
{
894
 
        if (enable != IsEnabled())
895
 
        {
896
 
                BControl::SetEnabled(enable);
897
 
                _MakeBitmaps();
898
 
                Invalidate();
899
 
        }
 
898
    if (enable != IsEnabled())
 
899
    {
 
900
        BControl::SetEnabled(enable);
 
901
        _MakeBitmaps();
 
902
        Invalidate();
 
903
    }
900
904
}
901
905
 
902
906
/*****************************************************************************
905
909
void
906
910
VolumeSlider::Draw(BRect updateRect)
907
911
{
908
 
        if (IsValid())
909
 
        {
910
 
                BRect r(Bounds());
911
 
                float sliderSideWidth = kVolumeSliderBitmapWidth;
912
 
                float sliderStart = (r.left + sliderSideWidth);
913
 
                float sliderEnd = (r.right - sliderSideWidth);
914
 
                float knobPos = sliderStart
915
 
                                                + (sliderEnd - sliderStart - 1.0) * (Value() - fMinValue)
916
 
                                                / (fMaxValue - fMinValue);
917
 
                // draw both sides (the original from Be doesn't seem
918
 
                // to make a difference for enabled/disabled state)
919
 
                DrawBitmapAsync(fLeftSideBits, r.LeftTop());
920
 
                DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top));
921
 
                // colors for the slider area between the two bitmaps
922
 
                rgb_color background = kBackground;//ui_color(B_PANEL_BACKGROUND_COLOR);
923
 
                rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
924
 
                rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT);
925
 
                rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);
926
 
                rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT);
927
 
                rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
928
 
                rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT);
929
 
                rgb_color green = kGreen;
930
 
                rgb_color greenShadow = kGreenShadow;
931
 
                rgb_color black = kBlack;
932
 
                rgb_color dotGrey = midShadow;
933
 
                rgb_color dotGreen = greenShadow;
934
 
                // make dimmed version of colors if we're disabled
935
 
                if (!IsEnabled())
936
 
                {
937
 
                        shadow = (rgb_color){ 200, 200, 200, 255 };
938
 
                        softShadow = dimmed_color_cmap8(softShadow, background, DIM_LEVEL);
939
 
                        darkShadow = dimmed_color_cmap8(darkShadow, background, DIM_LEVEL);
940
 
                        midShadow = shadow;
941
 
                        light = dimmed_color_cmap8(light, background, DIM_LEVEL);
942
 
                        softLight = dimmed_color_cmap8(softLight, background, DIM_LEVEL);
943
 
                        green = dimmed_color_cmap8(green, background, DIM_LEVEL);
944
 
                        greenShadow = dimmed_color_cmap8(greenShadow, background, DIM_LEVEL);
945
 
                        black = dimmed_color_cmap8(black, background, DIM_LEVEL);
946
 
                        dotGreen = dotGrey;
947
 
                }
948
 
                else if (fMuted)
949
 
                {
950
 
                        green = tint_color(kBackground, B_DARKEN_3_TINT);
951
 
                        greenShadow = tint_color(kBackground, B_DARKEN_4_TINT);
952
 
                        dotGreen = greenShadow;
953
 
                }
954
 
                // draw slider edges between bitmaps
955
 
                BeginLineArray(7);
956
 
                        AddLine(BPoint(sliderStart, r.top),
957
 
                                        BPoint(sliderEnd, r.top), softShadow);
958
 
                        AddLine(BPoint(sliderStart, r.bottom),
959
 
                                        BPoint(sliderEnd, r.bottom), softLight);
960
 
                        r.InsetBy(0.0, 1.0);
961
 
                        AddLine(BPoint(sliderStart, r.top),
962
 
                                        BPoint(sliderEnd, r.top), black);
963
 
                        AddLine(BPoint(sliderStart, r.bottom),
964
 
                                        BPoint(sliderEnd, r.bottom), light);
965
 
                        r.top++;
966
 
                        AddLine(BPoint(sliderStart, r.top),
967
 
                                        BPoint(knobPos, r.top), greenShadow);
968
 
                        AddLine(BPoint(knobPos, r.top),
969
 
                                        BPoint(sliderEnd, r.top), midShadow);
970
 
                        r.top++;
971
 
                        AddLine(BPoint(sliderStart, r.top),
972
 
                                        BPoint(knobPos, r.top), greenShadow);
973
 
                EndLineArray();
974
 
                // fill rest inside of slider
975
 
                r.InsetBy(0.0, 1.0);
976
 
                r.left = sliderStart;
977
 
                r.right = knobPos;
978
 
                SetHighColor(green);
979
 
                FillRect(r, B_SOLID_HIGH);
980
 
                r.left = knobPos + 1.0;
981
 
                r.right = sliderEnd;
982
 
                r.top -= 1.0;
983
 
                SetHighColor(shadow);
984
 
                FillRect(r, B_SOLID_HIGH);
985
 
                // draw little dots inside
986
 
                int32 dotCount = (int32)((sliderEnd - sliderStart) / 5.0);
987
 
                BPoint dotPos;
988
 
                dotPos.y = r.top + 4.0;
989
 
                for (int32 i = 0; i < dotCount; i++)
990
 
                {
991
 
                        dotPos.x = sliderStart + i * 5.0 + 4.0;
992
 
                        SetHighColor(dotPos.x < knobPos ? dotGreen : dotGrey);
993
 
                        StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 1.0));
994
 
                }
995
 
                // draw knob
996
 
                r.top -= 1.0;
997
 
                SetDrawingMode(B_OP_OVER); // part of knob is transparent
998
 
                DrawBitmapAsync(fKnobBits, BPoint(knobPos - kVolumeSliderKnobWidth / 2, r.top));
999
 
        }
 
912
    if (IsValid())
 
913
    {
 
914
        BRect r(Bounds());
 
915
        float sliderSideWidth = kVolumeSliderBitmapWidth;
 
916
        float sliderStart = (r.left + sliderSideWidth);
 
917
        float sliderEnd = (r.right - sliderSideWidth);
 
918
        float knobPos = sliderStart
 
919
                        + (sliderEnd - sliderStart - 1.0) * (Value() - fMinValue)
 
920
                        / (fMaxValue - fMinValue);
 
921
        // draw both sides (the original from Be doesn't seem
 
922
        // to make a difference for enabled/disabled state)
 
923
        DrawBitmapAsync(fLeftSideBits, r.LeftTop());
 
924
        DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top));
 
925
        // colors for the slider area between the two bitmaps
 
926
        rgb_color background = kBackground;//ui_color(B_PANEL_BACKGROUND_COLOR);
 
927
        rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
 
928
        rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT);
 
929
        rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);
 
930
        rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT);
 
931
        rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
 
932
        rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT);
 
933
        rgb_color green = kGreen;
 
934
        rgb_color greenShadow = kGreenShadow;
 
935
        rgb_color black = kBlack;
 
936
        rgb_color dotGrey = midShadow;
 
937
        rgb_color dotGreen = greenShadow;
 
938
        // make dimmed version of colors if we're disabled
 
939
        if (!IsEnabled())
 
940
        {
 
941
            shadow = (rgb_color){ 200, 200, 200, 255 };
 
942
            softShadow = dimmed_color_cmap8(softShadow, background, DIM_LEVEL);
 
943
            darkShadow = dimmed_color_cmap8(darkShadow, background, DIM_LEVEL);
 
944
            midShadow = shadow;
 
945
            light = dimmed_color_cmap8(light, background, DIM_LEVEL);
 
946
            softLight = dimmed_color_cmap8(softLight, background, DIM_LEVEL);
 
947
            green = dimmed_color_cmap8(green, background, DIM_LEVEL);
 
948
            greenShadow = dimmed_color_cmap8(greenShadow, background, DIM_LEVEL);
 
949
            black = dimmed_color_cmap8(black, background, DIM_LEVEL);
 
950
            dotGreen = dotGrey;
 
951
        }
 
952
        else if (fMuted)
 
953
        {
 
954
            green = tint_color(kBackground, B_DARKEN_3_TINT);
 
955
            greenShadow = tint_color(kBackground, B_DARKEN_4_TINT);
 
956
            dotGreen = greenShadow;
 
957
        }
 
958
        // draw slider edges between bitmaps
 
959
        BeginLineArray(7);
 
960
            AddLine(BPoint(sliderStart, r.top),
 
961
                    BPoint(sliderEnd, r.top), softShadow);
 
962
            AddLine(BPoint(sliderStart, r.bottom),
 
963
                    BPoint(sliderEnd, r.bottom), softLight);
 
964
            r.InsetBy(0.0, 1.0);
 
965
            AddLine(BPoint(sliderStart, r.top),
 
966
                    BPoint(sliderEnd, r.top), black);
 
967
            AddLine(BPoint(sliderStart, r.bottom),
 
968
                    BPoint(sliderEnd, r.bottom), light);
 
969
            r.top++;
 
970
            AddLine(BPoint(sliderStart, r.top),
 
971
                    BPoint(knobPos, r.top), greenShadow);
 
972
            AddLine(BPoint(knobPos, r.top),
 
973
                    BPoint(sliderEnd, r.top), midShadow);
 
974
            r.top++;
 
975
            AddLine(BPoint(sliderStart, r.top),
 
976
                    BPoint(knobPos, r.top), greenShadow);
 
977
        EndLineArray();
 
978
        // fill rest inside of slider
 
979
        r.InsetBy(0.0, 1.0);
 
980
        r.left = sliderStart;
 
981
        r.right = knobPos;
 
982
        SetHighColor(green);
 
983
        FillRect(r, B_SOLID_HIGH);
 
984
        r.left = knobPos + 1.0;
 
985
        r.right = sliderEnd;
 
986
        r.top -= 1.0;
 
987
        SetHighColor(shadow);
 
988
        FillRect(r, B_SOLID_HIGH);
 
989
        // draw little dots inside
 
990
        int32 dotCount = (int32)((sliderEnd - sliderStart) / 5.0);
 
991
        BPoint dotPos;
 
992
        dotPos.y = r.top + 4.0;
 
993
        for (int32 i = 0; i < dotCount; i++)
 
994
        {
 
995
            dotPos.x = sliderStart + i * 5.0 + 4.0;
 
996
            SetHighColor(dotPos.x < knobPos ? dotGreen : dotGrey);
 
997
            StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 1.0));
 
998
        }
 
999
        // draw knob
 
1000
        r.top -= 1.0;
 
1001
        SetDrawingMode(B_OP_OVER); // part of knob is transparent
 
1002
        DrawBitmapAsync(fKnobBits, BPoint(knobPos - kVolumeSliderKnobWidth / 2, r.top));
 
1003
    }
1000
1004
}
1001
1005
 
1002
1006
/*****************************************************************************
1005
1009
void
1006
1010
VolumeSlider::MouseDown(BPoint where)
1007
1011
{
1008
 
        if (Bounds().Contains(where) && IsEnabled())
1009
 
        {
1010
 
                fTracking = true;
1011
 
                SetValue(_ValueFor(where.x));
1012
 
                SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
1013
 
        }
 
1012
    if (Bounds().Contains(where) && IsEnabled())
 
1013
    {
 
1014
        fTracking = true;
 
1015
        SetValue(_ValueFor(where.x));
 
1016
        SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
 
1017
    }
1014
1018
}
1015
1019
 
1016
1020
/*****************************************************************************
1019
1023
void
1020
1024
VolumeSlider::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
1021
1025
{
1022
 
        if (fTracking)
1023
 
                SetValue(_ValueFor(where.x));
 
1026
    if (fTracking)
 
1027
        SetValue(_ValueFor(where.x));
1024
1028
}
1025
1029
 
1026
1030
/*****************************************************************************
1029
1033
void
1030
1034
VolumeSlider::MouseUp(BPoint where)
1031
1035
{
1032
 
        fTracking = false;
 
1036
    fTracking = false;
1033
1037
}
1034
1038
 
1035
1039
 
1039
1043
bool
1040
1044
VolumeSlider::IsValid() const
1041
1045
{
1042
 
        return (fLeftSideBits && fLeftSideBits->IsValid()
1043
 
                        && fRightSideBits && fRightSideBits->IsValid()
1044
 
                        && fKnobBits && fKnobBits->IsValid());
 
1046
    return (fLeftSideBits && fLeftSideBits->IsValid()
 
1047
            && fRightSideBits && fRightSideBits->IsValid()
 
1048
            && fKnobBits && fKnobBits->IsValid());
1045
1049
}
1046
1050
 
1047
1051
/*****************************************************************************
1050
1054
void
1051
1055
VolumeSlider::SetMuted(bool mute)
1052
1056
{
1053
 
        if (mute != fMuted)
1054
 
        {
1055
 
                fMuted = mute;
1056
 
                _MakeBitmaps();
1057
 
                Invalidate();
1058
 
        }
 
1057
    if (mute != fMuted)
 
1058
    {
 
1059
        fMuted = mute;
 
1060
        _MakeBitmaps();
 
1061
        Invalidate();
 
1062
    }
1059
1063
}
1060
1064
 
1061
1065
/*****************************************************************************
1064
1068
void
1065
1069
VolumeSlider::_MakeBitmaps()
1066
1070
{
1067
 
        if (IsValid())
1068
 
        {
1069
 
                // left side of slider
1070
 
                memcpy(fLeftSideBits->Bits(), kVolumeSliderLeftBitmapBits,
1071
 
                           fLeftSideBits->BitsLength());
1072
 
                // right side of slider
1073
 
                memcpy(fRightSideBits->Bits(), kVolumeSliderRightBits,
1074
 
                           fRightSideBits->BitsLength());
1075
 
                // slider knob
1076
 
                int32 length = fKnobBits->BitsLength();
1077
 
                memcpy(fKnobBits->Bits(), kVolumeSliderKnobBits, length);
1078
 
                uint8* bits = (uint8*)fKnobBits->Bits();
1079
 
                // black was used in the knob to represent transparency
1080
 
                // use screen to get index for the "transarent" color used in the bitmap
1081
 
                BScreen screen(B_MAIN_SCREEN_ID);
1082
 
                uint8 blackIndex = screen.IndexForColor(kBlack);
1083
 
                // replace black index with transparent index
1084
 
                for (int32 i = 0; i < length; i++)
1085
 
                        if (bits[i] == blackIndex)
1086
 
                                bits[i] = B_TRANSPARENT_MAGIC_CMAP8;
 
1071
    if (IsValid())
 
1072
    {
 
1073
        // left side of slider
 
1074
        memcpy(fLeftSideBits->Bits(), kVolumeSliderLeftBitmapBits,
 
1075
               fLeftSideBits->BitsLength());
 
1076
        // right side of slider
 
1077
        memcpy(fRightSideBits->Bits(), kVolumeSliderRightBits,
 
1078
               fRightSideBits->BitsLength());
 
1079
        // slider knob
 
1080
        int32 length = fKnobBits->BitsLength();
 
1081
        memcpy(fKnobBits->Bits(), kVolumeSliderKnobBits, length);
 
1082
        uint8* bits = (uint8*)fKnobBits->Bits();
 
1083
        // black was used in the knob to represent transparency
 
1084
        // use screen to get index for the "transarent" color used in the bitmap
 
1085
        BScreen screen(B_MAIN_SCREEN_ID);
 
1086
        uint8 blackIndex = screen.IndexForColor(kBlack);
 
1087
        // replace black index with transparent index
 
1088
        for (int32 i = 0; i < length; i++)
 
1089
            if (bits[i] == blackIndex)
 
1090
                bits[i] = B_TRANSPARENT_MAGIC_CMAP8;
1087
1091
 
1088
 
                if (!IsEnabled())
1089
 
                {
1090
 
                        // make ghosted versions of the bitmaps
1091
 
                        dim_bitmap(fLeftSideBits, kBackground, DIM_LEVEL);
1092
 
                        dim_bitmap(fRightSideBits, kBackground, DIM_LEVEL);
1093
 
                        dim_bitmap(fKnobBits, kBackground, DIM_LEVEL);
1094
 
                }
1095
 
                else if (fMuted)
1096
 
                {
1097
 
                        // replace green color (and shadow) in left slider side
1098
 
                        bits = (uint8*)fLeftSideBits->Bits();
1099
 
                        length = fLeftSideBits->BitsLength();
1100
 
                        uint8 greenIndex = screen.IndexForColor(kGreen);
1101
 
                        uint8 greenShadowIndex = screen.IndexForColor(kGreenShadow);
1102
 
                        rgb_color shadow = tint_color(kBackground, B_DARKEN_3_TINT);
1103
 
                        rgb_color midShadow = tint_color(kBackground, B_DARKEN_4_TINT);
1104
 
                        uint8 replaceIndex = screen.IndexForColor(shadow);
1105
 
                        uint8 replaceShadowIndex = screen.IndexForColor(midShadow);
1106
 
                        for (int32 i = 0; i < length; i++)
1107
 
                        {
1108
 
                                if (bits[i] == greenIndex)
1109
 
                                        bits[i] = replaceIndex;
1110
 
                                else if (bits[i] == greenShadowIndex)
1111
 
                                        bits[i] = replaceShadowIndex;
1112
 
                        }
1113
 
                }
1114
 
        }
 
1092
        if (!IsEnabled())
 
1093
        {
 
1094
            // make ghosted versions of the bitmaps
 
1095
            dim_bitmap(fLeftSideBits, kBackground, DIM_LEVEL);
 
1096
            dim_bitmap(fRightSideBits, kBackground, DIM_LEVEL);
 
1097
            dim_bitmap(fKnobBits, kBackground, DIM_LEVEL);
 
1098
        }
 
1099
        else if (fMuted)
 
1100
        {
 
1101
            // replace green color (and shadow) in left slider side
 
1102
            bits = (uint8*)fLeftSideBits->Bits();
 
1103
            length = fLeftSideBits->BitsLength();
 
1104
            uint8 greenIndex = screen.IndexForColor(kGreen);
 
1105
            uint8 greenShadowIndex = screen.IndexForColor(kGreenShadow);
 
1106
            rgb_color shadow = tint_color(kBackground, B_DARKEN_3_TINT);
 
1107
            rgb_color midShadow = tint_color(kBackground, B_DARKEN_4_TINT);
 
1108
            uint8 replaceIndex = screen.IndexForColor(shadow);
 
1109
            uint8 replaceShadowIndex = screen.IndexForColor(midShadow);
 
1110
            for (int32 i = 0; i < length; i++)
 
1111
            {
 
1112
                if (bits[i] == greenIndex)
 
1113
                    bits[i] = replaceIndex;
 
1114
                else if (bits[i] == greenShadowIndex)
 
1115
                    bits[i] = replaceShadowIndex;
 
1116
            }
 
1117
        }
 
1118
    }
1115
1119
}
1116
1120
 
1117
1121
/*****************************************************************************
1120
1124
int32
1121
1125
VolumeSlider::_ValueFor(float xPos) const
1122
1126
{
1123
 
        BRect r(Bounds());
1124
 
        float sliderStart = (r.left + kVolumeSliderBitmapWidth);
1125
 
        float sliderEnd = (r.right - kVolumeSliderBitmapWidth);
1126
 
        int32 value =  fMinValue + (int32)(((xPos - sliderStart) * (fMaxValue - fMinValue))
1127
 
                                  / (sliderEnd - sliderStart - 1.0));
1128
 
        if (value < fMinValue)
1129
 
                value = fMinValue;
1130
 
        if (value > fMaxValue)
1131
 
                value = fMaxValue;
1132
 
        return value;
 
1127
    BRect r(Bounds());
 
1128
    float sliderStart = (r.left + kVolumeSliderBitmapWidth);
 
1129
    float sliderEnd = (r.right - kVolumeSliderBitmapWidth);
 
1130
    int32 value =  fMinValue + (int32)(((xPos - sliderStart) * (fMaxValue - fMinValue))
 
1131
                  / (sliderEnd - sliderStart - 1.0));
 
1132
    if (value < fMinValue)
 
1133
        value = fMinValue;
 
1134
    if (value > fMaxValue)
 
1135
        value = fMaxValue;
 
1136
    return value;
1133
1137
}
1134
1138
 
1135
1139
/*****************************************************************************
1137
1141
 *****************************************************************************/
1138
1142
PositionInfoView::PositionInfoView( BRect frame, const char* name,
1139
1143
                                    intf_thread_t * p_interface )
1140
 
        : BView( frame, name, B_FOLLOW_NONE,
1141
 
                         B_WILL_DRAW | B_PULSE_NEEDED | B_FULL_UPDATE_ON_RESIZE ),
1142
 
          fMode( MODE_SMALL ),
1143
 
          fCurrentFileIndex( -1 ),
1144
 
          fCurrentFileSize( -1 ),
1145
 
          fCurrentTitleIndex( -1 ),
1146
 
          fCurrentTitleSize( -1 ),
1147
 
          fCurrentChapterIndex( -1 ),
1148
 
          fCurrentChapterSize( -1 ),
1149
 
          fSeconds( -1 ),
1150
 
          fTimeString( "-:--:--" ),
1151
 
          fLastPulseUpdate( system_time() ),
1152
 
          fStackedWidthCache( 0.0 ),
1153
 
          fStackedHeightCache( 0.0 )
 
1144
    : BView( frame, name, B_FOLLOW_NONE,
 
1145
             B_WILL_DRAW | B_PULSE_NEEDED | B_FULL_UPDATE_ON_RESIZE ),
 
1146
      fMode( MODE_SMALL ),
 
1147
      fCurrentFileIndex( -1 ),
 
1148
      fCurrentFileSize( -1 ),
 
1149
      fCurrentTitleIndex( -1 ),
 
1150
      fCurrentTitleSize( -1 ),
 
1151
      fCurrentChapterIndex( -1 ),
 
1152
      fCurrentChapterSize( -1 ),
 
1153
      fSeconds( -1 ),
 
1154
      fTimeString( "-:--:--" ),
 
1155
      fLastPulseUpdate( system_time() ),
 
1156
      fStackedWidthCache( 0.0 ),
 
1157
      fStackedHeightCache( 0.0 )
1154
1158
{
1155
1159
    p_intf = p_interface;
1156
1160
 
1157
 
        SetViewColor( B_TRANSPARENT_32_BIT );
1158
 
        SetLowColor( kBlack );
1159
 
        SetHighColor( 0, 255, 0, 255 );
1160
 
        SetFontSize( 11.0 );
 
1161
    SetViewColor( B_TRANSPARENT_32_BIT );
 
1162
    SetLowColor( kBlack );
 
1163
    SetHighColor( 0, 255, 0, 255 );
 
1164
    SetFontSize( 11.0 );
1161
1165
}
1162
1166
 
1163
1167
/*****************************************************************************
1173
1177
void
1174
1178
PositionInfoView::Draw( BRect updateRect )
1175
1179
{
1176
 
        rgb_color background = ui_color( B_PANEL_BACKGROUND_COLOR );
1177
 
        rgb_color shadow = tint_color( background, B_DARKEN_1_TINT );
1178
 
        rgb_color darkShadow = tint_color( background, B_DARKEN_4_TINT );
1179
 
        rgb_color light = tint_color( background, B_LIGHTEN_MAX_TINT );
1180
 
        rgb_color softLight = tint_color( background, B_LIGHTEN_1_TINT );
1181
 
        // frame
1182
 
        BRect r( Bounds() );
1183
 
        BeginLineArray( 8 );
1184
 
                AddLine( BPoint( r.left, r.bottom ),
1185
 
                                 BPoint( r.left, r.top ), shadow );
1186
 
                AddLine( BPoint( r.left + 1.0, r.top ),
1187
 
                                 BPoint( r.right, r.top ), shadow );
1188
 
                AddLine( BPoint( r.right, r.top + 1.0 ),
1189
 
                                 BPoint( r.right, r.bottom ), softLight );
1190
 
                AddLine( BPoint( r.right - 1.0, r.bottom ),
1191
 
                                 BPoint( r.left + 1.0, r.bottom ), softLight );
1192
 
                r.InsetBy( 1.0, 1.0 );
1193
 
                AddLine( BPoint( r.left, r.bottom ),
1194
 
                                 BPoint( r.left, r.top ), darkShadow );
1195
 
                AddLine( BPoint( r.left + 1.0, r.top ),
1196
 
                                 BPoint( r.right, r.top ), darkShadow );
1197
 
                AddLine( BPoint( r.right, r.top + 1.0 ),
1198
 
                                 BPoint( r.right, r.bottom ), light );
1199
 
                AddLine( BPoint( r.right - 1.0, r.bottom ),
1200
 
                                 BPoint( r.left + 1.0, r.bottom ), light );
1201
 
        EndLineArray();
1202
 
        // background
1203
 
        r.InsetBy( 1.0, 1.0 );
1204
 
        FillRect( r, B_SOLID_LOW );
1205
 
        // contents
1206
 
        font_height fh;
1207
 
        GetFontHeight( &fh );
1208
 
        switch ( fMode )
1209
 
        {
1210
 
                case MODE_SMALL:
1211
 
                {
1212
 
                        float width = StringWidth( fTimeString.String() );
1213
 
                        DrawString( fTimeString.String(),
1214
 
                                                BPoint( r.left + r.Width() / 2.0 - width / 2.0,
1215
 
                                                                r.top + r.Height() / 2.0 + fh.ascent / 2.0 - 1.0 ) );
1216
 
                        break;
1217
 
                }
1218
 
                case MODE_BIG:
1219
 
                {
1220
 
                        BFont font;
1221
 
                        GetFont( &font );
1222
 
                        BFont smallFont = font;
1223
 
                        BFont bigFont = font;
1224
 
                        BFont tinyFont = font;
1225
 
                        smallFont.SetSize( r.Height() / 5.0 );
1226
 
                        bigFont.SetSize( r.Height() / 3.0 );
1227
 
                        tinyFont.SetSize( r.Height() / 7.0 );
1228
 
                        float timeHeight = r.Height() / 2.5;
1229
 
                        float height = ( r.Height() - timeHeight ) / 3.0;
1230
 
                        SetFont( &tinyFont );
1231
 
                        SetHighColor( 0, 180, 0, 255 );
1232
 
                        DrawString( _("File"), BPoint( r.left + 3.0, r.top + height ) );
1233
 
                        DrawString( _("Title"), BPoint( r.left + 3.0, r.top + 2.0 * height ) );
1234
 
                        DrawString( _("Chapter"), BPoint( r.left + 3.0, r.top + 3.0 * height ) );
1235
 
                        SetFont( &smallFont );
1236
 
                        BString helper;
1237
 
                        SetHighColor( 0, 255, 0, 255 );
1238
 
                        // file
1239
 
                        _MakeString( helper, fCurrentFileIndex, fCurrentFileSize );
1240
 
                        float width = StringWidth( helper.String() );
1241
 
                        DrawString( helper.String(), BPoint( r.right - 3.0 - width, r.top + height ) );
1242
 
                        // title
1243
 
                        _MakeString( helper, fCurrentTitleIndex, fCurrentTitleSize );
1244
 
                        width = StringWidth( helper.String() );
1245
 
                        DrawString( helper.String(), BPoint( r.right - 3.0 - width, r.top + 2.0 * height ) );
1246
 
                        // chapter
1247
 
                        _MakeString( helper, fCurrentChapterIndex, fCurrentChapterSize );
1248
 
                        width = StringWidth( helper.String() );
1249
 
                        DrawString( helper.String(), BPoint( r.right - 3.0 - width, r.top + 3.0 * height ) );
1250
 
                        // time
1251
 
                        SetFont( &bigFont );
1252
 
                        width = StringWidth( fTimeString.String() );
1253
 
                        DrawString( fTimeString.String(),
1254
 
                                                BPoint( r.left + r.Width() / 2.0 - width / 2.0,
1255
 
                                                                r.bottom - 3.0 ) );
1256
 
                        break;
1257
 
                }
1258
 
        }
 
1180
    rgb_color background = ui_color( B_PANEL_BACKGROUND_COLOR );
 
1181
    rgb_color shadow = tint_color( background, B_DARKEN_1_TINT );
 
1182
    rgb_color darkShadow = tint_color( background, B_DARKEN_4_TINT );
 
1183
    rgb_color light = tint_color( background, B_LIGHTEN_MAX_TINT );
 
1184
    rgb_color softLight = tint_color( background, B_LIGHTEN_1_TINT );
 
1185
    // frame
 
1186
    BRect r( Bounds() );
 
1187
    BeginLineArray( 8 );
 
1188
        AddLine( BPoint( r.left, r.bottom ),
 
1189
                 BPoint( r.left, r.top ), shadow );
 
1190
        AddLine( BPoint( r.left + 1.0, r.top ),
 
1191
                 BPoint( r.right, r.top ), shadow );
 
1192
        AddLine( BPoint( r.right, r.top + 1.0 ),
 
1193
                 BPoint( r.right, r.bottom ), softLight );
 
1194
        AddLine( BPoint( r.right - 1.0, r.bottom ),
 
1195
                 BPoint( r.left + 1.0, r.bottom ), softLight );
 
1196
        r.InsetBy( 1.0, 1.0 );
 
1197
        AddLine( BPoint( r.left, r.bottom ),
 
1198
                 BPoint( r.left, r.top ), darkShadow );
 
1199
        AddLine( BPoint( r.left + 1.0, r.top ),
 
1200
                 BPoint( r.right, r.top ), darkShadow );
 
1201
        AddLine( BPoint( r.right, r.top + 1.0 ),
 
1202
                 BPoint( r.right, r.bottom ), light );
 
1203
        AddLine( BPoint( r.right - 1.0, r.bottom ),
 
1204
                 BPoint( r.left + 1.0, r.bottom ), light );
 
1205
    EndLineArray();
 
1206
    // background
 
1207
    r.InsetBy( 1.0, 1.0 );
 
1208
    FillRect( r, B_SOLID_LOW );
 
1209
    // contents
 
1210
    font_height fh;
 
1211
    GetFontHeight( &fh );
 
1212
    switch ( fMode )
 
1213
    {
 
1214
        case MODE_SMALL:
 
1215
        {
 
1216
            float width = StringWidth( fTimeString.String() );
 
1217
            DrawString( fTimeString.String(),
 
1218
                        BPoint( r.left + r.Width() / 2.0 - width / 2.0,
 
1219
                                r.top + r.Height() / 2.0 + fh.ascent / 2.0 - 1.0 ) );
 
1220
            break;
 
1221
        }
 
1222
        case MODE_BIG:
 
1223
        {
 
1224
            BFont font;
 
1225
            GetFont( &font );
 
1226
            BFont smallFont = font;
 
1227
            BFont bigFont = font;
 
1228
            BFont tinyFont = font;
 
1229
            smallFont.SetSize( r.Height() / 5.0 );
 
1230
            bigFont.SetSize( r.Height() / 3.0 );
 
1231
            tinyFont.SetSize( r.Height() / 7.0 );
 
1232
            float timeHeight = r.Height() / 2.5;
 
1233
            float height = ( r.Height() - timeHeight ) / 3.0;
 
1234
            SetFont( &tinyFont );
 
1235
            SetHighColor( 0, 180, 0, 255 );
 
1236
            DrawString( _("File"), BPoint( r.left + 3.0, r.top + height ) );
 
1237
            DrawString( _("Title"), BPoint( r.left + 3.0, r.top + 2.0 * height ) );
 
1238
            DrawString( _("Chapter"), BPoint( r.left + 3.0, r.top + 3.0 * height ) );
 
1239
            SetFont( &smallFont );
 
1240
            BString helper;
 
1241
            SetHighColor( 0, 255, 0, 255 );
 
1242
            // file
 
1243
            _MakeString( helper, fCurrentFileIndex, fCurrentFileSize );
 
1244
            float width = StringWidth( helper.String() );
 
1245
            DrawString( helper.String(), BPoint( r.right - 3.0 - width, r.top + height ) );
 
1246
            // title
 
1247
            _MakeString( helper, fCurrentTitleIndex, fCurrentTitleSize );
 
1248
            width = StringWidth( helper.String() );
 
1249
            DrawString( helper.String(), BPoint( r.right - 3.0 - width, r.top + 2.0 * height ) );
 
1250
            // chapter
 
1251
            _MakeString( helper, fCurrentChapterIndex, fCurrentChapterSize );
 
1252
            width = StringWidth( helper.String() );
 
1253
            DrawString( helper.String(), BPoint( r.right - 3.0 - width, r.top + 3.0 * height ) );
 
1254
            // time
 
1255
            SetFont( &bigFont );
 
1256
            width = StringWidth( fTimeString.String() );
 
1257
            DrawString( fTimeString.String(),
 
1258
                        BPoint( r.left + r.Width() / 2.0 - width / 2.0,
 
1259
                                r.bottom - 3.0 ) );
 
1260
            break;
 
1261
        }
 
1262
    }
1259
1263
}
1260
1264
 
1261
1265
/*****************************************************************************
1264
1268
void
1265
1269
PositionInfoView::ResizeToPreferred()
1266
1270
{
1267
 
        float width, height;
1268
 
        GetPreferredSize( &width, &height );
1269
 
        ResizeTo( width, height );
 
1271
    float width, height;
 
1272
    GetPreferredSize( &width, &height );
 
1273
    ResizeTo( width, height );
1270
1274
}
1271
1275
 
1272
1276
/*****************************************************************************
1275
1279
void
1276
1280
PositionInfoView::GetPreferredSize( float* width, float* height )
1277
1281
{
1278
 
        if ( width && height )
1279
 
        {
1280
 
                *width = 5.0 + ceilf( StringWidth( "0:00:00" ) ) + 5.0;
1281
 
                font_height fh;
1282
 
                GetFontHeight( &fh );
1283
 
                *height = 3.0 + ceilf( fh.ascent ) + 3.0;
1284
 
                fStackedWidthCache = *width * 1.2;
1285
 
                fStackedHeightCache = *height * 2.7;
1286
 
        }
 
1282
    if ( width && height )
 
1283
    {
 
1284
        *width = 5.0 + ceilf( StringWidth( "0:00:00" ) ) + 5.0;
 
1285
        font_height fh;
 
1286
        GetFontHeight( &fh );
 
1287
        *height = 3.0 + ceilf( fh.ascent ) + 3.0;
 
1288
        fStackedWidthCache = *width * 1.2;
 
1289
        fStackedHeightCache = *height * 2.7;
 
1290
    }
1287
1291
}
1288
1292
 
1289
1293
/*****************************************************************************
1292
1296
void
1293
1297
PositionInfoView::Pulse()
1294
1298
{
1295
 
        // allow for Pulse frequency to be higher, MediaControlView needs it
1296
 
        bigtime_t now = system_time();
1297
 
        if ( now - fLastPulseUpdate > 900000 )
1298
 
        {
 
1299
    // allow for Pulse frequency to be higher, MediaControlView needs it
 
1300
    bigtime_t now = system_time();
 
1301
    if ( now - fLastPulseUpdate > 900000 )
 
1302
    {
1299
1303
#if 0
1300
 
                int32 index, size;
1301
 
                p_intf->p_sys->p_wrapper->GetPlaylistInfo( index, size );
1302
 
                SetFile( index + 1, size );
1303
 
                p_intf->p_sys->p_wrapper->TitleInfo( index, size );
1304
 
                SetTitle( index, size );
1305
 
                p_intf->p_sys->p_wrapper->ChapterInfo( index, size );
1306
 
                SetChapter( index, size );
1307
 
                SetTime( p_intf->p_sys->p_wrapper->GetTimeAsString() );
1308
 
                fLastPulseUpdate = now;
 
1304
        int32 index, size;
 
1305
        p_intf->p_sys->p_wrapper->GetPlaylistInfo( index, size );
 
1306
        SetFile( index + 1, size );
 
1307
        p_intf->p_sys->p_wrapper->TitleInfo( index, size );
 
1308
        SetTitle( index, size );
 
1309
        p_intf->p_sys->p_wrapper->ChapterInfo( index, size );
 
1310
        SetChapter( index, size );
 
1311
        SetTime( p_intf->p_sys->p_wrapper->GetTimeAsString() );
 
1312
        fLastPulseUpdate = now;
1309
1313
#endif
1310
 
        }
 
1314
    }
1311
1315
}
1312
1316
 
1313
1317
/*****************************************************************************
1316
1320
void
1317
1321
PositionInfoView::GetBigPreferredSize( float* width, float* height )
1318
1322
{
1319
 
        if ( width && height )
1320
 
        {
1321
 
                *width = fStackedWidthCache;
1322
 
                *height = fStackedHeightCache;
1323
 
        }
 
1323
    if ( width && height )
 
1324
    {
 
1325
        *width = fStackedWidthCache;
 
1326
        *height = fStackedHeightCache;
 
1327
    }
1324
1328
}
1325
1329
 
1326
1330
/*****************************************************************************
1329
1333
void
1330
1334
PositionInfoView::SetMode( uint32 mode )
1331
1335
{
1332
 
        if ( fMode != mode )
1333
 
        {
1334
 
                fMode = mode;
1335
 
                _InvalidateContents();
1336
 
        }
 
1336
    if ( fMode != mode )
 
1337
    {
 
1338
        fMode = mode;
 
1339
        _InvalidateContents();
 
1340
    }
1337
1341
}
1338
1342
 
1339
1343
/*****************************************************************************
1342
1346
void
1343
1347
PositionInfoView::SetFile( int32 index, int32 size )
1344
1348
{
1345
 
        if ( fCurrentFileIndex != index || fCurrentFileSize != size )
1346
 
        {
1347
 
                fCurrentFileIndex = index;
1348
 
                fCurrentFileSize = size;
1349
 
                _InvalidateContents();
1350
 
        }
 
1349
    if ( fCurrentFileIndex != index || fCurrentFileSize != size )
 
1350
    {
 
1351
        fCurrentFileIndex = index;
 
1352
        fCurrentFileSize = size;
 
1353
        _InvalidateContents();
 
1354
    }
1351
1355
}
1352
1356
 
1353
1357
/*****************************************************************************
1356
1360
void
1357
1361
PositionInfoView::SetTitle( int32 index, int32 size )
1358
1362
{
1359
 
        if ( fCurrentTitleIndex != index || fCurrentFileSize != size )
1360
 
        {
1361
 
                fCurrentTitleIndex = index;
1362
 
                fCurrentTitleSize = size;
1363
 
                _InvalidateContents();
1364
 
        }
 
1363
    if ( fCurrentTitleIndex != index || fCurrentFileSize != size )
 
1364
    {
 
1365
        fCurrentTitleIndex = index;
 
1366
        fCurrentTitleSize = size;
 
1367
        _InvalidateContents();
 
1368
    }
1365
1369
}
1366
1370
 
1367
1371
/*****************************************************************************
1370
1374
void
1371
1375
PositionInfoView::SetChapter( int32 index, int32 size )
1372
1376
{
1373
 
        if ( fCurrentChapterIndex != index || fCurrentFileSize != size )
1374
 
        {
1375
 
                fCurrentChapterIndex = index;
1376
 
                fCurrentChapterSize = size;
1377
 
                _InvalidateContents();
1378
 
        }
 
1377
    if ( fCurrentChapterIndex != index || fCurrentFileSize != size )
 
1378
    {
 
1379
        fCurrentChapterIndex = index;
 
1380
        fCurrentChapterSize = size;
 
1381
        _InvalidateContents();
 
1382
    }
1379
1383
}
1380
1384
 
1381
1385
/*****************************************************************************
1384
1388
void
1385
1389
PositionInfoView::SetTime( int32 seconds )
1386
1390
{
1387
 
        if ( fSeconds != seconds )
1388
 
        {
1389
 
                if ( seconds >= 0 )
1390
 
                {
1391
 
                        int32 minutes = seconds / 60;
1392
 
                        int32 hours = minutes / 60;
1393
 
                        seconds -= minutes * 60 - hours * 60 * 60;
1394
 
                        minutes -= hours * 60;
1395
 
                        fTimeString.SetTo( "" );
1396
 
                        fTimeString << hours << ":" << minutes << ":" << seconds;
1397
 
                }
1398
 
                else
1399
 
                        fTimeString.SetTo( "-:--:--" );
 
1391
    if ( fSeconds != seconds )
 
1392
    {
 
1393
        if ( seconds >= 0 )
 
1394
        {
 
1395
            int32 minutes = seconds / 60;
 
1396
            int32 hours = minutes / 60;
 
1397
            seconds -= minutes * 60 - hours * 60 * 60;
 
1398
            minutes -= hours * 60;
 
1399
            fTimeString.SetTo( "" );
 
1400
            fTimeString << hours << ":" << minutes << ":" << seconds;
 
1401
        }
 
1402
        else
 
1403
            fTimeString.SetTo( "-:--:--" );
1400
1404
 
1401
 
                fSeconds = seconds;
1402
 
                _InvalidateContents();
1403
 
        }
 
1405
        fSeconds = seconds;
 
1406
        _InvalidateContents();
 
1407
    }
1404
1408
}
1405
1409
 
1406
1410
/*****************************************************************************
1409
1413
void
1410
1414
PositionInfoView::SetTime( const char* string )
1411
1415
{
1412
 
        fTimeString.SetTo( string );
1413
 
        _InvalidateContents();
 
1416
    fTimeString.SetTo( string );
 
1417
    _InvalidateContents();
1414
1418
}
1415
1419
 
1416
1420
/*****************************************************************************
1419
1423
void
1420
1424
PositionInfoView::_InvalidateContents( uint32 which )
1421
1425
{
1422
 
        BRect r( Bounds() );
1423
 
        r.InsetBy( 2.0, 2.0 );
1424
 
        Invalidate( r );
 
1426
    BRect r( Bounds() );
 
1427
    r.InsetBy( 2.0, 2.0 );
 
1428
    Invalidate( r );
1425
1429
}
1426
1430
 
1427
1431
/*****************************************************************************
1430
1434
void
1431
1435
PositionInfoView::_MakeString( BString& into, int32 index, int32 maxIndex ) const
1432
1436
{
1433
 
        into = "";
1434
 
        if ( index >= 0 && maxIndex >= 0 )
1435
 
                into << index;
1436
 
        else
1437
 
                into << "-";
1438
 
        into << "/";
1439
 
        if ( maxIndex >= 0 )
1440
 
                into << maxIndex;
1441
 
        else
1442
 
                into << "-";
 
1437
    into = "";
 
1438
    if ( index >= 0 && maxIndex >= 0 )
 
1439
        into << index;
 
1440
    else
 
1441
        into << "-";
 
1442
    into << "/";
 
1443
    if ( maxIndex >= 0 )
 
1444
        into << maxIndex;
 
1445
    else
 
1446
        into << "-";
1443
1447
}