mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-10 10:13:35 +00:00
Move painting code for checkbox & radio button to theme styles
This commit is contained in:
parent
b5e7ed2836
commit
bc01f16a4e
@ -445,6 +445,7 @@
|
|||||||
<text color="text" align="left" />
|
<text color="text" align="left" />
|
||||||
<text color="disabled" align="left" state="disabled" />
|
<text color="disabled" align="left" state="disabled" />
|
||||||
</style>
|
</style>
|
||||||
|
<style id="mini_label" extends="label" font="mini" />
|
||||||
<style id="link">
|
<style id="link">
|
||||||
<text color="link_text" align="left" />
|
<text color="link_text" align="left" />
|
||||||
<text color="link_hover" align="left" state="mouse" />
|
<text color="link_hover" align="left" state="mouse" />
|
||||||
@ -457,14 +458,14 @@
|
|||||||
<text color="workspace_link" align="left" />
|
<text color="workspace_link" align="left" />
|
||||||
<text color="workspace_link_hover" align="left" state="mouse" />
|
<text color="workspace_link_hover" align="left" state="mouse" />
|
||||||
</style>
|
</style>
|
||||||
<style id="workspace_update_link" padding-right="16">
|
<style id="workspace_update_link">
|
||||||
<background part="button_normal" />
|
<background-border part="button_normal" />
|
||||||
<background part="button_hot" state="mouse" />
|
<background-border part="button_hot" state="mouse" />
|
||||||
<background part="button_selected" state="selected" />
|
<background-border part="button_selected" state="selected" />
|
||||||
<icon part="warning_box" align="right" />
|
<icon part="warning_box" align="right" />
|
||||||
<text color="button_normal_text" />
|
<text color="button_normal_text" align="left" />
|
||||||
<text color="button_hot_text" state="mouse" />
|
<text color="button_hot_text" align="left" state="mouse" />
|
||||||
<text color="button_selected_text" state="selected" />
|
<text color="button_selected_text" align="left" state="selected" />
|
||||||
</style>
|
</style>
|
||||||
<style id="view" border="3" border-top="4">
|
<style id="view" border="3" border-top="4">
|
||||||
<background color="window_face" />
|
<background color="window_face" />
|
||||||
@ -485,39 +486,63 @@
|
|||||||
<border part="editor_selected" state="focus" />
|
<border part="editor_selected" state="focus" />
|
||||||
</style>
|
</style>
|
||||||
<style id="button">
|
<style id="button">
|
||||||
<background part="button_normal" />
|
<background-border part="button_normal" />
|
||||||
<background part="button_hot" state="mouse" />
|
<background-border part="button_hot" state="mouse" />
|
||||||
<background part="button_focused" state="focus" />
|
<background-border part="button_focused" state="focus" />
|
||||||
<background part="button_selected" state="selected" />
|
<background-border part="button_selected" state="selected" />
|
||||||
<text color="button_normal_text" />
|
<text color="button_normal_text" />
|
||||||
<text color="button_hot_text" state="mouse" />
|
<text color="button_hot_text" state="mouse" />
|
||||||
<text color="button_selected_text" state="selected" />
|
<text color="button_selected_text" state="selected" />
|
||||||
|
<text color="background" x="1" y="1" state="disabled" />
|
||||||
|
<newlayer />
|
||||||
|
<text color="disabled" state="disabled" />
|
||||||
|
</style>
|
||||||
|
<style id="check_box" border="2">
|
||||||
|
<background part="check_focus" color="check_hot_face" state="mouse focus" />
|
||||||
|
<background part="check_focus" color="check_focus_face" state="focus" />
|
||||||
|
<background color="check_hot_face" state="mouse" />
|
||||||
|
<text color="text" align="left middle" x="14" />
|
||||||
|
<text color="disabled" align="left middle" x="14" state="disabled" />
|
||||||
|
<icon part="check_normal" align="left middle" x="2" />
|
||||||
|
<icon part="check_selected" align="left middle" x="2" state="selected" />
|
||||||
|
<icon part="check_disabled" align="left middle" x="2" state="disabled" />
|
||||||
|
</style>
|
||||||
|
<style id="radio_button" border="2">
|
||||||
|
<background part="radio_focus" color="radio_hot_face" state="mouse focus" />
|
||||||
|
<background part="radio_focus" color="radio_focus_face" state="focus" />
|
||||||
|
<background color="radio_hot_face" state="mouse" />
|
||||||
|
<text color="text" align="left middle" x="14" />
|
||||||
|
<text color="disabled" align="left middle" x="14" state="disabled" />
|
||||||
|
<icon part="radio_normal" align="left middle" x="2" />
|
||||||
|
<icon part="radio_selected" align="left middle" x="2" state="selected" />
|
||||||
|
<icon part="radio_disabled" align="left middle" x="2" state="disabled" />
|
||||||
</style>
|
</style>
|
||||||
<style id="mini_button">
|
<style id="mini_button">
|
||||||
<background part="toolbutton_last" />
|
<background-border part="toolbutton_last" />
|
||||||
<background part="toolbutton_hot" state="mouse" />
|
<background-border part="toolbutton_hot" state="mouse" />
|
||||||
<background part="toolbutton_hot" state="focus" />
|
<background-border part="toolbutton_hot" state="focus" />
|
||||||
<background part="toolbutton_pushed" state="selected" />
|
<background-border part="toolbutton_pushed" state="selected" />
|
||||||
<text color="button_normal_text" />
|
<text color="button_normal_text" />
|
||||||
<text color="button_hot_text" state="mouse" />
|
<text color="button_hot_text" state="mouse" />
|
||||||
<text color="button_selected_text" state="selected" />
|
<text color="button_selected_text" state="selected" />
|
||||||
</style>
|
</style>
|
||||||
|
<style id="mini_check_box" extends="check_box" font="mini" />
|
||||||
<style id="combobox_button" extends="mini_button">
|
<style id="combobox_button" extends="mini_button">
|
||||||
<icon part="combobox_arrow_down" />
|
<icon part="combobox_arrow_down" />
|
||||||
<icon part="combobox_arrow_down_selected" state="selected" />
|
<icon part="combobox_arrow_down_selected" state="selected" />
|
||||||
<icon part="combobox_arrow_down_disabled" state="disabled" />
|
<icon part="combobox_arrow_down_disabled" state="disabled" />
|
||||||
</style>
|
</style>
|
||||||
<style id="drop_down_button" extends="button">
|
<style id="drop_down_button" extends="button">
|
||||||
<background part="drop_down_button_left_normal" />
|
<background-border part="drop_down_button_left_normal" />
|
||||||
<background part="drop_down_button_left_selected" state="selected" />
|
<background-border part="drop_down_button_left_selected" state="selected" />
|
||||||
<background part="drop_down_button_left_hot" state="mouse" />
|
<background-border part="drop_down_button_left_hot" state="mouse" />
|
||||||
<background part="drop_down_button_left_focused" state="focus" />
|
<background-border part="drop_down_button_left_focused" state="focus" />
|
||||||
</style>
|
</style>
|
||||||
<style id="drop_down_expand_button" extends="button">
|
<style id="drop_down_expand_button" extends="button">
|
||||||
<background part="drop_down_button_right_normal" />
|
<background-border part="drop_down_button_right_normal" />
|
||||||
<background part="drop_down_button_right_selected" state="selected" />
|
<background-border part="drop_down_button_right_selected" state="selected" />
|
||||||
<background part="drop_down_button_right_hot" state="mouse" />
|
<background-border part="drop_down_button_right_hot" state="mouse" />
|
||||||
<background part="drop_down_button_right_focused" state="focus" />
|
<background-border part="drop_down_button_right_focused" state="focus" />
|
||||||
<icon part="combobox_arrow_down" />
|
<icon part="combobox_arrow_down" />
|
||||||
<icon part="combobox_arrow_down_selected" state="selected" />
|
<icon part="combobox_arrow_down_selected" state="selected" />
|
||||||
<icon part="combobox_arrow_down_disabled" state="disabled" />
|
<icon part="combobox_arrow_down_disabled" state="disabled" />
|
||||||
@ -557,15 +582,15 @@
|
|||||||
<background color="workspace" />
|
<background color="workspace" />
|
||||||
</style>
|
</style>
|
||||||
<style id="horizontal_separator" border-left="2" border-top="4" border-right="2" border-bottom="0">
|
<style id="horizontal_separator" border-left="2" border-top="4" border-right="2" border-bottom="0">
|
||||||
<background part="separator_horz" color="window_face" align="middle" />
|
<background-border part="separator_horz" color="window_face" align="middle" />
|
||||||
<text color="separator_label" x="4" align="left middle" />
|
<text color="separator_label" x="4" align="left middle" />
|
||||||
</style>
|
</style>
|
||||||
<style id="menu_separator" extends="horizontal_separator" />
|
<style id="menu_separator" extends="horizontal_separator" />
|
||||||
<style id="separator_in_view" extends="horizontal_separator">
|
<style id="separator_in_view" extends="horizontal_separator">
|
||||||
<background part="separator_horz" color="background" align="middle" />
|
<background-border part="separator_horz" color="background" align="middle" />
|
||||||
</style>
|
</style>
|
||||||
<style id="vertical_separator" border-left="4" border-top="2" border-right="1" border-bottom="2">
|
<style id="vertical_separator" border-left="4" border-top="2" border-right="1" border-bottom="2">
|
||||||
<background part="separator_vert" align="center" />
|
<background-border part="separator_vert" align="center" />
|
||||||
</style>
|
</style>
|
||||||
<style id="recent_item" />
|
<style id="recent_item" />
|
||||||
<style id="recent_file" border="2">
|
<style id="recent_file" border="2">
|
||||||
@ -666,11 +691,11 @@
|
|||||||
<background color="timeline_normal" part="timeline_normal" />
|
<background color="timeline_normal" part="timeline_normal" />
|
||||||
</style>
|
</style>
|
||||||
<style id="timeline_box">
|
<style id="timeline_box">
|
||||||
<background color="timeline_normal" part="timeline_normal" />
|
<background-border color="timeline_normal" part="timeline_normal" />
|
||||||
<background color="timeline_hover" part="timeline_hover" state="mouse" />
|
<background-border color="timeline_hover" part="timeline_hover" state="mouse" />
|
||||||
<background color="timeline_active" part="timeline_active" state="focus" />
|
<background-border color="timeline_active" part="timeline_active" state="focus" />
|
||||||
<background color="timeline_active_hover" part="timeline_active_hover" state="focus mouse" />
|
<background-border color="timeline_active_hover" part="timeline_active_hover" state="focus mouse" />
|
||||||
<background color="timeline_clicked" part="timeline_clicked" state="selected" />
|
<background-border color="timeline_clicked" part="timeline_clicked" state="selected" />
|
||||||
</style>
|
</style>
|
||||||
<style id="timeline_open_eye" extends="timeline_box">
|
<style id="timeline_open_eye" extends="timeline_box">
|
||||||
<icon part="timeline_open_eye_normal" />
|
<icon part="timeline_open_eye_normal" />
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#include "app/document.h"
|
#include "app/document.h"
|
||||||
#include "app/ini_file.h"
|
#include "app/ini_file.h"
|
||||||
#include "app/modules/gfx.h"
|
#include "app/modules/gfx.h"
|
||||||
#include "app/modules/gui.h"
|
|
||||||
#include "app/modules/palettes.h"
|
#include "app/modules/palettes.h"
|
||||||
#include "app/pref/preferences.h"
|
#include "app/pref/preferences.h"
|
||||||
#include "app/shade.h"
|
#include "app/shade.h"
|
||||||
@ -309,7 +308,7 @@ class ContextBar::ContiguousField : public CheckBox
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ContiguousField() : CheckBox("Contiguous") {
|
ContiguousField() : CheckBox("Contiguous") {
|
||||||
setup_mini_font(this);
|
setStyle(SkinTheme::instance()->styles.miniCheckBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -1142,7 +1141,7 @@ class ContextBar::FreehandAlgorithmField : public CheckBox
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FreehandAlgorithmField() : CheckBox("Pixel-perfect") {
|
FreehandAlgorithmField() : CheckBox("Pixel-perfect") {
|
||||||
setup_mini_font(this);
|
setStyle(SkinTheme::instance()->styles.miniCheckBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupTooltips(TooltipManager* tooltipManager) {
|
void setupTooltips(TooltipManager* tooltipManager) {
|
||||||
@ -1292,7 +1291,7 @@ class ContextBar::AutoSelectLayerField : public CheckBox
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AutoSelectLayerField() : CheckBox("Auto Select Layer") {
|
AutoSelectLayerField() : CheckBox("Auto Select Layer") {
|
||||||
setup_mini_font(this);
|
setStyle(SkinTheme::instance()->styles.miniCheckBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -1397,17 +1396,17 @@ ContextBar::ContextBar()
|
|||||||
|
|
||||||
addChild(m_selectBoxHelp = new Label(""));
|
addChild(m_selectBoxHelp = new Label(""));
|
||||||
|
|
||||||
setup_mini_font(m_sprayLabel);
|
m_sprayLabel->setStyle(theme->styles.miniLabel());
|
||||||
|
|
||||||
addChild(m_freehandBox = new HBox());
|
addChild(m_freehandBox = new HBox());
|
||||||
#if 0 // TODO for v1.1
|
#if 0 // TODO for v1.1
|
||||||
m_freehandBox->addChild(m_freehandLabel = new Label("Freehand:"));
|
m_freehandBox->addChild(m_freehandLabel = new Label("Freehand:"));
|
||||||
setup_mini_font(m_freehandLabel);
|
m_freehandLabel->setStyle(theme->styles.miniLabel());
|
||||||
#endif
|
#endif
|
||||||
m_freehandBox->addChild(m_freehandAlgo = new FreehandAlgorithmField());
|
m_freehandBox->addChild(m_freehandAlgo = new FreehandAlgorithmField());
|
||||||
|
|
||||||
setup_mini_font(m_toleranceLabel);
|
m_toleranceLabel->setStyle(theme->styles.miniLabel());
|
||||||
setup_mini_font(m_inkOpacityLabel);
|
m_inkOpacityLabel->setStyle(theme->styles.miniLabel());
|
||||||
|
|
||||||
addChild(m_symmetry = new SymmetryField());
|
addChild(m_symmetry = new SymmetryField());
|
||||||
m_symmetry->setVisible(Preferences::instance().symmetryMode.enabled());
|
m_symmetry->setVisible(Preferences::instance().symmetryMode.enabled());
|
||||||
|
@ -546,6 +546,9 @@ void SkinTheme::loadXml(const std::string& skinId)
|
|||||||
if (layerName == "background") {
|
if (layerName == "background") {
|
||||||
layer.setType(ui::Style::Layer::Type::kBackground);
|
layer.setType(ui::Style::Layer::Type::kBackground);
|
||||||
}
|
}
|
||||||
|
else if (layerName == "background-border") {
|
||||||
|
layer.setType(ui::Style::Layer::Type::kBackgroundBorder);
|
||||||
|
}
|
||||||
else if (layerName == "border") {
|
else if (layerName == "border") {
|
||||||
layer.setType(ui::Style::Layer::Type::kBorder);
|
layer.setType(ui::Style::Layer::Type::kBorder);
|
||||||
}
|
}
|
||||||
@ -718,14 +721,11 @@ void SkinTheme::initWidget(Widget* widget)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kCheckWidget:
|
case kCheckWidget:
|
||||||
BORDER(2 * scale);
|
widget->setStyle(styles.checkBox());
|
||||||
widget->setChildSpacing(4 * scale);
|
break;
|
||||||
|
|
||||||
static_cast<ButtonBase*>(widget)->setIconInterface
|
case kRadioWidget:
|
||||||
(new ButtonIconImpl(parts.checkNormal(),
|
widget->setStyle(styles.radioButton());
|
||||||
parts.checkSelected(),
|
|
||||||
parts.checkDisabled(),
|
|
||||||
LEFT | MIDDLE));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kEntryWidget:
|
case kEntryWidget:
|
||||||
@ -789,17 +789,6 @@ void SkinTheme::initWidget(Widget* widget)
|
|||||||
widget->setStyle(styles.splitter());
|
widget->setStyle(styles.splitter());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kRadioWidget:
|
|
||||||
BORDER(2 * scale);
|
|
||||||
widget->setChildSpacing(4 * scale);
|
|
||||||
|
|
||||||
static_cast<ButtonBase*>(widget)->setIconInterface
|
|
||||||
(new ButtonIconImpl(parts.radioNormal(),
|
|
||||||
parts.radioSelected(),
|
|
||||||
parts.radioDisabled(),
|
|
||||||
LEFT | MIDDLE));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case kSeparatorWidget:
|
case kSeparatorWidget:
|
||||||
// Horizontal bar
|
// Horizontal bar
|
||||||
if (widget->align() & HORIZONTAL) {
|
if (widget->align() & HORIZONTAL) {
|
||||||
@ -906,54 +895,6 @@ gfx::Size SkinTheme::getEntryCaretSize(Widget* widget)
|
|||||||
return gfx::Size(2*guiscale(), widget->textHeight()+2*guiscale());
|
return gfx::Size(2*guiscale(), widget->textHeight()+2*guiscale());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinTheme::paintCheckBox(PaintEvent& ev)
|
|
||||||
{
|
|
||||||
Graphics* g = ev.graphics();
|
|
||||||
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
|
||||||
gfx::Rect bounds = widget->clientBounds();
|
|
||||||
IButtonIcon* iconInterface = widget->iconInterface();
|
|
||||||
gfx::Rect box, text, icon;
|
|
||||||
gfx::Color bg;
|
|
||||||
|
|
||||||
widget->getTextIconInfo(&box, &text, &icon,
|
|
||||||
iconInterface ? iconInterface->iconAlign(): 0,
|
|
||||||
iconInterface ? iconInterface->size().w: 0,
|
|
||||||
iconInterface ? iconInterface->size().h: 0);
|
|
||||||
|
|
||||||
// Check box look
|
|
||||||
LookType look = NormalLook;
|
|
||||||
SkinPropertyPtr skinPropery = widget->getProperty(SkinProperty::Name);
|
|
||||||
if (skinPropery)
|
|
||||||
look = skinPropery->getLook();
|
|
||||||
|
|
||||||
// Background
|
|
||||||
g->fillRect(bg = BGCOLOR, bounds);
|
|
||||||
|
|
||||||
// Mouse
|
|
||||||
if (widget->isEnabled()) {
|
|
||||||
if (widget->hasMouseOver())
|
|
||||||
g->fillRect(bg = colors.checkHotFace(), bounds);
|
|
||||||
else if (widget->hasFocus())
|
|
||||||
g->fillRect(bg = colors.checkFocusFace(), bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Text
|
|
||||||
drawText(g, nullptr, ColorNone, ColorNone, widget, text, 0,
|
|
||||||
widget->mnemonic());
|
|
||||||
|
|
||||||
// Paint the icon
|
|
||||||
if (iconInterface)
|
|
||||||
paintIcon(widget, g, iconInterface, icon.x, icon.y);
|
|
||||||
|
|
||||||
// Draw focus
|
|
||||||
if (look != WithoutBordersLook &&
|
|
||||||
(widget->hasFocus() || (iconInterface &&
|
|
||||||
widget->text().empty() &&
|
|
||||||
widget->hasMouseOver()))) {
|
|
||||||
drawRect(g, bounds, parts.checkFocus().get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkinTheme::paintEntry(PaintEvent& ev)
|
void SkinTheme::paintEntry(PaintEvent& ev)
|
||||||
{
|
{
|
||||||
Graphics* g = ev.graphics();
|
Graphics* g = ev.graphics();
|
||||||
@ -1271,43 +1212,6 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkinTheme::paintRadioButton(PaintEvent& ev)
|
|
||||||
{
|
|
||||||
Graphics* g = ev.graphics();
|
|
||||||
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
|
||||||
gfx::Rect bounds = widget->clientBounds();
|
|
||||||
IButtonIcon* iconInterface = widget->iconInterface();
|
|
||||||
gfx::Color bg = BGCOLOR;
|
|
||||||
|
|
||||||
gfx::Rect box, text, icon;
|
|
||||||
widget->getTextIconInfo(&box, &text, &icon,
|
|
||||||
iconInterface ? iconInterface->iconAlign(): 0,
|
|
||||||
iconInterface ? iconInterface->size().w: 0,
|
|
||||||
iconInterface ? iconInterface->size().h: 0);
|
|
||||||
|
|
||||||
// Background
|
|
||||||
g->fillRect(bg, g->getClipBounds());
|
|
||||||
|
|
||||||
// Mouse
|
|
||||||
if (widget->isEnabled()) {
|
|
||||||
if (widget->hasMouseOver())
|
|
||||||
g->fillRect(bg = colors.radioHotFace(), bounds);
|
|
||||||
else if (widget->hasFocus())
|
|
||||||
g->fillRect(bg = colors.radioFocusFace(), bounds);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Text
|
|
||||||
drawText(g, nullptr, ColorNone, ColorNone, widget, text, 0, widget->mnemonic());
|
|
||||||
|
|
||||||
// Icon
|
|
||||||
if (iconInterface)
|
|
||||||
paintIcon(widget, g, iconInterface, icon.x, icon.y);
|
|
||||||
|
|
||||||
// Focus
|
|
||||||
if (widget->hasFocus())
|
|
||||||
drawRect(g, bounds, parts.radioFocus().get());
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkinTheme::paintSlider(PaintEvent& ev)
|
void SkinTheme::paintSlider(PaintEvent& ev)
|
||||||
{
|
{
|
||||||
Graphics* g = ev.graphics();
|
Graphics* g = ev.graphics();
|
||||||
|
@ -56,13 +56,11 @@ namespace app {
|
|||||||
int getScrollbarSize() override;
|
int getScrollbarSize() override;
|
||||||
gfx::Size getEntryCaretSize(ui::Widget* widget) override;
|
gfx::Size getEntryCaretSize(ui::Widget* widget) override;
|
||||||
|
|
||||||
void paintCheckBox(ui::PaintEvent& ev) override;
|
|
||||||
void paintEntry(ui::PaintEvent& ev) override;
|
void paintEntry(ui::PaintEvent& ev) override;
|
||||||
void paintListBox(ui::PaintEvent& ev) override;
|
void paintListBox(ui::PaintEvent& ev) override;
|
||||||
void paintListItem(ui::PaintEvent& ev) override;
|
void paintListItem(ui::PaintEvent& ev) override;
|
||||||
void paintMenu(ui::PaintEvent& ev) override;
|
void paintMenu(ui::PaintEvent& ev) override;
|
||||||
void paintMenuItem(ui::PaintEvent& ev) override;
|
void paintMenuItem(ui::PaintEvent& ev) override;
|
||||||
void paintRadioButton(ui::PaintEvent& ev) override;
|
|
||||||
void paintSlider(ui::PaintEvent& ev) override;
|
void paintSlider(ui::PaintEvent& ev) override;
|
||||||
void paintComboBoxEntry(ui::PaintEvent& ev) override;
|
void paintComboBoxEntry(ui::PaintEvent& ev) override;
|
||||||
void paintTextBox(ui::PaintEvent& ev) override;
|
void paintTextBox(ui::PaintEvent& ev) override;
|
||||||
|
@ -295,11 +295,7 @@ void ButtonBase::onPaint(PaintEvent& ev)
|
|||||||
if (style())
|
if (style())
|
||||||
return Widget::onPaint(ev);
|
return Widget::onPaint(ev);
|
||||||
|
|
||||||
switch (m_drawType) {
|
ASSERT(false);
|
||||||
case kButtonWidget: ASSERT(false); break;
|
|
||||||
case kCheckWidget: theme()->paintCheckBox(ev); break;
|
|
||||||
case kRadioWidget: theme()->paintRadioButton(ev); break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonBase::generateButtonSelectSignal()
|
void ButtonBase::generateButtonSelectSignal()
|
||||||
|
@ -32,6 +32,7 @@ namespace ui {
|
|||||||
enum class Type {
|
enum class Type {
|
||||||
kNone,
|
kNone,
|
||||||
kBackground,
|
kBackground,
|
||||||
|
kBackgroundBorder,
|
||||||
kBorder,
|
kBorder,
|
||||||
kIcon,
|
kIcon,
|
||||||
kText,
|
kText,
|
||||||
|
@ -295,6 +295,7 @@ void Theme::paintLayer(Graphics* g,
|
|||||||
switch (layer.type()) {
|
switch (layer.type()) {
|
||||||
|
|
||||||
case Style::Layer::Type::kBackground:
|
case Style::Layer::Type::kBackground:
|
||||||
|
case Style::Layer::Type::kBackgroundBorder:
|
||||||
if (layer.color() != gfx::ColorNone) {
|
if (layer.color() != gfx::ColorNone) {
|
||||||
bgColor = layer.color();
|
bgColor = layer.color();
|
||||||
g->fillRect(layer.color(), rc);
|
g->fillRect(layer.color(), rc);
|
||||||
@ -307,10 +308,12 @@ void Theme::paintLayer(Graphics* g,
|
|||||||
layer.spriteBounds(),
|
layer.spriteBounds(),
|
||||||
layer.slicesBounds(), true);
|
layer.slicesBounds(), true);
|
||||||
|
|
||||||
rc.x += layer.slicesBounds().x;
|
if (layer.type() == Style::Layer::Type::kBackgroundBorder) {
|
||||||
rc.y += layer.slicesBounds().y;
|
rc.x += layer.slicesBounds().x;
|
||||||
rc.w -= layer.spriteBounds().w - layer.slicesBounds().w;
|
rc.y += layer.slicesBounds().y;
|
||||||
rc.h -= layer.spriteBounds().h - layer.slicesBounds().h;
|
rc.w -= layer.spriteBounds().w - layer.slicesBounds().w;
|
||||||
|
rc.h -= layer.spriteBounds().h - layer.slicesBounds().h;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Draw background using different methods
|
// Draw background using different methods
|
||||||
else {
|
else {
|
||||||
@ -488,6 +491,7 @@ void Theme::measureLayer(const Widget* widget,
|
|||||||
switch (layer.type()) {
|
switch (layer.type()) {
|
||||||
|
|
||||||
case Style::Layer::Type::kBackground:
|
case Style::Layer::Type::kBackground:
|
||||||
|
case Style::Layer::Type::kBackgroundBorder:
|
||||||
case Style::Layer::Type::kBorder:
|
case Style::Layer::Type::kBorder:
|
||||||
if (layer.spriteSheet() &&
|
if (layer.spriteSheet() &&
|
||||||
!layer.spriteBounds().isEmpty()) {
|
!layer.spriteBounds().isEmpty()) {
|
||||||
@ -509,8 +513,9 @@ void Theme::measureLayer(const Widget* widget,
|
|||||||
she::Font* font = (style->font() ? style->font(): widget->font());
|
she::Font* font = (style->font() ? style->font(): widget->font());
|
||||||
gfx::Size textSize(Graphics::measureUITextLength(widget->text(), font),
|
gfx::Size textSize(Graphics::measureUITextLength(widget->text(), font),
|
||||||
font->height());
|
font->height());
|
||||||
textHint.w = std::max(textHint.w, textSize.w);
|
|
||||||
textHint.h = std::max(textHint.h, textSize.h);
|
textHint.w = std::max(textHint.w, textSize.w+ABS(layer.offset().x));
|
||||||
|
textHint.h = std::max(textHint.h, textSize.h+ABS(layer.offset().y));
|
||||||
textAlign = layer.align();
|
textAlign = layer.align();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -518,8 +523,8 @@ void Theme::measureLayer(const Widget* widget,
|
|||||||
case Style::Layer::Type::kIcon: {
|
case Style::Layer::Type::kIcon: {
|
||||||
she::Surface* icon = layer.icon();
|
she::Surface* icon = layer.icon();
|
||||||
if (icon) {
|
if (icon) {
|
||||||
iconHint.w = std::max(iconHint.w, icon->width());
|
iconHint.w = std::max(iconHint.w, icon->width()+ABS(layer.offset().x));
|
||||||
iconHint.h = std::max(iconHint.h, icon->height());
|
iconHint.h = std::max(iconHint.h, icon->height()+ABS(layer.offset().y));
|
||||||
iconAlign = layer.align();
|
iconAlign = layer.align();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -577,7 +582,8 @@ gfx::Color Theme::calcBgColor(const Widget* widget,
|
|||||||
widget, style,
|
widget, style,
|
||||||
[&bgColor]
|
[&bgColor]
|
||||||
(const Style::Layer& layer) {
|
(const Style::Layer& layer) {
|
||||||
if (layer.type() == Style::Layer::Type::kBackground)
|
if (layer.type() == Style::Layer::Type::kBackground ||
|
||||||
|
layer.type() == Style::Layer::Type::kBackgroundBorder)
|
||||||
bgColor = layer.color();
|
bgColor = layer.color();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -601,7 +607,8 @@ void Theme::calcWidgetMetrics(const Widget* widget,
|
|||||||
|
|
||||||
for_each_layer(
|
for_each_layer(
|
||||||
widget, style,
|
widget, style,
|
||||||
[this, widget, style, &borderHint, &textHint, &textAlign, &iconHint, &iconAlign]
|
[this, widget, style, &borderHint,
|
||||||
|
&textHint, &textAlign, &iconHint, &iconAlign]
|
||||||
(const Style::Layer& layer) {
|
(const Style::Layer& layer) {
|
||||||
measureLayer(widget, style, layer,
|
measureLayer(widget, style, layer,
|
||||||
borderHint,
|
borderHint,
|
||||||
|
@ -65,13 +65,11 @@ namespace ui {
|
|||||||
virtual int getScrollbarSize() = 0;
|
virtual int getScrollbarSize() = 0;
|
||||||
virtual gfx::Size getEntryCaretSize(Widget* widget) = 0;
|
virtual gfx::Size getEntryCaretSize(Widget* widget) = 0;
|
||||||
|
|
||||||
virtual void paintCheckBox(PaintEvent& ev) = 0;
|
|
||||||
virtual void paintEntry(PaintEvent& ev) = 0;
|
virtual void paintEntry(PaintEvent& ev) = 0;
|
||||||
virtual void paintListBox(PaintEvent& ev) = 0;
|
virtual void paintListBox(PaintEvent& ev) = 0;
|
||||||
virtual void paintListItem(PaintEvent& ev) = 0;
|
virtual void paintListItem(PaintEvent& ev) = 0;
|
||||||
virtual void paintMenu(PaintEvent& ev) = 0;
|
virtual void paintMenu(PaintEvent& ev) = 0;
|
||||||
virtual void paintMenuItem(PaintEvent& ev) = 0;
|
virtual void paintMenuItem(PaintEvent& ev) = 0;
|
||||||
virtual void paintRadioButton(PaintEvent& ev) = 0;
|
|
||||||
virtual void paintSlider(PaintEvent& ev) = 0;
|
virtual void paintSlider(PaintEvent& ev) = 0;
|
||||||
virtual void paintComboBoxEntry(PaintEvent& ev) = 0;
|
virtual void paintComboBoxEntry(PaintEvent& ev) = 0;
|
||||||
virtual void paintTextBox(PaintEvent& ev) = 0;
|
virtual void paintTextBox(PaintEvent& ev) = 0;
|
||||||
|
@ -182,7 +182,7 @@ void Widget::setStyle(Style* style)
|
|||||||
{
|
{
|
||||||
m_style = style;
|
m_style = style;
|
||||||
m_border = m_theme->calcBorder(this, style);
|
m_border = m_theme->calcBorder(this, style);
|
||||||
m_bgColor = m_theme->calcBgColor(this, m_style);
|
m_bgColor = m_theme->calcBgColor(this, style);
|
||||||
if (style->font())
|
if (style->font())
|
||||||
m_font = style->font();
|
m_font = style->font();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user