mirror of https://github.com/stella-emu/stella.git
redesigned SliderWidget
better visual reaction of EditTextWidget and PopUpWidget improved BrowserDialog small refinement for ButtonWidget
This commit is contained in:
parent
d179b8ebe8
commit
920b051f02
|
@ -998,6 +998,8 @@ void FrameBuffer::VideoModeList::setZoom(uInt32 zoom)
|
|||
*** Button colors ***
|
||||
kBtnColor Normal button background
|
||||
kBtnColorHi Highlighted button background
|
||||
kBtnBorderColor,
|
||||
kBtnBorderColorHi,
|
||||
kBtnTextColor Normal button font color
|
||||
kBtnTextColorHi Highlighted button font color
|
||||
*** Checkbox colors ***
|
||||
|
@ -1023,7 +1025,7 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = {
|
|||
{ 0x686868, 0x000000, 0xa38c61, 0xdccfa5, 0x404040, // base
|
||||
0x000000, 0x62a108, 0x9f0000, 0x000000, // text
|
||||
0xc9af7c, 0xf0f0cf, 0xd55941, 0xc80000, // UI elements
|
||||
0xac3410, 0xd55941, 0xffffff, 0xffd652, // buttons
|
||||
0xac3410, 0xd55941, 0x686868, 0xdccfa5, 0xffffff, 0xf0f0cf/*0xffd652*/, // buttons
|
||||
0xac3410, // checkbox
|
||||
0xac3410, 0xd55941, // scrollbar
|
||||
0xac3410, 0xd55941, // slider
|
||||
|
@ -1034,7 +1036,7 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = {
|
|||
{ 0x686868, 0x000000, 0x404040, 0x404040, 0x404040, // base
|
||||
0x20a020, 0x00ff00, 0xc80000, 0x20a020, // text
|
||||
0x000000, 0x000000, 0x00ff00, 0xc80000, // UI elements
|
||||
0x000000, 0x000000, 0x20a020, 0x00ff00, // buttons
|
||||
0x000000, 0x000000, 0x686868, 0x00ff00, 0x20a020, 0x00ff00, // buttons
|
||||
0x20a020, // checkbox
|
||||
0x20a020, 0x00ff00, // scrollbar
|
||||
0x20a020, 0x00ff00, // slider
|
||||
|
@ -1046,7 +1048,7 @@ uInt32 FrameBuffer::ourGUIColors[3][kNumColors-256] = {
|
|||
0x808080, 0x000000, 0xc0c0c0, 0xe1e1e1, 0x333333, // base
|
||||
0x000000, 0x0078d7, 0x0078d7, 0xffffff, // text
|
||||
0xf0f0f0, 0xffffff, 0x0078d7, 0x0f0f0f, // UI elements
|
||||
0xe1e1e1, 0xe5f1fb, 0x000000, 0x000000, // buttons
|
||||
0xe1e1e1, 0xe5f1fb, 0x808080, 0x0078d7, 0x000000, 0x000000, // buttons
|
||||
0x333333, // checkbox
|
||||
0xc0c0c0, 0x808080, // scrollbar
|
||||
0x333333, 0x0078d7, // slider
|
||||
|
|
|
@ -57,6 +57,8 @@ enum {
|
|||
kWidFrameColor,
|
||||
kBtnColor,
|
||||
kBtnColorHi,
|
||||
kBtnBorderColor,
|
||||
kBtnBorderColorHi,
|
||||
kBtnTextColor,
|
||||
kBtnTextColorHi,
|
||||
kCheckColor,
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
*/
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
||||
int max_w, int max_h)
|
||||
: Dialog(boss->instance(), boss->parent()),
|
||||
int max_w, int max_h, const string& title)
|
||||
: Dialog(boss->instance(), boss->parent(), font, title),
|
||||
CommandSender(boss),
|
||||
_cmd(0),
|
||||
_mode(FileSave)
|
||||
|
@ -46,38 +46,31 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
|||
const int lineHeight = font.getLineHeight(),
|
||||
buttonWidth = font.getStringWidth("Defaults") + 20,
|
||||
buttonHeight = font.getLineHeight() + 4,
|
||||
selectHeight = lineHeight + 8;
|
||||
selectHeight = lineHeight + 12;
|
||||
int xpos, ypos;
|
||||
ButtonWidget* b;
|
||||
|
||||
xpos = 10; ypos = 4;
|
||||
_title = new StaticTextWidget(this, font, xpos, ypos,
|
||||
_w - 2 * xpos, lineHeight,
|
||||
"", TextAlign::Center);
|
||||
xpos = 10; ypos = 4 + _th;
|
||||
|
||||
// Current path - TODO: handle long paths ?
|
||||
ypos += lineHeight + 4;
|
||||
_currentPath = new StaticTextWidget(this, font, xpos, ypos,
|
||||
_w - 2 * xpos, lineHeight,
|
||||
"", TextAlign::Left);
|
||||
|
||||
StaticTextWidget* t = new StaticTextWidget(this, font, xpos, ypos + 2, "Pfad ");
|
||||
_currentPath = new EditTextWidget(this, font, xpos + t->getWidth(), ypos,
|
||||
_w - t->getWidth() - 2 * xpos, lineHeight);
|
||||
_currentPath->setEditable(false);
|
||||
// Add file list
|
||||
ypos += lineHeight + 4;
|
||||
ypos += lineHeight + 8;
|
||||
_fileList = new FileListWidget(this, font, xpos, ypos, _w - 2 * xpos,
|
||||
_h - selectHeight - buttonHeight - ypos - 20);
|
||||
_fileList->setEditable(false);
|
||||
addFocusWidget(_fileList);
|
||||
|
||||
// Add currently selected item
|
||||
ypos += _fileList->getHeight() + 4;
|
||||
ypos += _fileList->getHeight() + 8;
|
||||
|
||||
_type = new StaticTextWidget(this, font, xpos, ypos+2,
|
||||
font.getStringWidth("Name "), lineHeight,
|
||||
"Name", TextAlign::Center);
|
||||
_type = new StaticTextWidget(this, font, xpos, ypos + 2, "Name ");
|
||||
_selected = new EditTextWidget(this, font, xpos + _type->getWidth(), ypos,
|
||||
_w - _type->getWidth() - 2 * xpos, lineHeight, "");
|
||||
_selected->setEditable(false);
|
||||
addFocusWidget(_selected);
|
||||
|
||||
// Buttons
|
||||
_goUpButton = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
|
||||
|
@ -111,11 +104,10 @@ BrowserDialog::BrowserDialog(GuiObject* boss, const GUI::Font& font,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void BrowserDialog::show(const string& title, const string& startpath,
|
||||
void BrowserDialog::show(const string& startpath,
|
||||
BrowserDialog::ListMode mode, int cmd,
|
||||
const string& ext)
|
||||
{
|
||||
_title->setLabel(title);
|
||||
_cmd = cmd;
|
||||
_mode = mode;
|
||||
|
||||
|
@ -125,17 +117,23 @@ void BrowserDialog::show(const string& title, const string& startpath,
|
|||
_fileList->setFileListMode(FilesystemNode::kListAll);
|
||||
_fileList->setFileExtension(ext);
|
||||
_selected->setEditable(false);
|
||||
_selected->clearFlags(WIDGET_INVISIBLE);
|
||||
_type->clearFlags(WIDGET_INVISIBLE);
|
||||
break;
|
||||
|
||||
case FileSave:
|
||||
_fileList->setFileListMode(FilesystemNode::kListAll);
|
||||
_fileList->setFileExtension(ext);
|
||||
_selected->setEditable(false); // FIXME - disable user input for now
|
||||
_selected->clearFlags(WIDGET_INVISIBLE);
|
||||
_type->clearFlags(WIDGET_INVISIBLE);
|
||||
break;
|
||||
|
||||
case Directories:
|
||||
_fileList->setFileListMode(FilesystemNode::kListDirectoriesOnly);
|
||||
_selected->setEditable(false);
|
||||
_selected->setFlags(WIDGET_INVISIBLE);
|
||||
_type->setFlags(WIDGET_INVISIBLE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -164,7 +162,7 @@ void BrowserDialog::updateUI()
|
|||
_goUpButton->setEnabled(_fileList->currentDir().hasParent());
|
||||
|
||||
// Update the path display
|
||||
_currentPath->setLabel(_fileList->currentDir().getShortPath());
|
||||
_currentPath->setText(_fileList->currentDir().getShortPath());
|
||||
|
||||
// Enable/disable OK button based on current mode
|
||||
bool enable = _mode == Directories || !_fileList->selected().isDirectory();
|
||||
|
|
|
@ -39,11 +39,12 @@ class BrowserDialog : public Dialog, public CommandSender
|
|||
};
|
||||
|
||||
public:
|
||||
BrowserDialog(GuiObject* boss, const GUI::Font& font, int max_w, int max_h);
|
||||
BrowserDialog(GuiObject* boss, const GUI::Font& font, int max_w, int max_h,
|
||||
const string& title = "");
|
||||
virtual ~BrowserDialog() = default;
|
||||
|
||||
/** Place the browser window onscreen, using the given attributes */
|
||||
void show(const string& title, const string& startpath,
|
||||
void show(const string& startpath,
|
||||
BrowserDialog::ListMode mode, int cmd, const string& ext = "");
|
||||
|
||||
/** Get resulting file node (called after receiving kChooseCmd) */
|
||||
|
@ -63,8 +64,7 @@ class BrowserDialog : public Dialog, public CommandSender
|
|||
int _cmd;
|
||||
|
||||
FileListWidget* _fileList;
|
||||
StaticTextWidget* _currentPath;
|
||||
StaticTextWidget* _title;
|
||||
EditTextWidget* _currentPath;
|
||||
StaticTextWidget* _type;
|
||||
EditTextWidget* _selected;
|
||||
ButtonWidget* _goUpButton;
|
||||
|
|
|
@ -208,48 +208,48 @@ void ConfigPathDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
case kChooseRomDirCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select ROM directory", myRomPath->getText(),
|
||||
createBrowser("Select ROM directory");
|
||||
myBrowser->show(myRomPath->getText(),
|
||||
BrowserDialog::Directories, LauncherDialog::kRomDirChosenCmd);
|
||||
break;
|
||||
|
||||
case kChooseCheatFileCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select cheat file", myCheatFile->getText(),
|
||||
createBrowser("Select cheat file");
|
||||
myBrowser->show(myCheatFile->getText(),
|
||||
BrowserDialog::FileLoad, kCheatFileChosenCmd);
|
||||
break;
|
||||
|
||||
case kChoosePaletteFileCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select palette file", myPaletteFile->getText(),
|
||||
createBrowser("Select palette file");
|
||||
myBrowser->show(myPaletteFile->getText(),
|
||||
BrowserDialog::FileLoad, kPaletteFileChosenCmd);
|
||||
break;
|
||||
|
||||
case kChoosePropsFileCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select properties file", myPropsFile->getText(),
|
||||
createBrowser("Select properties file");
|
||||
myBrowser->show(myPropsFile->getText(),
|
||||
BrowserDialog::FileLoad, kPropsFileChosenCmd);
|
||||
break;
|
||||
|
||||
case kChooseNVRamDirCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select NVRAM directory", myNVRamPath->getText(),
|
||||
createBrowser("Select NVRAM directory");
|
||||
myBrowser->show(myNVRamPath->getText(),
|
||||
BrowserDialog::Directories, kNVRamDirChosenCmd);
|
||||
break;
|
||||
|
||||
case kChooseStateDirCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select state directory", myStatePath->getText(),
|
||||
createBrowser("Select state directory");
|
||||
myBrowser->show(myStatePath->getText(),
|
||||
BrowserDialog::Directories, kStateDirChosenCmd);
|
||||
break;
|
||||
|
||||
|
@ -288,13 +288,15 @@ void ConfigPathDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void ConfigPathDialog::createBrowser()
|
||||
void ConfigPathDialog::createBrowser(const string& title)
|
||||
{
|
||||
uInt32 w = 0, h = 0;
|
||||
getResizableBounds(w, h);
|
||||
|
||||
// Create file browser dialog
|
||||
if(!myBrowser || uInt32(myBrowser->getWidth()) != w ||
|
||||
uInt32(myBrowser->getHeight()) != h)
|
||||
myBrowser = make_unique<BrowserDialog>(this, myFont, w, h);
|
||||
uInt32(myBrowser->getHeight()) != h)
|
||||
myBrowser = make_unique<BrowserDialog>(this, myFont, w, h, title);
|
||||
else
|
||||
myBrowser->setTitle(title);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class ConfigPathDialog : public Dialog, public CommandSender
|
|||
|
||||
private:
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
void createBrowser();
|
||||
void createBrowser(const string& title);
|
||||
|
||||
void loadConfig() override;
|
||||
void saveConfig() override;
|
||||
|
|
|
@ -40,6 +40,21 @@ void EditTextWidget::setText(const string& str, bool changed)
|
|||
_changed = changed;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EditTextWidget::handleMouseEntered()
|
||||
{
|
||||
setFlags(WIDGET_HILITED);
|
||||
setDirty();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EditTextWidget::handleMouseLeft()
|
||||
{
|
||||
clearFlags(WIDGET_HILITED);
|
||||
setDirty();
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EditTextWidget::handleMouseDown(int x, int y, MouseButton b, int clickCount)
|
||||
{
|
||||
|
@ -74,7 +89,7 @@ void EditTextWidget::drawWidget(bool hilite)
|
|||
s.fillRect(_x, _y, _w, _h, kDlgColor);
|
||||
|
||||
// Draw a thin frame around us.
|
||||
s.frameRect(_x, _y, _w, _h, kColor);
|
||||
s.frameRect(_x, _y, _w, _h, hilite && isEditable() && isEnabled() ? kWidColorHi : kColor);
|
||||
|
||||
// Draw the text
|
||||
adjustOffset();
|
||||
|
|
|
@ -43,6 +43,8 @@ class EditTextWidget : public EditableWidget
|
|||
GUI::Rect getEditRect() const override;
|
||||
|
||||
void handleMouseDown(int x, int y, MouseButton b, int clickCount) override;
|
||||
void handleMouseEntered() override;
|
||||
void handleMouseLeft() override;
|
||||
|
||||
protected:
|
||||
string _backupString;
|
||||
|
|
|
@ -516,10 +516,9 @@ void LauncherDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
case kFirstRunMsgChosenCmd:
|
||||
// Show a file browser, starting from the users' home directory
|
||||
if(!myRomDir)
|
||||
myRomDir = make_unique<BrowserDialog>(this, instance().frameBuffer().font(), _w, _h);
|
||||
|
||||
myRomDir->show("Select ROM directory", "~",
|
||||
BrowserDialog::Directories, kStartupRomDirChosenCmd);
|
||||
myRomDir = make_unique<BrowserDialog>(this, instance().frameBuffer().font(),
|
||||
_w, _h, "Select ROM directory");
|
||||
myRomDir->show("~", BrowserDialog::Directories, kStartupRomDirChosenCmd);
|
||||
break;
|
||||
|
||||
case kStartupRomDirChosenCmd:
|
||||
|
|
|
@ -208,8 +208,8 @@ void PopUpWidget::drawWidget(bool hilite)
|
|||
isEnabled() ? _textcolor : uInt32(kColor), TextAlign::Left);
|
||||
|
||||
// Draw a thin frame around us.
|
||||
s.frameRect(x, _y, w, _h, kColor);
|
||||
s.frameRect(x + w - 16, _y + 1, 15, _h - 2, isEnabled() && hilite ? kTextColorHi : kBGColorLo);
|
||||
s.frameRect(x, _y, w, _h, isEnabled() && hilite ? kWidColorHi : kColor);
|
||||
s.frameRect(x + w - 16, _y + 1, 15, _h - 2, isEnabled() && hilite ? kWidColorHi : kBGColorLo);
|
||||
|
||||
// Fill the background
|
||||
s.fillRect(x + 1, _y + 1, w - 17, _h - 2, _changed ? kDbgChangedColor : kWidColor);
|
||||
|
|
|
@ -90,7 +90,7 @@ RomAuditDialog::RomAuditDialog(OSystem& osystem, DialogContainer& parent,
|
|||
addBGroupToFocusList(wid);
|
||||
|
||||
// Create file browser dialog
|
||||
myBrowser = make_unique<BrowserDialog>(this, font, myMaxWidth, myMaxHeight);
|
||||
myBrowser = make_unique<BrowserDialog>(this, font, myMaxWidth, myMaxHeight, "Select ROM directory to audit");
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -200,7 +200,7 @@ void RomAuditDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
break;
|
||||
|
||||
case kChooseAuditDirCmd:
|
||||
myBrowser->show("Select ROM directory to audit", myRomPath->getText(),
|
||||
myBrowser->show(myRomPath->getText(),
|
||||
BrowserDialog::Directories, kAuditDirChosenCmd);
|
||||
break;
|
||||
|
||||
|
|
|
@ -185,16 +185,16 @@ void SnapshotDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
case kChooseSnapSaveDirCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select snapshot save directory", mySnapSavePath->getText(),
|
||||
createBrowser("Select snapshot save directory");
|
||||
myBrowser->show(mySnapSavePath->getText(),
|
||||
BrowserDialog::Directories, kSnapSaveDirChosenCmd);
|
||||
break;
|
||||
|
||||
case kChooseSnapLoadDirCmd:
|
||||
// This dialog is resizable under certain conditions, so we need
|
||||
// to re-create it as necessary
|
||||
createBrowser();
|
||||
myBrowser->show("Select snapshot load directory", mySnapLoadPath->getText(),
|
||||
createBrowser("Select snapshot load directory");
|
||||
myBrowser->show(mySnapLoadPath->getText(),
|
||||
BrowserDialog::Directories, kSnapLoadDirChosenCmd);
|
||||
break;
|
||||
|
||||
|
@ -213,13 +213,15 @@ void SnapshotDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SnapshotDialog::createBrowser()
|
||||
void SnapshotDialog::createBrowser(const string& title)
|
||||
{
|
||||
uInt32 w = 0, h = 0;
|
||||
getResizableBounds(w, h);
|
||||
|
||||
// Create file browser dialog
|
||||
if(!myBrowser || uInt32(myBrowser->getWidth()) != w ||
|
||||
uInt32(myBrowser->getHeight()) != h)
|
||||
myBrowser = make_unique<BrowserDialog>(this, myFont, w, h);
|
||||
uInt32(myBrowser->getHeight()) != h)
|
||||
myBrowser = make_unique<BrowserDialog>(this, myFont, w, h, title);
|
||||
else
|
||||
myBrowser->setTitle(title);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class SnapshotDialog : public Dialog
|
|||
void setDefaults() override;
|
||||
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
void createBrowser();
|
||||
void createBrowser(const string& title);
|
||||
|
||||
private:
|
||||
enum {
|
||||
|
|
|
@ -356,7 +356,7 @@ ButtonWidget::ButtonWidget(GuiObject* boss, const GUI::Font& font,
|
|||
_cmd(cmd),
|
||||
_useBitmap(false)
|
||||
{
|
||||
_flags = WIDGET_ENABLED | WIDGET_BORDER | WIDGET_CLEARBG;
|
||||
_flags = WIDGET_ENABLED | WIDGET_CLEARBG;
|
||||
_bgcolor = kBtnColor;
|
||||
_bgcolorhi = kBtnColorHi;
|
||||
_textcolor = kBtnTextColor;
|
||||
|
@ -439,13 +439,16 @@ void ButtonWidget::handleMouseUp(int x, int y, MouseButton b, int clickCount)
|
|||
void ButtonWidget::drawWidget(bool hilite)
|
||||
{
|
||||
FBSurface& s = _boss->dialog().surface();
|
||||
|
||||
s.frameRect(_x, _y, _w, _h, hilite && isEnabled() ? kBtnBorderColorHi : kBtnBorderColor);
|
||||
|
||||
if (!_useBitmap)
|
||||
s.drawString(_font, _label, _x, _y + (_h - _fontHeight)/2 + 1, _w,
|
||||
!isEnabled() ? hilite ? uInt32(kColor) : uInt32(kBGColorLo) :
|
||||
!isEnabled() ? /*hilite ? uInt32(kColor) :*/ uInt32(kBGColorLo) :
|
||||
hilite ? _textcolorhi : _textcolor, _align);
|
||||
else
|
||||
s.drawBitmap(_bitmap, _x + (_w - _bmw) / 2, _y + (_h - _bmh) / 2,
|
||||
!isEnabled() ? hilite ? uInt32(kColor) : uInt32(kBGColorLo) :
|
||||
!isEnabled() ? /*hilite ? uInt32(kColor) :*/ uInt32(kBGColorLo) :
|
||||
hilite ? _textcolorhi : _textcolor,
|
||||
_bmw, _bmh);
|
||||
}
|
||||
|
@ -755,16 +758,21 @@ void SliderWidget::drawWidget(bool hilite)
|
|||
|
||||
// Draw the label, if any
|
||||
if(_labelWidth > 0)
|
||||
s.drawString(_font, _label, _x, _y + 2, _labelWidth,
|
||||
isEnabled() ? kTextColor : kColor, TextAlign::Left);
|
||||
s.drawString(_font, _label, _x, _y + 2, _labelWidth, isEnabled() ? kTextColor : kColor);
|
||||
|
||||
int p = valueToPos(_value),
|
||||
h = _h - 10,
|
||||
x = _x + _labelWidth,
|
||||
y = _y + (_h - h) / 2 + 1;
|
||||
|
||||
// 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);
|
||||
s.fillRect(x, y, _w - _labelWidth, h,
|
||||
!isEnabled() ? kBGColorHi : kBGColorLo);
|
||||
// Draw the 'bar'
|
||||
s.fillRect(_x + _labelWidth + 2, _y + 2, valueToPos(_value), _h - 4,
|
||||
s.fillRect(x, y, p, h,
|
||||
!isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor);
|
||||
// Draw the 'handle'
|
||||
s.fillRect(x + p, y - 2, 2, h + 4,
|
||||
!isEnabled() ? kColor : hilite ? kSliderColorHi : kSliderColor);
|
||||
}
|
||||
|
||||
|
@ -775,7 +783,7 @@ int SliderWidget::valueToPos(int value)
|
|||
else if(value > _valueMax) value = _valueMax;
|
||||
int range = std::max(_valueMax - _valueMin, 1); // don't divide by zero
|
||||
|
||||
return ((_w - _labelWidth - 4) * (value - _valueMin) / range);
|
||||
return ((_w - _labelWidth - 2) * (value - _valueMin) / range);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
Loading…
Reference in New Issue