Fix bug with save/load progress bar: cannot be edited now

The ui::Alert slider to show progress is read-only now.
This commit is contained in:
David Capello 2015-08-12 16:10:20 -03:00
parent a24864b2c8
commit 77d8024026
3 changed files with 14 additions and 10 deletions

View File

@ -60,6 +60,7 @@ void Alert::addProgress()
{
ASSERT(!m_progress);
m_progress = new Slider(0, 100, 0);
m_progress->setReadOnly(true);
m_progressPlaceholder->addChild(m_progress);
m_progressPlaceholder->setVisible(true);
}

View File

@ -28,11 +28,11 @@ static bool slider_press_left;
Slider::Slider(int min, int max, int value)
: Widget(kSliderWidget)
, m_min(min)
, m_max(max)
, m_value(MID(min, value, max))
, m_readOnly(false)
{
m_min = min;
m_max = max;
m_value = MID(min, value, max);
this->setFocusStop(true);
initTheme();
}
@ -76,7 +76,7 @@ bool Slider::onProcessMessage(Message* msg)
break;
case kMouseDownMessage:
if (!isEnabled())
if (!isEnabled() || isReadOnly())
return true;
setSelected(true);
@ -142,7 +142,7 @@ bool Slider::onProcessMessage(Message* msg)
break;
case kKeyDownMessage:
if (hasFocus()) {
if (hasFocus() && !isReadOnly()) {
int min = m_min;
int max = m_max;
int value = m_value;
@ -168,7 +168,7 @@ bool Slider::onProcessMessage(Message* msg)
break;
case kMouseWheelMessage:
if (isEnabled()) {
if (isEnabled() && !isReadOnly()) {
int value = m_value
+ static_cast<MouseMessage*>(msg)->wheelDelta().x
- static_cast<MouseMessage*>(msg)->wheelDelta().y;

View File

@ -1,5 +1,5 @@
// Aseprite UI Library
// Copyright (C) 2001-2013 David Capello
// Copyright (C) 2001-2013, 2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -13,8 +13,7 @@
namespace ui {
class Slider : public Widget
{
class Slider : public Widget {
public:
Slider(int min, int max, int value);
@ -25,6 +24,9 @@ namespace ui {
void setRange(int min, int max);
void setValue(int value);
bool isReadOnly() const { return m_readOnly; }
void setReadOnly(bool readOnly) { m_readOnly = readOnly; }
void getSliderThemeInfo(int* min, int* max, int* value);
// Signals
@ -47,6 +49,7 @@ namespace ui {
int m_min;
int m_max;
int m_value;
bool m_readOnly;
};
} // namespace ui