GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing raw.githubusercontent.com — raw.githubusercontent.com #include "QelStyleHelper.h"
namespace qel {
QelVisualState QelStyleHelper::resolveState(const QelStateContext &ctx)
{
if (!ctx.enabled) {
return QelVisualState::Disabled;
}
if (ctx.loading) {
return QelVisualState::Loading;
}
if (ctx.pressed) {
return QelVisualState::Active;
}
if (ctx.hovered) {
return QelVisualState::Hover;
}
if (ctx.focused) {
return QelVisualState::Focus;
}
return QelVisualState::Normal;
}
QelStyleHelper::ComponentStyle QelStyleHelper::styleForState(
const StateStyleSet &styles,
QelVisualState state)
{
switch (state) {
case QelVisualState::Hover:
return styles.hover;
case QelVisualState::Active:
return styles.active;
case QelVisualState::Focus:
return styles.focus;
case QelVisualState::Disabled:
return styles.disabled;
case QelVisualState::Loading:
return styles.loading;
case QelVisualState::Normal:
default:
return styles.normal;
}
}
QelStyleHelper::ComponentStyle QelStyleHelper::buttonStyle(
QelTheme::ButtonKind kind,
bool isPlain,
QelVisualState state)
{
const QelTheme::ButtonColors colors = QelTheme::buttonColors(kind, isPlain);
switch (state) {
case QelVisualState::Disabled:
case QelVisualState::Loading:
return {colors.disabled.background, colors.disabled.text, colors.disabled.border};
case QelVisualState::Active:
case QelVisualState::Hover:
case QelVisualState::Focus:
return {colors.hover.background, colors.hover.text, colors.hover.border};
case QelVisualState::Normal:
default:
return {colors.normal.background, colors.normal.text, colors.normal.border};
}
}
QelStyleHelper::StateStyleSet QelStyleHelper::buttonStateStyles(
QelTheme::ButtonKind kind,
bool isPlain)
{
return {
buttonStyle(kind, isPlain, QelVisualState::Normal),
buttonStyle(kind, isPlain, QelVisualState::Hover),
buttonStyle(kind, isPlain, QelVisualState::Active),
buttonStyle(kind, isPlain, QelVisualState::Focus),
buttonStyle(kind, isPlain, QelVisualState::Disabled),
buttonStyle(kind, isPlain, QelVisualState::Loading)
};
}
QString QelStyleHelper::composeStateStyleSheet(
const QString &baseSelector,
const QString &loadingSelector,
const StateStyleSet &styles,
bool disableFocusOutline)
{
QString style;
style += QString("%1 { background-color: %2; color: %3; border: 1px solid %4; }")
.arg(baseSelector)
.arg(styles.normal.background)
.arg(styles.normal.text)
.arg(styles.normal.border);
style += QString("%1:hover { background-color: %2; color: %3; border: 1px solid %4; }")
.arg(baseSelector)
.arg(styles.hover.background)
.arg(styles.hover.text)
.arg(styles.hover.border);
style += QString("%1:pressed { background-color: %2; color: %3; border: 1px solid %4; }")
.arg(baseSelector)
.arg(styles.active.background)
.arg(styles.active.text)
.arg(styles.active.border);
style += QString("%1:focus { background-color: %2; color: %3; border: 1px solid %4;%5 }")
.arg(baseSelector)
.arg(styles.focus.background)
.arg(styles.focus.text)
.arg(styles.focus.border)
.arg(disableFocusOutline ? " outline: none;" : "");
style += QString("%1:disabled { background-color: %2; color: %3; border: 1px solid %4; }")
.arg(baseSelector)
.arg(styles.disabled.background)
.arg(styles.disabled.text)
.arg(styles.disabled.border);
if (!loadingSelector.isEmpty()) {
style += QString("%1 { background-color: %2; color: %3; border: 1px solid %4; }")
.arg(loadingSelector)
.arg(styles.loading.background)
.arg(styles.loading.text)
.arg(styles.loading.border);
}
return style;
}
QString QelStyleHelper::buttonStateStyleSheet(QelTheme::ButtonKind kind, bool isPlain)
{
const StateStyleSet styles = buttonStateStyles(kind, isPlain);
return composeStateStyleSheet(
"QPushButton",
"QPushButton[qel-loading=\"true\"]",
styles,
true);
}
} // namespace qel
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |