replaced clearArea with the more general fillArea; added get/setValue methods to SliderWidget; changed look of SliderWidget a little bit; optimized drawing of SliderWidget
svn-id: r4500
This commit is contained in:
parent
5fa2ab9e00
commit
0a9baabbdc
6 changed files with 33 additions and 11 deletions
|
@ -29,7 +29,7 @@ void Dialog::draw()
|
||||||
{
|
{
|
||||||
Widget *w = _firstWidget;
|
Widget *w = _firstWidget;
|
||||||
|
|
||||||
_gui->clearArea(_x, _y, _w, _h);
|
_gui->fillArea(_x, _y, _w, _h, _gui->_bgcolor);
|
||||||
_gui->box(_x, _y, _w, _h);
|
_gui->box(_x, _y, _w, _h);
|
||||||
_gui->setAreaDirty(_x, _y, _w, _h);
|
_gui->setAreaDirty(_x, _y, _w, _h);
|
||||||
|
|
||||||
|
|
12
gui/dialog.h
12
gui/dialog.h
|
@ -43,6 +43,7 @@ protected:
|
||||||
int16 _x, _y;
|
int16 _x, _y;
|
||||||
uint16 _w, _h;
|
uint16 _w, _h;
|
||||||
Widget *_mouseWidget;
|
Widget *_mouseWidget;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Dialog(NewGui *gui, int x, int y, int w, int h)
|
Dialog(NewGui *gui, int x, int y, int w, int h)
|
||||||
: _gui(gui), _firstWidget(0), _x(x), _y(y), _w(w), _h(h), _mouseWidget(0)
|
: _gui(gui), _firstWidget(0), _x(x), _y(y), _w(w), _h(h), _mouseWidget(0)
|
||||||
|
@ -66,6 +67,7 @@ protected:
|
||||||
void addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey);
|
void addButton(int x, int y, int w, int h, const char *label, uint32 cmd, char hotkey);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class SaveLoadDialog : public Dialog {
|
class SaveLoadDialog : public Dialog {
|
||||||
public:
|
public:
|
||||||
SaveLoadDialog(NewGui *gui);
|
SaveLoadDialog(NewGui *gui);
|
||||||
|
@ -73,7 +75,17 @@ public:
|
||||||
virtual void handleCommand(uint32 cmd);
|
virtual void handleCommand(uint32 cmd);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SoundDialog;
|
||||||
|
class KeysDialog;
|
||||||
|
class MiscDialog;
|
||||||
|
|
||||||
class OptionsDialog : public Dialog {
|
class OptionsDialog : public Dialog {
|
||||||
|
protected:
|
||||||
|
SoundDialog *_soundDialog;
|
||||||
|
KeysDialog *_keysDialog;
|
||||||
|
MiscDialog *_miscDialog;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OptionsDialog(NewGui *gui);
|
OptionsDialog(NewGui *gui);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ void Widget::draw()
|
||||||
|
|
||||||
// Clear background
|
// Clear background
|
||||||
if (_flags & WIDGET_CLEARBG)
|
if (_flags & WIDGET_CLEARBG)
|
||||||
gui->clearArea(_x, _y, _w, _h);
|
gui->fillArea(_x, _y, _w, _h, gui->_bgcolor);
|
||||||
|
|
||||||
// Draw border
|
// Draw border
|
||||||
if (_flags & WIDGET_BORDER) {
|
if (_flags & WIDGET_BORDER) {
|
||||||
|
@ -148,15 +148,16 @@ void CheckboxWidget::drawWidget(bool hilite)
|
||||||
if (_state)
|
if (_state)
|
||||||
gui->drawBitmap(checked_img, _x + 3, _y + 3, gui->_textcolor);
|
gui->drawBitmap(checked_img, _x + 3, _y + 3, gui->_textcolor);
|
||||||
else
|
else
|
||||||
gui->clearArea(_x + 3, _y + 3, 8, 8);
|
gui->fillArea(_x + 3, _y + 3, 8, 8, gui->_bgcolor);
|
||||||
|
|
||||||
// Finally draw the label
|
// Finally draw the label
|
||||||
gui->drawString(_text, _x + 20, _y + 3, _w, gui->_textcolor);
|
gui->drawString(_text, _x + 20, _y + 3, _w, gui->_textcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
||||||
SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
|
SliderWidget::SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd, uint8 hotkey)
|
||||||
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey)
|
: ButtonWidget(boss, x, y, w, h, label, cmd, hotkey), _value(0), _old_value(1)
|
||||||
{
|
{
|
||||||
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE;
|
_flags = WIDGET_ENABLED | WIDGET_TRACK_MOUSE;
|
||||||
_type = kSliderWidget;
|
_type = kSliderWidget;
|
||||||
|
@ -168,9 +169,15 @@ void SliderWidget::drawWidget(bool hilite)
|
||||||
|
|
||||||
// Draw the box
|
// Draw the box
|
||||||
gui->box(_x, _y, _w, _h);
|
gui->box(_x, _y, _w, _h);
|
||||||
|
|
||||||
|
// Remove old 'bar' if necessary
|
||||||
|
if (_value != _old_value) {
|
||||||
|
gui->fillArea(_x + 2 + ((_w - 5) * _old_value / 100), _y + 2, 2, _h - 4, gui->_bgcolor);
|
||||||
|
_old_value = _value;
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the 'bar'
|
// Draw the 'bar'
|
||||||
gui->line(_x + 2 + ((_w - 5)* _value / 100), _y + 2, _x + 2 + ((_w - 5)* _value / 100), _y + _h - 3, hilite ? gui->_textcolorhi : gui->_textcolor);
|
gui->fillArea(_x + 2 + ((_w - 5) * _value / 100), _y + 2, 2, _h - 4, hilite ? gui->_textcolorhi : gui->_textcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliderWidget::handleMouseMoved(int x, int y, int state) {
|
void SliderWidget::handleMouseMoved(int x, int y, int state) {
|
||||||
|
@ -179,7 +186,7 @@ void SliderWidget::handleMouseMoved(int x, int y, int state) {
|
||||||
|
|
||||||
if (newvalue != _value) {
|
if (newvalue != _value) {
|
||||||
_value = newvalue;
|
_value = newvalue;
|
||||||
setFlags(WIDGET_CLEARBG); draw(); clearFlags(WIDGET_CLEARBG);
|
draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,9 +122,12 @@ protected:
|
||||||
/* SliderWidget */
|
/* SliderWidget */
|
||||||
class SliderWidget : public ButtonWidget {
|
class SliderWidget : public ButtonWidget {
|
||||||
protected:
|
protected:
|
||||||
int _value;
|
uint8 _value, _old_value;
|
||||||
public:
|
public:
|
||||||
SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd = 0, uint8 hotkey = 0);
|
SliderWidget(Dialog *boss, int x, int y, int w, int h, const char *label, uint32 cmd = 0, uint8 hotkey = 0);
|
||||||
|
void setValue(uint8 value) { _value = value; }
|
||||||
|
uint8 getValue() { return _value; }
|
||||||
|
|
||||||
void handleMouseMoved(int x, int y, int button);
|
void handleMouseMoved(int x, int y, int button);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -242,7 +242,7 @@ void NewGui::line(int x, int y, int x2, int y2, byte color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewGui::clearArea(int x, int y, int w, int h)
|
void NewGui::fillArea(int x, int y, int w, int h, byte color)
|
||||||
{
|
{
|
||||||
byte *ptr = getBasePtr(x, y);
|
byte *ptr = getBasePtr(x, y);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
|
@ -250,7 +250,7 @@ void NewGui::clearArea(int x, int y, int w, int h)
|
||||||
|
|
||||||
while (h--) {
|
while (h--) {
|
||||||
for (int i = 0; i < w; i++)
|
for (int i = 0; i < w; i++)
|
||||||
ptr[i] = _bgcolor;
|
ptr[i] = color;
|
||||||
ptr += 320;
|
ptr += 320;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
newgui.h
2
newgui.h
|
@ -95,7 +95,7 @@ public:
|
||||||
byte *getBasePtr(int x, int y);
|
byte *getBasePtr(int x, int y);
|
||||||
void box(int x, int y, int width, int height);
|
void box(int x, int y, int width, int height);
|
||||||
void line(int x, int y, int x2, int y2, byte color);
|
void line(int x, int y, int x2, int y2, byte color);
|
||||||
void clearArea(int x, int y, int w, int h);
|
void fillArea(int x, int y, int w, int h, byte color);
|
||||||
void setAreaDirty(int x, int y, int w, int h);
|
void setAreaDirty(int x, int y, int w, int h);
|
||||||
void drawChar(const char c, int x, int y);
|
void drawChar(const char c, int x, int y);
|
||||||
void drawString(const char *str, int x, int y, int w, byte color);
|
void drawString(const char *str, int x, int y, int w, byte color);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue