removed FLAT_UI code from TimeLineWidget

added toggle mode button to TimeMachineDialog
This commit is contained in:
thrust26 2018-02-06 12:46:27 +01:00
parent 1fa00f2372
commit 564e014620
6 changed files with 194 additions and 122 deletions

View File

@ -1033,7 +1033,7 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = {
0x20a020, 0x00ff00, // scrollbar
0x20a020, 0x00ff00, 0x404040, 0x686868, 0x404040, // slider
0xc80000, 0x00ff00, 0xc8c8ff, 0xc80000, // debugger
0x20a020, 0x20a020, 0x000000, 0x686868, 0x404040 // other
0x00ff00, 0x20a020, 0x000000, 0x686868, 0x404040 // other
},
// Light
{ 0x808080, 0x000000, 0xc0c0c0, 0xe1e1e1, 0x333333, // base

View File

@ -142,20 +142,21 @@ void TimeLineWidget::drawWidget(bool hilite)
{
FBSurface& s = _boss->dialog().surface();
#ifndef FLAT_UI
// Draw the label, if any
if(_labelWidth > 0)
s.drawString(_font, _label, _x, _y + 2, _labelWidth,
isEnabled() ? kTextColor : kColor, TextAlign::Right);
isEnabled() ? kTextColor : kColor, TextAlign::Left);
int p = valueToPos(_value),
x = _x + _labelWidth;
// Draw the box
s.frameRect(_x + _labelWidth, _y, _w - _labelWidth, _h, kColor);
s.frameRect(x, _y, _w - _labelWidth, _h, isEnabled() && hilite ? kScrollColor : kColor);
// Fill the box
s.fillRect(_x + _labelWidth + 1, _y + 1, _w - _labelWidth - 2, _h - 2,
!isEnabled() ? kBGColorHi : kWidColor);
s.fillRect(x + 1, _y + 1, _w - _labelWidth - 2, _h - 2,
!isEnabled() ? kSliderBGColorLo : hilite ? kSliderBGColorHi : kSliderBGColor);
// Draw the 'bar'
int vp = valueToPos(_value);
s.fillRect(_x + _labelWidth + 1, _y + 1, vp, _h - 2,
s.fillRect(x + 1, _y + 1, p, _h - 2,
!isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor);
// add 4 tickmarks for 5 intervals
@ -165,25 +166,26 @@ void TimeLineWidget::drawWidget(bool hilite)
int idx = int((_stepValue.size() * i + numTicks / 2) / numTicks);
if(idx > 1)
{
int tp = valueToPos(idx - 1);
s.vLine(_x + _labelWidth + tp, _y + _h / 2, _y + _h - 2, tp > vp ? kSliderColor : kWidColor);
int xt = x + valueToPos(idx - 1);
uInt32 color;
if(isEnabled())
{
if(xt > x + p)
color = hilite ? kSliderColorHi : kSliderColor;
else
color = hilite ? kSliderBGColorHi : kSliderBGColor;
}
else
{
if(xt > x + p)
color = kColor;
else
color = kSliderBGColorLo;
}
s.vLine(xt, _y + _h / 2, _y + _h - 2, color);
}
}
#else
// Draw the label, if any
if(_labelWidth > 0)
s.drawString(_font, _label, _x, _y + 2, _labelWidth,
isEnabled() ? kTextColor : kColor, TextAlign::Left);
// Draw the box
s.frameRect(_x + _labelWidth, _y, _w - _labelWidth, _h, isEnabled() && hilite ? kSliderColorHi : kShadowColor);
// Fill the box
s.fillRect(_x + _labelWidth + 1, _y + 1, _w - _labelWidth - 2, _h - 2,
!isEnabled() ? kBGColorHi : kWidColor);
// Draw the 'bar'
s.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4,
!isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor);
#endif
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,100 +34,137 @@
#include "Base.hxx"
using Common::Base;
const int BUTTON_W = 16, BUTTON_H = 14;
static uInt32 RECORD[BUTTON_H] =
{
0b0000001111000000,
0b0000111111110000,
0b0001111111111000,
0b0011111111111100,
0b0011111111111100,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0011111111111100,
0b0011111111111100,
0b0001111111111000,
0b0000111111110000,
0b0000001111000000
};
static uInt32 STOP[BUTTON_H] =
{
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110
};
static uInt32 PLAY[BUTTON_H] =
{
0b0110000000000000,
0b0111100000000000,
0b0111111000000000,
0b0111111110000000,
0b0111111111100000,
0b0111111111111000,
0b0111111111111110,
0b0111111111111110,
0b0111111111111000,
0b0111111111100000,
0b0111111110000000,
0b0111111000000000,
0b0111100000000000,
0b0110000000000000
};
static uInt32 REWIND_ALL[BUTTON_H] =
{
0,
0b0110000110000110,
0b0110001110001110,
0b0110011110011110,
0b0110111110111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0110111110111110,
0b0110011110011110,
0b0110001110001110,
0b0110000110000110,
0
};
static uInt32 REWIND_1[BUTTON_H] =
{
0,
0b0000001100011100,
0b0000011100011100,
0b0000111100011100,
0b0001111100011100,
0b0011111100011100,
0b0111111100011100,
0b0111111100011100,
0b0011111100011100,
0b0001111100011100,
0b0000111100011100,
0b0000011100011100,
0b0000001100011100,
0
};
static uInt32 UNWIND_1[BUTTON_H] =
{
0,
0b0011100011000000,
0b0011100011100000,
0b0011100011110000,
0b0011100011111000,
0b0011100011111100,
0b0011100011111110,
0b0011100011111110,
0b0011100011111100,
0b0011100011111000,
0b0011100011110000,
0b0011100011100000,
0b0011100011000000,
0
};
static uInt32 UNWIND_ALL[BUTTON_H] =
{
0,
0b0110000110000110,
0b0111000111000110,
0b0111100111100110,
0b0111110111110110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111110111110110,
0b0111100111100110,
0b0111000111000110,
0b0110000110000110,
0
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
int width)
: Dialog(osystem, parent),
_enterWinds(0)
{
const int BUTTON_W = 16, BUTTON_H = 14;
static uInt32 PLAY[BUTTON_H] =
{
0b0110000000000000,
0b0111100000000000,
0b0111111000000000,
0b0111111110000000,
0b0111111111100000,
0b0111111111111000,
0b0111111111111110,
0b0111111111111110,
0b0111111111111000,
0b0111111111100000,
0b0111111110000000,
0b0111111000000000,
0b0111100000000000,
0b0110000000000000
};
static uInt32 REWIND_ALL[BUTTON_H] =
{
0,
0b0110000110000110,
0b0110001110001110,
0b0110011110011110,
0b0110111110111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0110111110111110,
0b0110011110011110,
0b0110001110001110,
0b0110000110000110,
0
};
static uInt32 REWIND_1[BUTTON_H] =
{
0,
0b0000001100011100,
0b0000011100011100,
0b0000111100011100,
0b0001111100011100,
0b0011111100011100,
0b0111111100011100,
0b0111111100011100,
0b0011111100011100,
0b0001111100011100,
0b0000111100011100,
0b0000011100011100,
0b0000001100011100,
0
};
static uInt32 UNWIND_1[BUTTON_H] =
{
0,
0b0011100011000000,
0b0011100011100000,
0b0011100011110000,
0b0011100011111000,
0b0011100011111100,
0b0011100011111110,
0b0011100011111110,
0b0011100011111100,
0b0011100011111000,
0b0011100011110000,
0b0011100011100000,
0b0011100011000000,
0
};
static uInt32 UNWIND_ALL[BUTTON_H] =
{
0,
0b0110000110000110,
0b0111000111000110,
0b0111100111100110,
0b0111110111110110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111111111111110,
0b0111110111110110,
0b0111100111100110,
0b0111000111000110,
0b0110000110000110,
0
};
const GUI::Font& font = instance().frameBuffer().font();
const int H_BORDER = 6, BUTTON_GAP = 4, V_BORDER = 4;
const int buttonWidth = BUTTON_W + 8,
@ -163,25 +200,29 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
ypos += rowHeight;
// Add time info
myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos + 3, "04:32 59", TextAlign::Left, kBGColor);
myCurrentTimeWidget = new StaticTextWidget(this, font, xpos, ypos + 3, "00:00.00", TextAlign::Left, kBGColor);
myCurrentTimeWidget->setTextColor(kColorInfo);
myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("XX:XX XX"), ypos + 3,
"12:25 59", TextAlign::Right, kBGColor);
myLastTimeWidget = new StaticTextWidget(this, font, _w - H_BORDER - font.getStringWidth("00:00.00"), ypos + 3,
"00:00.00", TextAlign::Right, kBGColor);
myLastTimeWidget->setTextColor(kColorInfo);
xpos = myCurrentTimeWidget->getRight() + BUTTON_GAP * 4;
// Add buttons
myToggleWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, STOP,
BUTTON_W, BUTTON_H, kToggle);
xpos += buttonWidth + BUTTON_GAP;
myPlayWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, PLAY,
BUTTON_W, BUTTON_H, kPlay);
xpos += buttonWidth + BUTTON_GAP * 4;
myRewindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, REWIND_ALL,
BUTTON_W, BUTTON_H, kRewindAll);
xpos += buttonWidth + BUTTON_GAP;
myRewind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, REWIND_1,
BUTTON_W, BUTTON_H, kRewind1);
xpos += buttonWidth + BUTTON_GAP*2;
myPlayWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, PLAY,
BUTTON_W, BUTTON_H, kPlay);
xpos += buttonWidth + BUTTON_GAP*2;
xpos += buttonWidth + BUTTON_GAP;
myUnwind1Widget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, UNWIND_1,
BUTTON_W, BUTTON_H, kUnwind1);
@ -189,7 +230,7 @@ TimeMachineDialog::TimeMachineDialog(OSystem& osystem, DialogContainer& parent,
myUnwindAllWidget = new ButtonWidget(this, font, xpos, ypos, buttonWidth, buttonHeight, UNWIND_ALL,
BUTTON_W, BUTTON_H, kUnwindAll);
xpos = myUnwindAllWidget->getRight() + BUTTON_GAP * 3;
xpos = myUnwindAllWidget->getRight() + BUTTON_GAP * 4;
// Add message
myMessageWidget = new StaticTextWidget(this, font, xpos, ypos + 3, " ",
@ -228,6 +269,7 @@ void TimeMachineDialog::loadConfig()
myMessageWidget->setLabel("");
handleWinds(_enterWinds);
_enterWinds = 0;
handleToogle();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -280,6 +322,11 @@ void TimeMachineDialog::handleCommand(CommandSender* sender, int cmd,
break;
}
case kToggle:
instance().state().toggleTimeMachine();
handleToogle();
break;
case kPlay:
instance().eventHandler().leaveMenuMode();
break;
@ -370,3 +417,11 @@ void TimeMachineDialog::handleWinds(Int32 numWinds)
myUnwindAllWidget->setEnabled(!r.atLast());
myUnwind1Widget->setEnabled(!r.atLast());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void TimeMachineDialog::handleToogle()
{
myToggleWidget->setBitmap(instance().state().mode() == StateManager::Mode::Off ? RECORD : STOP,
BUTTON_W, BUTTON_H);
}

View File

@ -47,11 +47,14 @@ class TimeMachineDialog : public Dialog
string getTimeString(uInt64 cycles);
/** re/unwind and update display */
void handleWinds(Int32 numWinds = 0);
/** toggle Time Machine mode */
void handleToogle();
private:
enum
{
kTimeline = 'TMtl',
kToggle = 'TMtg',
kPlay = 'TMpl',
kRewindAll = 'TMra',
kRewind10 = 'TMr1',
@ -63,6 +66,7 @@ class TimeMachineDialog : public Dialog
TimeLineWidget* myTimeline;
ButtonWidget* myToggleWidget;
ButtonWidget* myPlayWidget;
ButtonWidget* myRewindAllWidget;
ButtonWidget* myRewind1Widget;

View File

@ -435,6 +435,15 @@ void ButtonWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::setBitmap(uInt32* bitmap, int bmw, int bmh)
{
_bitmap = bitmap;
_bmh = bmh;
_bmw = bmw;
_useBitmap = true;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void ButtonWidget::drawWidget(bool hilite)
{

View File

@ -229,6 +229,8 @@ class ButtonWidget : public StaticTextWidget, public CommandSender
void setCmd(int cmd) { _cmd = cmd; }
int getCmd() const { return _cmd; }
/* Sets/changes the button's bitmap **/
void setBitmap(uInt32* bitmap, int bmw, int bmh);
protected:
void handleMouseUp(int x, int y, MouseButton b, int clickCount) override;