From 6a4f6de77e2a027fd447adb82a0ecc612a657b4f Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Sun, 27 May 2012 10:41:27 +0000 Subject: [PATCH] FPlay: ffmpeg-0.11 + rewind git-svn-id: svn://kolibrios.org@2693 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/media/Fplay/audio.c | 55 +- programs/media/Fplay/fplay.c | 141 ++++- programs/media/Fplay/fplay.h | 12 +- programs/media/Fplay/pixlib2.c | 7 +- programs/media/Fplay/video.c | 176 +++++- programs/media/Fplay/winlib/button.c | 337 +++++++++++ programs/media/Fplay/winlib/caption.c | 246 +++++++++ programs/media/Fplay/winlib/clbhl.raw | Bin 0 -> 1152 bytes programs/media/Fplay/winlib/clbn.raw | Bin 0 -> 1152 bytes programs/media/Fplay/winlib/clbp.raw | Bin 0 -> 1152 bytes programs/media/Fplay/winlib/control.h | 191 +++++++ programs/media/Fplay/winlib/cptbody.raw | Bin 0 -> 96 bytes programs/media/Fplay/winlib/cptleft.raw | Bin 0 -> 768 bytes programs/media/Fplay/winlib/cptright.raw | Bin 0 -> 768 bytes programs/media/Fplay/winlib/frame.c | 289 ++++++++++ programs/media/Fplay/winlib/lborder.raw | Bin 0 -> 28 bytes programs/media/Fplay/winlib/link.h | 60 ++ programs/media/Fplay/winlib/minbhl.raw | Bin 0 -> 1152 bytes programs/media/Fplay/winlib/minbn.raw | Bin 0 -> 1152 bytes programs/media/Fplay/winlib/minbp.raw | Bin 0 -> 1152 bytes programs/media/Fplay/winlib/panel.c | 263 +++++++++ programs/media/Fplay/winlib/panel.raw | Bin 0 -> 220 bytes programs/media/Fplay/winlib/panelleft.raw | Bin 0 -> 3520 bytes programs/media/Fplay/winlib/panelright.raw | Bin 0 -> 3520 bytes programs/media/Fplay/winlib/pausebp.raw | Bin 0 -> 4096 bytes programs/media/Fplay/winlib/pausebtn.raw | Bin 0 -> 4096 bytes programs/media/Fplay/winlib/playbp.raw | Bin 0 -> 4096 bytes programs/media/Fplay/winlib/playbtn.raw | Bin 0 -> 4096 bytes programs/media/Fplay/winlib/rborder.raw | Bin 0 -> 28 bytes programs/media/Fplay/winlib/res2.asm | 65 +++ programs/media/Fplay/winlib/size_nesw.cur | Bin 0 -> 766 bytes programs/media/Fplay/winlib/size_ns.cur | Bin 0 -> 766 bytes programs/media/Fplay/winlib/size_nwse.cur | Bin 0 -> 766 bytes programs/media/Fplay/winlib/size_we.cur | Bin 0 -> 766 bytes programs/media/Fplay/winlib/types.h | 21 + programs/media/Fplay/winlib/window.c | 613 +++++++++++++++++++++ programs/media/Fplay/winlib/winlib.h | 125 +++++ 37 files changed, 2557 insertions(+), 44 deletions(-) create mode 100644 programs/media/Fplay/winlib/button.c create mode 100644 programs/media/Fplay/winlib/caption.c create mode 100644 programs/media/Fplay/winlib/clbhl.raw create mode 100644 programs/media/Fplay/winlib/clbn.raw create mode 100644 programs/media/Fplay/winlib/clbp.raw create mode 100644 programs/media/Fplay/winlib/control.h create mode 100644 programs/media/Fplay/winlib/cptbody.raw create mode 100644 programs/media/Fplay/winlib/cptleft.raw create mode 100644 programs/media/Fplay/winlib/cptright.raw create mode 100644 programs/media/Fplay/winlib/frame.c create mode 100644 programs/media/Fplay/winlib/lborder.raw create mode 100644 programs/media/Fplay/winlib/link.h create mode 100644 programs/media/Fplay/winlib/minbhl.raw create mode 100644 programs/media/Fplay/winlib/minbn.raw create mode 100644 programs/media/Fplay/winlib/minbp.raw create mode 100644 programs/media/Fplay/winlib/panel.c create mode 100644 programs/media/Fplay/winlib/panel.raw create mode 100644 programs/media/Fplay/winlib/panelleft.raw create mode 100644 programs/media/Fplay/winlib/panelright.raw create mode 100644 programs/media/Fplay/winlib/pausebp.raw create mode 100644 programs/media/Fplay/winlib/pausebtn.raw create mode 100644 programs/media/Fplay/winlib/playbp.raw create mode 100644 programs/media/Fplay/winlib/playbtn.raw create mode 100644 programs/media/Fplay/winlib/rborder.raw create mode 100644 programs/media/Fplay/winlib/res2.asm create mode 100644 programs/media/Fplay/winlib/size_nesw.cur create mode 100644 programs/media/Fplay/winlib/size_ns.cur create mode 100644 programs/media/Fplay/winlib/size_nwse.cur create mode 100644 programs/media/Fplay/winlib/size_we.cur create mode 100644 programs/media/Fplay/winlib/types.h create mode 100644 programs/media/Fplay/winlib/window.c create mode 100644 programs/media/Fplay/winlib/winlib.h diff --git a/programs/media/Fplay/audio.c b/programs/media/Fplay/audio.c index f0b70a1ca9..93dc329f58 100644 --- a/programs/media/Fplay/audio.c +++ b/programs/media/Fplay/audio.c @@ -25,6 +25,9 @@ static int snd_format; int sample_rate; static uint32_t samples_written = 0; +double audio_base = -1.0; + +double get_audio_base(); int init_audio(int format) { @@ -104,6 +107,13 @@ int decode_audio(AVCodecContext *ctx, queue_t *qa) if(len >= 0) { +// if(audio_base == -1.0) +// { +// if (pkt.pts != AV_NOPTS_VALUE) +// audio_base = get_audio_base() * pkt.pts; +// printf("audio base %f\n", audio_base); +// }; + pkt_tmp.data += len; pkt_tmp.size -= len; @@ -214,19 +224,36 @@ int audio_thread(void *param) double event_stamp, wait_stamp; int too_late = 0; - if(player_state == PAUSE) + if((player_state == PAUSE) || + (player_state == PLAY_INIT) ) { if( active ) { StopBuffer(hBuff); active = 0; - } + }; delay(1); continue; } - else if(player_state == PLAY_RESTART) + else if(player_state == REWIND) { + if( active ) + { + StopBuffer(hBuff); + active = 0; + }; + mutex_lock(&astream.lock); + astream.count = 0; + mutex_unlock(&astream.lock); + delay(1); + continue; + } + else if(player_state == PAUSE_2_PLAY) + { +// SetTimeBase(hBuff, audio_base); GetTimeStamp(hBuff, &last_time_stamp); +// printf("last_time_stamp %f\n", last_time_stamp); + if((err = PlayBuffer(hBuff, 0)) !=0 ) { errstr = "Cannot play buffer\n\r"; @@ -235,7 +262,27 @@ int audio_thread(void *param) active = 1; sync_audio(hBuff, buffsize); player_state = PLAY; - printf("audio delta %f\n", audio_delta); + printf("render: set audio latency to %f\n", audio_delta); + } + else if(player_state == REWIND_2_PLAY) + { + while( (astream.count < buffsize*2) && + (player_state != CLOSED) ) + yield(); + + SetTimeBase(hBuff, audio_base); + GetTimeStamp(hBuff, &last_time_stamp); + printf("last audio time stamp %f\n", last_time_stamp); + + if((err = PlayBuffer(hBuff, 0)) !=0 ) + { + errstr = "Cannot play buffer\n\r"; + goto exit_whith_error; + }; + active = 1; + sync_audio(hBuff, buffsize); + player_state = PLAY; + printf("render: set audio latency to %f\n", audio_delta); }; GetNotify(&evnt); diff --git a/programs/media/Fplay/fplay.c b/programs/media/Fplay/fplay.c index 17703d7532..6bfb4e6307 100644 --- a/programs/media/Fplay/fplay.c +++ b/programs/media/Fplay/fplay.c @@ -36,9 +36,23 @@ uint8_t *decoder_buffer; extern int sample_rate; char *movie_file; +void flush_video(); queue_t q_video; queue_t q_audio; +int64_t rewind_pos; + +int64_t stream_duration; + +extern double audio_base; + +double get_audio_base() +{ + + return (double)av_q2d(pFormatCtx->streams[audioStream]->time_base)*1000; + +}; + int main( int argc, char *argv[]) { @@ -64,7 +78,7 @@ int main( int argc, char *argv[]) return -1; // Couldn't open file }; -// printf("%s\n\r", __FUNCTION__); + pFormatCtx->flags |= AVFMT_FLAG_GENPTS; // Retrieve stream information if(avformat_find_stream_info(pFormatCtx, NULL)<0) @@ -77,22 +91,39 @@ int main( int argc, char *argv[]) // dump_format(pFormatCtx, 0, argv[1], 0); +// stream_duration = 1000.0 * pFormatCtx->duration * av_q2d(AV_TIME_BASE_Q); + stream_duration = pFormatCtx->duration; + + printf("duration %f\n", (double)stream_duration); // Find the first video stream videoStream=-1; audioStream=-1; for(i=0; i < pFormatCtx->nb_streams; i++) { +// pFormatCtx->streams[i]->discard = AVDISCARD_ALL; + if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_VIDEO && videoStream < 0) { videoStream=i; video_time_base = pFormatCtx->streams[i]->time_base; - + if(stream_duration == 0) +// stream_duration = 1000.0 * +// pFormatCtx->streams[i]->duration * +// av_q2d(pFormatCtx->streams[i]->time_base); + stream_duration = pFormatCtx->streams[i]->duration; + } if(pFormatCtx->streams[i]->codec->codec_type==AVMEDIA_TYPE_AUDIO && audioStream < 0) { audioStream=i; + if(stream_duration == 0) +// stream_duration = 1000.0 * +// pFormatCtx->streams[i]->duration * +// av_q2d(pFormatCtx->streams[i]->time_base); + stream_duration = pFormatCtx->streams[i]->duration; + } } @@ -102,7 +133,7 @@ int main( int argc, char *argv[]) return -1; // Didn't find a video stream } - player_state = PLAY_RESTART; + player_state = PLAY_INIT; // __asm__ __volatile__("int3"); @@ -200,12 +231,64 @@ int main( int argc, char *argv[]) return 0; } + +static int fill_queue() +{ + int eof = 0; + AVPacket packet; + + while( !eof) + { + int err; + +// __asm__ __volatile__("int3"); + + if(q_video.size+q_audio.size < 2*1024*1024) + { + err = av_read_frame(pFormatCtx, &packet); + if( err < 0) + { + eof = 1; + if (err != AVERROR_EOF) + printf("av_read_frame: error %x\n", err); + break; + } + if(packet.stream_index==videoStream) + { + put_packet(&q_video, &packet); + } + else if( (packet.stream_index == audioStream) && + (have_sound != 0) ) + { + put_packet(&q_audio, &packet); + if(audio_base == -1.0) + { + if (packet.dts != AV_NOPTS_VALUE) + audio_base = get_audio_base() * packet.dts; +// printf("audio base %f\n", audio_base); + }; + } + else + { + av_free_packet(&packet); + }; + } + else break; + }; + + return eof; + +}; + + void decoder() { - int eof = 0; + int eof; AVPacket packet; int ret; + eof = fill_queue(); + while( player_state != CLOSED && !eof) { int err; @@ -218,7 +301,55 @@ void decoder() continue; }; - if(q_video.size+q_audio.size < 12*1024*1024) + if( player_state == REWIND ) + { + // int64_t timestamp = 0; + // int stream_index = av_find_default_stream_index(pFormatCtx); + + // __asm__ __volatile__("int3"); + + if (pFormatCtx->start_time != AV_NOPTS_VALUE) + rewind_pos += pFormatCtx->start_time; + + printf("rewind %8"PRId64"\n", rewind_pos); + + ret = avformat_seek_file(pFormatCtx, -1, INT64_MIN, + rewind_pos, INT64_MAX, 0); +// ret = avformat_seek_file(pFormatCtx, -1, 0, +// 0, INT64_MAX, 0); +// __asm__ __volatile__("int3"); + + if (ret < 0) + { + printf("could not seek to position %f\n", + (double)rewind_pos / AV_TIME_BASE); + } + else + { + avcodec_flush_buffers(pCodecCtx); + avcodec_flush_buffers(aCodecCtx); + + while( get_packet(&q_video, &packet) != 0) + av_free_packet(&packet); + + while( get_packet(&q_audio, &packet)!= 0) + av_free_packet(&packet); + audio_base = -1.0; + + // __asm__ __volatile__("int3"); + + eof = fill_queue(); + }; + yield(); + + flush_video(); + + player_state = REWIND_2_PLAY; + printf("restart\n"); + continue; + }; + + if(q_video.size+q_audio.size < 4*1024*1024) { err = av_read_frame(pFormatCtx, &packet); if( err < 0) diff --git a/programs/media/Fplay/fplay.h b/programs/media/Fplay/fplay.h index 74c5b8a66c..e7d9f725c6 100644 --- a/programs/media/Fplay/fplay.h +++ b/programs/media/Fplay/fplay.h @@ -52,10 +52,13 @@ struct render }; enum player_state -{ CLOSED=0, STOP, PLAY_RESTART, PLAY, PAUSE, REWIND }; - -#define ID_PLAY 100 +{ CLOSED=0,PLAY_INIT, + STOP, PAUSE, PLAY, REWIND, + PAUSE_2_PLAY, REWIND_2_PLAY +}; +#define ID_PLAY 100 +#define ID_PROGRESS 101 typedef struct { volatile uint32_t lock; @@ -156,7 +159,8 @@ static inline void delay(uint32_t time) { __asm__ __volatile__( "int $0x40" - ::"a"(5), "b"(time)); + ::"a"(5), "b"(time) + :"memory"); }; diff --git a/programs/media/Fplay/pixlib2.c b/programs/media/Fplay/pixlib2.c index 88ca6d2340..3785f644b5 100644 --- a/programs/media/Fplay/pixlib2.c +++ b/programs/media/Fplay/pixlib2.c @@ -307,7 +307,7 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, { //bitmap->data = NULL; Not now, Serge // printf("blit done\n"); - delay(1); +// delay(1); return 0; }; return err; @@ -328,7 +328,8 @@ int blit_bitmap(bitmap_t *bitmap, int dst_x, int dst_y, __asm__ __volatile__( "int $0x40" - ::"a"(73),"b"(0),"c"(&bc)); + ::"a"(73),"b"(0x00),"c"(&bc) + :"memory"); return 0; }; @@ -340,7 +341,7 @@ static inline void* user_realloc(void *mem, size_t size) __asm__ __volatile__( "int $0x40" :"=a"(val) - :"a"(68),"b"(12),"c"(size),"d"(mem) + :"a"(68),"b"(20),"c"(size),"d"(mem) :"memory"); return val; diff --git a/programs/media/Fplay/video.c b/programs/media/Fplay/video.c index ace1998b13..1006a5dbd8 100644 --- a/programs/media/Fplay/video.c +++ b/programs/media/Fplay/video.c @@ -17,6 +17,7 @@ extern int res_pause_btn_pressed[]; extern int res_play_btn[]; extern int res_play_btn_pressed[]; +extern int64_t stream_duration; typedef struct { @@ -44,6 +45,18 @@ volatile uint32_t driver_lock; void get_client_rect(rect_t *rc); +void flush_video() +{ + int i; + + for(i = 0; i < 4; i++) + { + frames[i].pts = 0; + frames[i].ready = 0; + }; + vfx = 0; + dfx = 0; +}; int init_video(AVCodecContext *ctx) { @@ -113,19 +126,20 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) if( get_packet(qv, &pkt) == 0 ) return 0; - current_clock = -80.0 + get_master_clock(); + current_clock = -90.0 + get_master_clock(); if( pkt.dts == AV_NOPTS_VALUE && Frame->reordered_opaque != AV_NOPTS_VALUE) - pts = Frame->reordered_opaque; - else if(pkt.dts != AV_NOPTS_VALUE) + pts = Frame->reordered_opaque; + else if(pkt.dts != AV_NOPTS_VALUE) pts= pkt.dts; else pts= 0; - + + pts *= av_q2d(video_time_base)*1000.0; - if( pts > current_clock) + if( 1 /*pts > current_clock*/) { frameFinished = 0; @@ -140,7 +154,7 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) if( pkt.dts == AV_NOPTS_VALUE && Frame->reordered_opaque != AV_NOPTS_VALUE) - pts = Frame->reordered_opaque; + pts = Frame->reordered_opaque; else if(pkt.dts != AV_NOPTS_VALUE) pts= pkt.dts; else @@ -161,6 +175,8 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) Frame->linesize, ctx->pix_fmt, ctx->width, ctx->height); frames[dfx].pts = pts*1000.0; +// printf("pts %f\n", frames[dfx].pts); + frames[dfx].ready = 1; dfx++; @@ -175,6 +191,7 @@ int decode_video(AVCodecContext *ctx, queue_t *qv) extern volatile enum player_state player_state; //rect_t win_rect; +extern int64_t rewind_pos; int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { @@ -196,18 +213,18 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) case MSG_LBTNDOWN: if(player_state == PAUSE) { - win->panel.play_btn->img_default = res_play_btn; - win->panel.play_btn->img_hilite = res_play_btn; - win->panel.play_btn->img_pressed = res_play_btn_pressed; + win->panel.play_btn->img_default = res_pause_btn; + win->panel.play_btn->img_hilite = res_pause_btn; + win->panel.play_btn->img_pressed = res_pause_btn_pressed; send_message(win->panel.play_btn, MSG_PAINT, 0, 0); - player_state = PLAY_RESTART; + player_state = PAUSE_2_PLAY; } else if(player_state == PLAY) { - win->panel.play_btn->img_default = res_pause_btn; - win->panel.play_btn->img_hilite = res_pause_btn; - win->panel.play_btn->img_pressed = res_pause_btn_pressed; + win->panel.play_btn->img_default = res_play_btn; + win->panel.play_btn->img_hilite = res_play_btn; + win->panel.play_btn->img_pressed = res_play_btn_pressed; send_message(win->panel.play_btn, MSG_PAINT, 0, 0); player_state = PAUSE; } @@ -218,20 +235,36 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) { case ID_PLAY: if(player_state == PAUSE) - { - win->panel.play_btn->img_default = res_play_btn; - win->panel.play_btn->img_hilite = res_play_btn; - win->panel.play_btn->img_pressed = res_play_btn_pressed; - player_state = PLAY_RESTART; - } - else if(player_state == PLAY) { win->panel.play_btn->img_default = res_pause_btn; win->panel.play_btn->img_hilite = res_pause_btn; win->panel.play_btn->img_pressed = res_pause_btn_pressed; + player_state = PAUSE_2_PLAY; + } + else if(player_state == PLAY) + { + win->panel.play_btn->img_default = res_play_btn; + win->panel.play_btn->img_hilite = res_play_btn; + win->panel.play_btn->img_pressed = res_play_btn_pressed; player_state = PAUSE; } break; + + case 101: //ID_PROGRESS: + if(player_state != REWIND) + { + progress_t *prg = (progress_t*)arg2; + + rewind_pos = (int64_t)prg->pos * + (prg->max - prg->min)/prg->ctrl.w; + +// printf("progress action %f\n", (double)rewind_pos); + player_state = REWIND; + main_render->win->panel.prg->current = rewind_pos; + send_message(&main_render->win->panel.ctrl, MSG_PAINT, 0, 0); + }; + break; + default: break; } @@ -243,6 +276,8 @@ int MainWindowProc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) return 0; }; +#define VERSION_A 1 + void render_time(render_t *render) { double ctime; /* milliseconds */ @@ -261,28 +296,103 @@ void render_time(render_t *render) return; }; +#ifdef VERSION_A if(frames[vfx].ready == 1 ) { + int sys_time; + ctime = get_master_clock(); fdelay = (frames[vfx].pts - ctime); // printf("pts %f time %f delay %f\n", - // frames[vfx].pts, ctime, fdelay); +// frames[vfx].pts, ctime, fdelay); - if(fdelay > 20.0) + if(fdelay > 15.0) { - delay(2); + delay(1); // yield(); return; }; + ctime = get_master_clock(); + fdelay = (frames[vfx].pts - ctime); + + sys_time = get_tick_count(); + +// if(fdelay < 0) +// printf("systime %d pts %f time %f delay %f\n", +// sys_time*10, frames[vfx].pts, ctime, fdelay); + main_render->draw(main_render, &frames[vfx].picture); + main_render->win->panel.prg->current = frames[vfx].pts*1000; + send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0); frames[vfx].ready = 0; vfx++; vfx&= 3; } else yield(); +#else + + if(frames[vfx].ready == 1 ) + { + ctime = get_master_clock(); + fdelay = (frames[vfx].pts - ctime); + +// printf("pts %f time %f delay %f\n", +// frames[vfx].pts, ctime, fdelay); + + if(fdelay < 0.0 ) + { + int next_vfx; + fdelay = 0; + next_vfx = (vfx+1) & 3; + if( frames[next_vfx].ready == 1 ) + { + if(frames[next_vfx].pts <= ctime) + { + frames[vfx].ready = 0; // skip this frame + vfx++; + vfx&= 3; + } + else + { + if( (frames[next_vfx].pts - ctime) < + ( ctime - frames[vfx].pts) ) + { + frames[vfx].ready = 0; // skip this frame + vfx++; + vfx&= 3; + fdelay = (frames[next_vfx].pts - ctime); + } + } + }; + }; + + if(fdelay > 10.0) + { + int val = fdelay; + printf("pts %f time %f delay %d\n", + frames[vfx].pts, ctime, val); + delay(val/10); + }; + + ctime = get_master_clock(); + fdelay = (frames[vfx].pts - ctime); + + printf("pts %f time %f delay %f\n", + frames[vfx].pts, ctime, fdelay); + + main_render->draw(main_render, &frames[vfx].picture); + main_render->win->panel.prg->current = frames[vfx].pts; +// send_message(&render->win->panel.prg->ctrl, MSG_PAINT, 0, 0); + frames[vfx].ready = 0; + vfx++; + vfx&= 3; + } + else yield(); +#endif + } @@ -297,13 +407,18 @@ int video_thread(void *param) init_winlib(); MainWindow = create_window(movie_file,0, - 10,10,width,height+29+75,MainWindowProc); + 10,10,width,height+29+55,MainWindowProc); + MainWindow->panel.prg->max = stream_duration; // printf("MainWindow %x\n", MainWindow); main_render->win = MainWindow; show_window(MainWindow, NORMAL); + + render_draw_client(main_render); + player_state = PAUSE_2_PLAY; + run_render(MainWindow, main_render); // printf("exit thread\n"); @@ -448,7 +563,7 @@ void render_adjust_size(render_t *render, window_t *win) right = win->w; - bottom = win->h-CAPTION_HEIGHT-75; + bottom = win->h-CAPTION_HEIGHT-55; render->win_state = win->win_state; if(render->win_state == MINIMIZED) @@ -482,7 +597,7 @@ void render_adjust_size(render_t *render, window_t *win) }; render->win_width = win->w; - render->win_height = win->h-CAPTION_HEIGHT-75; + render->win_height = win->h-CAPTION_HEIGHT-55; render_set_size(render, new_w, new_h); }; @@ -600,9 +715,14 @@ void render_draw_client(render_t *render) render->win_state == ROLLED) return; - if(player_state == PAUSE) + if((player_state == PAUSE) || + (player_state == PLAY_INIT) ) { - main_render->draw(main_render, &frames[vfx].picture); + if(frames[vfx].ready == 1 ) + main_render->draw(main_render, &frames[vfx].picture); + else + draw_bar(0, CAPTION_HEIGHT, render->win_width, + render->rcvideo.b, 0); }; if(render->layout & HAS_TOP) diff --git a/programs/media/Fplay/winlib/button.c b/programs/media/Fplay/winlib/button.c new file mode 100644 index 0000000000..70a609019c --- /dev/null +++ b/programs/media/Fplay/winlib/button.c @@ -0,0 +1,337 @@ + +#include "system.h" +#include +#include +#include "winlib.h" + + +extern ctrl_t *mouse_capture; +uint32_t main_cursor; + +static int button_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); +static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); + + +button_t *create_button(char *caption, int id, int x, int y, + int w, int h, ctrl_t *parent) +{ + button_t *btn; + int len; + + if( !parent ) + return NULL; + + btn = (button_t*)malloc(sizeof(button_t)); + + link_initialize(&btn->link); + list_initialize(&btn->child); + + btn->handler = button_proc; + btn->parent = parent; + + btn->ctx = parent->ctx; + btn->id = id; + btn->style = 0; + + btn->rc.l = x; + btn->rc.t = y ; + + btn->rc.r = x + w; + btn->rc.b = y + h; + + btn->w = w; + btn->h = h; + + btn->state = 0; + + btn->caption = caption; + + if( !caption ) + btn->capt_len = 0; + else + { + len = strlen(caption); + btn->capt_len = len; + if( len ) + btn->caption = strdup(caption); + else + btn->caption = NULL; + } + + btn->img_default = NULL; + btn->img_hilite = NULL; + btn->img_pressed = NULL; + + list_append(&btn->link, &parent->child); + + return btn; +}; + +#if 0 +int draw_button(button_t *btn) +{ + void *bitmap; + + bitmap = btn->img_default; + + if(btn->state & bPressed) + bitmap = btn->img_pressed; + else if(btn->state & bHighlight) + bitmap = btn->img_hilite; + + if( bitmap ) + draw_bitmap(bitmap, btn->rc.l, btn->rc.t, btn->w, btn->h); + + if( btn->caption && btn->capt_len) + { + int txt_w; + int txt_x, txt_y; + txt_w = btn->capt_len*8-2; + + txt_x = btn->rc.l + 1 + (btn->w - txt_w)/2; + txt_y = btn->rc.t + 9; + + if(btn->state & bPressed){ + txt_x++; + txt_y++; + }; + draw_text(btn->caption, txt_x, txt_y, btn->capt_len, 0x10000000); + }; + return 0; +}; +#endif + +int draw_button_cairo(button_t *btn) +{ + int *pixmap, *src; + ctx_t *ctx; + int i, j; + int x, y; + + ctx = btn->ctx; + + x = btn->rc.l - ctx->offset_x; + y = btn->rc.t - ctx->offset_y; + + pixmap = ctx->pixmap; + + pixmap+= y*ctx->stride/4 + x; + + src = btn->img_default; + + if(btn->state & bPressed) + src = btn->img_pressed; + else if(btn->state & bHighlight) + src = btn->img_hilite; + + for(i=0; i < btn->h ;i++) + { + for(j=0; jw; j++) + pixmap[j] = src[j]; + pixmap+= ctx->stride/4; + src+=btn->w; + }; + + return 0; +}; + + +int draw_spin_cairo(button_t *btn) +{ + void *ctx; + + return 0; +}; + + +int button_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + int x, y; + int state; + int old_state; + int action=0; + + button_t *btn = (button_t*)ctrl; + + switch( msg ) + { + case MSG_PAINT: + draw_button_cairo(btn); + update_rect((ctrl_t*)btn); + break; + + case MSG_MOUSEENTER: +// printf("mouse enter\n"); + btn->state|= bHighlight; + send_message(btn, MSG_PAINT, 0, 0); + break; + + case MSG_MOUSELEAVE: +// printf("mouse leave\n"); + if( (ctrl_t*)btn != mouse_capture) { + btn->state &= ~bHighlight; + send_message(btn, MSG_PAINT, 0, 0); + }; + break; + + case MSG_LBTNDOWN: + case MSG_LBTNDBLCLK: +// printf("push button\n"); + capture_mouse((ctrl_t*)btn); + btn->state|= bPressed; + send_message(btn, MSG_PAINT, 0, 0); + break; + + case MSG_LBTNUP: + + // printf("button action\n"); + if(btn->state & bPressed) + action = MSG_COMMAND; + + release_mouse(); + + x = ((pos_t)arg2).x; + y = ((pos_t)arg2).y; + + if( pt_in_rect( &btn->rc, x, y) ) + state = bHighlight; + else + state = 0; + + if(action) + send_message(btn->parent,MSG_COMMAND,btn->id,(int)btn); + + btn->state = state; + send_message(btn, MSG_PAINT, 0, 0); + break; + + case MSG_MOUSEMOVE: + + if(main_cursor != 0) + { + set_cursor(0); + main_cursor = 0; + } + + if( ! (btn->state & bHighlight)) + { + btn->state|= bHighlight; + send_message(btn, MSG_PAINT, 0, 0); + }; + + if( (ctrl_t*)btn != mouse_capture) + return 0; + + x = ((pos_t)arg2).x; + y = ((pos_t)arg2).y; + + old_state = btn->state; + + if( pt_in_rect(&btn->rc, x, y) ) + btn->state |= bPressed; + else + btn->state &= ~bPressed; + + if( old_state ^ btn->state) + send_message(btn, MSG_PAINT, 0, 0); + } + return 0; +}; + + +int draw_progress(progress_t *prg) +{ + int *pixmap, src; + ctx_t *ctx; + int i, j; + int x, y; + + int len; + + ctx = prg->ctrl.ctx; + + x = prg->ctrl.rc.l - ctx->offset_x; + y = prg->ctrl.rc.t - ctx->offset_y; + + + len = prg->current*prg->ctrl.w/(prg->max - prg->min); + pixmap = ctx->pixmap; + + pixmap+= y*ctx->stride/4 + x; + + src = 0x32ebfb; //btn->img_default; + + for(i=0; i < prg->ctrl.h ;i++) + { + for(j=0; j < len; j++) + pixmap[j] = src; + pixmap+= ctx->stride/4; + }; + + return 0; +}; + + +int prg_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + progress_t *prg = (progress_t*)ctrl; + int pos; + + switch( msg ) + { + case MSG_PAINT: + draw_progress(prg); + update_rect(ctrl); + break; + + case MSG_LBTNDOWN: + prg->pos = ((pos_t)arg2).x - ctrl->rc.l; + send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); + break; + + default: + break; + } + return 0; +}; + + +progress_t *create_progress(char *caption, int id, int x, int y, + int w, int h, ctrl_t *parent) +{ + progress_t *prg; + int len; + + if( !parent ) + return NULL; + + prg = (progress_t*)malloc(sizeof(progress_t)); + + link_initialize(&prg->ctrl.link); + list_initialize(&prg->ctrl.child); + + prg->ctrl.handler = prg_proc; + prg->ctrl.parent = parent; + + prg->ctrl.ctx = parent->ctx; + prg->ctrl.id = id; + + prg->ctrl.rc.l = x; + prg->ctrl.rc.t = y ; + + prg->ctrl.rc.r = x + w; + prg->ctrl.rc.b = y + h; + + prg->ctrl.w = w; + prg->ctrl.h = h; + + prg->min = 0; + prg->max = 1; + prg->current = 0; + prg->pos = 0; + + list_append(&prg->ctrl.link, &parent->child); + + return prg; +}; + diff --git a/programs/media/Fplay/winlib/caption.c b/programs/media/Fplay/winlib/caption.c new file mode 100644 index 0000000000..0a1859a987 --- /dev/null +++ b/programs/media/Fplay/winlib/caption.c @@ -0,0 +1,246 @@ + +#include "system.h" +#include +#include +#include +#include "winlib.h" + +#define CAPTION_HEIGHT 24 +#define CAPTION_CORNER_W 8 + +extern int res_caption_left[]; +extern int res_caption_right[]; +extern int res_caption_body[]; + +extern int res_close_btn[]; +extern int res_close_btn_hl[]; +extern int res_close_btn_pressed[]; + +extern int res_minimize_btn[]; +extern int res_minimize_btn_hl[]; +extern int res_minimize_btn_pressed[]; + +void update_caption_size(window_t *win); + +int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2); + + +int init_caption(window_t *win) +{ + button_t *btn; + + caption_t *cpt = &win->caption; + ctx_t *ctx = &cpt->ctx; + + link_initialize(&cpt->ctrl.link); + list_initialize(&cpt->ctrl.child); + + cpt->ctrl.handler = caption_proc; + cpt->ctrl.parent = (ctrl_t*)win; + + ctx->pixmap = user_alloc(1920*CAPTION_HEIGHT*4); + if(!ctx->pixmap) + { + printf("not enough memory for caption bitmap\n"); + return 0; + }; + +// printf("win_w %d win_h %d\n", win->w, win->h); + + ctx->stride = win->w*4; + ctx->offset_x = 0; + ctx->offset_y = 0; + + cpt->ctrl.ctx = ctx; + + btn = create_button(NULL, ID_CLOSE,0,5,16,18,(ctrl_t*)cpt); + cpt->close_btn = btn; + + btn->img_default = res_close_btn; + btn->img_hilite = res_close_btn_hl; + btn->img_pressed = res_close_btn_pressed; + + btn = create_button(NULL, ID_MINIMIZE,0,5,16,18,(ctrl_t*)cpt); + cpt->minimize_btn = btn; + + btn->img_default = res_minimize_btn; + btn->img_hilite = res_minimize_btn_hl; + btn->img_pressed = res_minimize_btn_pressed; + + update_caption_size(win); + + return 1; +}; + + +void update_caption_size(window_t *win) +{ + caption_t *cpt = &win->caption; + + int old_size; + int new_size; + int stride; + + old_size = cpt->ctx.stride * CAPTION_HEIGHT; + old_size = (old_size+4095) & ~4095; + + stride = win->w*4; + + new_size = stride * CAPTION_HEIGHT; + new_size = (new_size+4095) & ~4095; + + if( new_size < old_size) + user_unmap(cpt->ctx.pixmap, new_size, old_size-new_size); + + cpt->ctx.stride = stride; + + cpt->ctrl.rc.l = 0; + cpt->ctrl.rc.t = 0; + cpt->ctrl.rc.r = win->w; + cpt->ctrl.rc.b = CAPTION_HEIGHT; + cpt->ctrl.w = win->w; + cpt->ctrl.h = CAPTION_HEIGHT; + win->client.t = CAPTION_HEIGHT; + + cpt->close_btn->rc.l = win->w - 25; + cpt->close_btn->rc.r = cpt->close_btn->rc.l + + cpt->close_btn->w; + + cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5; + cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l + + cpt->minimize_btn->w; + +}; + + +void draw_caption(caption_t *cpt) +{ + int *pixmap, *src; + int i, j, w; + + pixmap = cpt->ctx.pixmap; + src = res_caption_left; + + for(i=0; i < CAPTION_HEIGHT; i++) + { + for(j=0; j < CAPTION_CORNER_W; j++) + pixmap[j] = src[j]; + pixmap+= cpt->ctx.stride/4; + src+= CAPTION_CORNER_W; + }; + + w = cpt->ctrl.w - (2*CAPTION_CORNER_W); + if( w > 0) + { + pixmap = cpt->ctx.pixmap; + pixmap+= CAPTION_CORNER_W; + src = res_caption_body; + + for(i = 0; i < CAPTION_HEIGHT; i++) + { + for(j = 0; j < w; j++) + pixmap[j] = src[i]; + pixmap+= cpt->ctx.stride/4; + } + }; + + pixmap = cpt->ctx.pixmap; + pixmap+= cpt->ctrl.w - CAPTION_CORNER_W; + + src = res_caption_right; + + for(i = 0; i < CAPTION_HEIGHT; i++) + { + for(j = 0; j < CAPTION_CORNER_W; j++) + pixmap[j] = src[j]; + pixmap+= cpt->ctx.stride/4; + src+= CAPTION_CORNER_W; + }; + + ctrl_t *child; + child = (ctrl_t*)cpt->ctrl.child.next; + + while( &child->link != &cpt->ctrl.child) + { + send_message(child, 1, 0, 0); + child = (ctrl_t*)child->link.next; + }; +}; + + +int caption_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + caption_t *cpt = (caption_t*)ctrl; + window_t *win = (window_t*)ctrl->parent; + + ctrl_t *child; + int x, y; + + x = ((pos_t)arg2).x; + y = ((pos_t)arg2).y; + + switch( msg ) + { + case 1: + break; + + + case MSG_MOUSEMOVE: + child = get_child(ctrl, x, y); + if( win->child_over ) + { + if(child == win->child_over) + send_message(child, msg, 0, arg2); + else + send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2); + } + else if( child ) + send_message(child, MSG_MOUSEENTER, 0, arg2); + + win->child_over = child; + if( child ) + send_message(child,msg,0,arg2); + // else if(main_cursor != 0) + // { + // set_cursor(0); + // main_cursor = 0; + // } + break; + + + case MSG_COMMAND: + switch((short)arg1) + { + case ID_CLOSE: + win = (window_t*)ctrl->parent; + win->win_command = WIN_CLOSED; + break; + + case ID_MINIMIZE: + __asm__ __volatile__( + "int $0x40" + ::"a"(18),"b"(10)); + break; + default: + break; + }; + + default: + child = get_child(ctrl, x, y); + if(child) + return send_message(child, msg, 0, arg2); + } + return 1; +}; + + + +void blit_caption(caption_t *cpt) +{ +// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, +// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); + + Blit(cpt->ctx.pixmap, 0, 0, 0, 0, cpt->ctrl.w, cpt->ctrl.h, + cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); +}; + diff --git a/programs/media/Fplay/winlib/clbhl.raw b/programs/media/Fplay/winlib/clbhl.raw new file mode 100644 index 0000000000000000000000000000000000000000..0e9e1db8e9c9f5c755af02182f9cd4f872bdd8c5 GIT binary patch literal 1152 zcmbWzO=uHA6bJB@6dLFuX_`$on{>OI?sxWMHf>^C8#PpGNwJ116mk}%pePFB(SlN{ zh~UYS2T$Gw4@D4BiYKXez39=Cdi3yj-j-SDEqWMc7~b#y-i&FQC=?198ymyO$jDHO zYRQ<~=JR>jwvB$jkHKIt)S_B4WHXrzy4^0??KT(-lNHBNdKPzLkD@TCB}0~GZnawQ zeGkp1kHv)mo#hY0f!C2glaYJ8$9ZVT?aNn)vu8#GacU{!#7M z!!&BB)fA8s-Y^XAE0}LiMhp6euQ%?I&7$xyC3sF5O(x?^N8x{0;SRlMj{r%E?9sa)q7th)xpGlZ*bDO z?)j>_PV+oZGMS8o!(j;o0=|S7#`|T{>9lk@9a*hbvRz6C=`;#Vj<)4SO$ZE zFX4rO<<6tgNc#Q0ioUsA&h4o;8VxCz%WpLpn|C-I>MYG>Q?l8t>~=dzCX-sLR;$wM z^<=qRN}*8D8gs)K&l$B^P5WQ3S9w04ayT3$7K^ z%SDWRJRUNi&z%p(_-?l=l}g3wbUL{n^nsntX6`#)7~|XRw&p`dWJhl}6Zc>izMEi- zZ?#%dEEXl7&%e!UJS%x55()L;g)yG@fo0{c_*tjZsl3jz-|y9DUgPWay1pB4x7loz zolGXKc03;CcDu=|kKe|VJO5|X=brj!jlJ=uQb}`5rBdQYWDH|`JRa9vEZc7@`N6;k dgF)BF`uSa9qtWQUd06I+L?VB>2j{}T{s8G*w(9@@ literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/clbp.raw b/programs/media/Fplay/winlib/clbp.raw new file mode 100644 index 0000000000000000000000000000000000000000..92d0ad38eb35f02488ef44b1b472bfb34848d649 GIT binary patch literal 1152 zcmbu8y-EW?6os>Y$tD`zUH@Xh9|GA`6pbk?w6O3EEJU!hw6YOJ5DOo`)|ar-!bY_A z2`sg>(c0peZ^Fa~3kEEPyK{HWx#ylclVzE*f2?M+sU%6{`@RZ=!a$3&V8BLEG!Q0_ z8?5JfJ-q7{I(w(1#W9h+&5`HZaeg%RWBFexyGmkTQxk#W$kXtUtC6aw@x<4}m~Xy| zMdufX)m7@`Ym38TdC;fc}ZXI zZ9U$m+S`eBdQ{WrTg&9&KnGea&c<@+8vgs6ra248^TR?93kN#rB@a(u^;)3qt*V~x z(jEsqV9`M@_>reS2)g}mZB})DJpBug4tl{4Jk7)7-`q@5hX<2A&D6FFKk$^fhandler( (ctrl_t*)(ctrl), \ + (uint32_t)(msg), (uint32_t)(arg1), (uint32_t)(arg2)) + +static inline handler_t *subclass_control(ctrl_t *ctrl, handler_t *handler) +{ + handler_t *old = ctrl->handler; + ctrl->handler = handler; + return old; +}; + +//int inline send_message(ctrl_t *ctrl, u32_t msg, u32_t arg1, u32_t arg2) +//{ +// return ctrl->handler(ctrl, msg, arg1, arg2); +//}; + +static inline int pt_in_rect(rect_t *rc, int x, int y) +{ + if( (x >= rc->l) && (x < rc->r) && + (y >= rc->t) && (y < rc->b) ) + return 1; + return 0; +}; + +ctrl_t *get_child(ctrl_t *ctrl, int x, int y); + +ctrl_t *capture_mouse(ctrl_t *newm); + +#endif diff --git a/programs/media/Fplay/winlib/cptbody.raw b/programs/media/Fplay/winlib/cptbody.raw new file mode 100644 index 0000000000000000000000000000000000000000..16734596e5825fb7671c6e32df942c7ad6012c56 GIT binary patch literal 96 zcmW;CTM9rC6hKj9kk?Tpijo+Q`442@u8;M%lv3P#Ip?tVX064XlQ9OpcUo)IS}CQF bb0(!kj1dtbgn;)R=iFnh#TbLu`uXn%SW_Up literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/cptleft.raw b/programs/media/Fplay/winlib/cptleft.raw new file mode 100644 index 0000000000000000000000000000000000000000..08b9ca05c58ecf0ac7a420d4b805c7315b06d60a GIT binary patch literal 768 zcma*jJF0_F6op|c2Oz#dF+MRGP1MpyVd((GaXCdNVYR~Y61b3EB=8mSM_K0pf4}oQ zvF|&kX@aV%P!#3DdK?Fy&nMC}#XQeg*A?5gUHIPP@whC@f?*i&dc9EB^@ZPzq6p(S zUf-yy3jg(efBkRU7G+s};g+uJP!t93_xl&_Y?=mHmWkN8hubCW+{29$cAhT`LlHZ- z1wkNU&+{C+0k+ZM6&+?HjD*m-u-G)2Gk+wBI! ZFhqQxcc<&Rh@E$*X`1MlF5TXawBove^0I@E%$R?=nA3up=W?X!v({Qn|ElCojAF?cC zT~}P!h39$jKIeIY9LIre+mIv)+P1}g-{O;|X+XNJ!#vN}_Z?ML3Dl>q>tCpLSr&w0 zDE?KJCH@+QLDWpsggnpxDT)H)IEtCmGzF*cd$AYI%b|H`Z<>Qcb5kA!0gHB|-19sZ z%}BZHx~weAMD92aIB#y-HaN5s^|vgG700p2P16J?iXxF4h5-)Ug!=2c&Z4_~lWUp= cj_>=TUR70a=&saXQ4|*4^_!f#?fZ`EKOz_uNdN!< literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/frame.c b/programs/media/Fplay/winlib/frame.c new file mode 100644 index 0000000000..c648933b47 --- /dev/null +++ b/programs/media/Fplay/winlib/frame.c @@ -0,0 +1,289 @@ + +#include "system.h" +#include +#include +#include +#include "winlib.h" + +#define CAPTION_HEIGHT 29 +#define CAPTION_CORNER_W 8 +#define FRAME_WIDTH 7 + +extern uint32_t main_cursor; + +extern uint32_t cursor_ns; +extern uint32_t cursor_we; +extern uint32_t cursor_nwse; +extern uint32_t cursor_nesw; + +extern ctrl_t *mouse_capture; + +static int frame_proc(ctrl_t *ctrl, uint32_t msg, + uint32_t arg1, uint32_t arg2); + +void adjust_frame(window_t *win) +{ + frame_t *fr = &win->frame; + + fr->left.l = 0; + fr->left.t = win->client.t; + fr->left.r = FRAME_WIDTH; + fr->left.b = win->h-FRAME_WIDTH; + + fr->right.l = win->w - FRAME_WIDTH; + fr->right.t = win->client.t; + fr->right.r = win->w; + fr->right.b = win->h-FRAME_WIDTH; + + fr->bottom.l = 0; + fr->bottom.t = win->h - FRAME_WIDTH; + fr->bottom.r = win->w; + fr->bottom.b = win->h; + + win->client.l = FRAME_WIDTH; + win->client.r = win->w - FRAME_WIDTH; +// win->client.b = win->h - FRAME_WIDTH; +// printf("Left: l:%d t:%d r:%d b:%d\n", +// fr->left.l,fr->left.t,fr->left.r,fr->left.b); +// printf("Left: l:%d t:%d r:%d b:%d\n", +// fr->right.l,fr->right.t,fr->right.r,fr->right.b); +// printf("Left: l:%d t:%d r:%d b:%d\n", +// fr->bottom.l,fr->bottom.t,fr->bottom.r,fr->bottom.b); + +}; + +void init_frame(window_t *win) +{ + frame_t *fr = &win->frame; + + link_initialize(&fr->link); + list_initialize(&fr->child); + + fr->handler = frame_proc; + fr->parent = (ctrl_t*)win; + + adjust_frame(win); +}; + + +extern int res_border_left[]; +extern int res_border_right[]; + +int draw_frame(window_t *win) +{ + int *pixmap, *src; + int i, j; + + int w; + + frame_t *fr = &win->frame; + + + pixmap = win->ctx->pixmap; + pixmap+= CAPTION_HEIGHT*win->w; + src = res_border_left; + + for(fr->left.t; i < fr->left.b; i++) + { + for(j = 0; j < FRAME_WIDTH; j++) + pixmap[j] = src[j]; + + pixmap+= win->ctx->stride/4; + }; + + + pixmap = win->ctx->pixmap; + pixmap+= (CAPTION_HEIGHT+1)*win->w - FRAME_WIDTH; + src = res_border_right; + + for(i=fr->right.t; i < fr->right.b; i++) + { + for(j = 0; j < FRAME_WIDTH; j++) + pixmap[j] = src[j]; + + pixmap+= win->ctx->stride/4; + }; + + pixmap = win->ctx->pixmap; + + pixmap+= fr->bottom.t * win->w; + + for(i=0; i < FRAME_WIDTH; i++) + { + for(j = 0; j < win->w; j++) + pixmap[j] = 0x808080; + + pixmap+= win->ctx->stride/4; + }; + + ctrl_t *child; + child = (ctrl_t*)fr->child.next; + + while( &child->link != &fr->child) + { + send_message(child, 1, 0, 0); + child = (ctrl_t*)child->link.next; + }; + + return 0; +}; + +int frame_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + static pos_t spos; + static track_mode; + + uint32_t cursor; + ctrl_t *child; + + frame_t *fr = (frame_t*)ctrl; + window_t *win = (window_t*)fr->parent; + rect_t *rc = NULL; + int x, y; + + x = ((pos_t)arg2).x; + y = ((pos_t)arg2).y; + + +// child = get_child(ctrl, x, y); +// if(child) +// { +// return send_message(child, msg, 0, arg2); +// }; + + if( (msg == MSG_LBTNDOWN) || + (msg == MSG_MOUSEMOVE) ) + { + x = ((pos_t)arg2).x; + y = ((pos_t)arg2).y; + + if( pt_in_rect(&fr->left, x, y)) + { + rc = &fr->left; + if( (y+24) > win->h) + cursor = cursor_nesw; + else + cursor = cursor_we; + set_cursor(cursor); + main_cursor = cursor; + } + else if( pt_in_rect(&fr->right, x, y)) + { +// printf("pos x%d y%d\n", x, y); + + rc = &fr->right; + if( (y+24) > win->h) + cursor = cursor_nwse; + else + cursor = cursor_we; +// printf("Set cursor %x\n", cursor); + set_cursor(cursor); + main_cursor = cursor; + } + else if( pt_in_rect(&fr->bottom, x, y)) + { + rc = &fr->bottom; + cursor = cursor_ns; + if(x+24 > win->w) + cursor = cursor_nwse; + else if(x < rc->l+24) + cursor = cursor_nesw; + set_cursor(cursor); + main_cursor = cursor; + } + }; + + switch( msg ) + { + case MSG_LBTNDOWN: + if( rc != NULL) + { + int relx, rely; + + capture_mouse(ctrl); + spos = get_cursor_pos(); + fr->track = rc; + + relx = spos.x - win->rc.l; + rely = spos.y - win->rc.t; +// printf("relx %d rely %d\n", relx, rely); + + if(fr->track == &fr->left || + fr->track == &fr->right) + { + if(rely+24 > win->h) + track_mode = 1; + }; + if(fr->track == &fr->bottom) + { + if(relx < 24) + track_mode = 2; + else if(relx+24 > win->w) + track_mode = 3; + } + + break; + }; + + case MSG_LBTNUP: + release_mouse(); + fr->track = NULL; + track_mode = 0; + break; + + case MSG_MOUSEMOVE: + if(mouse_capture == ctrl) + { + pos_t npos; + npos = get_cursor_pos(); +// printf("cursor pos %dx%d\n", npos.x, npos.y); + + if( npos.val != spos.val) + { + int w, h; + + rect_t nrc = win->rc; + spos = npos; + + if(fr->track == &fr->left) + { + nrc.l = npos.x-2; + if(nrc.l < 0) + nrc.l = 0; + if(track_mode==1) + nrc.b = npos.y+2; + } + else if(fr->track == &fr->right) + { + nrc.r = npos.x+2; + if(track_mode==1) + nrc.b = npos.y+2; + } + else if(fr->track == &fr->bottom) + { + nrc.b = npos.y+2; + if(track_mode==2) + nrc.l = npos.x-2; + else if (track_mode==3) + nrc.r = npos.x+2; + }; + + w = nrc.r - nrc.l; + h = nrc.b - nrc.t; + + if(w < 150) + w = 150; + if(h < 120) + h = 120; + + __asm__ __volatile__( + "int $0x40" + ::"a"(67), "b"(nrc.l), "c"(nrc.t), + "d"(w-1),"S"(h-1) ); + }; + } + }; + + return 1; +} + diff --git a/programs/media/Fplay/winlib/lborder.raw b/programs/media/Fplay/winlib/lborder.raw new file mode 100644 index 0000000000000000000000000000000000000000..cb5f9b24d4fe3dd5590430afca1c4e6eff122bf0 GIT binary patch literal 28 kcmZQzVECUA8}dIY$os#ayVHL+2b=#cc9#DQbu|A20HQw&member)))) + +static inline void link_initialize(link_t *link) +{ + link->prev = NULL; + link->next = NULL; +} + +static inline void list_initialize(link_t *head) +{ + head->prev = head; + head->next = head; +} + +static inline void list_append(link_t *link, link_t *head) +{ + link->prev = head->prev; + link->next = head; + head->prev->next = link; + head->prev = link; +} + +static inline void list_remove(link_t *link) +{ + link->next->prev = link->prev; + link->prev->next = link->next; + link_initialize(link); +} + +static inline int list_empty(link_t *head) +{ + return head->next == head ? 1 : 0; +} + +static inline void list_prepend(link_t *link, link_t *head) +{ + link->next = head->next; + link->prev = head; + head->next->prev = link; + head->next = link; +} + +static inline void list_insert(link_t *new, link_t *old) +{ + new->prev = old->prev; + new->next = old; + new->prev->next = new; + old->prev = new; +} diff --git a/programs/media/Fplay/winlib/minbhl.raw b/programs/media/Fplay/winlib/minbhl.raw new file mode 100644 index 0000000000000000000000000000000000000000..f4b5e42c37fad512f7f7a4e6ad12f0cee4abfaf4 GIT binary patch literal 1152 zcmbV~%Wl&^6o!3?)THgkHcb=XCbq{O+lgKG;=nd!2IG;I)^WhW!owrwb-u-$I4+wBIyS$5bp zO%t2V2J7`2bzKjFv+S_TJ-2O(vMdjRo&JBDra_vf2f8s;p?r!{l^^N?)Kb&Q26p*;nSN8 zFP<-`hjW@w)cM@Mlyr9C8FDqnMKwcvHOJF-j%RDPgWqpxty-NUl~V-%6PmT?{-0+M z_%3{Z3g5G_5H{`aQ0@_#I5abdYS?h+7Ceu$Zs+qEo}Qk-b!W7XM|WV45FVZBo_;M1 nye`98cG%T*{ox+;_hIOh-SK$*-#)vRWp#TPhB0^_&i3waq^6T^ literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/minbn.raw b/programs/media/Fplay/winlib/minbn.raw new file mode 100644 index 0000000000000000000000000000000000000000..c7518434c4865a207e980820ab93f9a17e6c6f0a GIT binary patch literal 1152 zcmbW#y^4cC6a`>SL7Zp(v<6j{*+S^!Lr%4}tBp=E*y1PfXDYghRTO0JvUDu_iX=vLvdOn{*K^F%0e!tVQEHuwE4Z|Q5bYWoe%+oYc z-}h31;rAWKksgnSRAAWS-g%x&1%`dsb(Ce9RAAV*ZA)pIN(F{JzGIRkQh{M#RTV{1 zM7pkjuJPXA)v~Os3&VS5SyC8=bQ}kr=lM17_xtL?urG>&eBYqYy%f6cnCR~Lpo z&L01wOkmi@aZEuFkZs#SK^KO-X`0uWh<*c{H4MC}s-HPLPjrPf4CCJ()^VI`#_e_! Io`WviAA7rrUH||9 literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/minbp.raw b/programs/media/Fplay/winlib/minbp.raw new file mode 100644 index 0000000000000000000000000000000000000000..ee4a7ee8be23d0defca62c0ddb92af5e62d72d4a GIT binary patch literal 1152 zcmdUuO-{ow5QP&v{{>nnZK+C9P$@~%@F%Xqies>2#RdeTfP_%F3J2gi9D&8d&ru~R zRj8sX7EiGz^Ub^&%Xyw7NfJ1Y1Iw~j5_8GqnvLUlC1zP|vQo-F^Xst7{QTFL5SG3_ z8@^{F3cJ1)|`i$UrwsNZwZZ98agNmGaY zY`f+IU!c{Lh8qoiRAq>h!w{!Ok8+&G2%c;pryD#d&Pz +#include +#include +#include "winlib.h" + +#define PANEL_HEIGHT 55 +#define PANEL_CORNER_W 16 +#define FRAME_WIDTH 7 + +#define ID_PLAY 100 + +extern uint32_t main_cursor; + +extern int res_panel_left[]; +extern int res_panel_right[]; +extern int res_panel_body[]; + +extern int res_play_btn[]; +extern int res_play_btn_pressed[]; + +extern int res_pause_btn[]; +extern int res_pause_btn_pressed[]; + +//extern int res_minimize_btn[]; +//extern int res_minimize_btn_hl[]; +//extern int res_minimize_btn_pressed[]; + +void update_panel_size(window_t *win); + +int panel_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2); + +int init_panel(window_t *win) +{ + button_t *btn; + progress_t *prg; + + panel_t *panel = &win->panel; + ctx_t *ctx = &panel->ctx; + + link_initialize(&panel->ctrl.link); + list_initialize(&panel->ctrl.child); + + panel->ctrl.handler = panel_proc; + panel->ctrl.parent = (ctrl_t*)win; + + ctx->pixmap = user_alloc(1920*PANEL_HEIGHT*4); + if(!ctx->pixmap) + { + printf("not enough memory for caption bitmap\n"); + return 0; + }; + +// printf("win_w %d win_h %d\n", win->w, win->h); + + ctx->stride = win->w*4; + panel->ctrl.ctx = ctx; + + btn = create_button(NULL, ID_PLAY,0,19,32,32,&panel->ctrl); + panel->play_btn = btn; + + btn->img_default = res_pause_btn; + btn->img_hilite = res_pause_btn; + btn->img_pressed = res_pause_btn_pressed; + + prg = create_progress(NULL,101,0,4,0,8,&panel->ctrl); + panel->prg = prg; + +// btn = create_button(NULL, ID_MINIMIZE,0,5,16,18,(ctrl_t*)cpt); +// cpt->minimize_btn = btn; + +// btn->img_default = res_minimize_btn; +// btn->img_hilite = res_minimize_btn_hl; +// btn->img_pressed = res_minimize_btn_pressed; + + update_panel_size(win); + + return 1; +}; + +void update_panel_size(window_t *win) +{ + panel_t *panel = &win->panel; + + int old_size; + int new_size; + int stride; + + old_size = panel->ctx.stride * PANEL_HEIGHT; + old_size = (old_size+4095) & ~4095; + + stride = win->w*4; + + new_size = stride * PANEL_HEIGHT; + new_size = (new_size+4095) & ~4095; + + if( new_size < old_size) + user_unmap(panel->ctx.pixmap, new_size, old_size-new_size); + + panel->ctx.stride = stride; + panel->ctx.offset_x = 0; + panel->ctx.offset_y = win->h-PANEL_HEIGHT; + + panel->draw.l = 0; + panel->draw.t = win->h-PANEL_HEIGHT; + panel->draw.r = win->w; + panel->draw.b = win->h; + + panel->ctrl.rc.l = FRAME_WIDTH; + panel->ctrl.rc.t = win->h-PANEL_HEIGHT; + panel->ctrl.rc.r = win->w-FRAME_WIDTH; + panel->ctrl.rc.b = win->h-FRAME_WIDTH; + + panel->ctrl.w = win->w; + panel->ctrl.h = PANEL_HEIGHT; + win->client.b = win->h-PANEL_HEIGHT; + + panel->play_btn->rc.l = win->w/2 - 16; + panel->play_btn->rc.t = panel->ctrl.rc.t+19; + panel->play_btn->rc.r = panel->play_btn->rc.l + panel->play_btn->w; + panel->play_btn->rc.b = panel->play_btn->rc.t + panel->play_btn->h; + + panel->prg->ctrl.rc.l = 8; + panel->prg->ctrl.rc.t = panel->ctrl.rc.t+7; + panel->prg->ctrl.rc.r = panel->ctrl.rc.r-8; + panel->prg->ctrl.rc.b = panel->prg->ctrl.rc.t+8; + panel->prg->ctrl.w = panel->prg->ctrl.rc.r - + panel->prg->ctrl.rc.l; + + panel->prg->ctrl.h = panel->prg->ctrl.rc.b - + panel->prg->ctrl.rc.t; + +// cpt->minimize_btn->rc.l = win->w - 25 - 16 - 5; +// cpt->minimize_btn->rc.r = cpt->minimize_btn->rc.l + +// cpt->minimize_btn->w; + +}; + + +void draw_panel(panel_t *panel) +{ + int *pixmap, *src; + int i, j, w; + + pixmap = panel->ctx.pixmap; + src = res_panel_left; + + for(i=0; i < PANEL_HEIGHT; i++) + { + for(j=0; j < PANEL_CORNER_W; j++) + pixmap[j] = src[j]; + pixmap+= panel->ctx.stride/4; + src+= PANEL_CORNER_W; + }; + + w = panel->ctrl.w - (2*PANEL_CORNER_W); + if( w > 0) + { + pixmap = panel->ctx.pixmap; + pixmap+= PANEL_CORNER_W; + src = res_panel_body; + + for(i = 0; i < PANEL_HEIGHT; i++) + { + for(j = 0; j < w; j++) + pixmap[j] = src[i]; + pixmap+= panel->ctx.stride/4; + } + }; + + pixmap = panel->ctx.pixmap; + pixmap+= panel->ctrl.w - PANEL_CORNER_W; + + src = res_panel_right; + + for(i = 0; i < PANEL_HEIGHT; i++) + { + for(j = 0; j < PANEL_CORNER_W; j++) + pixmap[j] = src[j]; + pixmap+= panel->ctx.stride/4; + src+= PANEL_CORNER_W; + }; + + ctrl_t *child; + child = (ctrl_t*)panel->ctrl.child.next; + + while( &child->link != &panel->ctrl.child) + { + send_message(child, 1, 0, 0); + child = (ctrl_t*)child->link.next; + }; +}; + +int panel_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + panel_t *panel = (panel_t*)ctrl; + window_t *win = get_parent_window(ctrl); + + ctrl_t *child; + int x, y; + + x = ((pos_t)arg2).x; + y = ((pos_t)arg2).y; + + switch( msg ) + { + case 1: + draw_panel((panel_t*)ctrl); + break; + + case MSG_MOUSEMOVE: + child = get_child(ctrl, x, y); + if( win->child_over ) + { + if(child == win->child_over) + send_message(child, msg, 0, arg2); + else + send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2); + } + else if( child ) + send_message(child, MSG_MOUSEENTER, 0, arg2); + + win->child_over = child; + if( child ) + send_message(child,msg,0,arg2); + else if(main_cursor != 0) + { + set_cursor(0); + main_cursor = 0; + } + break; + + case MSG_COMMAND: + switch((short)arg1) + { + case ID_PLAY: + case 101: + win = get_parent_window(ctrl); + send_message(win, msg, arg1, arg2); + break; + + default: + break; + }; + + default: + child = get_child(ctrl, x, y); + if(child) + return send_message(child, msg, 0, arg2); + } + return 1; +}; + +void blit_panel(panel_t *panel) +{ +// printf("%s w:%d h:%d stride: %d\n",__FUNCTION__, +// cpt->ctrl.w, cpt->ctrl.h, cpt->ctx.stride); + + Blit(panel->ctx.pixmap, panel->draw.l, panel->draw.t, + 0, 0, panel->ctrl.w, panel->ctrl.h, + panel->ctrl.w, panel->ctrl.h, panel->ctx.stride); +}; + diff --git a/programs/media/Fplay/winlib/panel.raw b/programs/media/Fplay/winlib/panel.raw new file mode 100644 index 0000000000000000000000000000000000000000..678ae0bbaba03e12b23da8ff19fc4ea26ff23754 GIT binary patch literal 220 zcmWFx4E!Gm#4<86D42nP;lHS;CIJsYIgD_y>C5q4qTrwVzNZ{m4n; zeAjiw`BB`0dwxL>i2K`eY0TwEQ3S_vpsMO4|4@D=NrEiPcHn;hEWagR)<5#VnLqC4 zrGKP`o+|`M*by+{Ys~=@qiXJ2k!$&o|ZCiE^b99H}IHD*Dp+UXL(K}aj^E_i1 rhR;8cAJQ~M9LFpzyq{%RP*v4VXZ6-qT=^8IX+q!k=(-L~)3CH&BZ}C! literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/panelright.raw b/programs/media/Fplay/winlib/panelright.raw new file mode 100644 index 0000000000000000000000000000000000000000..54efe900493788bb0da31312870ffb5173f6917f GIT binary patch literal 3520 zcmeH~Jqm;{5QVj{Q5*j{6|}Mv!N$frXzw|!J&j=PB`hqx&s#>wk}YDgHoNRbc*JD< zV4Qi8*!Mm94=Rph+)-WEAl+e!`4-+V4DfPYSLvNt{!tWxmt|S!TvitmZ`(FJ&y(gL z;vL6<@B4qlhhYd_R6m-l)}LqTp8A(0i89Z7$23g@L4YjFl=-Tvz^f<)JosKmY2VG)>R*ciXnN_7B@T<2b&}(^-f3 zrfIOQs}i5*Im)tp{xcB2EDQF1e_3OBU5#DW;W!Sk>*`q+8-@YXG+~}+Y}>}rb9?|I CM%cFi literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/pausebp.raw b/programs/media/Fplay/winlib/pausebp.raw new file mode 100644 index 0000000000000000000000000000000000000000..9d2aa2e70d6a99ba50af6e00639dd45149bd55d3 GIT binary patch literal 4096 zcmb`J*^d-e6vi1ChMn%|rK-BRx~rG!>1DQ_VGv_f2op7NBf}uVgCUM6gKP#8jSu1$ z0wKnz{{l}&BTq*E74%JCP~Uj<;dp;{a*FC@mJlCK>fT$o?)RPVEVqInkYEc|EEXl3 z&B~rVdt_{EOm^(pA=|cXv$k{RPP=yS;6ZU5XG`a81(Q96LP7TJ+b1IS^7*{{Bj#_wJ23FjkE9 zp1$wLyzw86lemfp$9~gy%13$NyXMYjIuJiJ)3|X4K6##N^3XN;RFG2OTMLT5owLT6 z^}vjov)6Ukbm9y&)L5*S53I9i`}XZJK0Y4%?RnIbC)J8C6OBMxO{`?cQ9Tf>Iq}#U zkuPCrc=(>>pgNGZoKI~Gs|(E+_G!HFAt-tV!2eNpqE-xZriVy#&Ua;qV z_HiWt{xcuj{d+Arz0{PmZ#3o6AKiHU;e#1@;ds?@E|+`plNx}52JnCrmc)j)Z(@ia zN1v_8-7gw320VWGp)KdnwPkgsBai-kjQ{uVv$FJBB!}ioHfNIc!1-E}^a$|5QSGU> zBnRL4Pb?RYRpgu7%^v(;e{9R8cRTXI#mNEu(3W6Kl=| z3w&xEpXqm+`{dyN?Z4t{4;Y3IH@K+(Ne)T>zr8at5dW*I9l3FNF#czjBYA2eFtt0} z|D^upC;0RRv`FH6ZrOgXb&DUCU0cgZ?YXPLgG0GowmHaL z{~3}TTqkGxtS85hmWSeBxzLj9m)ZmQ_vXo(96nT(a>?n5JJ|d8?~nB+|HCkh|E1_p z{rHW@m1ED9On>XGf9mhzJ57N@fBi3?sLFiTABwO4721E`pgE}j8O*VKJ}dRABhMTu z%I%xAp7{U#eM`=rjb!DmMi2g9zs<@kFNHEY?U~+|k8>X1seS!#RPDiMtTCZ4u@}o` z$Bhp;nVa$C=7;qj{GaZ1`4+Qq6|d9Nm?PL$>8!@kvKb){<7YjSn9YV-(Y zdeW7!Z2p;Ye8uumm!6BVaN!D=i3mFrKoISTY?V7vA^yQ`_ zjmRBv;aF?X=JlZ|y+j=|2FyPp`QtRI|3zr}a%IIt8~pTvNE#2$=1UCYNc4xCr? zGv-dkvSx4AYJk3>JNZ_r zRMz!9$zft*!su9t^MUWFTVev2jVy_){G%uu8uKJ(|Cm_to%Sn@3H6I6@S&bC#;j?6 zvzIaVPOH`GskMHbjpk^^_rwiNwRb3&VNbXyF0mX|Ya3w>dq>=w&8BoZ9UDXHg#Jmc iV%%Y@fyW-6o8{RsoUN>(MXgq|7~}~?oLGAj%>MunxX&B_ literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/pausebtn.raw b/programs/media/Fplay/winlib/pausebtn.raw new file mode 100644 index 0000000000000000000000000000000000000000..5e22c5d92b38dd4d3fe7a45f70d42fa001942b77 GIT binary patch literal 4096 zcmbW4Nsm-j6vvrodZ@8$o`?5p=&J7ONwAsJh@y;Pa3F!8jX-OFL>Gn_g9vd7`W19z zB*ujcz6!e24eHLVi{t&>%6Yu5>Y_Rql<{%3f%lF6hb*C2^RLW04dY~Q|J zwrtrV8#iv0b?eqy*}QqP)s2jdNF)+jlfAWIawZmw$$N@XH!;Jp#1nCeY7!2I1z+`j@-hrl_a`PML}OsZmu9mmQ&Uq`z)%5GaaG5; zcDrqP0atz4v17+jAL8-2=Qr_ZvsoK6akpA6YZu$YgtNR;uh%UXT06sdptkXsxO2Ij zb@g>=w`vC4H94qS8>Lc7G#B*7YJH*g!ns1B zAjM))N~NN)Q8xCfGB;C}xlT%+n@`L9Y}%|Pd45k_7WdX=ekLP(7BaFhmzLR1#`xw) zqi*~!m#iIZWilBrx1*z@D{5hUeB9%mI^-<5FBD7;+@is&$m!z+`Qp=rd~+u$U)@g1 z)k|49a=0l+k2K}Zt)$hn_sK^I*}v$>RJ$zYa>3>iTi6T)0v^YH4m9udyXxujTsC9y zbF#RnEVnb0yK+Fz0{Z?D9E_`sE=3k|t)$>9I_1pn{fC*{;J$K)$- z@G~9;HtB6f#x-{p{DP^!grrju zi%%@r#6JA{@!7){;%CqAgT@d3{kx^U_?MTea^tGghkxco-s1b?*Vw`E^G{uXuisWb zel!v?H9R5DickE+?Z;;JfQJu!Q>j6IGZ)$Oa}Ws!rBsZ{fyGpR{6AIY+Pf9Gex=$M z|LNm7=}g5Xl??Y`@7lG?;~Q+|lHR45y?ywFi0s>&l&?Q4uH@g~U%ptjKJ@ngiPy8z zo{X)EulEY_4n6|sa6k_#2lx>R1xycxWnnfhpWn)_!2k8fikv@Jkc)2>SH%C^b_%v4K9(t%Eh-c(x^pE@0&Rm>h>G9h)erUzXyuX%6&uo0{^0^IbvI%;V$ZEc40h1Wy>Y{Rmq%tJrW$-2S>#T>r{lN&5jmcpp1(p`!KFyXrnG z_g&?jyi;S`L;P5Sp3CL3y$5JL@IHM@PVnVv;>T70xqq#e^FjFN^$w`>N^?U0!U_J+ zPYBQGw7xmZGvC~5wQ6I38rGmaIOBbMhf|#$>dR^?z9=raT&>pz;SJK0x9(lswK=3u kn4i=t!Z!>Zc-;3{ht=62tYLb%;J+sr)Cod<(LD?1|J4QU7ytkO literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/playbp.raw b/programs/media/Fplay/winlib/playbp.raw new file mode 100644 index 0000000000000000000000000000000000000000..420cdc73d2caf890aa55c53a752b5c86f5d940d9 GIT binary patch literal 4096 zcmbVOId2_R6i#d>alFKS+w3!MX5Jbis1O-S@LO~A&#mD*X{_QA5OZSA)mOg`hfE=EU3v2*9n3{P=4TFGs4 zauVdcU7X(M`0n`l_!?a5B$tVa2^5P(l*?rk#G-b3Gc+`m@#HZ*>)m^+b84o?s&CJp zJw}h>RVo$qhTh{!-sGz9liOC9df#!JOau8-EB919=2yeEZ7}qlE1y#?BO@aj2OcZN zMyuy}8E@*R$9Y`EBgfv*d&)<7P`lR7Rz5I)^i1={J*Y|dc3lUa=bB)SdP6xW2lay< zYA!aa2VUnh0|Nsn6bhMc+qMM9mRfcZ_#VQ*LlpWZ!hrSd$vrRQ(#t`8VBKns3Dp1UrgcB(aZr%}1jin5d-zlEg=~>I*MF^MxGL1I-`xDF*$>*8uhAeb3|j zo+JCa2DjY`FgFw7z+5-xW~-R#RMBdNAQ$qWN6b?%2ky!ItH*f{H1E_-o{H}{oMn#e z?V&RjV*Wsc<)tDXI}u3KuzWnl($N%$4^<5>@<_#xFmz469H-kGnuELt#GnV{K~9W3 zHfzTd?Q!g3e>=d!d=<;b5`6Y?9q+tp;p($xTz)#n#V4CMbE=LLOR0Hgx)Vumm=o3u zYjl+Z_t&1}j37R7)O+?@o`WavriqK$=|FVGIDfi^-|x=gpFijE%ePbb;9VbY+_Z81 z`4kt=H^h?!iwjlpDlndfq4OVpcP4Oe?FIH2@rg-%&bWT~^_q)=a{*2+$D+4^dp~sX z$$|0Poen;H&&R7bEL^$};nCxX@@ zigE1WNP5MWnsMa&AoIiJ_lvc+im(3_I)BK4nDjvZGkDIZR7x_RBnPQ2`E+q~F~Iw` zTX^o71Q*W6cOJv!tU2LaqEC!csQ||= z$+x8}94zT6)`Ev4hkfDVizmMHx@Wjib6n-jEXzCmFXJp*)lF>bBMxhwz7tz>pmT|J z$UN}8P?$tT_Hpc@%u?1uMf6!{w`}?5*wPy|YKbLvRx!A?#cxMZYOU*^>fm0~rF|cU zVTP?7k|fFI68WuikpD07!K#QCPEl|qClXwZR;MKQsFl659+%kMi}RM+`Hdr%;_AvA za31j)2J4jXO-@djC>Fc}Jk$@} zmuueN{B?bv?kHX{ZOOK<5f%c05F&sCGRQy# zNJs?aNQ9Q05D*|CA_%a!1OZ5vO+an}f}*}R)a-b@>s=9)`t|F2_5XGD%VaW=S%(Bc zAhB3XcJACM+qP|!&6_vNh7B8>Y~8xm?d{vQPdv|Cm%a61qLWIcWcTjfvT@_aA)eu` z_JrH`__)A%y*SJDIJXT0guvC#lb5wH?Yr;$Vm|PMOS|2ce!uSo z3==R7*Y?os^?EKY;2MWryLPR~A)QVSdEr>#8T(i!ps$AmZ`=yMKfG#ZYB#bLF2U>}`Ln>M+aSF2S) z>h+rPsH?4p+HI=+)=+pyTCJwzO76i!sLfif=4?b!B$f+$W2L^ZdO@#LDoMFqmMALg z`ABV5rPZuTr(Kg?w=Vr&!%4T>(7n2Hs7td^Q@jD^N~NM_BWD9UNG_Kf=5}ms?4eqi zn3x#GojOF9+!u=lwNsKty{tZ0WV%`=R>uXSGz^^yCetZB3U?+kW(iLa{6Rl7EjdW_|cji zny<+0bfg^0Qm+-2b3sbVJ)h6HzQq=P(MuNRcs%a*z_Z$5cA`Tcu%8RF5|wjmx1fHO zWZ`Hew?8k-dvAMk{YpZvT`tL`ryKIrnVK9wQgJ%nc0u!%SKgr%lz$jzoGon9+ssn% z@D)yA@=ndeiT7kO>2xzeO3I}`a~#T(hl+CkY$Si&nUa70>dUX+Hsq5J19{^WUv55E zl4s9X<;1a)%*_^Lsu?P8@`xWP^~rZOvCaH6Jn$_i+qZ9bvl0%>FLZ;nuXfVX?`GBa zyj-~$$=x3Z_;5ge|Gp`oeiX>7H$Ay@A(UfJ7My;y5@`GtUu`6lp0kN<@N6CsW5Z|0 zQit>*f^N!BsQGAd9yAzu9oH8 zsl3jDtk!?Z@eTrwz4Lt#ckJ)kvu7A@u$fDCmtyuV#}Bg!ohiQTSDzLaa$4_gd2qik zU*4LMw_dNhoLsq767q9cvAgZG_DoW;nS|CJy+rJn@a=A7IGhZ$C;Ip=z zFqhzfOiqqV(wme_5K|5bY1F8Nl+4Yfl}lPxdWF+D@S(MwByV-Nqp zq1K7J`Oli~e4`HG$@|2_xFj?Nei9CG?I-%d(|?R7mB@4JqVfu}IxGIeC1&7SuUXCE zm-U_f4-B6t|0(MW_$_f5leqfgB_?zxlaH9rw3vI68{+IGm>C0qm*e6GwwUku$NUFt z6q_|UU>>1^P^X+5AEze0qW6gh@J1D+C4r{e< zoZ~#)iK)#F@GpQ@(*JVJal-jRcEVVt+h`q QxYvR~ogn0wz5j#xFUV+#lK=n! literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/rborder.raw b/programs/media/Fplay/winlib/rborder.raw new file mode 100644 index 0000000000000000000000000000000000000000..897339e8d9ceb19c3f5783821d01a94468f2a4f9 GIT binary patch literal 28 kcmXri(fsdXXZhdF!REi8yVL)uAn*Sfu_6B%7#RKo0H;R_5>;kpW?zTNoS(CM5Wr=bzYBU8z#5 zMtv`J*rk=$l6JtA4$x?cNAzCmNSs+&;wa}i;7L_VA$r56BQwtc^DB3MAhR)SQLk0C zWhsnn#Gvj{gH9upH=(=Z*^aoO{|CsJZ@p&kt^Je6nl~loS?w@ J88gxOtOvUepxpof literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/size_ns.cur b/programs/media/Fplay/winlib/size_ns.cur new file mode 100644 index 0000000000000000000000000000000000000000..1b50dd7d46c74964149f44be0dbf6bcf8f3ed17f GIT binary patch literal 766 zcmd6ku@1s83`Ae6?(M`%NB#o-jC@)?g^`i51H#-ulc(=%~f34N+Wm8F1H yIOKePzR&&Seo5_a`b+J9Z>!3-cu2aRBc`MNVIOf(y{5HKxWxOebNG&PzQGeFl9-(U literal 0 HcmV?d00001 diff --git a/programs/media/Fplay/winlib/size_nwse.cur b/programs/media/Fplay/winlib/size_nwse.cur new file mode 100644 index 0000000000000000000000000000000000000000..fb20e7f05fb475a9afe57a382342ddc91b26966a GIT binary patch literal 766 zcmd5)F%H5o47?U3Ml&%nRAS*5@FiYAMxK?YFfw*zKpf|`NVNwT;ga*&xyDMP04*AH z9bg)_7T5sTi(0}_Y_L=mk3KlF~b?S zDm3Dzm{^nrX@QdpkB$QRl+sCACAC(u3- +#include +#include +#include +#include "winlib.h" + +int draw_frame(window_t *win); +static int draw_window(window_t *win); + +uint32_t main_cursor; +uint32_t cursor_ns; +uint32_t cursor_we; +uint32_t cursor_nwse; +uint32_t cursor_nesw; + +static pos_t old_pos; + +ctrl_t *mouse_capture = NULL; + +static link_t timers; +static uint32_t realtime; +static uint32_t wait_time; +static uint32_t exp_time; + +static int need_update; + +#define LOAD_FROM_MEM 1 + + +void adjust_frame(window_t *win); + + +#include "control.inc" +//#include "io.inc" +#include "timer.inc" + +//#include "button.inc" +//#include "scroller.inc" + +static window_t Window; + + + +void init_frame(window_t *win); + +window_t *create_window(char *caption, int style, int x, int y, + int w, int h, handler_t handler) +{ + int stride; + ctx_t *ctx = &Window.client_ctx; + + if(handler==0) return 0; + + Window.handler = handler; + Window.ctx = ctx; + + list_initialize(&Window.link); + list_initialize(&Window.child); + + ctx->pixmap = user_alloc(1280*1024*4); + if(!ctx->pixmap) + { + printf("not enough memory for context bitmap\n"); + return NULL; + }; + + stride = w*4; + ctx->stride = stride; + + Window.rc.l = x; + Window.rc.t = y; + Window.rc.r = x + w; + Window.rc.b = y + h; + + Window.w = w; + Window.h = h; + + Window.caption_txt = caption; + Window.style = style; + + Window.child_over = NULL; + Window.child_focus = NULL; + + init_caption(&Window); + init_panel(&Window); + init_frame(&Window); + send_message((ctrl_t*)&Window, MSG_SIZE, 0, 0); + return &Window; +}; + + +int def_window_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) +{ + ctrl_t *child; + + window_t *win = (window_t*)ctrl; + + switch(msg) + { + case MSG_PAINT: + draw_window(win); + break; + + case 2: + child = (ctrl_t*)win->child.next; + while( &child->link != &win->child) + { + send_message(child, 2, arg1, arg2); + child = (ctrl_t*)child->link.next; + }; + break; + + case MSG_MOUSEMOVE: + child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16)); + if( win->child_over ) + { + if(child == win->child_over) + send_message(child, msg, 0, arg2); + else + send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2); + } + else if( child ) + send_message(child, MSG_MOUSEENTER, 0, arg2); + + win->child_over = child; + if( child ) + send_message(child,msg,0,arg2); + else if(main_cursor != 0) + { + set_cursor(0); + main_cursor = 0; + } + break; + + case MSG_SIZE: + break; + + default: + child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16)); + win->child_over = child; + if(child) send_message(child, msg, 0, arg2); + }; + + return 0; +} + +static int draw_window(window_t *win) +{ + ctrl_t *child; + void *ctx; + rect_t *rc = &win->client; + + draw_caption(&win->caption); + draw_panel(&win->panel); + +// draw_frame(win); + +// child = (ctrl_t*)win->child.next; + +// while( &child->link != &win->child) +// { +// send_message(child, 1, 0, 0); +// child = (ctrl_t*)child->link.next; +// }; + + return 0; +}; + +void blit_client(window_t *win) +{ + int w, h; + + w = win->client.r - win->client.l; + h = win->client.b - win->client.t; + + Blit(win->ctx->pixmap, win->client.l, win->client.t, + 0, 0, w, h, w, h,win->ctx->stride); +}; + + +int show_window(window_t *win, int state) +{ + win->win_state = state; + + draw_window(win); + + BeginDraw(); + DrawWindow(win->rc.l, win->rc.t, win->w-1, win->h-1, + NULL,0,0x41); + EndDraw(); + + blit_caption(&win->caption); + blit_panel(&win->panel); +// blit_client(win); + return 0; +} + +void window_update_layout(window_t *win) +{ + char proc_info[1024]; + + int new_w, new_h; + uint8_t state; + + int winx, winy, winw, winh; + +// __asm__ __volatile__("int3"); + + get_proc_info(proc_info); + + winx = *(uint32_t*)(proc_info+34); + winy = *(uint32_t*)(proc_info+38); + winw = *(uint32_t*)(proc_info+42)+1; + winh = *(uint32_t*)(proc_info+46)+1; + + state = *(uint8_t*)(proc_info+70); + + if(state & 2) + { win->win_state = MINIMIZED; + return; + } + if(state & 4) + { + win->win_state = ROLLED; + return; + }; + + if(state & 1) + win->win_state = MAXIMIZED; + else + win->win_state = NORMAL; + + if( (winx != win->rc.l) || (winy != win->rc.t) ) + { + win->rc.l = winx; + win->rc.t = winy; + win->rc.r = winx + win->w; + win->rc.b = winy + win->h; + }; + + if( winw == win->w && + winh == win->h) + return; + + int old_size; + int new_size; + int stride; + + old_size = win->ctx->stride * win->h; + old_size = (old_size+4095) & ~4095; + + new_size = winw*winh*4; + new_size = (new_size+4095) & ~4095; + + stride = winw*4; + +// printf("update win size %d %d\n", winw, winh); + + if( new_size < old_size) + user_unmap(win->ctx->pixmap, new_size, old_size-new_size); + win->ctx->stride = stride; + + win->rc.r = winx + winw; + win->rc.b = winy + winh; + win->w = winw; + win->h = winh; + + update_caption_size(win); + update_panel_size(win); + adjust_frame(win); + + send_message((ctrl_t*)win, MSG_SIZE, 0, 0); + draw_window(win); +}; + + +int send_mouse_message(window_t *win, uint32_t msg) +{ + ctrl_t *child; + + if(mouse_capture) + return send_message(mouse_capture, msg, 0, old_pos.val); + + if(pt_in_rect(&win->caption.ctrl.rc, old_pos.x, old_pos.y)) + { + return send_message(&win->caption.ctrl, msg, 0, old_pos.val); + } + + if(pt_in_rect(&win->panel.ctrl.rc, old_pos.x, old_pos.y)) + { +// old_pos.x-= win->panel.ctrl.rc.l; +// old_pos.y-= win->panel.ctrl.rc.t; + return send_message(&win->panel.ctrl, msg, 0, old_pos.val); + } + + if(pt_in_rect(&win->client, old_pos.x, old_pos.y)) + return send_message((ctrl_t*)win, msg, 0, old_pos.val); + + return send_message(&win->frame, msg, 0, old_pos .val); + +// if( ( old_pos.x < win->rc.r) && ( old_pos.y < win->rc.b)) +// send_message((ctrl_t*)win, msg, 0, old_pos.val); +}; + +void do_sys_draw(window_t *win) +{ +// printf("%s win:%x\n", __FUNCTION__, win); + + window_update_layout(win); + + BeginDraw(); + DrawWindow(0,0,0,0, NULL, 0x000000,0x41); + EndDraw(); + + blit_caption(&win->caption); + blit_panel(&win->panel); + +// blit_client(win); + send_message((ctrl_t*)win, MSG_DRAW_CLIENT, 0, 0); + need_update=0; +}; + +static void do_sys_mouse(window_t *win) +{ + static uint32_t mouse_click_time; + static int mouse_action; + static int old_buttons; + int buttons; + uint32_t wheels; + uint32_t click_time; + int action; + + pos_t pos; + + mouse_action = 0; + pos = get_mouse_pos(); + + if(pos.val != old_pos.val) + { + mouse_action = 0x80000000; + old_pos = pos; + }; +// printf("pos x%d y%d\n", pos.x, pos.y); + + buttons = get_mouse_buttons(); + wheels = get_mouse_wheels(); + + if( wheels & 0xFFFF){ + wheels = (short)wheels>0 ? MSG_WHEELDOWN : MSG_WHEELUP; + send_mouse_message(win, wheels); + } + + if((action = (buttons ^ old_buttons))!=0) + { + mouse_action|= action<<3; + mouse_action|= buttons & ~old_buttons; + } + old_buttons = buttons; + + if(mouse_action & 0x80000000) { + DBG("mouse move \n\r"); + send_mouse_message(win, MSG_MOUSEMOVE); + }; + + if(mouse_action & 0x09) + { + if((mouse_action & 0x09)==0x09) + { +// printf("left button down x= %d y= %d\n\r", old_x.x, old_x.y); + click_time = get_tick_count(); + if(click_time < mouse_click_time+35) { + mouse_click_time = click_time; + send_mouse_message(win,MSG_LBTNDBLCLK); + } + else { + mouse_click_time = click_time; + send_mouse_message(win,MSG_LBTNDOWN); + }; + } + else { +// printf("left button up \n\r"); + send_mouse_message(win,MSG_LBTNUP); + } + }; + + if(mouse_action & 0x12) + { + if((mouse_action & 0x12)==0x12) { + DBG("right button down \n\r"); + send_mouse_message(win,MSG_RBTNDOWN); + } + else { + DBG("right button up \n\r"); + send_mouse_message(win,MSG_RBTNUP); + }; + }; + if(mouse_action & 0x24) + { + if((mouse_action & 0x24)==0x24){ + DBG("middle button down \n\r"); + send_mouse_message(win,MSG_MBTNDOWN); + } + else { + DBG("middle button up \n\r"); + send_mouse_message(win,MSG_MBTNUP); + }; + }; + + +}; + + +void run_window(window_t *win) +{ + int ev; + oskey_t key; + +// buttons = get_mouse_buttons(); +// wheels = get_mouse_wheels(); + realtime = get_tick_count(); + exp_time = -1; + + while(1) + { + wait_time = exp_time - realtime; + + ev = wait_for_event(wait_time); + + realtime = get_tick_count(); + +// if(exp_time < realtime) +// exp_time = update_timers(realtime); + + switch(ev) + { + case MSG_PAINT: + do_sys_draw(win); + continue; + + case 2: + key = get_key(); + if( key.state == 0) + send_message((ctrl_t*)win, ev, 0, key.code); + continue; + + case 6: + do_sys_mouse(win); + continue; + + default: + continue; + }; + }; +} + +void render_time(void *render); + +void run_render(window_t *win, void *render) +{ + int ev; + oskey_t key; + + realtime = get_tick_count(); + exp_time = -1; + + while(win->win_command != WIN_CLOSED) + { + wait_time = exp_time - realtime; + + ev = check_os_event(); + + realtime = get_tick_count(); + +// if(exp_time < realtime) +// exp_time = update_timers(realtime); + + switch(ev) + { + case MSG_PAINT: + do_sys_draw(win); + break; + + case 2: + key = get_key(); + if( key.state == 0) + send_message((ctrl_t*)win, ev, 0, key.code); + break; + + case 6: + do_sys_mouse(win); + break; + + default: + break; + }; + + render_time(render); + }; +}; + + + +extern unsigned char res_cursor_ns[]; +extern unsigned char res_cursor_we[]; +extern unsigned char res_cursor_nwse[]; +extern unsigned char res_cursor_nesw[]; + +int init_resources() +{ + cursor_ns = load_cursor(res_cursor_ns, LOAD_FROM_MEM); + cursor_we = load_cursor(res_cursor_we, LOAD_FROM_MEM); + cursor_nwse = load_cursor(res_cursor_nwse, LOAD_FROM_MEM); + cursor_nesw = load_cursor(res_cursor_nesw, LOAD_FROM_MEM); + return 1; +} + +void init_winlib(void) +{ + __asm__ __volatile__( + "int $0x40" + ::"a"(40), "b"(0xC0000027)); + + init_resources(); + list_initialize(&timers); +}; + +ctx_t *get_window_ctx() +{ + return &Window.client_ctx; +}; + +void update_rect(ctrl_t *ctrl) +{ + int ctx_w, ctx_h; + int src_x, src_y; + + src_x = ctrl->rc.l - ctrl->ctx->offset_x; + src_y = ctrl->rc.t - ctrl->ctx->offset_y; + + ctx_w = ctrl->parent->w; + ctx_h = ctrl->parent->h; + + Blit(ctrl->ctx->pixmap, ctrl->rc.l, ctrl->rc.t, src_x, src_y, + ctrl->w, ctrl->h, ctx_w, ctx_h, ctrl->ctx->stride); + +// need_update++; +}; + + +void Blit(void *bitmap, int dst_x, int dst_y, + int src_x, int src_y, int w, int h, + int src_w, int src_h, int stride) +{ + volatile struct blit_call bc; + + bc.dstx = dst_x; + bc.dsty = dst_y; + bc.w = w; + bc.h = h; + bc.srcx = src_x; + bc.srcy = src_y; + bc.srcw = src_w; + bc.srch = src_h; + bc.stride = stride; + bc.bitmap = bitmap; + + __asm__ __volatile__( + "int $0x40" + ::"a"(73),"b"(0),"c"(&bc.dstx)); + +}; + +ctrl_t *get_child(ctrl_t *ctrl, int x, int y) +{ + ctrl_t *child = NULL; + + ctrl_t *tmp = (ctrl_t*)ctrl->child.next; + + while( &tmp->link != &ctrl->child ) + { + if(pt_in_rect(&tmp->rc, x, y)) + { + child = get_child(tmp, x, y); + return child == NULL ? tmp : child; + }; + tmp = (ctrl_t*)tmp->link.next; + }; + return child; +}; + +ctrl_t *capture_mouse(ctrl_t *newm) +{ + ctrl_t *old = mouse_capture; + + mouse_capture = newm; + + __asm__ __volatile__( + "int $0x40" + ::"a"(40), "b"(0x80000027)); + + return old; +} + +void release_mouse(void) +{ + mouse_capture = NULL; + __asm__ __volatile__( + "int $0x40" + ::"a"(40), "b"(0xC0000027)); +} diff --git a/programs/media/Fplay/winlib/winlib.h b/programs/media/Fplay/winlib/winlib.h new file mode 100644 index 0000000000..981c325f61 --- /dev/null +++ b/programs/media/Fplay/winlib/winlib.h @@ -0,0 +1,125 @@ +#ifndef __WINLIB_H__ +#define __WINLIB_H__ + +#include "control.h" + +typedef struct +{ + link_t link; + link_t child; + + handler_t *handler; + ctrl_t *parent; + + ctx_t *ctx; + uint32_t id; + uint32_t style; + + rect_t rc; + int w; + int h; + + rect_t left; /* left border */ + rect_t right; /* right border */ + rect_t bottom; /* bottom border */ + + button_t *close_btn; + rect_t *track; +}frame_t; + +typedef struct +{ + ctrl_t ctrl; + ctx_t ctx; + ctrl_t *child_over; + button_t *close_btn; + button_t *minimize_btn; + +}caption_t; + +typedef struct +{ + ctrl_t ctrl; + ctx_t ctx; + rect_t draw; + ctrl_t *child_over; + progress_t *prg; + button_t *play_btn; +}panel_t; + +typedef struct +{ + link_t link; + link_t child; + + handler_t *handler; + ctrl_t *parent; + + ctx_t *ctx; + uint32_t id; + uint32_t style; + + rect_t rc; + int w; + int h; + + rect_t client; + + ctx_t client_ctx; + + char *caption_txt; + ctrl_t *child_over; + ctrl_t *child_focus; + + caption_t caption; + panel_t panel; + frame_t frame; + + enum win_state{ + NORMAL, MINIMIZED, ROLLED, MAXIMIZED + }win_state; + enum win_command{ + WIN_CLOSED=1 + }win_command; + +}window_t; + +#define get_parent_window(x) ((window_t*)((x)->parent)) + +ctrl_t *win_get_child(window_t *win, int x, int y); + +void init_winlib(void); + +void draw_caption(caption_t *cpt); +void draw_panel(panel_t *panel); +void blit_caption(caption_t *cpt); +int init_caption(window_t *win); +int init_panel(window_t *win); + + + +window_t *create_window(char *caption, int style, int x, int y, + int w, int h, handler_t handler); + +int show_window(window_t *win, int state); + +int def_window_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2); + +void frame_run(window_t *win); + +button_t *create_button(char *caption, int id, int x, int y, + int w, int h, ctrl_t *parent); +progress_t *create_progress(char *caption, int id, int x, int y, + int w, int h, ctrl_t *parent); + +scroller_t *create_scroller(uint32_t style, int id, int x, int y, + int w, int h, ctrl_t *parent); + +//static uint32_t update_timers(uint32_t realtime); + +int set_timer(ctrl_t *ctrl, ostimer_t *timer, uint32_t delay); + +void update_rect(ctrl_t *ctrl); + + +#endif