Browse Source

UI changes

master
Stefan Naumann 4 years ago
parent
commit
a87eb5c939
  1. 2
      cfg/config.json
  2. 2
      src/config.py
  3. 13
      src/piplayer.py
  4. 182
      src/ui.py

2
cfg/config.json

@ -1 +1 @@
{"WindowX": 654, "WindowY": 49, "WindowWidth": 1265, "WindowHeight": 954, "Loop": false}
{"WindowX": 654, "WindowY": 49, "WindowWidth": 1265, "WindowHeight": 954, "Loop": true}

2
src/config.py

@ -1,2 +1,2 @@
dbusconfig="/opt/dbuscontrol.sh"
configfile="../cfg/config.json"
configfile="/opt/piplayer/cfg/config.json"

13
src/piplayer.py

@ -161,21 +161,12 @@ def FLTK_run () :
y = ui.window.y();
h = ui.window.h();
w = ui.window.w();
if (Fl.event_button1() and
Fl.event_inside ( ui.statusProgress.x(),
ui.statusProgress.y(),
ui.statusProgress.x() + ui.statusProgress.w(),
ui.statusProgress.y() + ui.statusProgress.h() ) ):
if (Fl.event_button1() and Fl.event_inside ( ui.statusProgress )):
ui.seekCb ();
elif ((Fl.event_clicks()) and
Fl.event_inside ( ui.playlistList.x(),
ui.playlistList.y(),
ui.playlistList.x() + ui.playlistList.w(),
ui.playlistList.y() + ui.playlistList.h())):
elif ((Fl.event_clicks()) and Fl.event_inside ( ui.playlistList )):
Fl.event_clicks( 0 );
ui.plCb( ui.playlistList );
try:
msg, _ = s.recvfrom(4096)
except socket.error:

182
src/ui.py

@ -10,6 +10,8 @@ import piplayer
import playlist
import re
btnSize = 40;
## indicates whether the omxplayer is currently playing or if its paused
playState = True;
## indicates the duration of the media in mikroseconds
@ -163,7 +165,7 @@ def ReinitPlaylistList ( ) :
i = 0
while ( i < pl.length() ):
v = pl.index( i );
playlistList.add ( v["name"], i );
playlistList.add ( str(i)+". " + v["name"], i );
i=i+1
playlistList.value ( pl.current+1 );
@ -184,7 +186,7 @@ def prevCb ( ptr ):
def resizeWindow ( ):
global window;
global playBtn
global stateBtn
global fullBtn
global statusLabel
global statusProgress
global loopBtn
@ -199,27 +201,30 @@ def resizeWindow ( ):
h = window.h()
w = window.w()
statusLabel.resize ( w-290, h-50, statusLabel.w(), statusLabel.h() );
playBtn.position ( 20, h-60 );
prevBtn.position ( 60, h-60 );
stateBtn.position ( 100, h-60);
nextBtn.position ( 140, h-60 );
loopBtn.position ( 180, h-60 );
prevBtn.position ( 0, h-btnSize );
playBtn.position ( btnSize, h-btnSize );
nextBtn.position ( btnSize*2, h-btnSize );
loopBtn.position ( btnSize*3, h-btnSize );
statusProgress.resize ( 170, h-30, w-470, 20 );
statusLabel.resize ( w-290, h-30, statusLabel.w(), statusLabel.h() );
volUp.position ( w-(btnSize*2)-10-40, h-30 );
volDown.position ( w-(btnSize*2)-10-20, h-30 );
playlistBtn.position ( w-60, h-60 );
volUp.position ( w - 100, h-50 );
volDown.position ( w - 120, h-50 );
statusProgress.resize ( 240, h-50, w-540, 20 );
fullBtn.position ( w-(btnSize*2), h-btnSize);
playlistBtn.position ( w-btnSize, h-btnSize );
if ( playlistState == True ):
playlistList.set_visible();
playlistCleanBtn.set_visible();
playlistUpBtn.set_visible();
playlistDownBtn.set_visible();
playlistList.resize ( w-200, 0, 200, h-140);
playlistCleanBtn.position ( w-180, h-120 );
playlistUpBtn.position ( w-120, h-120 );
playlistDownBtn.position ( w-60, h-120 );
playlistList.resize ( w-200, 0, 200, h-80);
playlistCleanBtn.position ( w-180, h-80 );
playlistUpBtn.position ( w-120, h-80);
playlistDownBtn.position ( w-60, h-80 );
ReinitPlaylistList();
else:
playlistList.clear_visible();
@ -228,7 +233,7 @@ def resizeWindow ( ):
playlistDownBtn.clear_visible();
playBtn.redraw();
stateBtn.redraw();
fullBtn.redraw();
loopBtn.redraw();
statusProgress.redraw();
window.redraw();
@ -249,7 +254,7 @@ def sizeCalc ( ):
if ( playlistState == True ):
w = w - 200;
x2 = x + w;
y2 = y + h - 75;
y2 = y + h - 40;
return (x,y,x2,y2);
@ -317,7 +322,7 @@ window=""
## Button object for the play button
playBtn=""
## Button object for the fullscreen-button
stateBtn=""
fullBtn=""
## Button object for the loop-buttn
loopBtn=""
## Output object for the statusLabel-Output
@ -341,6 +346,12 @@ def plCb ( ptr ):
pl.setCurrent( playlistList.value()-1 );
pl.setConst();
callDBus( ["stop"] );
def style ( ptr ):
ptr.box ( FL_FLAT_BOX );
ptr.color ( 0x272828ff );
ptr.labelcolor ( FL_WHITE );
ptr.selection_color ( 0xaaaaaaff );
## initiates the player-window
@ -348,12 +359,11 @@ def plCb ( ptr ):
def init ( cfg, media ):
global window
global playBtn
global stateBtn
global fullBtn
global statusLabel
global statusProgress
global volUp
global volDown
global stateBtn
global loopBtn
global loop
global playlistBtn
@ -378,89 +388,107 @@ def init ( cfg, media ):
window = Fl_Window( cfg.get("WindowX", 100) , cfg.get("WindowY", 100), cfg.get("WindowWidth", 640), cfg.get("WindowHeight", 480))
window.label("PiPlayer")
window.size_range ( 320, 240, 0, 0);
window.color ( 0x272828ff );
w = window.w();
h = window.h();
playBtn = Fl_Button(20, 420, 40, 40)
playBtn.labeltype(FL_SYMBOL_LABEL)
playBtn.label("@||")
playBtn.callback(playCb)
playBtn.box ( FL_THIN_UP_BOX );
prevBtn = Fl_Button ( 60, 420, 40, 40 )
videoSpace = Fl_Multiline_Output ( 0,0, w, h-30, "" );
videoSpace.box ( FL_FLAT_BOX );
videoSpace.color ( FL_BLACK );
prevBtn = Fl_Button ( 0, h-btnSize, btnSize, btnSize )
prevBtn.labeltype(FL_SYMBOL_LABEL)
prevBtn.label("@<|");
prevBtn.callback ( prevCb );
prevBtn.box ( FL_THIN_UP_BOX )
prevBtn.tooltip ( "Previous" );
style(prevBtn);
stateBtn = Fl_Button ( 100, 420, 40, 40 );
stateBtn.label("Full")
stateBtn.callback( fullscreenCb )
stateBtn.shortcut ( FL_Escape );
stateBtn.box ( FL_THIN_UP_BOX );
nextBtn = Fl_Button ( 140, 420, 40, 40 );
playBtn = Fl_Button(40, h-btnSize, btnSize, btnSize)
playBtn.labeltype(FL_SYMBOL_LABEL)
playBtn.label("@||")
playBtn.callback(playCb)
playBtn.tooltip ( "Play / Pause" );
style(playBtn);
nextBtn = Fl_Button ( 80, h-btnSize, btnSize, btnSize );
nextBtn.labeltype(FL_SYMBOL_LABEL)
nextBtn.label("@|>");
nextBtn.callback ( nextCb );
nextBtn.box ( FL_THIN_UP_BOX )
nextBtn.tooltip ( "Next" );
style(nextBtn);
loopBtn = Fl_Button ( 180, 420, 40, 40 );
loopBtn.label ('Loop');
loopBtn = Fl_Button ( 120, h-btnSize, btnSize, btnSize );
loopBtn.labeltype(FL_SYMBOL_LABEL)
loopBtn.label ('@returnarrow');
loopBtn.callback ( loopBtnCb );
loopBtn.box ( FL_THIN_UP_BOX );
loopBtn.value ( loop );
loopBtn.tooltip ( "Loop" );
style(loopBtn);
videoSpace = Fl_Multiline_Output ( 0,0, w, h-80, "" );
videoSpace.box ( FL_FLAT_BOX );
videoSpace.color ( FL_BLACK );
statusProgress = Fl_Progress ( 170, h-30, w-470, 20 );
statusProgress.box( FL_FLAT_BOX );
statusProgress.minimum(0);
statusProgress.maximum(1);
statusProgress.color ( 0xffffffff );
statusProgress.selection_color( 0xaaaaaaff );
statusLabel = Fl_Output ( w-290, h-30, 150, 20 );
statusLabel.label ("");
statusLabel.box ( FL_FLAT_BOX );
statusLabel.textcolor ( FL_WHITE );
style(statusLabel);
volUp = Fl_Button ( w-(btnSize*2)-50, h-30, 20,20 );
volUp.label ( "+" );
volUp.callback ( volUpCb );
volUp.tooltip ( "Volume Up" );
style(volUp);
volDown = Fl_Button ( w-(btnSize*2)-30, h-30, 20,20 );
volDown.label ( "-" );
volDown.callback ( volDownCb );
volDown.tooltip ( "Volume Down" );
style(volDown);
fullBtn = Fl_Button ( w-(btnSize*2), h-btnSize, btnSize, btnSize );
fullBtn.labeltype(FL_SYMBOL_LABEL)
fullBtn.label("@square")
fullBtn.callback( fullscreenCb )
fullBtn.shortcut ( FL_Escape );
fullBtn.tooltip ( "Fullscreen" );
style(fullBtn);
playlistBtn = Fl_Button ( 580, 420, 40, 40 );
playlistBtn.label ("List");
playlistBtn = Fl_Button ( w-btnSize, h-btnSize, btnSize, btnSize );
playlistBtn.labeltype(FL_SYMBOL_LABEL)
playlistBtn.label ("@menu");
playlistBtn.callback ( playlistbtnCb );
playlistBtn.box ( FL_THIN_UP_BOX );
playlistBtn.value ( playlistState );
playlistBtn.tooltip ( "Show Playlist" );
style(playlistBtn);
playlistList = Fl_Select_Browser ( 420, 0, 200, 400 );
playlistList = Fl_Select_Browser ( 420, 0, 200, w-80 );
playlistList.box ( FL_FLAT_BOX );
#playlistList.callback ( plCb );
playlistCleanBtn = Fl_Button ( w-180, h-120, 40, 40 )
playlistCleanBtn = Fl_Button ( w-180, h-80, 40, 40 )
playlistCleanBtn.label("Clean");
playlistCleanBtn.callback ( plcleanCb );
playlistCleanBtn.box ( FL_THIN_UP_BOX );
playlistCleanBtn.tooltip ( "Empty Playlist");
style(playlistCleanBtn);
playlistUpBtn = Fl_Button ( w-120, h-120, 40, 40 )
playlistUpBtn.label("Up");
playlistUpBtn = Fl_Button ( w-120, h-80, 40, 40 )
playlistUpBtn.labeltype(FL_SYMBOL_LABEL)
playlistUpBtn.label("@<-");
playlistUpBtn.callback ( plupCb );
playlistUpBtn.box ( FL_THIN_UP_BOX );
playlistUpBtn.tooltip ( "Move selected element up");
style(playlistUpBtn);
playlistDownBtn = Fl_Button ( w-60, h-120, 40, 40 )
playlistDownBtn.label("Down");
playlistDownBtn = Fl_Button ( w-60, h-80, 40, 40 )
playlistDownBtn.labeltype(FL_SYMBOL_LABEL)
playlistDownBtn.label("@->");
playlistDownBtn.callback ( pldownCb );
playlistDownBtn.box ( FL_THIN_UP_BOX );
statusLabel = Fl_Output ( 350, 430, 150, 20 );
statusLabel.label ("");
statusLabel.box ( FL_FLAT_BOX );
statusProgress = Fl_Progress ( 240, 430, 50, 20 );
statusProgress.box( FL_FLAT_BOX );
statusProgress.minimum(0);
statusProgress.maximum(1);
statusProgress.color ( 0xffffffff );
statusProgress.selection_color( 0x272828ff );
volUp = Fl_Button ( 540, 430, 20,20 );
volUp.label ( "+" );
volUp.box ( FL_THIN_UP_BOX );
volUp.callback ( volUpCb );
volDown = Fl_Button ( 520, 430, 20,20 );
volDown.label ( "-" );
volDown.box ( FL_THIN_UP_BOX );
volDown.callback ( volDownCb );
playlistCleanBtn.tooltip ( "Move selected element down");
style(playlistDownBtn);
resizeWindow();