mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-11 13:14:17 +00:00
Remove SkinParts enum
Now we generate the list of SkinTheme parts from the skin.xml file using the gen utility. Several refactors included in SkinTheme class to simplify code.
This commit is contained in:
parent
43a3ee8bce
commit
53a925e86d
@ -220,37 +220,37 @@ private:
|
||||
int c = 0;
|
||||
for (int v=0; v<3; ++v) {
|
||||
for (int u=0; u<3; ++u) {
|
||||
const char* iconId = "canvas_empty";
|
||||
SkinPartPtr icon = theme->parts.canvasEmpty();
|
||||
|
||||
if (c == sel) {
|
||||
iconId = "canvas_c";
|
||||
icon = theme->parts.canvasC();
|
||||
}
|
||||
else if (u+1 < 3 && (u+1)+3*v == sel) {
|
||||
iconId = "canvas_w";
|
||||
icon = theme->parts.canvasW();
|
||||
}
|
||||
else if (u-1 >= 0 && (u-1)+3*v == sel) {
|
||||
iconId = "canvas_e";
|
||||
icon = theme->parts.canvasE();
|
||||
}
|
||||
else if (v+1 < 3 && u+3*(v+1) == sel) {
|
||||
iconId = "canvas_n";
|
||||
icon = theme->parts.canvasN();
|
||||
}
|
||||
else if (v-1 >= 0 && u+3*(v-1) == sel) {
|
||||
iconId = "canvas_s";
|
||||
icon = theme->parts.canvasS();
|
||||
}
|
||||
else if (u+1 < 3 && v+1 < 3 && (u+1)+3*(v+1) == sel) {
|
||||
iconId = "canvas_nw";
|
||||
icon = theme->parts.canvasNw();
|
||||
}
|
||||
else if (u-1 >= 0 && v+1 < 3 && (u-1)+3*(v+1) == sel) {
|
||||
iconId = "canvas_ne";
|
||||
icon = theme->parts.canvasNe();
|
||||
}
|
||||
else if (u+1 < 3 && v-1 >= 0 && (u+1)+3*(v-1) == sel) {
|
||||
iconId = "canvas_sw";
|
||||
icon = theme->parts.canvasSw();
|
||||
}
|
||||
else if (u-1 >= 0 && v-1 >= 0 && (u-1)+3*(v-1) == sel) {
|
||||
iconId = "canvas_se";
|
||||
icon = theme->parts.canvasSe();
|
||||
}
|
||||
|
||||
dir()->getItem(c)->setIcon(theme->get_part(iconId));
|
||||
dir()->getItem(c)->setIcon(icon);
|
||||
++c;
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,8 @@
|
||||
|
||||
#include "app/modules/gfx.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/skin/skin_parts.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/bind.h"
|
||||
#include "doc/image.h"
|
||||
#include "ui/box.h"
|
||||
@ -25,9 +26,9 @@
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
using namespace filters;
|
||||
using namespace ui;
|
||||
using namespace app::skin;
|
||||
|
||||
FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
|
||||
: Box(VERTICAL)
|
||||
@ -91,10 +92,12 @@ FilterTargetButtons::FilterTargetButtons(int imgtype, bool withChannels)
|
||||
withChannels ? 0: 2,
|
||||
withChannels ? 0: 2, 2, 2);
|
||||
setup_mini_look(images);
|
||||
set_gfxicon_to_button(images,
|
||||
getTargetNormalIcon(),
|
||||
getTargetSelectedIcon(), -1,
|
||||
CENTER | MIDDLE);
|
||||
|
||||
images->setIconInterface(
|
||||
new ButtonIconImpl(getTargetNormalIcon(),
|
||||
getTargetSelectedIcon(),
|
||||
SkinPartPtr(nullptr),
|
||||
CENTER | MIDDLE));
|
||||
|
||||
// Make hierarchy
|
||||
ADD(hbox, r, onChannelChange);
|
||||
@ -170,39 +173,44 @@ void FilterTargetButtons::onImagesChange(ButtonBase* button)
|
||||
m_target |= TARGET_ALL_FRAMES;
|
||||
}
|
||||
|
||||
set_gfxicon_to_button(button,
|
||||
getTargetNormalIcon(),
|
||||
getTargetSelectedIcon(), -1,
|
||||
CENTER | MIDDLE);
|
||||
button->setIconInterface(
|
||||
new ButtonIconImpl(getTargetNormalIcon(),
|
||||
getTargetSelectedIcon(),
|
||||
SkinPartPtr(nullptr),
|
||||
CENTER | MIDDLE));
|
||||
|
||||
TargetChange();
|
||||
}
|
||||
|
||||
int FilterTargetButtons::getTargetNormalIcon() const
|
||||
SkinPartPtr FilterTargetButtons::getTargetNormalIcon() const
|
||||
{
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
if (m_target & TARGET_ALL_FRAMES) {
|
||||
return (m_target & TARGET_ALL_LAYERS) ?
|
||||
PART_TARGET_FRAMES_LAYERS:
|
||||
PART_TARGET_FRAMES;
|
||||
theme->parts.targetFramesLayers():
|
||||
theme->parts.targetFrames();
|
||||
}
|
||||
else {
|
||||
return (m_target & TARGET_ALL_LAYERS) ?
|
||||
PART_TARGET_LAYERS:
|
||||
PART_TARGET_ONE;
|
||||
theme->parts.targetLayers():
|
||||
theme->parts.targetOne();
|
||||
}
|
||||
}
|
||||
|
||||
int FilterTargetButtons::getTargetSelectedIcon() const
|
||||
SkinPartPtr FilterTargetButtons::getTargetSelectedIcon() const
|
||||
{
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
if (m_target & TARGET_ALL_FRAMES) {
|
||||
return (m_target & TARGET_ALL_LAYERS) ?
|
||||
PART_TARGET_FRAMES_LAYERS_SELECTED:
|
||||
PART_TARGET_FRAMES_SELECTED;
|
||||
theme->parts.targetFramesLayersSelected():
|
||||
theme->parts.targetFramesSelected();
|
||||
}
|
||||
else {
|
||||
return (m_target & TARGET_ALL_LAYERS) ?
|
||||
PART_TARGET_LAYERS_SELECTED:
|
||||
PART_TARGET_ONE_SELECTED;
|
||||
theme->parts.targetLayersSelected():
|
||||
theme->parts.targetOneSelected();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define APP_COMMANDS_FILTERS_FILTER_TARGET_BUTTONS_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/skin/skin_part.h"
|
||||
#include "base/signal.h"
|
||||
#include "filters/target.h"
|
||||
#include "ui/box.h"
|
||||
@ -37,8 +38,8 @@ namespace app {
|
||||
|
||||
private:
|
||||
void selectTargetButton(const char* name, Target specificTarget);
|
||||
int getTargetNormalIcon() const;
|
||||
int getTargetSelectedIcon() const;
|
||||
skin::SkinPartPtr getTargetNormalIcon() const;
|
||||
skin::SkinPartPtr getTargetSelectedIcon() const;
|
||||
|
||||
Target m_target;
|
||||
};
|
||||
|
@ -100,7 +100,7 @@ void draw_color_button(ui::Graphics* g,
|
||||
const Rect& rc, const app::Color& color,
|
||||
bool hot, bool drag)
|
||||
{
|
||||
SkinTheme* theme = (SkinTheme*)ui::CurrentTheme::get();
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
int scale = ui::guiscale();
|
||||
|
||||
// Draw background (the color)
|
||||
@ -111,25 +111,22 @@ void draw_color_button(ui::Graphics* g,
|
||||
rc.h-2*scale), color);
|
||||
|
||||
// Draw opaque border
|
||||
{
|
||||
int parts[8] = {
|
||||
PART_COLORBAR_0_NW,
|
||||
PART_COLORBAR_0_N,
|
||||
PART_COLORBAR_1_NE,
|
||||
PART_COLORBAR_1_E,
|
||||
PART_COLORBAR_3_SE,
|
||||
PART_COLORBAR_2_S,
|
||||
PART_COLORBAR_2_SW,
|
||||
PART_COLORBAR_0_W
|
||||
};
|
||||
theme->draw_bounds_array(g, rc, parts);
|
||||
}
|
||||
theme->drawRect(
|
||||
g, rc,
|
||||
theme->parts.colorbar0()->getBitmapNW(),
|
||||
theme->parts.colorbar0()->getBitmapN(),
|
||||
theme->parts.colorbar1()->getBitmapNE(),
|
||||
theme->parts.colorbar1()->getBitmapE(),
|
||||
theme->parts.colorbar3()->getBitmapSE(),
|
||||
theme->parts.colorbar2()->getBitmapS(),
|
||||
theme->parts.colorbar2()->getBitmapSW(),
|
||||
theme->parts.colorbar0()->getBitmapW());
|
||||
|
||||
// Draw hot
|
||||
if (hot) {
|
||||
theme->draw_bounds_nw(g,
|
||||
gfx::Rect(rc.x, rc.y, rc.w, rc.h-1 - 1*scale),
|
||||
PART_COLORBAR_BORDER_HOTFG_NW);
|
||||
theme->drawRect(
|
||||
g, gfx::Rect(rc.x, rc.y, rc.w, rc.h-1 - 1*scale),
|
||||
theme->parts.colorbarBorderHotfg().get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include "app/ui/main_menu_bar.h"
|
||||
#include "app/ui/main_menu_bar.h"
|
||||
#include "app/ui/main_window.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_property.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
@ -264,23 +263,6 @@ void setup_bevels(Widget* widget, int b1, int b2, int b3, int b4)
|
||||
skinProp->setLowerRight(b4);
|
||||
}
|
||||
|
||||
// Sets the IconInterface pointer interface of the button to show the
|
||||
// specified set of icons. Each icon is a part of the SkinTheme.
|
||||
void set_gfxicon_to_button(ButtonBase* button,
|
||||
int normal_part_id,
|
||||
int selected_part_id,
|
||||
int disabled_part_id, int icon_align)
|
||||
{
|
||||
ButtonIconImpl* buttonIcon =
|
||||
new ButtonIconImpl(static_cast<SkinTheme*>(button->getTheme()),
|
||||
normal_part_id,
|
||||
selected_part_id,
|
||||
disabled_part_id,
|
||||
icon_align);
|
||||
|
||||
button->setIconInterface(buttonIcon);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Button style (convert radio or check buttons and draw it like
|
||||
// normal buttons)
|
||||
|
@ -45,11 +45,6 @@ namespace app {
|
||||
ui::Widget* setup_look(ui::Widget* widget, skin::LookType lookType);
|
||||
void setup_bevels(ui::Widget* widget, int b1, int b2, int b3, int b4);
|
||||
|
||||
void set_gfxicon_to_button(ui::ButtonBase* button,
|
||||
int normal_part_id,
|
||||
int selected_part_id,
|
||||
int disabled_part_id, int icon_align);
|
||||
|
||||
ui::CheckBox* check_button_new(const char* text, int b1, int b2, int b3, int b4);
|
||||
|
||||
// This function can be used to reinvalidate a specific rectangle if
|
||||
|
@ -65,11 +65,11 @@ AniControls::AniControls()
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
|
||||
addItem(theme->get_part(PART_ANI_FIRST));
|
||||
addItem(theme->get_part(PART_ANI_PREVIOUS));
|
||||
addItem(theme->get_part(PART_ANI_PLAY));
|
||||
addItem(theme->get_part(PART_ANI_NEXT));
|
||||
addItem(theme->get_part(PART_ANI_LAST));
|
||||
addItem(theme->parts.aniFirst());
|
||||
addItem(theme->parts.aniPrevious());
|
||||
addItem(theme->parts.aniPlay());
|
||||
addItem(theme->parts.aniNext());
|
||||
addItem(theme->parts.aniLast());
|
||||
ItemChange.connect(Bind(&AniControls::onPlayButton, this));
|
||||
|
||||
setTriggerOnMouseUp(true);
|
||||
@ -81,8 +81,9 @@ void AniControls::updateUsingEditor(Editor* editor)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
getItem(ACTION_PLAY)->setIcon(
|
||||
theme->get_part(
|
||||
(editor && editor->isPlaying()) ? PART_ANI_STOP: PART_ANI_PLAY));
|
||||
(editor && editor->isPlaying() ?
|
||||
theme->parts.aniStop():
|
||||
theme->parts.aniPlay()));
|
||||
}
|
||||
|
||||
void AniControls::onPlayButton()
|
||||
|
@ -47,11 +47,9 @@ public:
|
||||
, m_delegate(delegate)
|
||||
, m_brush(brush)
|
||||
, m_slot(slot) {
|
||||
setIcon(BrushPopup::createSurfaceForBrush(brush));
|
||||
}
|
||||
|
||||
~Item() {
|
||||
icon()->dispose();
|
||||
SkinPartPtr icon(new SkinPart);
|
||||
icon->setBitmap(0, BrushPopup::createSurfaceForBrush(brush));
|
||||
setIcon(icon);
|
||||
}
|
||||
|
||||
const BrushRef& brush() const {
|
||||
|
@ -48,7 +48,7 @@ ButtonSet::Item::Item()
|
||||
setup_mini_font(this);
|
||||
}
|
||||
|
||||
void ButtonSet::Item::setIcon(she::Surface* icon)
|
||||
void ButtonSet::Item::setIcon(const SkinPartPtr& icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
invalidate();
|
||||
@ -65,25 +65,25 @@ void ButtonSet::Item::onPaint(ui::PaintEvent& ev)
|
||||
Graphics* g = ev.getGraphics();
|
||||
gfx::Rect rc = getClientBounds();
|
||||
gfx::Color fg, bg;
|
||||
int nw;
|
||||
SkinPartPtr nw;
|
||||
|
||||
if (!gfx::is_transparent(getBgColor()))
|
||||
g->fillRect(getBgColor(), g->getClipBounds());
|
||||
|
||||
if (isSelected() || hasMouseOver()) {
|
||||
if (hasCapture()) {
|
||||
nw = PART_TOOLBUTTON_PUSHED_NW;
|
||||
nw = theme->parts.toolbuttonPushed();
|
||||
fg = theme->colors.buttonSelectedText();
|
||||
bg = theme->colors.buttonSelectedFace();
|
||||
}
|
||||
else {
|
||||
nw = PART_TOOLBUTTON_HOT_NW;
|
||||
nw = theme->parts.toolbuttonHot();
|
||||
fg = theme->colors.buttonHotText();
|
||||
bg = theme->colors.buttonHotFace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
nw = PART_TOOLBUTTON_LAST_NW;
|
||||
nw = theme->parts.toolbuttonLast();
|
||||
fg = theme->colors.buttonNormalText();
|
||||
bg = theme->colors.buttonNormalFace();
|
||||
}
|
||||
@ -92,16 +92,17 @@ void ButtonSet::Item::onPaint(ui::PaintEvent& ev)
|
||||
if (info.col < info.grid_cols-1) rc.w+=1*guiscale();
|
||||
if (info.row < info.grid_rows-1) rc.h+=3*guiscale();
|
||||
|
||||
theme->draw_bounds_nw(g, rc, nw, bg);
|
||||
theme->drawRect(g, rc, nw.get(), bg);
|
||||
|
||||
if (m_icon) {
|
||||
int u = rc.x + rc.w/2 - m_icon->width()/2;
|
||||
int v = rc.y + rc.h/2 - m_icon->height()/2 - 1*guiscale();
|
||||
gfx::Size iconSize = m_icon->getSize();
|
||||
int u = rc.x + rc.w/2 - iconSize.w/2;
|
||||
int v = rc.y + rc.h/2 - iconSize.h/2 - 1*guiscale();
|
||||
|
||||
if (isSelected() && hasCapture())
|
||||
g->drawColoredRgbaSurface(m_icon, theme->colors.buttonSelectedText(), u, v);
|
||||
g->drawColoredRgbaSurface(m_icon->getBitmap(0), theme->colors.buttonSelectedText(), u, v);
|
||||
else
|
||||
g->drawRgbaSurface(m_icon, u, v);
|
||||
g->drawRgbaSurface(m_icon->getBitmap(0), u, v);
|
||||
}
|
||||
|
||||
if (!getText().empty()) {
|
||||
@ -192,7 +193,7 @@ void ButtonSet::addItem(const std::string& text, int hspan, int vspan)
|
||||
addItem(item, hspan, vspan);
|
||||
}
|
||||
|
||||
void ButtonSet::addItem(she::Surface* icon, int hspan, int vspan)
|
||||
void ButtonSet::addItem(const skin::SkinPartPtr& icon, int hspan, int vspan)
|
||||
{
|
||||
Item* item = new Item();
|
||||
item->setIcon(icon);
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define APP_UI_BUTTON_SET_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/skin/skin_part.h"
|
||||
#include "base/signal.h"
|
||||
#include "ui/grid.h"
|
||||
|
||||
@ -21,21 +22,21 @@ namespace app {
|
||||
class Item : public ui::Widget {
|
||||
public:
|
||||
Item();
|
||||
void setIcon(she::Surface* icon);
|
||||
she::Surface* icon() const { return m_icon; }
|
||||
void setIcon(const skin::SkinPartPtr& icon);
|
||||
skin::SkinPartPtr icon() const { return m_icon; }
|
||||
ButtonSet* buttonSet();
|
||||
protected:
|
||||
void onPaint(ui::PaintEvent& ev) override;
|
||||
bool onProcessMessage(ui::Message* msg) override;
|
||||
void onPreferredSize(ui::PreferredSizeEvent& ev) override;
|
||||
private:
|
||||
she::Surface* m_icon;
|
||||
skin::SkinPartPtr m_icon;
|
||||
};
|
||||
|
||||
ButtonSet(int columns);
|
||||
|
||||
void addItem(const std::string& text, int hspan = 1, int vspan = 1);
|
||||
void addItem(she::Surface* icon, int hspan = 1, int vspan = 1);
|
||||
void addItem(const skin::SkinPartPtr& icon, int hspan = 1, int vspan = 1);
|
||||
void addItem(Item* item, int hspan = 1, int vspan = 1);
|
||||
Item* getItem(int index);
|
||||
|
||||
|
@ -100,10 +100,10 @@ protected:
|
||||
ColorBar::ScrollableView::ScrollableView()
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
int l = theme->get_part(PART_EDITOR_SELECTED_W)->width();
|
||||
int t = theme->get_part(PART_EDITOR_SELECTED_N)->height();
|
||||
int r = theme->get_part(PART_EDITOR_SELECTED_E)->width();
|
||||
int b = theme->get_part(PART_EDITOR_SELECTED_S)->height();
|
||||
int l = theme->parts.editorSelected()->getBitmapW()->width();
|
||||
int t = theme->parts.editorSelected()->getBitmapN()->height();
|
||||
int r = theme->parts.editorSelected()->getBitmapE()->width();
|
||||
int b = theme->parts.editorSelected()->getBitmapS()->height();
|
||||
|
||||
setBorder(gfx::Border(l, t, r, b));
|
||||
}
|
||||
@ -112,10 +112,11 @@ void ColorBar::ScrollableView::onPaint(ui::PaintEvent& ev)
|
||||
{
|
||||
ui::Graphics* g = ev.getGraphics();
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
theme->draw_bounds_nw(g,
|
||||
getClientBounds(),
|
||||
hasFocus() ? PART_EDITOR_SELECTED_NW:
|
||||
PART_EDITOR_NORMAL_NW,
|
||||
|
||||
theme->drawRect(
|
||||
g, getClientBounds(),
|
||||
(hasFocus() ? theme->parts.editorSelected().get():
|
||||
theme->parts.editorNormal().get()),
|
||||
gfx::ColorNone);
|
||||
}
|
||||
|
||||
@ -223,10 +224,10 @@ ColorBar::ColorBar(int align)
|
||||
// Change labels foreground color
|
||||
m_buttons.ItemChange.connect(Bind<void>(&ColorBar::onPaletteButtonClick, this));
|
||||
|
||||
m_buttons.addItem(theme->get_part(PART_PAL_EDIT));
|
||||
m_buttons.addItem(theme->get_part(PART_PAL_SORT));
|
||||
m_buttons.addItem(theme->get_part(PART_PAL_PRESETS));
|
||||
m_buttons.addItem(theme->get_part(PART_PAL_OPTIONS));
|
||||
m_buttons.addItem(theme->parts.palEdit());
|
||||
m_buttons.addItem(theme->parts.palSort());
|
||||
m_buttons.addItem(theme->parts.palPresets());
|
||||
m_buttons.addItem(theme->parts.palOptions());
|
||||
|
||||
// Tooltips
|
||||
TooltipManager* tooltipManager = new TooltipManager();
|
||||
|
@ -83,8 +83,9 @@ void ColorSpectrum::onPaint(ui::PaintEvent& ev)
|
||||
ui::Graphics* g = ev.getGraphics();
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
|
||||
theme->draw_bounds_nw(g, getClientBounds(),
|
||||
PART_EDITOR_NORMAL_NW, getBgColor());
|
||||
theme->drawRect(g, getClientBounds(),
|
||||
theme->parts.editorNormal().get(),
|
||||
getBgColor());
|
||||
|
||||
gfx::Rect rc = getClientBounds().shrink(3*ui::guiscale());
|
||||
if (rc.isEmpty())
|
||||
|
@ -63,26 +63,26 @@ public:
|
||||
BrushTypeField(ContextBar* owner)
|
||||
: ButtonSet(1)
|
||||
, m_owner(owner)
|
||||
, m_bitmap(BrushPopup::createSurfaceForBrush(BrushRef(nullptr)))
|
||||
, m_popupWindow(this) {
|
||||
addItem(m_bitmap);
|
||||
SkinPartPtr part(new SkinPart);
|
||||
part->setBitmap(
|
||||
0, BrushPopup::createSurfaceForBrush(BrushRef(nullptr)));
|
||||
|
||||
addItem(part);
|
||||
m_popupWindow.BrushChange.connect(&BrushTypeField::onBrushChange, this);
|
||||
}
|
||||
|
||||
~BrushTypeField() {
|
||||
closePopup();
|
||||
|
||||
m_bitmap->dispose();
|
||||
}
|
||||
|
||||
void updateBrush(tools::Tool* tool = nullptr) {
|
||||
if (m_bitmap)
|
||||
m_bitmap->dispose();
|
||||
SkinPartPtr part(new SkinPart);
|
||||
part->setBitmap(
|
||||
0, BrushPopup::createSurfaceForBrush(
|
||||
m_owner->activeBrush(tool)));
|
||||
|
||||
m_bitmap = BrushPopup::createSurfaceForBrush(
|
||||
m_owner->activeBrush(tool));
|
||||
|
||||
getItem(0)->setIcon(m_bitmap);
|
||||
getItem(0)->setIcon(part);
|
||||
}
|
||||
|
||||
void setupTooltips(TooltipManager* tooltipManager) {
|
||||
@ -325,21 +325,21 @@ class ContextBar::InkTypeField : public ButtonSet
|
||||
public:
|
||||
InkTypeField(ContextBar* owner) : ButtonSet(1)
|
||||
, m_owner(owner) {
|
||||
addItem(
|
||||
static_cast<SkinTheme*>(getTheme())->get_part(PART_INK_DEFAULT));
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
addItem(theme->parts.inkDefault());
|
||||
}
|
||||
|
||||
void setInkType(InkType inkType) {
|
||||
int part = PART_INK_DEFAULT;
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
SkinPartPtr part = theme->parts.inkDefault();
|
||||
|
||||
switch (inkType) {
|
||||
case InkType::ALPHA_COMPOSITING: part = PART_INK_DEFAULT; break;
|
||||
case InkType::COPY_COLOR: part = PART_INK_COPY_COLOR; break;
|
||||
case InkType::LOCK_ALPHA: part = PART_INK_LOCK_ALPHA; break;
|
||||
case InkType::ALPHA_COMPOSITING: part = theme->parts.inkDefault(); break;
|
||||
case InkType::COPY_COLOR: part = theme->parts.inkCopyColor(); break;
|
||||
case InkType::LOCK_ALPHA: part = theme->parts.inkLockAlpha(); break;
|
||||
}
|
||||
|
||||
getItem(0)->setIcon(
|
||||
static_cast<SkinTheme*>(getTheme())->get_part(part));
|
||||
getItem(0)->setIcon(part);
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -483,10 +483,12 @@ public:
|
||||
: m_icon(1)
|
||||
, m_maskColor(app::Color::fromMask(), IMAGE_RGB)
|
||||
, m_owner(owner) {
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
addChild(&m_icon);
|
||||
addChild(&m_maskColor);
|
||||
|
||||
m_icon.addItem(static_cast<SkinTheme*>(getTheme())->get_part(PART_SELECTION_OPAQUE));
|
||||
m_icon.addItem(theme->parts.selectionOpaque());
|
||||
gfx::Size sz = m_icon.getItem(0)->getPreferredSize();
|
||||
sz.w += 2*guiscale();
|
||||
m_icon.getItem(0)->setMinSize(sz);
|
||||
@ -536,9 +538,10 @@ private:
|
||||
void onOpaqueChange() {
|
||||
bool opaque = Preferences::instance().selection.opaque();
|
||||
|
||||
int part = (opaque ? PART_SELECTION_OPAQUE: PART_SELECTION_MASKED);
|
||||
m_icon.getItem(0)->setIcon(
|
||||
static_cast<SkinTheme*>(getTheme())->get_part(part));
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
SkinPartPtr part = (opaque ? theme->parts.selectionOpaque():
|
||||
theme->parts.selectionMasked());
|
||||
m_icon.getItem(0)->setIcon(part);
|
||||
|
||||
m_maskColor.setVisible(!opaque);
|
||||
if (!opaque) {
|
||||
@ -559,7 +562,7 @@ class ContextBar::PivotField : public ButtonSet {
|
||||
public:
|
||||
PivotField()
|
||||
: ButtonSet(1) {
|
||||
addItem(static_cast<SkinTheme*>(getTheme())->get_part(PART_PIVOT_HIDDEN));
|
||||
addItem(SkinTheme::instance()->parts.pivotHidden());
|
||||
|
||||
ItemChange.connect(Bind<void>(&PivotField::onPopup, this));
|
||||
|
||||
@ -580,15 +583,15 @@ private:
|
||||
CheckBox hidden("Hidden pivot by default");
|
||||
HBox box;
|
||||
ButtonSet buttonset(3);
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_NORTHWEST));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_NORTH));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_NORTHEAST));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_WEST));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_CENTER));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_EAST));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_SOUTHWEST));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_SOUTH));
|
||||
buttonset.addItem(theme->get_part(PART_PIVOT_SOUTHEAST));
|
||||
buttonset.addItem(theme->parts.pivotNorthwest());
|
||||
buttonset.addItem(theme->parts.pivotNorth());
|
||||
buttonset.addItem(theme->parts.pivotNortheast());
|
||||
buttonset.addItem(theme->parts.pivotWest());
|
||||
buttonset.addItem(theme->parts.pivotCenter());
|
||||
buttonset.addItem(theme->parts.pivotEast());
|
||||
buttonset.addItem(theme->parts.pivotSouthwest());
|
||||
buttonset.addItem(theme->parts.pivotSouth());
|
||||
buttonset.addItem(theme->parts.pivotSoutheast());
|
||||
box.addChild(&buttonset);
|
||||
|
||||
menu.addChild(&hidden);
|
||||
@ -618,9 +621,22 @@ private:
|
||||
}
|
||||
|
||||
void onPivotChange() {
|
||||
int part = PART_PIVOT_HIDDEN + int(Preferences::instance().selection.pivot());
|
||||
getItem(0)->setIcon(
|
||||
static_cast<SkinTheme*>(getTheme())->get_part(part));
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
SkinPartPtr part;
|
||||
switch (Preferences::instance().selection.pivot()) {
|
||||
case app::gen::PivotMode::HIDDEN: part = theme->parts.pivotHidden(); break;
|
||||
case app::gen::PivotMode::NORTHWEST: part = theme->parts.pivotNorthwest(); break;
|
||||
case app::gen::PivotMode::NORTH: part = theme->parts.pivotNorth(); break;
|
||||
case app::gen::PivotMode::NORTHEAST: part = theme->parts.pivotNortheast(); break;
|
||||
case app::gen::PivotMode::WEST: part = theme->parts.pivotWest(); break;
|
||||
case app::gen::PivotMode::CENTER: part = theme->parts.pivotCenter(); break;
|
||||
case app::gen::PivotMode::EAST: part = theme->parts.pivotEast(); break;
|
||||
case app::gen::PivotMode::SOUTHWEST: part = theme->parts.pivotSouthwest(); break;
|
||||
case app::gen::PivotMode::SOUTH: part = theme->parts.pivotSouth(); break;
|
||||
case app::gen::PivotMode::SOUTHEAST: part = theme->parts.pivotSoutheast(); break;
|
||||
}
|
||||
if (part)
|
||||
getItem(0)->setIcon(part);
|
||||
}
|
||||
|
||||
};
|
||||
@ -693,20 +709,21 @@ public:
|
||||
}
|
||||
|
||||
void setFreehandAlgorithm(FreehandAlgorithm algo) {
|
||||
int part = PART_FREEHAND_ALGO_DEFAULT;
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
SkinPartPtr part = theme->parts.freehandAlgoDefault();
|
||||
m_freehandAlgo = algo;
|
||||
switch (m_freehandAlgo) {
|
||||
case kDefaultFreehandAlgorithm:
|
||||
part = PART_FREEHAND_ALGO_DEFAULT;
|
||||
part = theme->parts.freehandAlgoDefault();
|
||||
break;
|
||||
case kPixelPerfectFreehandAlgorithm:
|
||||
part = PART_FREEHAND_ALGO_PIXEL_PERFECT;
|
||||
part = theme->parts.freehandAlgoPixelPerfect();
|
||||
break;
|
||||
case kDotsFreehandAlgorithm:
|
||||
part = PART_FREEHAND_ALGO_DOTS;
|
||||
part = theme->parts.freehandAlgoDots();
|
||||
break;
|
||||
}
|
||||
m_bitmap = static_cast<SkinTheme*>(getTheme())->get_part(part);
|
||||
m_bitmap = part;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@ -717,24 +734,20 @@ public:
|
||||
// ContextBar.
|
||||
}
|
||||
|
||||
int getWidth() override {
|
||||
return m_bitmap->width();
|
||||
}
|
||||
|
||||
int getHeight() override {
|
||||
return m_bitmap->height();
|
||||
gfx::Size getSize() override {
|
||||
return m_bitmap->getSize();
|
||||
}
|
||||
|
||||
she::Surface* getNormalIcon() override {
|
||||
return m_bitmap;
|
||||
return m_bitmap->getBitmap(0);
|
||||
}
|
||||
|
||||
she::Surface* getSelectedIcon() override {
|
||||
return m_bitmap;
|
||||
return m_bitmap->getBitmap(0);
|
||||
}
|
||||
|
||||
she::Surface* getDisabledIcon() override {
|
||||
return m_bitmap;
|
||||
return m_bitmap->getBitmap(0);
|
||||
}
|
||||
|
||||
int getIconAlign() override {
|
||||
@ -771,9 +784,9 @@ private:
|
||||
Region rgn(m_popupWindow->getBounds().createUnion(getBounds()));
|
||||
m_popupWindow->setHotRegion(rgn);
|
||||
m_freehandAlgoButton = new ButtonSet(3);
|
||||
m_freehandAlgoButton->addItem(theme->get_part(PART_FREEHAND_ALGO_DEFAULT));
|
||||
m_freehandAlgoButton->addItem(theme->get_part(PART_FREEHAND_ALGO_PIXEL_PERFECT));
|
||||
m_freehandAlgoButton->addItem(theme->get_part(PART_FREEHAND_ALGO_DOTS));
|
||||
m_freehandAlgoButton->addItem(theme->parts.freehandAlgoDefault());
|
||||
m_freehandAlgoButton->addItem(theme->parts.freehandAlgoPixelPerfect());
|
||||
m_freehandAlgoButton->addItem(theme->parts.freehandAlgoDots());
|
||||
m_freehandAlgoButton->setSelectedItem((int)m_freehandAlgo);
|
||||
m_freehandAlgoButton->ItemChange.connect(&FreehandAlgorithmField::onFreehandAlgoChange, this);
|
||||
m_freehandAlgoButton->setTransparent(true);
|
||||
@ -804,7 +817,7 @@ private:
|
||||
Preferences::instance().tool(tool).freehandAlgorithm(m_freehandAlgo);
|
||||
}
|
||||
|
||||
she::Surface* m_bitmap;
|
||||
SkinPartPtr m_bitmap;
|
||||
FreehandAlgorithm m_freehandAlgo;
|
||||
PopupWindow* m_popupWindow;
|
||||
ButtonSet* m_freehandAlgoButton;
|
||||
@ -860,9 +873,9 @@ public:
|
||||
SelectionModeField() : ButtonSet(3) {
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
|
||||
addItem(theme->get_part(PART_SELECTION_REPLACE));
|
||||
addItem(theme->get_part(PART_SELECTION_ADD));
|
||||
addItem(theme->get_part(PART_SELECTION_SUBTRACT));
|
||||
addItem(theme->parts.selectionReplace());
|
||||
addItem(theme->parts.selectionAdd());
|
||||
addItem(theme->parts.selectionSubtract());
|
||||
|
||||
setSelectedItem((int)Preferences::instance().selection.mode());
|
||||
}
|
||||
@ -893,8 +906,8 @@ public:
|
||||
DropPixelsField() : ButtonSet(2) {
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
|
||||
addItem(theme->get_part(PART_DROP_PIXELS_OK));
|
||||
addItem(theme->get_part(PART_DROP_PIXELS_CANCEL));
|
||||
addItem(theme->parts.dropPixelsOk());
|
||||
addItem(theme->parts.dropPixelsCancel());
|
||||
setOfferCapture(false);
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,8 @@ DropDownButton::DropDownButton(const char* text)
|
||||
, m_button(new Button(text))
|
||||
, m_dropDown(new Button(""))
|
||||
{
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
setup_look(m_button, LeftButtonLook);
|
||||
setup_look(m_dropDown, RightButtonLook);
|
||||
|
||||
@ -41,10 +43,9 @@ DropDownButton::DropDownButton(const char* text)
|
||||
setChildSpacing(0);
|
||||
|
||||
m_dropDown->setIconInterface
|
||||
(new ButtonIconImpl(static_cast<SkinTheme*>(m_dropDown->getTheme()),
|
||||
PART_COMBOBOX_ARROW_DOWN,
|
||||
PART_COMBOBOX_ARROW_DOWN_SELECTED,
|
||||
PART_COMBOBOX_ARROW_DOWN_DISABLED,
|
||||
(new ButtonIconImpl(theme->parts.comboboxArrowDown(),
|
||||
theme->parts.comboboxArrowDownSelected(),
|
||||
theme->parts.comboboxArrowDownDisabled(),
|
||||
CENTER | MIDDLE));
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,10 @@ EditorView::EditorView(EditorView::Type type)
|
||||
, m_type(type)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
int l = theme->get_part(PART_EDITOR_SELECTED_W)->width();
|
||||
int t = theme->get_part(PART_EDITOR_SELECTED_N)->height();
|
||||
int r = theme->get_part(PART_EDITOR_SELECTED_E)->width();
|
||||
int b = theme->get_part(PART_EDITOR_SELECTED_S)->height();
|
||||
int l = theme->parts.editorSelected()->getBitmapW()->width();
|
||||
int t = theme->parts.editorSelected()->getBitmapN()->height();
|
||||
int r = theme->parts.editorSelected()->getBitmapE()->width();
|
||||
int b = theme->parts.editorSelected()->getBitmapS()->height();
|
||||
|
||||
setBorder(gfx::Border(l, t, r, b));
|
||||
setBgColor(gfx::rgba(0, 0, 0));
|
||||
@ -75,9 +75,11 @@ void EditorView::onPaint(PaintEvent& ev)
|
||||
|
||||
}
|
||||
|
||||
theme->draw_bounds_nw(g, getClientBounds(),
|
||||
selected ? PART_EDITOR_SELECTED_NW:
|
||||
PART_EDITOR_NORMAL_NW,
|
||||
theme->drawRect(
|
||||
g, getClientBounds(),
|
||||
(selected ?
|
||||
theme->parts.editorSelected().get():
|
||||
theme->parts.editorNormal().get()),
|
||||
getBgColor());
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ static struct HandlesInfo {
|
||||
HandleType TransformHandles::getHandleAtPoint(Editor* editor, const gfx::Point& pt, const gfx::Transformation& transform)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
she::Surface* gfx = theme->get_part(PART_TRANSFORMATION_HANDLE);
|
||||
she::Surface* gfx = theme->parts.transformationHandle()->getBitmap(0);
|
||||
fixmath::fixed angle = fixmath::ftofix(128.0 * transform.angle() / PI);
|
||||
|
||||
gfx::Transformation::Corners corners;
|
||||
@ -130,7 +130,7 @@ void TransformHandles::drawHandles(Editor* editor, const gfx::Transformation& tr
|
||||
if (visiblePivot(angle)) {
|
||||
gfx::Rect pivotBounds = getPivotHandleBounds(editor, transform, corners);
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
she::Surface* part = theme->get_part(PART_PIVOT_HANDLE);
|
||||
she::Surface* part = theme->parts.pivotHandle()->getBitmap(0);
|
||||
|
||||
g.drawRgbaSurface(part, pivotBounds.x, pivotBounds.y);
|
||||
}
|
||||
@ -151,7 +151,7 @@ void TransformHandles::invalidateHandles(Editor* editor, const gfx::Transformati
|
||||
|
||||
// Invalidate each corner handle.
|
||||
for (size_t c=0; c<HANDLES; ++c) {
|
||||
she::Surface* part = theme->get_part(PART_TRANSFORMATION_HANDLE);
|
||||
she::Surface* part = theme->parts.transformationHandle()->getBitmap(0);
|
||||
int u = (screenPoints[handles_info[c].i1].x+screenPoints[handles_info[c].i2].x)/2;
|
||||
int v = (screenPoints[handles_info[c].i1].y+screenPoints[handles_info[c].i2].y)/2;
|
||||
|
||||
@ -163,11 +163,11 @@ void TransformHandles::invalidateHandles(Editor* editor, const gfx::Transformati
|
||||
// Invalidate area where the pivot is.
|
||||
if (visiblePivot(angle)) {
|
||||
gfx::Rect pivotBounds = getPivotHandleBounds(editor, transform, corners);
|
||||
she::Surface* part = theme->get_part(PART_PIVOT_HANDLE);
|
||||
she::Surface* part = theme->parts.pivotHandle()->getBitmap(0);
|
||||
|
||||
editor->invalidateRect(
|
||||
gfx::Rect(pivotBounds.x, pivotBounds.y,
|
||||
part->width(), part->height()));
|
||||
part->width(), part->height()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,17 +176,17 @@ gfx::Rect TransformHandles::getPivotHandleBounds(Editor* editor,
|
||||
const gfx::Transformation::Corners& corners)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
she::Surface* part = theme->get_part(PART_PIVOT_HANDLE);
|
||||
gfx::Size partSize = theme->parts.pivotHandle()->getSize();
|
||||
gfx::Point screenPivotPos = editor->editorToScreen(transform.pivot());
|
||||
|
||||
screenPivotPos.x += editor->zoom().apply(1) / 2;
|
||||
screenPivotPos.y += editor->zoom().apply(1) / 2;
|
||||
|
||||
return gfx::Rect(
|
||||
screenPivotPos.x-part->width()/2,
|
||||
screenPivotPos.y-part->height()/2,
|
||||
part->width(),
|
||||
part->height());
|
||||
screenPivotPos.x-partSize.w/2,
|
||||
screenPivotPos.y-partSize.h/2,
|
||||
partSize.w,
|
||||
partSize.h);
|
||||
}
|
||||
|
||||
bool TransformHandles::inHandle(const gfx::Point& pt, int x, int y, int gfx_w, int gfx_h, fixmath::fixed angle)
|
||||
@ -200,7 +200,7 @@ bool TransformHandles::inHandle(const gfx::Point& pt, int x, int y, int gfx_w, i
|
||||
void TransformHandles::drawHandle(Graphics* g, int x, int y, fixmath::fixed angle)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(CurrentTheme::get());
|
||||
she::Surface* part = theme->get_part(PART_TRANSFORMATION_HANDLE);
|
||||
she::Surface* part = theme->parts.transformationHandle()->getBitmap(0);
|
||||
|
||||
adjustHandle(x, y, part->width(), part->height(), angle);
|
||||
|
||||
|
@ -21,7 +21,8 @@
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/recent_files.h"
|
||||
#include "app/ui/file_list.h"
|
||||
#include "app/ui/skin/skin_parts.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/widget_loader.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/convert_to.h"
|
||||
@ -239,6 +240,7 @@ FileSelector::FileSelector(FileSelectorType type, FileSelectorDelegate* delegate
|
||||
, m_delegate(delegate)
|
||||
, m_navigationLocked(false)
|
||||
{
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
bool withResizeOptions = (delegate && delegate->hasResizeCombobox());
|
||||
|
||||
addChild(new ArrowNavigator(this));
|
||||
@ -252,26 +254,26 @@ FileSelector::FileSelector(FileSelectorType type, FileSelectorDelegate* delegate
|
||||
goUpButton()->setFocusStop(false);
|
||||
newFolderButton()->setFocusStop(false);
|
||||
|
||||
set_gfxicon_to_button(goBackButton(),
|
||||
PART_COMBOBOX_ARROW_LEFT,
|
||||
PART_COMBOBOX_ARROW_LEFT_SELECTED,
|
||||
PART_COMBOBOX_ARROW_LEFT_DISABLED,
|
||||
CENTER | MIDDLE);
|
||||
set_gfxicon_to_button(goForwardButton(),
|
||||
PART_COMBOBOX_ARROW_RIGHT,
|
||||
PART_COMBOBOX_ARROW_RIGHT_SELECTED,
|
||||
PART_COMBOBOX_ARROW_RIGHT_DISABLED,
|
||||
CENTER | MIDDLE);
|
||||
set_gfxicon_to_button(goUpButton(),
|
||||
PART_COMBOBOX_ARROW_UP,
|
||||
PART_COMBOBOX_ARROW_UP_SELECTED,
|
||||
PART_COMBOBOX_ARROW_UP_DISABLED,
|
||||
CENTER | MIDDLE);
|
||||
set_gfxicon_to_button(newFolderButton(),
|
||||
PART_NEWFOLDER,
|
||||
PART_NEWFOLDER_SELECTED,
|
||||
PART_NEWFOLDER,
|
||||
CENTER | MIDDLE);
|
||||
goBackButton()->setIconInterface(
|
||||
new ButtonIconImpl(theme->parts.comboboxArrowLeft(),
|
||||
theme->parts.comboboxArrowLeftSelected(),
|
||||
theme->parts.comboboxArrowLeftDisabled(),
|
||||
CENTER | MIDDLE));
|
||||
goForwardButton()->setIconInterface(
|
||||
new ButtonIconImpl(theme->parts.comboboxArrowRight(),
|
||||
theme->parts.comboboxArrowRightSelected(),
|
||||
theme->parts.comboboxArrowRightDisabled(),
|
||||
CENTER | MIDDLE));
|
||||
goUpButton()->setIconInterface(
|
||||
new ButtonIconImpl(theme->parts.comboboxArrowUp(),
|
||||
theme->parts.comboboxArrowUpSelected(),
|
||||
theme->parts.comboboxArrowUpDisabled(),
|
||||
CENTER | MIDDLE));
|
||||
newFolderButton()->setIconInterface(
|
||||
new ButtonIconImpl(theme->parts.newfolder(),
|
||||
theme->parts.newfolderSelected(),
|
||||
theme->parts.newfolder(),
|
||||
CENTER | MIDDLE));
|
||||
|
||||
setup_mini_look(goBackButton());
|
||||
setup_mini_look(goForwardButton());
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "app/modules/gfx.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/skin/button_icon_impl.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "base/bind.h"
|
||||
#include "gfx/border.h"
|
||||
@ -30,14 +31,18 @@ PopupWindowPin::PopupWindowPin(const std::string& text, ClickBehavior clickBehav
|
||||
: PopupWindow(text, clickBehavior)
|
||||
, m_pin("")
|
||||
{
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
// Configure the micro check-box look without borders, only the "pin" icon is shown.
|
||||
setup_look(&m_pin, WithoutBordersLook);
|
||||
m_pin.setChildSpacing(0);
|
||||
m_pin.setBorder(gfx::Border(0));
|
||||
|
||||
m_pin.Click.connect(&PopupWindowPin::onPinClick, this);
|
||||
|
||||
set_gfxicon_to_button(&m_pin, PART_UNPINNED, PART_PINNED, PART_UNPINNED, CENTER | MIDDLE);
|
||||
m_pin.setIconInterface(
|
||||
new ButtonIconImpl(theme->parts.unpinned(),
|
||||
theme->parts.pinned(),
|
||||
theme->parts.unpinned(),
|
||||
CENTER | MIDDLE));
|
||||
}
|
||||
|
||||
void PopupWindowPin::onPinClick(Event& ev)
|
||||
|
@ -46,9 +46,9 @@ class MiniCenterButton : public SkinButton<CheckBox> {
|
||||
public:
|
||||
MiniCenterButton()
|
||||
: SkinButton<CheckBox>(
|
||||
PART_WINDOW_CENTER_BUTTON_NORMAL,
|
||||
PART_WINDOW_CENTER_BUTTON_HOT,
|
||||
PART_WINDOW_CENTER_BUTTON_SELECTED)
|
||||
SkinTheme::instance()->parts.windowCenterButtonNormal(),
|
||||
SkinTheme::instance()->parts.windowCenterButtonHot(),
|
||||
SkinTheme::instance()->parts.windowCenterButtonSelected())
|
||||
{
|
||||
setup_bevels(this, 0, 0, 0, 0);
|
||||
setDecorative(true);
|
||||
@ -56,13 +56,12 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
void onSetDecorativeWidgetBounds() override
|
||||
{
|
||||
void onSetDecorativeWidgetBounds() override {
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
Widget* window = getParent();
|
||||
gfx::Rect rect(0, 0, 0, 0);
|
||||
gfx::Size iconSize = theme->get_part_size(PART_WINDOW_PLAY_BUTTON_NORMAL);
|
||||
gfx::Size closeSize = theme->get_part_size(PART_WINDOW_CLOSE_BUTTON_NORMAL);
|
||||
gfx::Size iconSize = theme->parts.windowPlayButtonNormal()->getSize();
|
||||
gfx::Size closeSize = theme->parts.windowCloseButtonNormal()->getSize();
|
||||
|
||||
rect.w = iconSize.w;
|
||||
rect.h = iconSize.h;
|
||||
@ -91,11 +90,11 @@ protected:
|
||||
class MiniPlayButton : public SkinButton<Button> {
|
||||
public:
|
||||
MiniPlayButton()
|
||||
: SkinButton<Button>(PART_WINDOW_PLAY_BUTTON_NORMAL,
|
||||
PART_WINDOW_PLAY_BUTTON_HOT,
|
||||
PART_WINDOW_PLAY_BUTTON_SELECTED)
|
||||
, m_isPlaying(false)
|
||||
{
|
||||
: SkinButton<Button>(SkinPartPtr(nullptr),
|
||||
SkinPartPtr(nullptr),
|
||||
SkinPartPtr(nullptr))
|
||||
, m_isPlaying(false) {
|
||||
setupIcons();
|
||||
setup_bevels(this, 0, 0, 0, 0);
|
||||
setDecorative(true);
|
||||
}
|
||||
@ -104,29 +103,21 @@ public:
|
||||
|
||||
Signal0<void> Popup;
|
||||
|
||||
protected:
|
||||
void onClick(Event& ev) override
|
||||
{
|
||||
private:
|
||||
|
||||
void onClick(Event& ev) override {
|
||||
m_isPlaying = !m_isPlaying;
|
||||
if (m_isPlaying)
|
||||
setParts(PART_WINDOW_STOP_BUTTON_NORMAL,
|
||||
PART_WINDOW_STOP_BUTTON_HOT,
|
||||
PART_WINDOW_STOP_BUTTON_SELECTED);
|
||||
else
|
||||
setParts(PART_WINDOW_PLAY_BUTTON_NORMAL,
|
||||
PART_WINDOW_PLAY_BUTTON_HOT,
|
||||
PART_WINDOW_PLAY_BUTTON_SELECTED);
|
||||
setupIcons();
|
||||
|
||||
SkinButton<Button>::onClick(ev);
|
||||
}
|
||||
|
||||
void onSetDecorativeWidgetBounds() override
|
||||
{
|
||||
void onSetDecorativeWidgetBounds() override {
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(getTheme());
|
||||
Widget* window = getParent();
|
||||
gfx::Rect rect(0, 0, 0, 0);
|
||||
gfx::Size playSize = theme->get_part_size(PART_WINDOW_PLAY_BUTTON_NORMAL);
|
||||
gfx::Size closeSize = theme->get_part_size(PART_WINDOW_CLOSE_BUTTON_NORMAL);
|
||||
gfx::Size playSize = theme->parts.windowPlayButtonNormal()->getSize();
|
||||
gfx::Size closeSize = theme->parts.windowCloseButtonNormal()->getSize();
|
||||
|
||||
rect.w = playSize.w;
|
||||
rect.h = playSize.h;
|
||||
@ -138,8 +129,7 @@ protected:
|
||||
setBounds(rect);
|
||||
}
|
||||
|
||||
bool onProcessMessage(Message* msg) override
|
||||
{
|
||||
bool onProcessMessage(Message* msg) override {
|
||||
switch (msg->type()) {
|
||||
|
||||
case kSetCursorMessage:
|
||||
@ -164,7 +154,19 @@ protected:
|
||||
return SkinButton<Button>::onProcessMessage(msg);
|
||||
}
|
||||
|
||||
private:
|
||||
void setupIcons() {
|
||||
SkinTheme* theme = SkinTheme::instance();
|
||||
|
||||
if (m_isPlaying)
|
||||
setParts(theme->parts.windowStopButtonNormal(),
|
||||
theme->parts.windowStopButtonHot(),
|
||||
theme->parts.windowStopButtonSelected());
|
||||
else
|
||||
setParts(theme->parts.windowPlayButtonNormal(),
|
||||
theme->parts.windowPlayButtonHot(),
|
||||
theme->parts.windowPlayButtonSelected());
|
||||
}
|
||||
|
||||
bool m_isPlaying;
|
||||
};
|
||||
|
||||
|
@ -18,18 +18,15 @@ namespace app {
|
||||
|
||||
using namespace app::skin;
|
||||
|
||||
ButtonIconImpl::ButtonIconImpl(SkinTheme* theme,
|
||||
int normalIcon,
|
||||
int selectedIcon,
|
||||
int disabledIcon,
|
||||
ButtonIconImpl::ButtonIconImpl(const SkinPartPtr& normalIcon,
|
||||
const SkinPartPtr& selectedIcon,
|
||||
const SkinPartPtr& disabledIcon,
|
||||
int iconAlign)
|
||||
: m_theme(theme)
|
||||
, m_normalIcon(normalIcon)
|
||||
: m_normalIcon(normalIcon)
|
||||
, m_selectedIcon(selectedIcon)
|
||||
, m_disabledIcon(disabledIcon)
|
||||
, m_iconAlign(iconAlign)
|
||||
{
|
||||
ASSERT(theme != NULL);
|
||||
}
|
||||
|
||||
void ButtonIconImpl::destroy()
|
||||
@ -37,29 +34,24 @@ void ButtonIconImpl::destroy()
|
||||
delete this;
|
||||
}
|
||||
|
||||
int ButtonIconImpl::getWidth()
|
||||
gfx::Size ButtonIconImpl::getSize()
|
||||
{
|
||||
return m_theme->get_part(m_normalIcon)->width();
|
||||
}
|
||||
|
||||
int ButtonIconImpl::getHeight()
|
||||
{
|
||||
return m_theme->get_part(m_normalIcon)->height();
|
||||
return m_normalIcon ? m_normalIcon->getSize(): gfx::Size(0, 0);
|
||||
}
|
||||
|
||||
she::Surface* ButtonIconImpl::getNormalIcon()
|
||||
{
|
||||
return m_theme->get_part(m_normalIcon);
|
||||
return m_normalIcon ? m_normalIcon->getBitmap(0): nullptr;
|
||||
}
|
||||
|
||||
she::Surface* ButtonIconImpl::getSelectedIcon()
|
||||
{
|
||||
return m_theme->get_part(m_selectedIcon);
|
||||
return m_selectedIcon ? m_selectedIcon->getBitmap(0): nullptr;
|
||||
}
|
||||
|
||||
she::Surface* ButtonIconImpl::getDisabledIcon()
|
||||
{
|
||||
return m_theme->get_part(m_disabledIcon);
|
||||
return m_disabledIcon ? m_disabledIcon->getBitmap(0): nullptr;
|
||||
}
|
||||
|
||||
int ButtonIconImpl::getIconAlign()
|
||||
|
@ -9,6 +9,7 @@
|
||||
#define APP_UI_SKIN_BUTTON_ICON_IMPL_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/skin/skin_part.h"
|
||||
#include "ui/button.h"
|
||||
|
||||
namespace app {
|
||||
@ -18,26 +19,23 @@ namespace app {
|
||||
|
||||
class ButtonIconImpl : public ui::IButtonIcon {
|
||||
public:
|
||||
ButtonIconImpl(SkinTheme* theme,
|
||||
int normalIcon,
|
||||
int selectedIcon,
|
||||
int disabledIcon,
|
||||
ButtonIconImpl(const SkinPartPtr& normalIcon,
|
||||
const SkinPartPtr& selectedIcon,
|
||||
const SkinPartPtr& disabledIcon,
|
||||
int iconAlign);
|
||||
|
||||
// IButtonIcon implementation
|
||||
void destroy();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
gfx::Size getSize();
|
||||
she::Surface* getNormalIcon();
|
||||
she::Surface* getSelectedIcon();
|
||||
she::Surface* getDisabledIcon();
|
||||
int getIconAlign();
|
||||
|
||||
public:
|
||||
SkinTheme* m_theme;
|
||||
int m_normalIcon;
|
||||
int m_selectedIcon;
|
||||
int m_disabledIcon;
|
||||
SkinPartPtr m_normalIcon;
|
||||
SkinPartPtr m_selectedIcon;
|
||||
SkinPartPtr m_disabledIcon;
|
||||
int m_iconAlign;
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define APP_UI_SKIN_SKIN_BUTTON_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/skin/skin_parts.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "ui/button.h"
|
||||
#include "ui/graphics.h"
|
||||
@ -21,9 +20,9 @@ namespace app {
|
||||
template<typename Base = ui::Button>
|
||||
class SkinButton : public Base {
|
||||
public:
|
||||
SkinButton(SkinParts partNormal,
|
||||
SkinParts partHot,
|
||||
SkinParts partSelected)
|
||||
SkinButton(const SkinPartPtr& partNormal,
|
||||
const SkinPartPtr& partHot,
|
||||
const SkinPartPtr& partSelected)
|
||||
: Base("")
|
||||
, m_partNormal(partNormal)
|
||||
, m_partHot(partHot)
|
||||
@ -31,9 +30,9 @@ namespace app {
|
||||
{
|
||||
}
|
||||
|
||||
void setParts(SkinParts partNormal,
|
||||
SkinParts partHot,
|
||||
SkinParts partSelected) {
|
||||
void setParts(const SkinPartPtr& partNormal,
|
||||
const SkinPartPtr& partHot,
|
||||
const SkinPartPtr& partSelected) {
|
||||
m_partNormal = partNormal;
|
||||
m_partHot = partHot;
|
||||
m_partSelected = partSelected;
|
||||
@ -45,7 +44,7 @@ namespace app {
|
||||
gfx::Rect bounds(Base::getClientBounds());
|
||||
ui::Graphics* g = ev.getGraphics();
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(Base::getTheme());
|
||||
SkinParts part;
|
||||
SkinPartPtr part;
|
||||
|
||||
if (Base::isSelected())
|
||||
part = m_partSelected;
|
||||
@ -54,13 +53,13 @@ namespace app {
|
||||
else
|
||||
part = m_partNormal;
|
||||
|
||||
g->drawRgbaSurface(theme->get_part(part), bounds.x, bounds.y);
|
||||
g->drawRgbaSurface(part->getBitmap(0), bounds.x, bounds.y);
|
||||
}
|
||||
|
||||
private:
|
||||
SkinParts m_partNormal;
|
||||
SkinParts m_partHot;
|
||||
SkinParts m_partSelected;
|
||||
SkinPartPtr m_partNormal;
|
||||
SkinPartPtr m_partHot;
|
||||
SkinPartPtr m_partSelected;
|
||||
};
|
||||
|
||||
} // namespace skin
|
||||
|
@ -44,5 +44,14 @@ void SkinPart::setBitmap(std::size_t index, she::Surface* bitmap)
|
||||
m_bitmaps[index] = bitmap;
|
||||
}
|
||||
|
||||
gfx::Size SkinPart::getSize() const
|
||||
{
|
||||
if (!m_bitmaps.empty())
|
||||
return gfx::Size(m_bitmaps[0]->width(),
|
||||
m_bitmaps[0]->height());
|
||||
else
|
||||
return gfx::Size(0, 0);
|
||||
}
|
||||
|
||||
} // namespace skin
|
||||
} // namespace app
|
||||
|
@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/shared_ptr.h"
|
||||
#include "gfx/size.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -27,8 +28,7 @@ namespace app {
|
||||
SkinPart();
|
||||
~SkinPart();
|
||||
|
||||
std::size_t size() const { return m_bitmaps.size(); }
|
||||
|
||||
std::size_t countBitmaps() const { return m_bitmaps.size(); }
|
||||
void clear();
|
||||
|
||||
// It doesn't destroy the previous bitmap in the given "index".
|
||||
@ -38,6 +38,17 @@ namespace app {
|
||||
return (index < m_bitmaps.size() ? m_bitmaps[index]: NULL);
|
||||
}
|
||||
|
||||
she::Surface* getBitmapNW() const { return getBitmap(0); }
|
||||
she::Surface* getBitmapN() const { return getBitmap(1); }
|
||||
she::Surface* getBitmapNE() const { return getBitmap(2); }
|
||||
she::Surface* getBitmapE() const { return getBitmap(3); }
|
||||
she::Surface* getBitmapSE() const { return getBitmap(4); }
|
||||
she::Surface* getBitmapS() const { return getBitmap(5); }
|
||||
she::Surface* getBitmapSW() const { return getBitmap(6); }
|
||||
she::Surface* getBitmapW() const { return getBitmap(7); }
|
||||
|
||||
gfx::Size getSize() const;
|
||||
|
||||
private:
|
||||
Bitmaps m_bitmaps;
|
||||
};
|
||||
|
@ -1,203 +0,0 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
// published by the Free Software Foundation.
|
||||
|
||||
#ifndef APP_UI_SKIN_SKIN_PARTS_H_INCLUDED
|
||||
#define APP_UI_SKIN_SKIN_PARTS_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
namespace app {
|
||||
namespace skin {
|
||||
|
||||
#define SKIN_PART_NESW(name) \
|
||||
name##_NW, \
|
||||
name##_N, \
|
||||
name##_NE, \
|
||||
name##_E, \
|
||||
name##_SE, \
|
||||
name##_S, \
|
||||
name##_SW, \
|
||||
name##_W
|
||||
|
||||
// TODO remove this enum, we use skin::Style now.
|
||||
// Available parts in the skin sheet
|
||||
enum SkinParts {
|
||||
|
||||
PART_NONE,
|
||||
|
||||
PART_RADIO_NORMAL,
|
||||
PART_RADIO_SELECTED,
|
||||
PART_RADIO_DISABLED,
|
||||
|
||||
PART_CHECK_NORMAL,
|
||||
PART_CHECK_SELECTED,
|
||||
PART_CHECK_DISABLED,
|
||||
|
||||
SKIN_PART_NESW(PART_CHECK_FOCUS),
|
||||
SKIN_PART_NESW(PART_RADIO_FOCUS),
|
||||
SKIN_PART_NESW(PART_BUTTON_NORMAL),
|
||||
SKIN_PART_NESW(PART_BUTTON_HOT),
|
||||
SKIN_PART_NESW(PART_BUTTON_FOCUSED),
|
||||
SKIN_PART_NESW(PART_BUTTON_SELECTED),
|
||||
SKIN_PART_NESW(PART_SUNKEN_NORMAL),
|
||||
SKIN_PART_NESW(PART_SUNKEN_FOCUSED),
|
||||
SKIN_PART_NESW(PART_SUNKEN2_NORMAL),
|
||||
SKIN_PART_NESW(PART_SUNKEN2_FOCUSED),
|
||||
SKIN_PART_NESW(PART_SUNKEN_MINI_NORMAL),
|
||||
SKIN_PART_NESW(PART_SUNKEN_MINI_FOCUSED),
|
||||
|
||||
PART_WINDOW_CLOSE_BUTTON_NORMAL,
|
||||
PART_WINDOW_CLOSE_BUTTON_HOT,
|
||||
PART_WINDOW_CLOSE_BUTTON_SELECTED,
|
||||
|
||||
PART_WINDOW_PLAY_BUTTON_NORMAL,
|
||||
PART_WINDOW_PLAY_BUTTON_HOT,
|
||||
PART_WINDOW_PLAY_BUTTON_SELECTED,
|
||||
|
||||
PART_WINDOW_STOP_BUTTON_NORMAL,
|
||||
PART_WINDOW_STOP_BUTTON_HOT,
|
||||
PART_WINDOW_STOP_BUTTON_SELECTED,
|
||||
|
||||
PART_WINDOW_CENTER_BUTTON_NORMAL,
|
||||
PART_WINDOW_CENTER_BUTTON_HOT,
|
||||
PART_WINDOW_CENTER_BUTTON_SELECTED,
|
||||
|
||||
SKIN_PART_NESW(PART_SLIDER_FULL),
|
||||
SKIN_PART_NESW(PART_SLIDER_EMPTY),
|
||||
SKIN_PART_NESW(PART_SLIDER_FULL_FOCUSED),
|
||||
SKIN_PART_NESW(PART_SLIDER_EMPTY_FOCUSED),
|
||||
SKIN_PART_NESW(PART_MINI_SLIDER_FULL),
|
||||
SKIN_PART_NESW(PART_MINI_SLIDER_EMPTY),
|
||||
SKIN_PART_NESW(PART_MINI_SLIDER_FULL_FOCUSED),
|
||||
SKIN_PART_NESW(PART_MINI_SLIDER_EMPTY_FOCUSED),
|
||||
|
||||
PART_MINI_SLIDER_THUMB,
|
||||
PART_MINI_SLIDER_THUMB_FOCUSED,
|
||||
|
||||
PART_SEPARATOR_HORZ,
|
||||
PART_SEPARATOR_VERT,
|
||||
|
||||
PART_COMBOBOX_ARROW_DOWN,
|
||||
PART_COMBOBOX_ARROW_DOWN_SELECTED,
|
||||
PART_COMBOBOX_ARROW_DOWN_DISABLED,
|
||||
PART_COMBOBOX_ARROW_UP,
|
||||
PART_COMBOBOX_ARROW_UP_SELECTED,
|
||||
PART_COMBOBOX_ARROW_UP_DISABLED,
|
||||
PART_COMBOBOX_ARROW_LEFT,
|
||||
PART_COMBOBOX_ARROW_LEFT_SELECTED,
|
||||
PART_COMBOBOX_ARROW_LEFT_DISABLED,
|
||||
PART_COMBOBOX_ARROW_RIGHT,
|
||||
PART_COMBOBOX_ARROW_RIGHT_SELECTED,
|
||||
PART_COMBOBOX_ARROW_RIGHT_DISABLED,
|
||||
|
||||
PART_NEWFOLDER,
|
||||
PART_NEWFOLDER_SELECTED,
|
||||
|
||||
SKIN_PART_NESW(PART_TOOLBUTTON_NORMAL),
|
||||
SKIN_PART_NESW(PART_TOOLBUTTON_HOT),
|
||||
SKIN_PART_NESW(PART_TOOLBUTTON_LAST),
|
||||
SKIN_PART_NESW(PART_TOOLBUTTON_PUSHED),
|
||||
|
||||
SKIN_PART_NESW(PART_EDITOR_NORMAL),
|
||||
SKIN_PART_NESW(PART_EDITOR_SELECTED),
|
||||
|
||||
SKIN_PART_NESW(PART_COLORBAR_0),
|
||||
SKIN_PART_NESW(PART_COLORBAR_1),
|
||||
SKIN_PART_NESW(PART_COLORBAR_2),
|
||||
SKIN_PART_NESW(PART_COLORBAR_3),
|
||||
SKIN_PART_NESW(PART_COLORBAR_BORDER_FG),
|
||||
SKIN_PART_NESW(PART_COLORBAR_BORDER_BG),
|
||||
SKIN_PART_NESW(PART_COLORBAR_BORDER_HOTFG),
|
||||
SKIN_PART_NESW(PART_TOOLTIP),
|
||||
SKIN_PART_NESW(PART_TOOLTIP_ARROW),
|
||||
|
||||
PART_ANI_FIRST,
|
||||
PART_ANI_PREVIOUS,
|
||||
PART_ANI_PLAY,
|
||||
PART_ANI_STOP,
|
||||
PART_ANI_NEXT,
|
||||
PART_ANI_LAST,
|
||||
|
||||
PART_PAL_EDIT,
|
||||
PART_PAL_SORT,
|
||||
PART_PAL_PRESETS,
|
||||
PART_PAL_OPTIONS,
|
||||
|
||||
PART_TARGET_ONE,
|
||||
PART_TARGET_ONE_SELECTED,
|
||||
PART_TARGET_FRAMES,
|
||||
PART_TARGET_FRAMES_SELECTED,
|
||||
PART_TARGET_LAYERS,
|
||||
PART_TARGET_LAYERS_SELECTED,
|
||||
PART_TARGET_FRAMES_LAYERS,
|
||||
PART_TARGET_FRAMES_LAYERS_SELECTED,
|
||||
|
||||
PART_SCALE_ARROW_1,
|
||||
PART_SCALE_ARROW_2,
|
||||
PART_SCALE_ARROW_3,
|
||||
PART_ROTATE_ARROW_1,
|
||||
PART_ROTATE_ARROW_2,
|
||||
PART_ROTATE_ARROW_3,
|
||||
|
||||
PART_SELECTION_REPLACE,
|
||||
PART_SELECTION_REPLACE_SELECTED,
|
||||
PART_SELECTION_ADD,
|
||||
PART_SELECTION_ADD_SELECTED,
|
||||
PART_SELECTION_SUBTRACT,
|
||||
PART_SELECTION_SUBTRACT_SELECTED,
|
||||
|
||||
PART_UNPINNED,
|
||||
PART_PINNED,
|
||||
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_LEFT_NORMAL),
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_LEFT_HOT),
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_LEFT_FOCUSED),
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_LEFT_SELECTED),
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_RIGHT_NORMAL),
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_RIGHT_HOT),
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_RIGHT_FOCUSED),
|
||||
SKIN_PART_NESW(PART_DROP_DOWN_BUTTON_RIGHT_SELECTED),
|
||||
|
||||
PART_TRANSFORMATION_HANDLE,
|
||||
PART_PIVOT_HANDLE,
|
||||
|
||||
PART_DROP_PIXELS_OK,
|
||||
PART_DROP_PIXELS_OK_SELECTED,
|
||||
PART_DROP_PIXELS_CANCEL,
|
||||
PART_DROP_PIXELS_CANCEL_SELECTED,
|
||||
|
||||
PART_FREEHAND_ALGO_DEFAULT,
|
||||
PART_FREEHAND_ALGO_DEFAULT_SELECTED,
|
||||
PART_FREEHAND_ALGO_PIXEL_PERFECT,
|
||||
PART_FREEHAND_ALGO_PIXEL_PERFECT_SELECTED,
|
||||
PART_FREEHAND_ALGO_DOTS,
|
||||
PART_FREEHAND_ALGO_DOTS_SELECTED,
|
||||
|
||||
PART_INK_DEFAULT,
|
||||
PART_INK_COPY_COLOR,
|
||||
PART_INK_LOCK_ALPHA,
|
||||
|
||||
PART_SELECTION_OPAQUE,
|
||||
PART_SELECTION_MASKED,
|
||||
|
||||
PART_PIVOT_HIDDEN,
|
||||
PART_PIVOT_NORTHWEST,
|
||||
PART_PIVOT_NORTH,
|
||||
PART_PIVOT_NORTHEAST,
|
||||
PART_PIVOT_WEST,
|
||||
PART_PIVOT_CENTER,
|
||||
PART_PIVOT_EAST,
|
||||
PART_PIVOT_SOUTHWEST,
|
||||
PART_PIVOT_SOUTH,
|
||||
PART_PIVOT_SOUTHEAST,
|
||||
|
||||
PARTS
|
||||
};
|
||||
|
||||
} // namespace skin
|
||||
} // namespace app
|
||||
|
||||
#endif
|
@ -49,8 +49,6 @@ namespace skin {
|
||||
using namespace gfx;
|
||||
using namespace ui;
|
||||
|
||||
static std::map<std::string, int> sheet_mapping;
|
||||
|
||||
const char* SkinTheme::kThemeCloseButtonId = "theme_close_button";
|
||||
|
||||
// Controls the "X" button in a window to close it.
|
||||
@ -153,146 +151,6 @@ SkinTheme::SkinTheme()
|
||||
|
||||
// Initialize all graphics in NULL (these bitmaps are loaded from the skin)
|
||||
m_sheet = NULL;
|
||||
m_part.resize(PARTS, NULL);
|
||||
|
||||
sheet_mapping["radio_normal"] = PART_RADIO_NORMAL;
|
||||
sheet_mapping["radio_selected"] = PART_RADIO_SELECTED;
|
||||
sheet_mapping["radio_disabled"] = PART_RADIO_DISABLED;
|
||||
sheet_mapping["check_normal"] = PART_CHECK_NORMAL;
|
||||
sheet_mapping["check_selected"] = PART_CHECK_SELECTED;
|
||||
sheet_mapping["check_disabled"] = PART_CHECK_DISABLED;
|
||||
sheet_mapping["check_focus"] = PART_CHECK_FOCUS_NW;
|
||||
sheet_mapping["radio_focus"] = PART_RADIO_FOCUS_NW;
|
||||
sheet_mapping["button_normal"] = PART_BUTTON_NORMAL_NW;
|
||||
sheet_mapping["button_hot"] = PART_BUTTON_HOT_NW;
|
||||
sheet_mapping["button_focused"] = PART_BUTTON_FOCUSED_NW;
|
||||
sheet_mapping["button_selected"] = PART_BUTTON_SELECTED_NW;
|
||||
sheet_mapping["sunken_normal"] = PART_SUNKEN_NORMAL_NW;
|
||||
sheet_mapping["sunken_focused"] = PART_SUNKEN_FOCUSED_NW;
|
||||
sheet_mapping["sunken2_normal"] = PART_SUNKEN2_NORMAL_NW;
|
||||
sheet_mapping["sunken2_focused"] = PART_SUNKEN2_FOCUSED_NW;
|
||||
sheet_mapping["sunken_mini_normal"] = PART_SUNKEN_MINI_NORMAL_NW;
|
||||
sheet_mapping["sunken_mini_focused"] = PART_SUNKEN_MINI_FOCUSED_NW;
|
||||
sheet_mapping["window_close_button_normal"] = PART_WINDOW_CLOSE_BUTTON_NORMAL;
|
||||
sheet_mapping["window_close_button_hot"] = PART_WINDOW_CLOSE_BUTTON_HOT;
|
||||
sheet_mapping["window_close_button_selected"] = PART_WINDOW_CLOSE_BUTTON_SELECTED;
|
||||
sheet_mapping["window_play_button_normal"] = PART_WINDOW_PLAY_BUTTON_NORMAL;
|
||||
sheet_mapping["window_play_button_hot"] = PART_WINDOW_PLAY_BUTTON_HOT;
|
||||
sheet_mapping["window_play_button_selected"] = PART_WINDOW_PLAY_BUTTON_SELECTED;
|
||||
sheet_mapping["window_stop_button_normal"] = PART_WINDOW_STOP_BUTTON_NORMAL;
|
||||
sheet_mapping["window_stop_button_hot"] = PART_WINDOW_STOP_BUTTON_HOT;
|
||||
sheet_mapping["window_stop_button_selected"] = PART_WINDOW_STOP_BUTTON_SELECTED;
|
||||
sheet_mapping["window_center_button_normal"] = PART_WINDOW_CENTER_BUTTON_NORMAL;
|
||||
sheet_mapping["window_center_button_hot"] = PART_WINDOW_CENTER_BUTTON_HOT;
|
||||
sheet_mapping["window_center_button_selected"] = PART_WINDOW_CENTER_BUTTON_SELECTED;
|
||||
sheet_mapping["slider_full"] = PART_SLIDER_FULL_NW;
|
||||
sheet_mapping["slider_empty"] = PART_SLIDER_EMPTY_NW;
|
||||
sheet_mapping["slider_full_focused"] = PART_SLIDER_FULL_FOCUSED_NW;
|
||||
sheet_mapping["slider_empty_focused"] = PART_SLIDER_EMPTY_FOCUSED_NW;
|
||||
sheet_mapping["mini_slider_full"] = PART_MINI_SLIDER_FULL_NW;
|
||||
sheet_mapping["mini_slider_empty"] = PART_MINI_SLIDER_EMPTY_NW;
|
||||
sheet_mapping["mini_slider_full_focused"] = PART_MINI_SLIDER_FULL_FOCUSED_NW;
|
||||
sheet_mapping["mini_slider_empty_focused"] = PART_MINI_SLIDER_EMPTY_FOCUSED_NW;
|
||||
sheet_mapping["mini_slider_thumb"] = PART_MINI_SLIDER_THUMB;
|
||||
sheet_mapping["mini_slider_thumb_focused"] = PART_MINI_SLIDER_THUMB_FOCUSED;
|
||||
sheet_mapping["separator_horz"] = PART_SEPARATOR_HORZ;
|
||||
sheet_mapping["separator_vert"] = PART_SEPARATOR_VERT;
|
||||
sheet_mapping["combobox_arrow_down"] = PART_COMBOBOX_ARROW_DOWN;
|
||||
sheet_mapping["combobox_arrow_down_selected"] = PART_COMBOBOX_ARROW_DOWN_SELECTED;
|
||||
sheet_mapping["combobox_arrow_down_disabled"] = PART_COMBOBOX_ARROW_DOWN_DISABLED;
|
||||
sheet_mapping["combobox_arrow_up"] = PART_COMBOBOX_ARROW_UP;
|
||||
sheet_mapping["combobox_arrow_up_selected"] = PART_COMBOBOX_ARROW_UP_SELECTED;
|
||||
sheet_mapping["combobox_arrow_up_disabled"] = PART_COMBOBOX_ARROW_UP_DISABLED;
|
||||
sheet_mapping["combobox_arrow_left"] = PART_COMBOBOX_ARROW_LEFT;
|
||||
sheet_mapping["combobox_arrow_left_selected"] = PART_COMBOBOX_ARROW_LEFT_SELECTED;
|
||||
sheet_mapping["combobox_arrow_left_disabled"] = PART_COMBOBOX_ARROW_LEFT_DISABLED;
|
||||
sheet_mapping["combobox_arrow_right"] = PART_COMBOBOX_ARROW_RIGHT;
|
||||
sheet_mapping["combobox_arrow_right_selected"] = PART_COMBOBOX_ARROW_RIGHT_SELECTED;
|
||||
sheet_mapping["combobox_arrow_right_disabled"] = PART_COMBOBOX_ARROW_RIGHT_DISABLED;
|
||||
sheet_mapping["newfolder"] = PART_NEWFOLDER;
|
||||
sheet_mapping["newfolder_selected"] = PART_NEWFOLDER_SELECTED;
|
||||
sheet_mapping["toolbutton_normal"] = PART_TOOLBUTTON_NORMAL_NW;
|
||||
sheet_mapping["toolbutton_hot"] = PART_TOOLBUTTON_HOT_NW;
|
||||
sheet_mapping["toolbutton_last"] = PART_TOOLBUTTON_LAST_NW;
|
||||
sheet_mapping["toolbutton_pushed"] = PART_TOOLBUTTON_PUSHED_NW;
|
||||
sheet_mapping["editor_normal"] = PART_EDITOR_NORMAL_NW;
|
||||
sheet_mapping["editor_selected"] = PART_EDITOR_SELECTED_NW;
|
||||
sheet_mapping["colorbar_0"] = PART_COLORBAR_0_NW;
|
||||
sheet_mapping["colorbar_1"] = PART_COLORBAR_1_NW;
|
||||
sheet_mapping["colorbar_2"] = PART_COLORBAR_2_NW;
|
||||
sheet_mapping["colorbar_3"] = PART_COLORBAR_3_NW;
|
||||
sheet_mapping["colorbar_border_fg"] = PART_COLORBAR_BORDER_FG_NW;
|
||||
sheet_mapping["colorbar_border_bg"] = PART_COLORBAR_BORDER_BG_NW;
|
||||
sheet_mapping["colorbar_border_hotfg"] = PART_COLORBAR_BORDER_HOTFG_NW;
|
||||
sheet_mapping["tooltip"] = PART_TOOLTIP_NW;
|
||||
sheet_mapping["tooltip_arrow"] = PART_TOOLTIP_ARROW_NW;
|
||||
sheet_mapping["ani_first"] = PART_ANI_FIRST;
|
||||
sheet_mapping["ani_previous"] = PART_ANI_PREVIOUS;
|
||||
sheet_mapping["ani_play"] = PART_ANI_PLAY;
|
||||
sheet_mapping["ani_stop"] = PART_ANI_STOP;
|
||||
sheet_mapping["ani_next"] = PART_ANI_NEXT;
|
||||
sheet_mapping["ani_last"] = PART_ANI_LAST;
|
||||
sheet_mapping["pal_edit"] = PART_PAL_EDIT;
|
||||
sheet_mapping["pal_sort"] = PART_PAL_SORT;
|
||||
sheet_mapping["pal_presets"] = PART_PAL_PRESETS;
|
||||
sheet_mapping["pal_options"] = PART_PAL_OPTIONS;
|
||||
sheet_mapping["target_one"] = PART_TARGET_ONE;
|
||||
sheet_mapping["target_one_selected"] = PART_TARGET_ONE_SELECTED;
|
||||
sheet_mapping["target_frames"] = PART_TARGET_FRAMES;
|
||||
sheet_mapping["target_frames_selected"] = PART_TARGET_FRAMES_SELECTED;
|
||||
sheet_mapping["target_layers"] = PART_TARGET_LAYERS;
|
||||
sheet_mapping["target_layers_selected"] = PART_TARGET_LAYERS_SELECTED;
|
||||
sheet_mapping["target_frames_layers"] = PART_TARGET_FRAMES_LAYERS;
|
||||
sheet_mapping["target_frames_layers_selected"] = PART_TARGET_FRAMES_LAYERS_SELECTED;
|
||||
sheet_mapping["scale_arrow_1"] = PART_SCALE_ARROW_1;
|
||||
sheet_mapping["scale_arrow_2"] = PART_SCALE_ARROW_2;
|
||||
sheet_mapping["scale_arrow_3"] = PART_SCALE_ARROW_3;
|
||||
sheet_mapping["rotate_arrow_1"] = PART_ROTATE_ARROW_1;
|
||||
sheet_mapping["rotate_arrow_2"] = PART_ROTATE_ARROW_2;
|
||||
sheet_mapping["rotate_arrow_3"] = PART_ROTATE_ARROW_3;
|
||||
sheet_mapping["selection_replace"] = PART_SELECTION_REPLACE;
|
||||
sheet_mapping["selection_replace_selected"] = PART_SELECTION_REPLACE_SELECTED;
|
||||
sheet_mapping["selection_add"] = PART_SELECTION_ADD;
|
||||
sheet_mapping["selection_add_selected"] = PART_SELECTION_ADD_SELECTED;
|
||||
sheet_mapping["selection_subtract"] = PART_SELECTION_SUBTRACT;
|
||||
sheet_mapping["selection_subtract_selected"] = PART_SELECTION_SUBTRACT_SELECTED;
|
||||
sheet_mapping["unpinned"] = PART_UNPINNED;
|
||||
sheet_mapping["pinned"] = PART_PINNED;
|
||||
sheet_mapping["drop_down_button_left_normal"] = PART_DROP_DOWN_BUTTON_LEFT_NORMAL_NW;
|
||||
sheet_mapping["drop_down_button_left_hot"] = PART_DROP_DOWN_BUTTON_LEFT_HOT_NW;
|
||||
sheet_mapping["drop_down_button_left_focused"] = PART_DROP_DOWN_BUTTON_LEFT_FOCUSED_NW;
|
||||
sheet_mapping["drop_down_button_left_selected"] = PART_DROP_DOWN_BUTTON_LEFT_SELECTED_NW;
|
||||
sheet_mapping["drop_down_button_right_normal"] = PART_DROP_DOWN_BUTTON_RIGHT_NORMAL_NW;
|
||||
sheet_mapping["drop_down_button_right_hot"] = PART_DROP_DOWN_BUTTON_RIGHT_HOT_NW;
|
||||
sheet_mapping["drop_down_button_right_focused"] = PART_DROP_DOWN_BUTTON_RIGHT_FOCUSED_NW;
|
||||
sheet_mapping["drop_down_button_right_selected"] = PART_DROP_DOWN_BUTTON_RIGHT_SELECTED_NW;
|
||||
sheet_mapping["transformation_handle"] = PART_TRANSFORMATION_HANDLE;
|
||||
sheet_mapping["pivot_handle"] = PART_PIVOT_HANDLE;
|
||||
sheet_mapping["drop_pixels_ok"] = PART_DROP_PIXELS_OK;
|
||||
sheet_mapping["drop_pixels_ok_selected"] = PART_DROP_PIXELS_OK_SELECTED;
|
||||
sheet_mapping["drop_pixels_cancel"] = PART_DROP_PIXELS_CANCEL;
|
||||
sheet_mapping["drop_pixels_cancel_selected"] = PART_DROP_PIXELS_CANCEL_SELECTED;
|
||||
sheet_mapping["freehand_algo_default"] = PART_FREEHAND_ALGO_DEFAULT;
|
||||
sheet_mapping["freehand_algo_default_selected"] = PART_FREEHAND_ALGO_DEFAULT_SELECTED;
|
||||
sheet_mapping["freehand_algo_pixel_perfect"] = PART_FREEHAND_ALGO_PIXEL_PERFECT;
|
||||
sheet_mapping["freehand_algo_pixel_perfect_selected"] = PART_FREEHAND_ALGO_PIXEL_PERFECT_SELECTED;
|
||||
sheet_mapping["freehand_algo_dots"] = PART_FREEHAND_ALGO_DOTS;
|
||||
sheet_mapping["freehand_algo_dots_selected"] = PART_FREEHAND_ALGO_DOTS_SELECTED;
|
||||
sheet_mapping["ink_default"] = PART_INK_DEFAULT;
|
||||
sheet_mapping["ink_copy_color"] = PART_INK_COPY_COLOR;
|
||||
sheet_mapping["ink_lock_alpha"] = PART_INK_LOCK_ALPHA;
|
||||
sheet_mapping["selection_opaque"] = PART_SELECTION_OPAQUE;
|
||||
sheet_mapping["selection_masked"] = PART_SELECTION_MASKED;
|
||||
sheet_mapping["pivot_hidden"] = PART_PIVOT_HIDDEN;
|
||||
sheet_mapping["pivot_northwest"] = PART_PIVOT_NORTHWEST;
|
||||
sheet_mapping["pivot_north"] = PART_PIVOT_NORTH;
|
||||
sheet_mapping["pivot_northeast"] = PART_PIVOT_NORTHEAST;
|
||||
sheet_mapping["pivot_west"] = PART_PIVOT_WEST;
|
||||
sheet_mapping["pivot_center"] = PART_PIVOT_CENTER;
|
||||
sheet_mapping["pivot_east"] = PART_PIVOT_EAST;
|
||||
sheet_mapping["pivot_southwest"] = PART_PIVOT_SOUTHWEST;
|
||||
sheet_mapping["pivot_south"] = PART_PIVOT_SOUTH;
|
||||
sheet_mapping["pivot_southeast"] = PART_PIVOT_SOUTHEAST;
|
||||
}
|
||||
|
||||
SkinTheme::~SkinTheme()
|
||||
@ -309,9 +167,7 @@ SkinTheme::~SkinTheme()
|
||||
if (m_sheet)
|
||||
m_sheet->dispose();
|
||||
|
||||
m_part.clear();
|
||||
m_parts_by_id.clear();
|
||||
sheet_mapping.clear();
|
||||
|
||||
// Destroy fonts
|
||||
if (m_defaultFont)
|
||||
@ -357,13 +213,6 @@ void SkinTheme::loadFonts()
|
||||
m_miniFont = loadFont("UserMiniFont", "skins/" + m_selected_skin + "/minifont.png");
|
||||
}
|
||||
|
||||
gfx::Size SkinTheme::get_part_size(int part_i) const
|
||||
{
|
||||
she::Surface* bmp = get_part(part_i);
|
||||
ASSERT(bmp);
|
||||
return gfx::Size(bmp->width(), bmp->height());
|
||||
}
|
||||
|
||||
void SkinTheme::onRegenerate()
|
||||
{
|
||||
loadSheet();
|
||||
@ -371,9 +220,6 @@ void SkinTheme::onRegenerate()
|
||||
|
||||
scrollbar_size = 12 * guiscale();
|
||||
|
||||
m_part.clear();
|
||||
m_part.resize(PARTS, NULL);
|
||||
|
||||
// Load the skin XML
|
||||
std::string xml_filename = "skins/" + m_selected_skin + "/skin.xml";
|
||||
ResourceFinder rf;
|
||||
@ -529,15 +375,6 @@ void SkinTheme::onRegenerate()
|
||||
part->setBitmap(7, sliceSheet(part->getBitmap(7), gfx::Rect(x, y+h1, w1, h2))); // W
|
||||
}
|
||||
|
||||
// Prepare the m_part vector (which is used for backward
|
||||
// compatibility for widgets that doesn't use SkinStyle).
|
||||
std::map<std::string, int>::iterator it = sheet_mapping.find(part_id);
|
||||
if (it != sheet_mapping.end()) {
|
||||
int c = it->second;
|
||||
for (size_t i=0; i<part->size(); ++i)
|
||||
m_part[c+i] = part->getBitmap(i);
|
||||
}
|
||||
|
||||
xmlPart = xmlPart->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
@ -690,10 +527,10 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
case kButtonWidget:
|
||||
BORDER4(
|
||||
m_part[PART_BUTTON_NORMAL_W]->width(),
|
||||
m_part[PART_BUTTON_NORMAL_N]->height(),
|
||||
m_part[PART_BUTTON_NORMAL_E]->width(),
|
||||
m_part[PART_BUTTON_NORMAL_S]->height());
|
||||
parts.buttonNormal()->getBitmapW()->width(),
|
||||
parts.buttonNormal()->getBitmapN()->height(),
|
||||
parts.buttonNormal()->getBitmapE()->width(),
|
||||
parts.buttonNormal()->getBitmapS()->height());
|
||||
widget->setChildSpacing(0);
|
||||
break;
|
||||
|
||||
@ -702,19 +539,18 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
widget->setChildSpacing(4 * scale);
|
||||
|
||||
static_cast<ButtonBase*>(widget)->setIconInterface
|
||||
(new ButtonIconImpl(static_cast<SkinTheme*>(widget->getTheme()),
|
||||
PART_CHECK_NORMAL,
|
||||
PART_CHECK_SELECTED,
|
||||
PART_CHECK_DISABLED,
|
||||
(new ButtonIconImpl(parts.checkNormal(),
|
||||
parts.checkSelected(),
|
||||
parts.checkDisabled(),
|
||||
LEFT | MIDDLE));
|
||||
break;
|
||||
|
||||
case kEntryWidget:
|
||||
BORDER4(
|
||||
m_part[PART_SUNKEN_NORMAL_W]->width(),
|
||||
m_part[PART_SUNKEN_NORMAL_N]->height(),
|
||||
m_part[PART_SUNKEN_NORMAL_E]->width(),
|
||||
m_part[PART_SUNKEN_NORMAL_S]->height());
|
||||
parts.sunkenNormal()->getBitmapW()->width(),
|
||||
parts.sunkenNormal()->getBitmapN()->height(),
|
||||
parts.sunkenNormal()->getBitmapE()->width(),
|
||||
parts.sunkenNormal()->getBitmapS()->height());
|
||||
break;
|
||||
|
||||
case kGridWidget:
|
||||
@ -748,10 +584,9 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
16 * guiscale()));
|
||||
|
||||
static_cast<ButtonBase*>(button)->setIconInterface
|
||||
(new ButtonIconImpl(static_cast<SkinTheme*>(button->getTheme()),
|
||||
PART_COMBOBOX_ARROW_DOWN,
|
||||
PART_COMBOBOX_ARROW_DOWN_SELECTED,
|
||||
PART_COMBOBOX_ARROW_DOWN_DISABLED,
|
||||
(new ButtonIconImpl(parts.comboboxArrowDown(),
|
||||
parts.comboboxArrowDownSelected(),
|
||||
parts.comboboxArrowDownDisabled(),
|
||||
CENTER | MIDDLE));
|
||||
}
|
||||
break;
|
||||
@ -778,10 +613,9 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
widget->setChildSpacing(4 * scale);
|
||||
|
||||
static_cast<ButtonBase*>(widget)->setIconInterface
|
||||
(new ButtonIconImpl(static_cast<SkinTheme*>(widget->getTheme()),
|
||||
PART_RADIO_NORMAL,
|
||||
PART_RADIO_SELECTED,
|
||||
PART_RADIO_DISABLED,
|
||||
(new ButtonIconImpl(parts.radioNormal(),
|
||||
parts.radioSelected(),
|
||||
parts.radioDisabled(),
|
||||
LEFT | MIDDLE));
|
||||
break;
|
||||
|
||||
@ -814,10 +648,10 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
case kSliderWidget:
|
||||
BORDER4(
|
||||
m_part[PART_SLIDER_EMPTY_W]->width()-1*scale,
|
||||
m_part[PART_SLIDER_EMPTY_N]->height(),
|
||||
m_part[PART_SLIDER_EMPTY_E]->width()-1*scale,
|
||||
m_part[PART_SLIDER_EMPTY_S]->height()-1*scale);
|
||||
parts.sliderEmpty()->getBitmapW()->width()-1*scale,
|
||||
parts.sliderEmpty()->getBitmapN()->height(),
|
||||
parts.sliderEmpty()->getBitmapE()->width()-1*scale,
|
||||
parts.sliderEmpty()->getBitmapS()->height()-1*scale);
|
||||
widget->setChildSpacing(widget->getTextHeight());
|
||||
widget->setAlign(CENTER | MIDDLE);
|
||||
break;
|
||||
@ -829,10 +663,10 @@ void SkinTheme::initWidget(Widget* widget)
|
||||
|
||||
case kViewWidget:
|
||||
BORDER4(
|
||||
m_part[PART_SUNKEN_NORMAL_W]->width()-1*scale,
|
||||
m_part[PART_SUNKEN_NORMAL_N]->height(),
|
||||
m_part[PART_SUNKEN_NORMAL_E]->width()-1*scale,
|
||||
m_part[PART_SUNKEN_NORMAL_S]->height()-1*scale);
|
||||
parts.sunkenNormal()->getBitmapW()->width()-1*scale,
|
||||
parts.sunkenNormal()->getBitmapN()->height(),
|
||||
parts.sunkenNormal()->getBitmapE()->width()-1*scale,
|
||||
parts.sunkenNormal()->getBitmapS()->height()-1*scale);
|
||||
widget->setChildSpacing(0);
|
||||
widget->setBgColor(colors.windowFace());
|
||||
break;
|
||||
@ -885,10 +719,7 @@ void SkinTheme::setDecorativeWidgetBounds(Widget* widget)
|
||||
{
|
||||
if (widget->getId() == kThemeCloseButtonId) {
|
||||
Widget* window = widget->getParent();
|
||||
gfx::Rect rect(0, 0, 0, 0);
|
||||
|
||||
rect.w = m_part[PART_WINDOW_CLOSE_BUTTON_NORMAL]->width();
|
||||
rect.h = m_part[PART_WINDOW_CLOSE_BUTTON_NORMAL]->height();
|
||||
gfx::Rect rect(parts.windowCloseButtonNormal()->getSize());
|
||||
|
||||
rect.offset(window->getBounds().x2() - 3*guiscale() - rect.w,
|
||||
window->getBounds().y + 3*guiscale());
|
||||
@ -920,12 +751,12 @@ void SkinTheme::paintButton(PaintEvent& ev)
|
||||
IButtonIcon* iconInterface = widget->getIconInterface();
|
||||
gfx::Rect box, text, icon;
|
||||
gfx::Color fg, bg;
|
||||
int part_nw;
|
||||
SkinPartPtr part_nw;
|
||||
|
||||
widget->getTextIconInfo(&box, &text, &icon,
|
||||
iconInterface ? iconInterface->getIconAlign(): 0,
|
||||
iconInterface ? iconInterface->getWidth() : 0,
|
||||
iconInterface ? iconInterface->getHeight() : 0);
|
||||
iconInterface ? iconInterface->getSize().w: 0,
|
||||
iconInterface ? iconInterface->getSize().h: 0);
|
||||
|
||||
// Tool buttons are smaller
|
||||
LookType look = NormalLook;
|
||||
@ -937,19 +768,19 @@ void SkinTheme::paintButton(PaintEvent& ev)
|
||||
if (widget->isSelected()) {
|
||||
fg = colors.buttonSelectedText();
|
||||
bg = colors.buttonSelectedFace();
|
||||
part_nw = (look == MiniLook ? PART_TOOLBUTTON_NORMAL_NW:
|
||||
look == LeftButtonLook ? PART_DROP_DOWN_BUTTON_LEFT_SELECTED_NW:
|
||||
look == RightButtonLook ? PART_DROP_DOWN_BUTTON_RIGHT_SELECTED_NW:
|
||||
PART_BUTTON_SELECTED_NW);
|
||||
part_nw = (look == MiniLook ? parts.toolbuttonNormal():
|
||||
look == LeftButtonLook ? parts.dropDownButtonLeftSelected():
|
||||
look == RightButtonLook ? parts.dropDownButtonRightSelected():
|
||||
parts.buttonSelected());
|
||||
}
|
||||
// With mouse
|
||||
else if (widget->isEnabled() && widget->hasMouseOver()) {
|
||||
fg = colors.buttonHotText();
|
||||
bg = colors.buttonHotFace();
|
||||
part_nw = (look == MiniLook ? PART_TOOLBUTTON_HOT_NW:
|
||||
look == LeftButtonLook ? PART_DROP_DOWN_BUTTON_LEFT_HOT_NW:
|
||||
look == RightButtonLook ? PART_DROP_DOWN_BUTTON_RIGHT_HOT_NW:
|
||||
PART_BUTTON_HOT_NW);
|
||||
part_nw = (look == MiniLook ? parts.toolbuttonHot():
|
||||
look == LeftButtonLook ? parts.dropDownButtonLeftHot():
|
||||
look == RightButtonLook ? parts.dropDownButtonRightHot():
|
||||
parts.buttonHot());
|
||||
}
|
||||
// Without mouse
|
||||
else {
|
||||
@ -957,22 +788,23 @@ void SkinTheme::paintButton(PaintEvent& ev)
|
||||
bg = colors.buttonNormalFace();
|
||||
|
||||
if (widget->hasFocus())
|
||||
part_nw = (look == MiniLook ? PART_TOOLBUTTON_HOT_NW:
|
||||
look == LeftButtonLook ? PART_DROP_DOWN_BUTTON_LEFT_FOCUSED_NW:
|
||||
look == RightButtonLook ? PART_DROP_DOWN_BUTTON_RIGHT_FOCUSED_NW:
|
||||
PART_BUTTON_FOCUSED_NW);
|
||||
part_nw = (look == MiniLook ? parts.toolbuttonHot():
|
||||
look == LeftButtonLook ? parts.dropDownButtonLeftFocused():
|
||||
look == RightButtonLook ? parts.dropDownButtonRightFocused():
|
||||
parts.buttonFocused());
|
||||
else
|
||||
part_nw = (look == MiniLook ? PART_TOOLBUTTON_NORMAL_NW:
|
||||
look == LeftButtonLook ? PART_DROP_DOWN_BUTTON_LEFT_NORMAL_NW:
|
||||
look == RightButtonLook ? PART_DROP_DOWN_BUTTON_RIGHT_NORMAL_NW:
|
||||
PART_BUTTON_NORMAL_NW);
|
||||
part_nw = (look == MiniLook ? parts.toolbuttonNormal():
|
||||
look == LeftButtonLook ? parts.dropDownButtonLeftNormal():
|
||||
look == RightButtonLook ? parts.dropDownButtonRightNormal():
|
||||
parts.buttonNormal());
|
||||
}
|
||||
|
||||
// external background
|
||||
g->fillRect(BGCOLOR, g->getClipBounds());
|
||||
|
||||
// draw borders
|
||||
draw_bounds_nw(g, widget->getClientBounds(), part_nw, bg);
|
||||
if (part_nw)
|
||||
drawRect(g, widget->getClientBounds(), part_nw.get(), bg);
|
||||
|
||||
// text
|
||||
drawTextString(g, NULL, fg, ColorNone, widget,
|
||||
@ -999,8 +831,8 @@ void SkinTheme::paintCheckBox(PaintEvent& ev)
|
||||
|
||||
widget->getTextIconInfo(&box, &text, &icon,
|
||||
iconInterface ? iconInterface->getIconAlign(): 0,
|
||||
iconInterface ? iconInterface->getWidth() : 0,
|
||||
iconInterface ? iconInterface->getHeight() : 0);
|
||||
iconInterface ? iconInterface->getSize().w: 0,
|
||||
iconInterface ? iconInterface->getSize().h: 0);
|
||||
|
||||
// Check box look
|
||||
LookType look = NormalLook;
|
||||
@ -1028,7 +860,7 @@ void SkinTheme::paintCheckBox(PaintEvent& ev)
|
||||
|
||||
// draw focus
|
||||
if (look != WithoutBordersLook && widget->hasFocus())
|
||||
draw_bounds_nw(g, bounds, PART_CHECK_FOCUS_NW, gfx::ColorNone);
|
||||
drawRect(g, bounds, parts.checkFocus().get(), gfx::ColorNone);
|
||||
}
|
||||
|
||||
void SkinTheme::paintGrid(PaintEvent& ev)
|
||||
@ -1063,10 +895,10 @@ void SkinTheme::paintEntry(PaintEvent& ev)
|
||||
isMiniLook = (skinPropery->getLook() == MiniLook);
|
||||
|
||||
gfx::Color bg = colors.background();
|
||||
draw_bounds_nw(g, bounds,
|
||||
drawRect(g, bounds,
|
||||
(widget->hasFocus() ?
|
||||
(isMiniLook ? PART_SUNKEN_MINI_FOCUSED_NW: PART_SUNKEN_FOCUSED_NW):
|
||||
(isMiniLook ? PART_SUNKEN_MINI_NORMAL_NW : PART_SUNKEN_NORMAL_NW)),
|
||||
(isMiniLook ? parts.sunkenMiniFocused().get(): parts.sunkenFocused().get()):
|
||||
(isMiniLook ? parts.sunkenMiniNormal().get() : parts.sunkenNormal().get())),
|
||||
bg);
|
||||
|
||||
// Draw the text
|
||||
@ -1256,9 +1088,9 @@ void SkinTheme::paintMenuItem(ui::PaintEvent& ev)
|
||||
// Draw an indicator for selected items
|
||||
if (widget->isSelected()) {
|
||||
she::Surface* icon =
|
||||
m_part[widget->isEnabled() ?
|
||||
PART_CHECK_SELECTED:
|
||||
PART_CHECK_DISABLED];
|
||||
(widget->isEnabled() ?
|
||||
parts.checkSelected()->getBitmap(0):
|
||||
parts.checkDisabled()->getBitmap(0));
|
||||
|
||||
int x = bounds.x+4*scale-icon->width()/2;
|
||||
int y = bounds.y+bounds.h/2-icon->height()/2;
|
||||
@ -1336,8 +1168,8 @@ void SkinTheme::paintRadioButton(PaintEvent& ev)
|
||||
gfx::Rect box, text, icon;
|
||||
widget->getTextIconInfo(&box, &text, &icon,
|
||||
iconInterface ? iconInterface->getIconAlign(): 0,
|
||||
iconInterface ? iconInterface->getWidth() : 0,
|
||||
iconInterface ? iconInterface->getHeight() : 0);
|
||||
iconInterface ? iconInterface->getSize().w: 0,
|
||||
iconInterface ? iconInterface->getSize().h: 0);
|
||||
|
||||
// Background
|
||||
g->fillRect(bg, g->getClipBounds());
|
||||
@ -1359,7 +1191,7 @@ void SkinTheme::paintRadioButton(PaintEvent& ev)
|
||||
|
||||
// Focus
|
||||
if (widget->hasFocus())
|
||||
draw_bounds_nw(g, bounds, PART_RADIO_FOCUS_NW, gfx::ColorNone);
|
||||
drawRect(g, bounds, parts.radioFocus().get(), gfx::ColorNone);
|
||||
}
|
||||
|
||||
void SkinTheme::paintSeparator(ui::PaintEvent& ev)
|
||||
@ -1372,10 +1204,10 @@ void SkinTheme::paintSeparator(ui::PaintEvent& ev)
|
||||
g->fillRect(BGCOLOR, bounds);
|
||||
|
||||
if (widget->getAlign() & HORIZONTAL)
|
||||
draw_part_as_hline(g, bounds, PART_SEPARATOR_HORZ);
|
||||
drawHline(g, bounds, parts.separatorHorz().get());
|
||||
|
||||
if (widget->getAlign() & VERTICAL)
|
||||
draw_part_as_vline(g, bounds, PART_SEPARATOR_VERT);
|
||||
drawVline(g, bounds, parts.separatorVert().get());
|
||||
|
||||
// text
|
||||
if (widget->hasText()) {
|
||||
@ -1434,10 +1266,10 @@ void SkinTheme::paintSlider(PaintEvent& ev)
|
||||
|
||||
// Draw customized background
|
||||
if (bgPainter) {
|
||||
int nw = PART_MINI_SLIDER_EMPTY_NW;
|
||||
SkinPartPtr nw = parts.miniSliderEmpty();
|
||||
she::Surface* thumb =
|
||||
widget->hasFocus() ? m_part[PART_MINI_SLIDER_THUMB_FOCUSED]:
|
||||
m_part[PART_MINI_SLIDER_THUMB];
|
||||
(widget->hasFocus() ? parts.miniSliderThumbFocused()->getBitmap(0):
|
||||
parts.miniSliderThumb()->getBitmap(0));
|
||||
|
||||
// Draw background
|
||||
g->fillRect(BGCOLOR, rc);
|
||||
@ -1452,7 +1284,7 @@ void SkinTheme::paintSlider(PaintEvent& ev)
|
||||
3 * guiscale(),
|
||||
1 * guiscale()));
|
||||
|
||||
draw_bounds_nw(g, rc, nw, gfx::ColorNone);
|
||||
drawRect(g, rc, nw.get(), gfx::ColorNone);
|
||||
|
||||
// Draw background (using the customized ISliderBgPainter implementation)
|
||||
rc.shrink(Border(1, 1, 1, 2) * guiscale());
|
||||
@ -1461,31 +1293,31 @@ void SkinTheme::paintSlider(PaintEvent& ev)
|
||||
}
|
||||
else {
|
||||
// Draw borders
|
||||
int full_part_nw;
|
||||
int empty_part_nw;
|
||||
SkinPartPtr full_part;
|
||||
SkinPartPtr empty_part;
|
||||
|
||||
if (isMiniLook) {
|
||||
full_part_nw = widget->hasMouseOver() ? PART_MINI_SLIDER_FULL_FOCUSED_NW:
|
||||
PART_MINI_SLIDER_FULL_NW;
|
||||
empty_part_nw = widget->hasMouseOver() ? PART_MINI_SLIDER_EMPTY_FOCUSED_NW:
|
||||
PART_MINI_SLIDER_EMPTY_NW;
|
||||
full_part = widget->hasMouseOver() ? parts.miniSliderFullFocused():
|
||||
parts.miniSliderFull();
|
||||
empty_part = widget->hasMouseOver() ? parts.miniSliderEmptyFocused():
|
||||
parts.miniSliderEmpty();
|
||||
}
|
||||
else {
|
||||
full_part_nw = widget->hasFocus() ? PART_SLIDER_FULL_FOCUSED_NW:
|
||||
PART_SLIDER_FULL_NW;
|
||||
empty_part_nw = widget->hasFocus() ? PART_SLIDER_EMPTY_FOCUSED_NW:
|
||||
PART_SLIDER_EMPTY_NW;
|
||||
full_part = widget->hasFocus() ? parts.sliderFullFocused():
|
||||
parts.sliderFull();
|
||||
empty_part = widget->hasFocus() ? parts.sliderEmptyFocused():
|
||||
parts.sliderEmpty();
|
||||
}
|
||||
|
||||
if (value == min)
|
||||
draw_bounds_nw(g, rc, empty_part_nw, colors.sliderEmptyFace());
|
||||
drawRect(g, rc, empty_part.get(), colors.sliderEmptyFace());
|
||||
else if (value == max)
|
||||
draw_bounds_nw(g, rc, full_part_nw, colors.sliderFullFace());
|
||||
drawRect(g, rc, full_part.get(), colors.sliderFullFace());
|
||||
else
|
||||
draw_bounds_nw2(g, rc, x,
|
||||
full_part_nw, empty_part_nw,
|
||||
colors.sliderFullFace(),
|
||||
colors.sliderEmptyFace());
|
||||
drawRect2(g, rc, x,
|
||||
full_part.get(), empty_part.get(),
|
||||
colors.sliderFullFace(),
|
||||
colors.sliderEmptyFace());
|
||||
|
||||
// Draw text
|
||||
std::string old_text = widget->getText();
|
||||
@ -1536,10 +1368,10 @@ void SkinTheme::paintComboBoxEntry(ui::PaintEvent& ev)
|
||||
|
||||
gfx::Color fg, bg = colors.background();
|
||||
|
||||
draw_bounds_nw(g, bounds,
|
||||
widget->hasFocus() ?
|
||||
PART_SUNKEN2_FOCUSED_NW:
|
||||
PART_SUNKEN2_NORMAL_NW, bg);
|
||||
drawRect(g, bounds,
|
||||
(widget->hasFocus() ?
|
||||
parts.sunken2Focused().get():
|
||||
parts.sunken2Normal().get()), bg);
|
||||
|
||||
// Draw the text
|
||||
x = bounds.x + widget->border().left();
|
||||
@ -1599,22 +1431,22 @@ void SkinTheme::paintComboBoxButton(PaintEvent& ev)
|
||||
Button* widget = static_cast<Button*>(ev.getSource());
|
||||
Graphics* g = ev.getGraphics();
|
||||
IButtonIcon* iconInterface = widget->getIconInterface();
|
||||
int part_nw;
|
||||
SkinPartPtr part_nw;
|
||||
gfx::Color bg;
|
||||
|
||||
if (widget->isSelected()) {
|
||||
bg = colors.buttonSelectedFace();
|
||||
part_nw = PART_TOOLBUTTON_PUSHED_NW;
|
||||
part_nw = parts.toolbuttonPushed();
|
||||
}
|
||||
// With mouse
|
||||
else if (widget->isEnabled() && widget->hasMouseOver()) {
|
||||
bg = colors.buttonHotFace();
|
||||
part_nw = PART_TOOLBUTTON_HOT_NW;
|
||||
part_nw = parts.toolbuttonHot();
|
||||
}
|
||||
// Without mouse
|
||||
else {
|
||||
bg = colors.buttonNormalFace();
|
||||
part_nw = PART_TOOLBUTTON_LAST_NW;
|
||||
part_nw = parts.toolbuttonLast();
|
||||
}
|
||||
|
||||
Rect rc = widget->getClientBounds();
|
||||
@ -1623,13 +1455,13 @@ void SkinTheme::paintComboBoxButton(PaintEvent& ev)
|
||||
g->fillRect(BGCOLOR, rc);
|
||||
|
||||
// draw borders
|
||||
draw_bounds_nw(g, rc, part_nw, bg);
|
||||
drawRect(g, rc, part_nw.get(), bg);
|
||||
|
||||
// Paint the icon
|
||||
if (iconInterface) {
|
||||
// Icon
|
||||
int x = rc.x + rc.w/2 - iconInterface->getWidth()/2;
|
||||
int y = rc.y + rc.h/2 - iconInterface->getHeight()/2;
|
||||
int x = rc.x + rc.w/2 - iconInterface->getSize().w/2;
|
||||
int y = rc.y + rc.h/2 - iconInterface->getSize().h/2;
|
||||
|
||||
paintIcon(widget, ev.getGraphics(), iconInterface, x, y);
|
||||
}
|
||||
@ -1765,16 +1597,16 @@ void SkinTheme::paintWindowButton(ui::PaintEvent& ev)
|
||||
ButtonBase* widget = static_cast<ButtonBase*>(ev.getSource());
|
||||
Graphics* g = ev.getGraphics();
|
||||
Rect rc = widget->getClientBounds();
|
||||
int part;
|
||||
SkinPartPtr part;
|
||||
|
||||
if (widget->isSelected())
|
||||
part = PART_WINDOW_CLOSE_BUTTON_SELECTED;
|
||||
part = parts.windowCloseButtonSelected();
|
||||
else if (widget->hasMouseOver())
|
||||
part = PART_WINDOW_CLOSE_BUTTON_HOT;
|
||||
part = parts.windowCloseButtonHot();
|
||||
else
|
||||
part = PART_WINDOW_CLOSE_BUTTON_NORMAL;
|
||||
part = parts.windowCloseButtonNormal();
|
||||
|
||||
g->drawRgbaSurface(m_part[part], rc.x, rc.y);
|
||||
g->drawRgbaSurface(part->getBitmap(0), rc.x, rc.y);
|
||||
}
|
||||
|
||||
void SkinTheme::paintTooltip(PaintEvent& ev)
|
||||
@ -1785,24 +1617,25 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
|
||||
Rect rc = widget->getClientBounds();
|
||||
gfx::Color fg = colors.tooltipText();
|
||||
gfx::Color bg = colors.tooltipFace();
|
||||
SkinPartPtr tooltipPart = parts.tooltip();
|
||||
|
||||
int nw = PART_TOOLTIP_NW;
|
||||
int n = PART_TOOLTIP_N;
|
||||
int ne = PART_TOOLTIP_NE;
|
||||
int e = PART_TOOLTIP_E;
|
||||
int se = PART_TOOLTIP_SE;
|
||||
int s = PART_TOOLTIP_S;
|
||||
int sw = PART_TOOLTIP_SW;
|
||||
int w = PART_TOOLTIP_W;
|
||||
she::Surface* nw = tooltipPart->getBitmapNW();
|
||||
she::Surface* n = tooltipPart->getBitmapN();
|
||||
she::Surface* ne = tooltipPart->getBitmapNE();
|
||||
she::Surface* e = tooltipPart->getBitmapE();
|
||||
she::Surface* se = tooltipPart->getBitmapSE();
|
||||
she::Surface* s = tooltipPart->getBitmapS();
|
||||
she::Surface* sw = tooltipPart->getBitmapSW();
|
||||
she::Surface* w = tooltipPart->getBitmapW();
|
||||
|
||||
switch (widget->getArrowAlign()) {
|
||||
case TOP | LEFT: nw = PART_TOOLTIP_ARROW_NW; break;
|
||||
case TOP | RIGHT: ne = PART_TOOLTIP_ARROW_NE; break;
|
||||
case BOTTOM | LEFT: sw = PART_TOOLTIP_ARROW_SW; break;
|
||||
case BOTTOM | RIGHT: se = PART_TOOLTIP_ARROW_SE; break;
|
||||
case TOP | LEFT: nw = parts.tooltipArrow()->getBitmapNW(); break;
|
||||
case TOP | RIGHT: ne = parts.tooltipArrow()->getBitmapNE(); break;
|
||||
case BOTTOM | LEFT: sw = parts.tooltipArrow()->getBitmapSW(); break;
|
||||
case BOTTOM | RIGHT: se = parts.tooltipArrow()->getBitmapSE(); break;
|
||||
}
|
||||
|
||||
draw_bounds_template(g, rc, nw, n, ne, e, se, s, sw, w);
|
||||
drawRect(g, rc, nw, n, ne, e, se, s, sw, w);
|
||||
|
||||
// Draw arrow in sides
|
||||
she::Surface* arrow = NULL;
|
||||
@ -1812,25 +1645,25 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
|
||||
|
||||
switch (widget->getArrowAlign()) {
|
||||
case TOP:
|
||||
arrow = m_part[PART_TOOLTIP_ARROW_N];
|
||||
arrow = parts.tooltipArrow()->getBitmapN();
|
||||
g->drawRgbaSurface(arrow,
|
||||
target.x+target.w/2-arrow->width()/2,
|
||||
rc.y);
|
||||
break;
|
||||
case BOTTOM:
|
||||
arrow = m_part[PART_TOOLTIP_ARROW_S];
|
||||
arrow = parts.tooltipArrow()->getBitmapS();
|
||||
g->drawRgbaSurface(arrow,
|
||||
target.x+target.w/2-arrow->width()/2,
|
||||
rc.y+rc.h-arrow->height());
|
||||
break;
|
||||
case LEFT:
|
||||
arrow = m_part[PART_TOOLTIP_ARROW_W];
|
||||
arrow = parts.tooltipArrow()->getBitmapW();
|
||||
g->drawRgbaSurface(arrow,
|
||||
rc.x,
|
||||
target.y+target.h/2-arrow->height()/2);
|
||||
break;
|
||||
case RIGHT:
|
||||
arrow = m_part[PART_TOOLTIP_ARROW_E];
|
||||
arrow = parts.tooltipArrow()->getBitmapE();
|
||||
g->drawRgbaSurface(arrow,
|
||||
rc.x+rc.w-arrow->width(),
|
||||
target.y+target.h/2-arrow->height()/2);
|
||||
@ -1838,23 +1671,19 @@ void SkinTheme::paintTooltip(PaintEvent& ev)
|
||||
}
|
||||
|
||||
// Fill background
|
||||
g->fillRect(bg, Rect(rc).shrink(
|
||||
g->fillRect(
|
||||
bg, Rect(rc).shrink(
|
||||
Border(
|
||||
m_part[w]->width(),
|
||||
m_part[n]->height(),
|
||||
m_part[e]->width(),
|
||||
m_part[s]->height())));
|
||||
w->width(),
|
||||
n->height(),
|
||||
e->width(),
|
||||
s->height())));
|
||||
|
||||
rc.shrink(widget->border());
|
||||
|
||||
g->drawAlignedUIString(widget->getText(), fg, bg, rc, widget->getAlign());
|
||||
}
|
||||
|
||||
she::Surface* SkinTheme::get_part(const std::string& id) const
|
||||
{
|
||||
return get_part_by_id(id)->getBitmap(0);
|
||||
}
|
||||
|
||||
gfx::Color SkinTheme::getWidgetBgColor(Widget* widget)
|
||||
{
|
||||
gfx::Color c = widget->getBgColor();
|
||||
@ -1948,46 +1777,19 @@ void SkinTheme::drawEntryCaret(ui::Graphics* g, Entry* widget, int x, int y)
|
||||
g->drawVLine(color, u, y-1, h+2);
|
||||
}
|
||||
|
||||
she::Surface* SkinTheme::get_toolicon(const char* tool_id) const
|
||||
she::Surface* SkinTheme::getToolIcon(const char* toolId) const
|
||||
{
|
||||
std::map<std::string, she::Surface*>::const_iterator it = m_toolicon.find(tool_id);
|
||||
std::map<std::string, she::Surface*>::const_iterator it = m_toolicon.find(toolId);
|
||||
if (it != m_toolicon.end())
|
||||
return it->second;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void SkinTheme::draw_bounds_template(Graphics* g, const Rect& rc,
|
||||
int nw, int n, int ne, int e, int se, int s, int sw, int w)
|
||||
{
|
||||
draw_bounds_template(g, rc,
|
||||
m_part[nw],
|
||||
m_part[n],
|
||||
m_part[ne],
|
||||
m_part[e],
|
||||
m_part[se],
|
||||
m_part[s],
|
||||
m_part[sw],
|
||||
m_part[w]);
|
||||
}
|
||||
|
||||
void SkinTheme::draw_bounds_template(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr& skinPart)
|
||||
{
|
||||
draw_bounds_template(g, rc,
|
||||
skinPart->getBitmap(0),
|
||||
skinPart->getBitmap(1),
|
||||
skinPart->getBitmap(2),
|
||||
skinPart->getBitmap(3),
|
||||
skinPart->getBitmap(4),
|
||||
skinPart->getBitmap(5),
|
||||
skinPart->getBitmap(6),
|
||||
skinPart->getBitmap(7));
|
||||
}
|
||||
|
||||
void SkinTheme::draw_bounds_template(Graphics* g, const Rect& rc,
|
||||
she::Surface* nw, she::Surface* n, she::Surface* ne,
|
||||
she::Surface* e, she::Surface* se, she::Surface* s,
|
||||
she::Surface* sw, she::Surface* w)
|
||||
void SkinTheme::drawRect(Graphics* g, const Rect& rc,
|
||||
she::Surface* nw, she::Surface* n, she::Surface* ne,
|
||||
she::Surface* e, she::Surface* se, she::Surface* s,
|
||||
she::Surface* sw, she::Surface* w)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@ -2045,42 +1847,17 @@ void SkinTheme::draw_bounds_template(Graphics* g, const Rect& rc,
|
||||
}
|
||||
}
|
||||
|
||||
void SkinTheme::draw_bounds_array(ui::Graphics* g, const gfx::Rect& rc, int parts[8])
|
||||
void SkinTheme::drawRect(ui::Graphics* g, const gfx::Rect& rc, SkinPart* skinPart, gfx::Color bg)
|
||||
{
|
||||
int nw = parts[0];
|
||||
int n = parts[1];
|
||||
int ne = parts[2];
|
||||
int e = parts[3];
|
||||
int se = parts[4];
|
||||
int s = parts[5];
|
||||
int sw = parts[6];
|
||||
int w = parts[7];
|
||||
|
||||
draw_bounds_template(g, rc,
|
||||
nw, n, ne, e,
|
||||
se, s, sw, w);
|
||||
}
|
||||
|
||||
void SkinTheme::draw_bounds_nw(Graphics* g, const Rect& rc, int nw, gfx::Color bg)
|
||||
{
|
||||
draw_bounds_template(g, rc,
|
||||
nw+0, nw+1, nw+2, nw+3,
|
||||
nw+4, nw+5, nw+6, nw+7);
|
||||
|
||||
// Center
|
||||
if (!is_transparent(bg)) {
|
||||
g->fillRect(bg, Rect(rc).shrink(
|
||||
Border(
|
||||
m_part[nw+7]->width(),
|
||||
m_part[nw+1]->height(),
|
||||
m_part[nw+3]->width(),
|
||||
m_part[nw+5]->height())));
|
||||
}
|
||||
}
|
||||
|
||||
void SkinTheme::draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr skinPart, gfx::Color bg)
|
||||
{
|
||||
draw_bounds_template(g, rc, skinPart);
|
||||
drawRect(g, rc,
|
||||
skinPart->getBitmap(0),
|
||||
skinPart->getBitmap(1),
|
||||
skinPart->getBitmap(2),
|
||||
skinPart->getBitmap(3),
|
||||
skinPart->getBitmap(4),
|
||||
skinPart->getBitmap(5),
|
||||
skinPart->getBitmap(6),
|
||||
skinPart->getBitmap(7));
|
||||
|
||||
// Center
|
||||
if (!is_transparent(bg)) {
|
||||
@ -2097,13 +1874,15 @@ void SkinTheme::draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinP
|
||||
}
|
||||
}
|
||||
|
||||
void SkinTheme::draw_bounds_nw2(Graphics* g, const Rect& rc, int x_mid, int nw1, int nw2, gfx::Color bg1, gfx::Color bg2)
|
||||
void SkinTheme::drawRect2(Graphics* g, const Rect& rc, int x_mid,
|
||||
SkinPart* nw1, SkinPart* nw2,
|
||||
gfx::Color bg1, gfx::Color bg2)
|
||||
{
|
||||
Rect rc2(rc.x, rc.y, x_mid-rc.x+1, rc.h);
|
||||
{
|
||||
IntersectClip clip(g, rc2);
|
||||
if (clip)
|
||||
draw_bounds_nw(g, rc, nw1, bg1);
|
||||
drawRect(g, rc, nw1, bg1);
|
||||
}
|
||||
|
||||
rc2.x += rc2.w;
|
||||
@ -2111,42 +1890,42 @@ void SkinTheme::draw_bounds_nw2(Graphics* g, const Rect& rc, int x_mid, int nw1,
|
||||
|
||||
IntersectClip clip(g, rc2);
|
||||
if (clip)
|
||||
draw_bounds_nw(g, rc, nw2, bg2);
|
||||
drawRect(g, rc, nw2, bg2);
|
||||
}
|
||||
|
||||
void SkinTheme::draw_part_as_hline(ui::Graphics* g, const gfx::Rect& rc, int part)
|
||||
void SkinTheme::drawHline(ui::Graphics* g, const gfx::Rect& rc, SkinPart* part)
|
||||
{
|
||||
int x;
|
||||
|
||||
for (x = rc.x;
|
||||
x < rc.x2()-m_part[part]->width();
|
||||
x += m_part[part]->width()) {
|
||||
g->drawRgbaSurface(m_part[part], x, rc.y);
|
||||
x < rc.x2()-part->getSize().w;
|
||||
x += part->getSize().w) {
|
||||
g->drawRgbaSurface(part->getBitmap(0), x, rc.y);
|
||||
}
|
||||
|
||||
if (x < rc.x2()) {
|
||||
Rect rc2(x, rc.y, rc.w-(x-rc.x), m_part[part]->height());
|
||||
Rect rc2(x, rc.y, rc.w-(x-rc.x), part->getSize().h);
|
||||
IntersectClip clip(g, rc2);
|
||||
if (clip)
|
||||
g->drawRgbaSurface(m_part[part], x, rc.y);
|
||||
g->drawRgbaSurface(part->getBitmap(0), x, rc.y);
|
||||
}
|
||||
}
|
||||
|
||||
void SkinTheme::draw_part_as_vline(ui::Graphics* g, const gfx::Rect& rc, int part)
|
||||
void SkinTheme::drawVline(ui::Graphics* g, const gfx::Rect& rc, SkinPart* part)
|
||||
{
|
||||
int y;
|
||||
|
||||
for (y = rc.y;
|
||||
y < rc.y2()-m_part[part]->height();
|
||||
y += m_part[part]->height()) {
|
||||
g->drawRgbaSurface(m_part[part], rc.x, y);
|
||||
y < rc.y2()-part->getSize().h;
|
||||
y += part->getSize().h) {
|
||||
g->drawRgbaSurface(part->getBitmap(0), rc.x, y);
|
||||
}
|
||||
|
||||
if (y < rc.y2()) {
|
||||
Rect rc2(rc.x, y, m_part[part]->width(), rc.h-(y-rc.y));
|
||||
Rect rc2(rc.x, y, part->getSize().w, rc.h-(y-rc.y));
|
||||
IntersectClip clip(g, rc2);
|
||||
if (clip)
|
||||
g->drawRgbaSurface(m_part[part], rc.x, y);
|
||||
g->drawRgbaSurface(part->getBitmap(0), rc.x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "app/ui/skin/skin_part.h"
|
||||
#include "app/ui/skin/skin_parts.h"
|
||||
#include "app/ui/skin/style_sheet.h"
|
||||
#include "gfx/color.h"
|
||||
#include "gfx/fwd.h"
|
||||
@ -85,18 +84,17 @@ namespace app {
|
||||
|
||||
int get_button_selected_offset() const { return 0; } // TODO Configurable in xml
|
||||
|
||||
she::Surface* get_part(int part_i) const { return m_part[part_i]; }
|
||||
she::Surface* get_part(const std::string& id) const;
|
||||
she::Surface* get_toolicon(const char* tool_id) const;
|
||||
gfx::Size get_part_size(int part_i) const;
|
||||
she::Surface* getToolIcon(const char* toolId) const;
|
||||
|
||||
// Helper functions to draw bounds/hlines with sheet parts
|
||||
void draw_bounds_array(ui::Graphics* g, const gfx::Rect& rc, int parts[8]);
|
||||
void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, int nw, gfx::Color bg = gfx::ColorNone);
|
||||
void draw_bounds_nw(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr skinPart, gfx::Color bg = gfx::ColorNone);
|
||||
void draw_bounds_nw2(ui::Graphics* g, const gfx::Rect& rc, int x_mid, int nw1, int nw2, gfx::Color bg1, gfx::Color bg2);
|
||||
void draw_part_as_hline(ui::Graphics* g, const gfx::Rect& rc, int part);
|
||||
void draw_part_as_vline(ui::Graphics* g, const gfx::Rect& rc, int part);
|
||||
void drawRect(ui::Graphics* g, const gfx::Rect& rc,
|
||||
she::Surface* nw, she::Surface* n, she::Surface* ne,
|
||||
she::Surface* e, she::Surface* se, she::Surface* s,
|
||||
she::Surface* sw, she::Surface* w);
|
||||
void drawRect(ui::Graphics* g, const gfx::Rect& rc, SkinPart* skinPart, gfx::Color bg = gfx::ColorNone);
|
||||
void drawRect2(ui::Graphics* g, const gfx::Rect& rc, int x_mid, SkinPart* nw1, SkinPart* nw2, gfx::Color bg1, gfx::Color bg2);
|
||||
void drawHline(ui::Graphics* g, const gfx::Rect& rc, SkinPart* skinPart);
|
||||
void drawVline(ui::Graphics* g, const gfx::Rect& rc, SkinPart* skinPart);
|
||||
void paintProgressBar(ui::Graphics* g, const gfx::Rect& rc, double progress);
|
||||
|
||||
Style* getStyle(const std::string& id) {
|
||||
@ -122,13 +120,6 @@ namespace app {
|
||||
private:
|
||||
void loadSheet();
|
||||
void loadFonts();
|
||||
void draw_bounds_template(ui::Graphics* g, const gfx::Rect& rc,
|
||||
int nw, int n, int ne, int e, int se, int s, int sw, int w);
|
||||
void draw_bounds_template(ui::Graphics* g, const gfx::Rect& rc, const SkinPartPtr& skinPart);
|
||||
void draw_bounds_template(ui::Graphics* g, const gfx::Rect& rc,
|
||||
she::Surface* nw, she::Surface* n, she::Surface* ne,
|
||||
she::Surface* e, she::Surface* se, she::Surface* s,
|
||||
she::Surface* sw, she::Surface* w);
|
||||
|
||||
she::Surface* sliceSheet(she::Surface* sur, const gfx::Rect& bounds);
|
||||
gfx::Color getWidgetBgColor(ui::Widget* widget);
|
||||
@ -143,7 +134,6 @@ namespace app {
|
||||
|
||||
std::string m_selected_skin;
|
||||
she::Surface* m_sheet;
|
||||
std::vector<she::Surface*> m_part;
|
||||
std::map<std::string, SkinPartPtr> m_parts_by_id;
|
||||
std::map<std::string, she::Surface*> m_toolicon;
|
||||
std::map<std::string, gfx::Color> m_colors_by_id;
|
||||
|
@ -39,8 +39,8 @@ void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const cha
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(ui::CurrentTheme::get());
|
||||
|
||||
if (m_part && m_part->size() > 0) {
|
||||
if (m_part->size() == 1) {
|
||||
if (m_part && m_part->countBitmaps() > 0) {
|
||||
if (m_part->countBitmaps() == 1) {
|
||||
if (!gfx::is_transparent(m_color))
|
||||
g->fillRect(m_color, bounds);
|
||||
|
||||
@ -65,8 +65,8 @@ void BackgroundRule::onPaint(ui::Graphics* g, const gfx::Rect& bounds, const cha
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_part->size() == 8) {
|
||||
theme->draw_bounds_nw(g, bounds, m_part, m_color);
|
||||
else if (m_part->countBitmaps() == 8) {
|
||||
theme->drawRect(g, bounds, m_part.get(), m_color);
|
||||
}
|
||||
}
|
||||
else if (!gfx::is_transparent(m_color)) {
|
||||
|
@ -427,7 +427,7 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
|
||||
// Color
|
||||
if (m_state == SHOW_COLOR) {
|
||||
// Draw eyedropper icon
|
||||
she::Surface* icon = theme->get_toolicon("eyedropper");
|
||||
she::Surface* icon = theme->getToolIcon("eyedropper");
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon, x, rc.y + rc.h/2 - icon->height()/2);
|
||||
x += icon->width() + 4*guiscale();
|
||||
@ -457,7 +457,7 @@ void StatusBar::onPaint(ui::PaintEvent& ev)
|
||||
// Show tool
|
||||
if (m_state == SHOW_TOOL) {
|
||||
// Draw eyedropper icon
|
||||
she::Surface* icon = theme->get_toolicon(m_tool->getId().c_str());
|
||||
she::Surface* icon = theme->getToolIcon(m_tool->getId().c_str());
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon, x, rc.y + rc.h/2 - icon->height()/2);
|
||||
x += icon->width() + 4*guiscale();
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
static Size getToolIconSize(Widget* widget)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(widget->getTheme());
|
||||
she::Surface* icon = theme->get_toolicon("configuration");
|
||||
she::Surface* icon = theme->getToolIcon("configuration");
|
||||
if (icon)
|
||||
return Size(icon->width(), icon->height());
|
||||
else
|
||||
@ -316,24 +316,24 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||
ToolGroup* tool_group = *it;
|
||||
Tool* tool = m_selectedInGroup[tool_group];
|
||||
gfx::Color face;
|
||||
int nw;
|
||||
SkinPartPtr nw;
|
||||
|
||||
if (App::instance()->activeTool() == tool || m_hotIndex == c) {
|
||||
nw = PART_TOOLBUTTON_HOT_NW;
|
||||
nw = theme->parts.toolbuttonHot();
|
||||
face = hotFace;
|
||||
}
|
||||
else {
|
||||
nw = c >= 0 && c < groups-1 ? PART_TOOLBUTTON_NORMAL_NW:
|
||||
PART_TOOLBUTTON_LAST_NW;
|
||||
nw = c >= 0 && c < groups-1 ? theme->parts.toolbuttonNormal():
|
||||
theme->parts.toolbuttonLast();
|
||||
face = normalFace;
|
||||
}
|
||||
|
||||
toolrc = getToolGroupBounds(c);
|
||||
toolrc.offset(-getBounds().x, -getBounds().y);
|
||||
theme->draw_bounds_nw(g, toolrc, nw, face);
|
||||
theme->drawRect(g, toolrc, nw.get(), face);
|
||||
|
||||
// Draw the tool icon
|
||||
she::Surface* icon = theme->get_toolicon(tool->getId().c_str());
|
||||
she::Surface* icon = theme->getToolIcon(tool->getId().c_str());
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon,
|
||||
toolrc.x+toolrc.w/2-icon->width()/2,
|
||||
@ -345,13 +345,13 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||
toolrc = getToolGroupBounds(ConfigureToolIndex);
|
||||
toolrc.offset(-getBounds().x, -getBounds().y);
|
||||
bool isHot = (m_hotIndex == ConfigureToolIndex);
|
||||
theme->draw_bounds_nw(g,
|
||||
toolrc,
|
||||
isHot ? PART_TOOLBUTTON_HOT_NW:
|
||||
PART_TOOLBUTTON_LAST_NW,
|
||||
isHot ? hotFace: normalFace);
|
||||
theme->drawRect(
|
||||
g, toolrc,
|
||||
(isHot ? theme->parts.toolbuttonHot().get():
|
||||
theme->parts.toolbuttonLast().get()),
|
||||
(isHot ? hotFace: normalFace));
|
||||
|
||||
she::Surface* icon = theme->get_toolicon("configuration");
|
||||
she::Surface* icon = theme->getToolIcon("configuration");
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon,
|
||||
toolrc.x+toolrc.w/2-icon->width()/2,
|
||||
@ -363,13 +363,14 @@ void ToolBar::onPaint(ui::PaintEvent& ev)
|
||||
toolrc.offset(-getBounds().x, -getBounds().y);
|
||||
isHot = (m_hotIndex == PreviewVisibilityIndex ||
|
||||
App::instance()->getMainWindow()->getPreviewEditor()->isPreviewEnabled());
|
||||
theme->draw_bounds_nw(g,
|
||||
theme->drawRect(
|
||||
g,
|
||||
toolrc,
|
||||
isHot ? PART_TOOLBUTTON_HOT_NW:
|
||||
PART_TOOLBUTTON_LAST_NW,
|
||||
isHot ? hotFace: normalFace);
|
||||
(isHot ? theme->parts.toolbuttonHot().get():
|
||||
theme->parts.toolbuttonLast().get()),
|
||||
(isHot ? hotFace: normalFace));
|
||||
|
||||
icon = theme->get_toolicon("minieditor");
|
||||
icon = theme->getToolIcon("minieditor");
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon,
|
||||
toolrc.x+toolrc.w/2-icon->width()/2,
|
||||
@ -726,26 +727,27 @@ void ToolBar::ToolStrip::onPaint(PaintEvent& ev)
|
||||
Tool* tool = *it;
|
||||
if (tool->getGroup() == m_group) {
|
||||
gfx::Color face;
|
||||
int nw;
|
||||
SkinPartPtr nw;
|
||||
|
||||
if (App::instance()->activeTool() == tool ||
|
||||
m_hotTool == tool) {
|
||||
nw = PART_TOOLBUTTON_HOT_NW;
|
||||
nw = theme->parts.toolbuttonHot();
|
||||
face = theme->colors.buttonHotFace();
|
||||
}
|
||||
else {
|
||||
nw = PART_TOOLBUTTON_LAST_NW;
|
||||
nw = theme->parts.toolbuttonLast();
|
||||
face = theme->colors.buttonNormalFace();
|
||||
}
|
||||
|
||||
toolrc = getToolBounds(index++);
|
||||
toolrc.offset(-getBounds().x, -getBounds().y);
|
||||
theme->draw_bounds_nw(g, toolrc, nw, face);
|
||||
theme->drawRect(g, toolrc, nw.get(), face);
|
||||
|
||||
// Draw the tool icon
|
||||
she::Surface* icon = theme->get_toolicon(tool->getId().c_str());
|
||||
she::Surface* icon = theme->getToolIcon(tool->getId().c_str());
|
||||
if (icon) {
|
||||
g->drawRgbaSurface(icon,
|
||||
g->drawRgbaSurface(
|
||||
icon,
|
||||
toolrc.x+toolrc.w/2-icon->width()/2,
|
||||
toolrc.y+toolrc.h/2-icon->height()/2);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/main_window.h"
|
||||
#include "app/ui/skin/skin_parts.h"
|
||||
#include "app/ui/skin/skin_theme.h"
|
||||
#include "app/ui/timeline.h"
|
||||
#include "app/ui_context.h"
|
||||
|
@ -432,8 +432,9 @@ Widget* WidgetLoader::convertXmlElementToWidget(const TiXmlElement* elem, Widget
|
||||
int hspan = int_attr(elem, "hspan", 1);
|
||||
int vspan = int_attr(elem, "vspan", 1);
|
||||
|
||||
she::Surface* sur = theme->get_part(std::string(icon));
|
||||
buttonset->addItem(sur, hspan, vspan);
|
||||
SkinPartPtr part = theme->getPartById(std::string(icon));
|
||||
if (part)
|
||||
buttonset->addItem(part, hspan, vspan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
{
|
||||
std::vector<std::string> dimensions;
|
||||
std::vector<std::string> colors;
|
||||
std::vector<std::string> parts;
|
||||
std::vector<std::string> styles;
|
||||
|
||||
TiXmlHandle handle(doc);
|
||||
@ -39,6 +40,17 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
elem = elem->NextSiblingElement();
|
||||
}
|
||||
|
||||
elem = handle
|
||||
.FirstChild("skin")
|
||||
.FirstChild("parts")
|
||||
.FirstChild("part").ToElement();
|
||||
while (elem) {
|
||||
const char* id = elem->Attribute("id");
|
||||
if (!strchr(id, ':'))
|
||||
parts.push_back(id);
|
||||
elem = elem->NextSiblingElement();
|
||||
}
|
||||
|
||||
elem = handle
|
||||
.FirstChild("skin")
|
||||
.FirstChild("stylesheet")
|
||||
@ -105,6 +117,26 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
std::cout
|
||||
<< " };\n";
|
||||
|
||||
// Parts sub class
|
||||
std::cout
|
||||
<< " class Parts {\n"
|
||||
<< " template<typename> friend class SkinFile;\n"
|
||||
<< " public:\n";
|
||||
for (auto part : parts) {
|
||||
std::string id = convert_xmlid_to_cppid(part, false);
|
||||
std::cout
|
||||
<< " const skin::SkinPartPtr& " << id << "() const { return m_" << id << "; }\n";
|
||||
}
|
||||
std::cout
|
||||
<< " private:\n";
|
||||
for (auto part : parts) {
|
||||
std::string id = convert_xmlid_to_cppid(part, false);
|
||||
std::cout
|
||||
<< " skin::SkinPartPtr m_" << id << ";\n";
|
||||
}
|
||||
std::cout
|
||||
<< " };\n";
|
||||
|
||||
// Styles sub class
|
||||
std::cout
|
||||
<< "\n"
|
||||
@ -130,37 +162,46 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
<< "\n"
|
||||
<< " Dimensions dimensions;\n"
|
||||
<< " Colors colors;\n"
|
||||
<< " Parts parts;\n"
|
||||
<< " Styles styles;\n"
|
||||
<< "\n"
|
||||
<< " protected:\n"
|
||||
<< " void updateInternals() {\n";
|
||||
for (auto dimension : dimensions) {
|
||||
std::string id = convert_xmlid_to_cppid(dimension, false);
|
||||
std::cout << " dimensions.m_" << id
|
||||
<< " = dimensionById(\"" << dimension << "\");\n";
|
||||
std::cout << " byId(dimensions.m_" << id
|
||||
<< ", \"" << dimension << "\");\n";
|
||||
}
|
||||
for (auto color : colors) {
|
||||
std::string id = convert_xmlid_to_cppid(color, false);
|
||||
std::cout << " colors.m_" << id
|
||||
<< " = colorById(\"" << color << "\");\n";
|
||||
std::cout << " byId(colors.m_" << id
|
||||
<< ", \"" << color << "\");\n";
|
||||
}
|
||||
for (auto part : parts) {
|
||||
std::string id = convert_xmlid_to_cppid(part, false);
|
||||
std::cout << " byId(parts.m_" << id
|
||||
<< ", \"" << part << "\");\n";
|
||||
}
|
||||
for (auto style : styles) {
|
||||
std::string id = convert_xmlid_to_cppid(style, false);
|
||||
std::cout << " styles.m_" << id
|
||||
<< " = styleById(\"" << style << "\");\n";
|
||||
std::cout << " byId(styles.m_" << id
|
||||
<< ", \"" << style << "\");\n";
|
||||
}
|
||||
std::cout
|
||||
<< " }\n"
|
||||
<< "\n"
|
||||
<< " private:\n"
|
||||
<< " int dimensionById(const std::string& id) {\n"
|
||||
<< " return static_cast<T*>(this)->getDimensionById(id);\n"
|
||||
<< " void byId(int& dimension, const std::string& id) {\n"
|
||||
<< " dimension = static_cast<T*>(this)->getDimensionById(id);\n"
|
||||
<< " }\n"
|
||||
<< " gfx::Color colorById(const std::string& id) {\n"
|
||||
<< " return static_cast<T*>(this)->getColorById(id);\n"
|
||||
<< " void byId(gfx::Color& color, const std::string& id) {\n"
|
||||
<< " color = static_cast<T*>(this)->getColorById(id);\n"
|
||||
<< " }\n"
|
||||
<< " skin::Style* styleById(const std::string& id) {\n"
|
||||
<< " return static_cast<T*>(this)->getStyle(id);\n"
|
||||
<< " void byId(skin::SkinPartPtr& part, const std::string& id) {\n"
|
||||
<< " part = static_cast<T*>(this)->getPartById(id);\n"
|
||||
<< " }\n"
|
||||
<< " void byId(skin::Style*& style, const std::string& id) {\n"
|
||||
<< " style = static_cast<T*>(this)->getStyle(id);\n"
|
||||
<< " }\n";
|
||||
|
||||
std::cout
|
||||
|
@ -274,10 +274,11 @@ bool ButtonBase::onProcessMessage(Message* msg)
|
||||
void ButtonBase::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
gfx::Rect box;
|
||||
gfx::Size iconSize = (m_iconInterface ? m_iconInterface->getSize(): gfx::Size(0, 0));
|
||||
getTextIconInfo(&box, NULL, NULL,
|
||||
m_iconInterface ? m_iconInterface->getIconAlign(): 0,
|
||||
m_iconInterface ? m_iconInterface->getWidth(): 0,
|
||||
m_iconInterface ? m_iconInterface->getHeight(): 0);
|
||||
m_iconInterface ? m_iconInterface->getIconAlign(): 0,
|
||||
iconSize.w,
|
||||
iconSize.h);
|
||||
|
||||
ev.setPreferredSize(box.w + border().width(),
|
||||
box.h + border().height());
|
||||
|
@ -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.
|
||||
@ -25,8 +25,7 @@ namespace ui {
|
||||
public:
|
||||
virtual ~IButtonIcon() { }
|
||||
virtual void destroy() = 0;
|
||||
virtual int getWidth() = 0;
|
||||
virtual int getHeight() = 0;
|
||||
virtual gfx::Size getSize() = 0;
|
||||
virtual she::Surface* getNormalIcon() = 0;
|
||||
virtual she::Surface* getSelectedIcon() = 0;
|
||||
virtual she::Surface* getDisabledIcon() = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user