Some refactoring of Settings classes.
- Rename the current RangeSetting -> BoundedSetting and add an appropriate setting type enum, since that one actually describes a single value clamped to a range, rather than an actual range. - Add RangeSetting class that has both a lower/upper bound and a pair of values representing the lower and upper ends of the range currently selected.
This commit is contained in:
parent
758a63dc70
commit
d519acd691
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
@ -78,6 +79,16 @@ OptionsSetting::DefaultValue() const
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BoundedSetting
|
||||
|
||||
|
||||
setting_type
|
||||
BoundedSetting::Type() const
|
||||
{
|
||||
return SETTING_TYPE_BOUNDED;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - RangeSetting
|
||||
|
||||
|
||||
@ -284,7 +295,7 @@ OptionsSettingImpl::SetDefaultOption(SettingsOption* option)
|
||||
// #pragma mark - RangeSettingImpl
|
||||
|
||||
|
||||
RangeSettingImpl::RangeSettingImpl(const BString& id, const BString& name,
|
||||
BoundedSettingImpl::BoundedSettingImpl(const BString& id, const BString& name,
|
||||
const BVariant& lowerBound, const BVariant& upperBound,
|
||||
const BVariant& defaultValue)
|
||||
:
|
||||
@ -297,12 +308,52 @@ RangeSettingImpl::RangeSettingImpl(const BString& id, const BString& name,
|
||||
|
||||
|
||||
BVariant
|
||||
RangeSettingImpl::DefaultValue() const
|
||||
BoundedSettingImpl::DefaultValue() const
|
||||
{
|
||||
return fDefaultValue;
|
||||
}
|
||||
|
||||
|
||||
BVariant
|
||||
BoundedSettingImpl::LowerBound() const
|
||||
{
|
||||
return fLowerBound;
|
||||
}
|
||||
|
||||
|
||||
BVariant
|
||||
BoundedSettingImpl::UpperBound() const
|
||||
{
|
||||
return fUpperBound;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - RangeSettingImpl
|
||||
|
||||
|
||||
RangeSettingImpl::RangeSettingImpl(const BString& id, const BString& name,
|
||||
const BVariant& lowerBound, const BVariant& upperBound,
|
||||
const BVariant& lowerValue, const BVariant& upperValue)
|
||||
:
|
||||
AbstractSetting(id, name),
|
||||
fLowerBound(lowerBound),
|
||||
fUpperBound(upperBound),
|
||||
fLowerValue(lowerValue),
|
||||
fUpperValue(upperValue)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BVariant
|
||||
RangeSettingImpl::DefaultValue() const
|
||||
{
|
||||
// this one doesn't really make sense for RangeSetting since it
|
||||
// describes a pair of values, which BVariant can't readily
|
||||
// represent.
|
||||
return BVariant();
|
||||
}
|
||||
|
||||
|
||||
BVariant
|
||||
RangeSettingImpl::LowerBound() const
|
||||
{
|
||||
@ -317,6 +368,20 @@ RangeSettingImpl::UpperBound() const
|
||||
}
|
||||
|
||||
|
||||
BVariant
|
||||
RangeSettingImpl::LowerValue() const
|
||||
{
|
||||
return fLowerValue;
|
||||
}
|
||||
|
||||
|
||||
BVariant
|
||||
RangeSettingImpl::UpperValue() const
|
||||
{
|
||||
return fUpperValue;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - RectSettingImpl
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2011, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2011-2013, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef SETTING_H
|
||||
@ -18,6 +18,7 @@ enum setting_type {
|
||||
SETTING_TYPE_BOOL,
|
||||
SETTING_TYPE_FLOAT,
|
||||
SETTING_TYPE_OPTIONS,
|
||||
SETTING_TYPE_BOUNDED,
|
||||
SETTING_TYPE_RANGE,
|
||||
SETTING_TYPE_RECT
|
||||
};
|
||||
@ -78,7 +79,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class RangeSetting : public virtual Setting {
|
||||
class BoundedSetting : public virtual Setting {
|
||||
public:
|
||||
virtual setting_type Type() const;
|
||||
|
||||
@ -87,6 +88,14 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class RangeSetting : public virtual BoundedSetting {
|
||||
virtual setting_type Type() const;
|
||||
|
||||
virtual BVariant LowerValue() const = 0;
|
||||
virtual BVariant UpperValue() const = 0;
|
||||
};
|
||||
|
||||
|
||||
class RectSetting : public virtual Setting {
|
||||
public:
|
||||
virtual setting_type Type() const;
|
||||
@ -164,9 +173,9 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class RangeSettingImpl : public AbstractSetting, public RangeSetting {
|
||||
class BoundedSettingImpl : public AbstractSetting, public BoundedSetting {
|
||||
public:
|
||||
RangeSettingImpl(const BString& id,
|
||||
BoundedSettingImpl(const BString& id,
|
||||
const BString& name,
|
||||
const BVariant& lowerBound,
|
||||
const BVariant& upperBound,
|
||||
@ -184,6 +193,30 @@ private:
|
||||
};
|
||||
|
||||
|
||||
class RangeSettingImpl : public AbstractSetting, public RangeSetting {
|
||||
public:
|
||||
RangeSettingImpl(const BString& id,
|
||||
const BString& name,
|
||||
const BVariant& lowerBound,
|
||||
const BVariant& upperBound,
|
||||
const BVariant& lowerValue,
|
||||
const BVariant& upperValue);
|
||||
|
||||
virtual BVariant DefaultValue() const;
|
||||
|
||||
virtual BVariant LowerBound() const;
|
||||
virtual BVariant UpperBound() const;
|
||||
virtual BVariant LowerValue() const;
|
||||
virtual BVariant UpperValue() const;
|
||||
|
||||
private:
|
||||
BVariant fLowerBound;
|
||||
BVariant fUpperBound;
|
||||
BVariant fLowerValue;
|
||||
BVariant fUpperValue;
|
||||
};
|
||||
|
||||
|
||||
class RectSettingImpl : public AbstractSetting, public RectSetting {
|
||||
public:
|
||||
RectSettingImpl(const BString& id,
|
||||
|
Loading…
Reference in New Issue
Block a user