From a69bb94df7e01f69b312f9aa5a1cd0e698d719ad Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 19 May 2013 16:43:16 +0100 Subject: [PATCH] Resume as default patch from dingo35 --- vrecording.cc | 194 +++++++++++++------------------------------------- vrecording.h | 18 ++--- 2 files changed, 59 insertions(+), 153 deletions(-) diff --git a/vrecording.cc b/vrecording.cc index b285061..0a5b3f6 100644 --- a/vrecording.cc +++ b/vrecording.cc @@ -73,36 +73,26 @@ VRecording::VRecording(RecMan* trecman, Recording* trec) add(&summary); - - buttonPlay.setPosition(10, area.h - 40); - buttonResume.setPosition(150, area.h - 40); - buttonMove.setPosition(290, area.h - 40); - buttonDelete.setPosition(430, area.h - 40); - int sfh = getFontHeight(); - - buttonPlay.setSize(130, sfh); - buttonResume.setSize(130, sfh); - buttonMove.setSize(130, sfh); - buttonDelete.setSize(130, sfh); - buttonRegion.x = 10; buttonRegion.y = area.h - 40; buttonRegion.w = 550; buttonRegion.h = sfh; - buttonPlay.setText(tr("Play")); - buttonResume.setText(tr("Resume")); - buttonMove.setText(tr("Move")); - buttonDelete.setText(tr("Delete")); + button[PLAY].setText(tr("Play")); + button[RESUME].setText(tr("Resume")); + button[MOVE].setText(tr("Move")); + button[DELETE].setText(tr("Delete")); - add(&buttonPlay); - add(&buttonResume); - add(&buttonMove); - add(&buttonDelete); + for (int i=PLAY, hor=10; ifrom = this; @@ -152,7 +142,7 @@ int VRecording::handleCommand(int command) return 4; } - if (selected == 2) + if (selected == RESUME) { Message* m = new Message(); // Must be done after this view deleted m->from = this; @@ -162,7 +152,7 @@ int VRecording::handleCommand(int command) return 4; } - if (selected == 3) + if (selected == MOVE) { VRecMove* vrm = new VRecMove(recman); vrm->setParent(this); @@ -172,7 +162,7 @@ int VRecording::handleCommand(int command) return 2; } - if (selected == 4) + if (selected == DELETE) { VQuestion* v = new VQuestion(this); v->setSize(260, 180); @@ -208,73 +198,20 @@ int VRecording::handleCommand(int command) return 1; } -void VRecording::doRight() +void VRecording::moveCursor(Direction direction) { - switch(selected) - { - case 1: - buttonPlay.setActive(0); - buttonResume.setActive(1); - buttonPlay.draw(); - buttonResume.draw(); - break; - case 2: - buttonResume.setActive(0); - buttonMove.setActive(1); - buttonResume.draw(); - buttonMove.draw(); - break; - case 3: - buttonMove.setActive(0); - buttonDelete.setActive(1); - buttonMove.draw(); - buttonDelete.draw(); - break; - case 4: - buttonDelete.setActive(0); - buttonPlay.setActive(1); - buttonDelete.draw(); - buttonPlay.draw(); - break; + button[selected].setActive(0); + button[selected].draw(); + if (direction == RIGHT) + { + if (++selected == last) selected = PLAY; } - - if (++selected == 5) selected = 1; - - BoxStack::getInstance()->update(this, &buttonRegion); -} - -void VRecording::doLeft() -{ - switch(selected) + else { - case 1: - buttonPlay.setActive(0); - buttonDelete.setActive(1); - buttonPlay.draw(); - buttonDelete.draw(); - break; - case 2: - buttonResume.setActive(0); - buttonPlay.setActive(1); - buttonResume.draw(); - buttonPlay.draw(); - break; - case 3: - buttonMove.setActive(0); - buttonResume.setActive(1); - buttonMove.draw(); - buttonResume.draw(); - break; - case 4: - buttonDelete.setActive(0); - buttonMove.setActive(1); - buttonDelete.draw(); - buttonMove.draw(); - break; + if (--selected < 0) selected = last - 1; } - - if (--selected == 0) selected = 4; - + button[selected].setActive(1); + button[selected].draw(); BoxStack::getInstance()->update(this, &buttonRegion); } @@ -282,66 +219,33 @@ void VRecording::processMessage(Message* m) { if (m->message == Message::MOUSE_MOVE) { - if (buttonPlay.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + for (int i = PLAY; i < last; i++) { - buttonPlay.setActive(1); - buttonResume.setActive(0); - buttonMove.setActive(0); - buttonDelete.setActive(0); - selected=1; - draw(); - BoxStack::getInstance()->update(this); - } - else if (buttonResume.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) - { - buttonPlay.setActive(0); - buttonResume.setActive(1); - buttonMove.setActive(0); - buttonDelete.setActive(0); - selected=2; - draw(); - BoxStack::getInstance()->update(this); - } - else if (buttonMove.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) - { - buttonPlay.setActive(0); - buttonResume.setActive(0); - buttonMove.setActive(1); - buttonDelete.setActive(0); - selected=3; - draw(); - BoxStack::getInstance()->update(this); - } - else if (buttonDelete.mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) - { - buttonPlay.setActive(0); - buttonResume.setActive(0); - buttonMove.setActive(0); - buttonDelete.setActive(1); - selected=4; - draw(); - BoxStack::getInstance()->update(this); + if (button[i].mouseMove((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + { + for (int j = PLAY; j < last; j++) + button[j].setActive(0); + button[i].setActive(1); + selected=i; + draw(); + BoxStack::getInstance()->update(this); + break; + } } } else if (m->message == Message::MOUSE_LBDOWN) { - if (buttonPlay.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + int cancel = true; + for (int i = PLAY; i < last; i++) { - BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press - } - else if (buttonResume.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) - { - BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press - } - else if (buttonMove.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) - { - BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press - } - else if (buttonDelete.mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) - { - BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press + if (button[i].mouseLBDOWN((m->parameter>>16)-getScreenX(),(m->parameter&0xFFFF)-getScreenY())) + { + BoxStack::getInstance()->handleCommand(Remote::OK); //simulate OK press + cancel = false; + break; + } } - else + if (cancel) { //check if press is outside this view! then simulate cancel int x=(m->parameter>>16)-getScreenX(); @@ -354,7 +258,7 @@ void VRecording::processMessage(Message* m) } else if (m->message == Message::QUESTION_YES) { - if (selected == 4) + if (selected == DELETE) { Message* m2 = new Message(); // Delete self m2->from = this; diff --git a/vrecording.h b/vrecording.h index 9d3e043..e6c60ad 100644 --- a/vrecording.h +++ b/vrecording.h @@ -51,17 +51,19 @@ class VRecording : public TBBoxx Recording* rec; WTextbox summary; - - WButton buttonPlay; // 1 - WButton buttonResume; // 2 - WButton buttonMove; // 3 - WButton buttonDelete; // 4 + + enum Action { PLAY=0, RESUME, MOVE, DELETE, last }; + WButton button[last]; +// WButton buttonPlay; // 1 +// WButton buttonResume; // 2 +// WButton buttonMove; // 3 +// WButton buttonDelete; // 4 int selected; Region buttonRegion; - - void doLeft(); - void doRight(); + + enum Direction { LEFT, RIGHT }; + void moveCursor(Direction direction); }; #endif -- 2.39.5