mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-09 07:13:43 +00:00
Simplify window icons in theme definition
This commit is contained in:
parent
97809952eb
commit
75020d9405
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 13 KiB |
@ -190,18 +190,13 @@
|
||||
<part id="sunken_mini_focused" x="16" y="80" w1="4" w2="4" w3="4" h1="3" h2="6" h3="3" />
|
||||
<part id="window" x="0" y="0" w1="3" w2="7" w3="3" h1="15" h2="4" h3="5" />
|
||||
<part id="menu" x="0" y="96" w1="3" w2="10" w3="3" h1="3" h2="9" h3="4" />
|
||||
<part id="window_close_button_normal" x="16" y="0" w="9" h="11" />
|
||||
<part id="window_close_button_hot" x="25" y="0" w="9" h="11" />
|
||||
<part id="window_close_button_selected" x="34" y="0" w="9" h="11" />
|
||||
<part id="window_play_button_normal" x="16" y="11" w="9" h="11" />
|
||||
<part id="window_play_button_hot" x="25" y="11" w="9" h="11" />
|
||||
<part id="window_play_button_selected" x="34" y="11" w="9" h="11" />
|
||||
<part id="window_stop_button_normal" x="16" y="22" w="9" h="11" />
|
||||
<part id="window_stop_button_hot" x="25" y="22" w="9" h="11" />
|
||||
<part id="window_stop_button_selected" x="34" y="22" w="9" h="11" />
|
||||
<part id="window_center_button_normal" x="16" y="33" w="9" h="11" />
|
||||
<part id="window_center_button_hot" x="25" y="33" w="9" h="11" />
|
||||
<part id="window_center_button_selected" x="34" y="33" w="9" h="11" />
|
||||
<part id="window_button_normal" x="16" y="0" w="9" h="11" />
|
||||
<part id="window_button_hot" x="25" y="0" w="9" h="11" />
|
||||
<part id="window_button_selected" x="34" y="0" w="9" h="11" />
|
||||
<part id="window_close_icon" x="16" y="11" w="5" h="6" />
|
||||
<part id="window_play_icon" x="21" y="11" w="5" h="6" />
|
||||
<part id="window_stop_icon" x="26" y="11" w="5" h="6" />
|
||||
<part id="window_center_icon" x="31" y="11" w="5" h="6" />
|
||||
<part id="slider_full" x="0" y="144" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
<part id="slider_empty" x="16" y="144" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
<part id="slider_full_focused" x="0" y="160" w1="5" w2="6" w3="5" h1="5" h2="5" h3="6" />
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -45,9 +45,10 @@ class MiniCenterButton : public SkinButton<CheckBox> {
|
||||
public:
|
||||
MiniCenterButton()
|
||||
: SkinButton<CheckBox>(
|
||||
SkinTheme::instance()->parts.windowCenterButtonNormal(),
|
||||
SkinTheme::instance()->parts.windowCenterButtonHot(),
|
||||
SkinTheme::instance()->parts.windowCenterButtonSelected())
|
||||
SkinTheme::instance()->parts.windowButtonNormal(),
|
||||
SkinTheme::instance()->parts.windowButtonHot(),
|
||||
SkinTheme::instance()->parts.windowButtonSelected(),
|
||||
SkinTheme::instance()->parts.windowCenterIcon())
|
||||
{
|
||||
setup_bevels(this, 0, 0, 0, 0);
|
||||
setDecorative(true);
|
||||
@ -59,8 +60,8 @@ protected:
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
|
||||
Widget* window = parent();
|
||||
gfx::Rect rect(0, 0, 0, 0);
|
||||
gfx::Size iconSize = theme->parts.windowPlayButtonNormal()->size();
|
||||
gfx::Size closeSize = theme->parts.windowCloseButtonNormal()->size();
|
||||
gfx::Size iconSize = theme->parts.windowButtonNormal()->size();
|
||||
gfx::Size closeSize = theme->parts.windowButtonNormal()->size();
|
||||
|
||||
rect.w = iconSize.w;
|
||||
rect.h = iconSize.h;
|
||||
@ -89,8 +90,9 @@ protected:
|
||||
class MiniPlayButton : public SkinButton<Button> {
|
||||
public:
|
||||
MiniPlayButton()
|
||||
: SkinButton<Button>(SkinPartPtr(nullptr),
|
||||
SkinPartPtr(nullptr),
|
||||
: SkinButton<Button>(SkinTheme::instance()->parts.windowButtonNormal(),
|
||||
SkinTheme::instance()->parts.windowButtonHot(),
|
||||
SkinTheme::instance()->parts.windowButtonSelected(),
|
||||
SkinPartPtr(nullptr))
|
||||
, m_isPlaying(false) {
|
||||
enableFlags(CTRL_RIGHT_CLICK);
|
||||
@ -121,8 +123,8 @@ private:
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->theme());
|
||||
Widget* window = parent();
|
||||
gfx::Rect rect(0, 0, 0, 0);
|
||||
gfx::Size playSize = theme->parts.windowPlayButtonNormal()->size();
|
||||
gfx::Size closeSize = theme->parts.windowCloseButtonNormal()->size();
|
||||
gfx::Size playSize = theme->parts.windowButtonNormal()->size();
|
||||
gfx::Size closeSize = theme->parts.windowButtonNormal()->size();
|
||||
|
||||
rect.w = playSize.w;
|
||||
rect.h = playSize.h;
|
||||
@ -163,13 +165,9 @@ private:
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
if (m_isPlaying)
|
||||
setParts(theme->parts.windowStopButtonNormal(),
|
||||
theme->parts.windowStopButtonHot(),
|
||||
theme->parts.windowStopButtonSelected());
|
||||
setIcon(theme->parts.windowStopIcon());
|
||||
else
|
||||
setParts(theme->parts.windowPlayButtonNormal(),
|
||||
theme->parts.windowPlayButtonHot(),
|
||||
theme->parts.windowPlayButtonSelected());
|
||||
setIcon(theme->parts.windowPlayIcon());
|
||||
}
|
||||
|
||||
bool m_isPlaying;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2015, 2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "she/surface.h"
|
||||
#include "ui/button.h"
|
||||
#include "ui/graphics.h"
|
||||
#include "ui/paint_event.h"
|
||||
@ -21,20 +22,18 @@ namespace app {
|
||||
public:
|
||||
SkinButton(const SkinPartPtr& partNormal,
|
||||
const SkinPartPtr& partHot,
|
||||
const SkinPartPtr& partSelected)
|
||||
const SkinPartPtr& partSelected,
|
||||
const SkinPartPtr& partIcon)
|
||||
: Base("")
|
||||
, m_partNormal(partNormal)
|
||||
, m_partHot(partHot)
|
||||
, m_partSelected(partSelected)
|
||||
, m_partIcon(partIcon)
|
||||
{
|
||||
}
|
||||
|
||||
void setParts(const SkinPartPtr& partNormal,
|
||||
const SkinPartPtr& partHot,
|
||||
const SkinPartPtr& partSelected) {
|
||||
m_partNormal = partNormal;
|
||||
m_partHot = partHot;
|
||||
m_partSelected = partSelected;
|
||||
void setIcon(const SkinPartPtr& partIcon) {
|
||||
m_partIcon = partIcon;
|
||||
Base::invalidate();
|
||||
}
|
||||
|
||||
@ -43,21 +42,36 @@ namespace app {
|
||||
gfx::Rect bounds(Base::clientBounds());
|
||||
ui::Graphics* g = ev.graphics();
|
||||
SkinPartPtr part;
|
||||
gfx::Color fg;
|
||||
|
||||
if (Base::isSelected())
|
||||
if (Base::isSelected()) {
|
||||
fg = SkinTheme::instance()->colors.buttonSelectedText();
|
||||
part = m_partSelected;
|
||||
else if (Base::hasMouseOver())
|
||||
}
|
||||
else if (Base::hasMouseOver()) {
|
||||
fg = SkinTheme::instance()->colors.buttonHotText();
|
||||
part = m_partHot;
|
||||
else
|
||||
}
|
||||
else {
|
||||
fg = SkinTheme::instance()->colors.buttonNormalText();
|
||||
part = m_partNormal;
|
||||
}
|
||||
|
||||
g->drawRgbaSurface(part->bitmap(0), bounds.x, bounds.y);
|
||||
gfx::Size sz(part->bitmap(0)->width(),
|
||||
part->bitmap(0)->height());
|
||||
|
||||
part = m_partIcon;
|
||||
g->drawColoredRgbaSurface(part->bitmap(0), fg,
|
||||
bounds.x+sz.w/2-part->bitmap(0)->width()/2,
|
||||
bounds.y+sz.h/2-part->bitmap(0)->height()/2);
|
||||
}
|
||||
|
||||
private:
|
||||
SkinPartPtr m_partNormal;
|
||||
SkinPartPtr m_partHot;
|
||||
SkinPartPtr m_partSelected;
|
||||
SkinPartPtr m_partIcon;
|
||||
};
|
||||
|
||||
} // namespace skin
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
protected:
|
||||
|
||||
void onSizeHint(SizeHintEvent& ev) override {
|
||||
ev.setSizeHint(SkinTheme::instance()->parts.windowCloseButtonNormal()->size());
|
||||
ev.setSizeHint(SkinTheme::instance()->parts.windowButtonNormal()->size());
|
||||
}
|
||||
|
||||
void onClick(Event& ev) override {
|
||||
@ -760,7 +760,7 @@ void SkinTheme::setDecorativeWidgetBounds(Widget* widget)
|
||||
{
|
||||
if (widget->id() == kThemeCloseButtonId) {
|
||||
Widget* window = widget->parent();
|
||||
gfx::Rect rect(parts.windowCloseButtonNormal()->size());
|
||||
gfx::Rect rect(parts.windowButtonNormal()->size());
|
||||
|
||||
rect.offset(window->bounds().x2() - 3*guiscale() - rect.w,
|
||||
window->bounds().y + 3*guiscale());
|
||||
@ -1689,20 +1689,36 @@ void SkinTheme::paintPopupWindow(PaintEvent& ev)
|
||||
|
||||
void SkinTheme::paintWindowButton(ui::PaintEvent& ev)
|
||||
{
|
||||
// Merge this code with SkinButton class
|
||||
|
||||
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
||||
Graphics* g = ev.graphics();
|
||||
Rect rc = widget->clientBounds();
|
||||
SkinPartPtr part;
|
||||
gfx::Color fg;
|
||||
|
||||
if (widget->isSelected())
|
||||
part = parts.windowCloseButtonSelected();
|
||||
else if (widget->hasMouseOver())
|
||||
part = parts.windowCloseButtonHot();
|
||||
else
|
||||
part = parts.windowCloseButtonNormal();
|
||||
if (widget->isSelected()) {
|
||||
fg = colors.buttonSelectedText();
|
||||
part = parts.windowButtonSelected();
|
||||
}
|
||||
else if (widget->hasMouseOver()) {
|
||||
fg = colors.buttonHotText();
|
||||
part = parts.windowButtonHot();
|
||||
}
|
||||
else {
|
||||
fg = colors.buttonNormalText();
|
||||
part = parts.windowButtonNormal();
|
||||
}
|
||||
|
||||
g->fillRect(BGCOLOR, rc);
|
||||
g->drawRgbaSurface(part->bitmap(0), rc.x, rc.y);
|
||||
gfx::Size sz(part->bitmap(0)->width(),
|
||||
part->bitmap(0)->height());
|
||||
|
||||
part = parts.windowCloseIcon();
|
||||
g->drawColoredRgbaSurface(part->bitmap(0), fg,
|
||||
rc.x+sz.w/2-part->bitmap(0)->width()/2,
|
||||
rc.y+sz.h/2-part->bitmap(0)->height()/2);
|
||||
}
|
||||
|
||||
void SkinTheme::paintTooltip(PaintEvent& ev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user