mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-02 13:20:12 +00:00
Cursors coordinates are specified in the default_skin.xml now.
This commit is contained in:
parent
f95a67f8fc
commit
a2c3517717
@ -1,8 +1,26 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- ASE Default Skin -->
|
<skin name="Default Skin"
|
||||||
<skin name="ASE Default Skin"
|
|
||||||
author="Ilija Melentijevic"
|
author="Ilija Melentijevic"
|
||||||
url="http://ilkke.blogspot.com/">
|
url="http://ilkke.blogspot.com/">
|
||||||
|
|
||||||
|
<cursors>
|
||||||
|
<cursor id="normal" x="80" y="0" w="16" h="16" focusx="0" focusy="0" />
|
||||||
|
<cursor id="normal_add" x="80" y="16" w="16" h="16" focusx="0" focusy="0" />
|
||||||
|
<cursor id="forbidden" x="80" y="32" w="16" h="16" focusx="0" focusy="0" />
|
||||||
|
<cursor id="hand" x="80" y="48" w="16" h="16" focusx="5" focusy="3" />
|
||||||
|
<cursor id="scroll" x="80" y="64" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="move" x="80" y="80" w="16" h="16" focusx="0" focusy="0" />
|
||||||
|
<cursor id="size_tl" x="80" y="96" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="size_t" x="80" y="112" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="size_tr" x="80" y="128" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="size_l" x="80" y="144" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="size_r" x="80" y="160" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="size_bl" x="80" y="176" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="size_b" x="80" y="192" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="size_br" x="80" y="208" w="16" h="16" focusx="8" focusy="8" />
|
||||||
|
<cursor id="eyedropper" x="80" y="224" w="16" h="16" focusx="0" focusy="15" />
|
||||||
|
</cursors>
|
||||||
|
|
||||||
<tools>
|
<tools>
|
||||||
|
|
||||||
<tool id="rectangular_marquee" x="144" y="0" w="16" h="16" />
|
<tool id="rectangular_marquee" x="144" y="0" w="16" h="16" />
|
||||||
|
@ -49,22 +49,6 @@ static struct
|
|||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
} sheet_info[PARTS] = {
|
} sheet_info[PARTS] = {
|
||||||
|
|
||||||
{ 80, 0, 16, 16 }, // PART_CURSOR_NORMAL,
|
|
||||||
{ 80, 16, 16, 16 }, // PART_CURSOR_NORMAL_ADD,
|
|
||||||
{ 80, 32, 16, 16 }, // PART_CURSOR_FORBIDDEN,
|
|
||||||
{ 80, 48, 16, 16 }, // PART_CURSOR_HAND,
|
|
||||||
{ 80, 64, 16, 16 }, // PART_CURSOR_SCROLL,
|
|
||||||
{ 80, 80, 16, 16 }, // PART_CURSOR_MOVE,
|
|
||||||
{ 80, 96, 16, 16 }, // PART_CURSOR_SIZE_TL,
|
|
||||||
{ 80,112, 16, 16 }, // PART_CURSOR_SIZE_T,
|
|
||||||
{ 80,128, 16, 16 }, // PART_CURSOR_SIZE_TR,
|
|
||||||
{ 80,144, 16, 16 }, // PART_CURSOR_SIZE_L,
|
|
||||||
{ 80,160, 16, 16 }, // PART_CURSOR_SIZE_R,
|
|
||||||
{ 80,176, 16, 16 }, // PART_CURSOR_SIZE_BL,
|
|
||||||
{ 80,192, 16, 16 }, // PART_CURSOR_SIZE_B,
|
|
||||||
{ 80,208, 16, 16 }, // PART_CURSOR_SIZE_BR,
|
|
||||||
{ 80,224, 16, 16 }, // PART_CURSOR_EYEDROPPER,
|
|
||||||
|
|
||||||
{ 32, 32, 8, 8 }, // PART_RADIO_NORMAL
|
{ 32, 32, 8, 8 }, // PART_RADIO_NORMAL
|
||||||
{ 32, 48, 8, 8 }, // PART_RADIO_SELECTED
|
{ 32, 48, 8, 8 }, // PART_RADIO_SELECTED
|
||||||
{ 32, 32, 8, 8 }, // PART_RADIO_DISABLED
|
{ 32, 32, 8, 8 }, // PART_RADIO_DISABLED
|
||||||
@ -343,23 +327,25 @@ static struct
|
|||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
int x, y;
|
const char* id;
|
||||||
} focus_info[] = {
|
int focusx, focusy;
|
||||||
{ 0, 0 }, // JI_CURSOR_NORMAL,
|
} cursors_info[JI_CURSORS] = {
|
||||||
{ 0, 0 }, // JI_CURSOR_NORMAL_ADD,
|
{ "null", 0, 0 }, // JI_CURSOR_NULL
|
||||||
{ 0, 0 }, // JI_CURSOR_FORBIDDEN,
|
{ "normal", 0, 0 }, // JI_CURSOR_NORMAL
|
||||||
{ 5, 3 }, // JI_CURSOR_HAND,
|
{ "normal_add", 0, 0 }, // JI_CURSOR_NORMAL_ADD
|
||||||
{ 8, 8 }, // JI_CURSOR_SCROLL,
|
{ "forbidden", 0, 0 }, // JI_CURSOR_FORBIDDEN
|
||||||
{ 0, 0 }, // JI_CURSOR_MOVE,
|
{ "hand", 0, 0 }, // JI_CURSOR_HAND
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_TL,
|
{ "scroll", 0, 0 }, // JI_CURSOR_SCROLL
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_T,
|
{ "move", 0, 0 }, // JI_CURSOR_MOVE
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_TR,
|
{ "size_tl", 0, 0 }, // JI_CURSOR_SIZE_TL
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_L,
|
{ "size_t", 0, 0 }, // JI_CURSOR_SIZE_T
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_R,
|
{ "size_tr", 0, 0 }, // JI_CURSOR_SIZE_TR
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_BL,
|
{ "size_l", 0, 0 }, // JI_CURSOR_SIZE_L
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_B,
|
{ "size_r", 0, 0 }, // JI_CURSOR_SIZE_R
|
||||||
{ 8, 8 }, // JI_CURSOR_SIZE_BR,
|
{ "size_bl", 0, 0 }, // JI_CURSOR_SIZE_BL
|
||||||
{ 0, 15 }, // JI_CURSOR_EYEDROPPER,
|
{ "size_b", 0, 0 }, // JI_CURSOR_SIZE_B
|
||||||
|
{ "size_br", 0, 0 }, // JI_CURSOR_SIZE_BR
|
||||||
|
{ "eyedropper", 0, 0 }, // JI_CURSOR_EYEDROPPER
|
||||||
};
|
};
|
||||||
|
|
||||||
SkinneableTheme::SkinneableTheme()
|
SkinneableTheme::SkinneableTheme()
|
||||||
@ -367,6 +353,8 @@ SkinneableTheme::SkinneableTheme()
|
|||||||
this->name = "Skinneable Theme";
|
this->name = "Skinneable Theme";
|
||||||
|
|
||||||
m_sheet_bmp = NULL;
|
m_sheet_bmp = NULL;
|
||||||
|
for (int c=0; c<JI_CURSORS; ++c)
|
||||||
|
m_cursors[c] = NULL;
|
||||||
for (int c=0; c<PARTS; ++c)
|
for (int c=0; c<PARTS; ++c)
|
||||||
m_part[c] = NULL;
|
m_part[c] = NULL;
|
||||||
|
|
||||||
@ -393,6 +381,10 @@ SkinneableTheme::SkinneableTheme()
|
|||||||
|
|
||||||
SkinneableTheme::~SkinneableTheme()
|
SkinneableTheme::~SkinneableTheme()
|
||||||
{
|
{
|
||||||
|
for (int c=0; c<JI_CURSORS; ++c)
|
||||||
|
if (m_cursors[c])
|
||||||
|
destroy_bitmap(m_cursors[c]);
|
||||||
|
|
||||||
for (int c=0; c<PARTS; ++c)
|
for (int c=0; c<PARTS; ++c)
|
||||||
destroy_bitmap(m_part[c]);
|
destroy_bitmap(m_part[c]);
|
||||||
|
|
||||||
@ -414,62 +406,101 @@ void SkinneableTheme::regen()
|
|||||||
textbox_fg_color = COLOR_FOREGROUND;
|
textbox_fg_color = COLOR_FOREGROUND;
|
||||||
textbox_bg_color = COLOR_BACKGROUND;
|
textbox_bg_color = COLOR_BACKGROUND;
|
||||||
|
|
||||||
for (int c=0; c<PARTS; ++c) {
|
// Load the skin XML
|
||||||
if (m_part[c]) destroy_bitmap(m_part[c]);
|
DIRS* dirs = filename_in_datadir("skins/default_skin.xml");
|
||||||
|
for (DIRS* dir=dirs; dir; dir=dir->next) {
|
||||||
|
if (!dir->path || !exists(dir->path))
|
||||||
|
continue;
|
||||||
|
|
||||||
m_part[c] = create_bitmap(sheet_info[c].w, sheet_info[c].h);
|
TiXmlDocument doc;
|
||||||
clear_to_color(m_part[c], bitmap_mask_color(m_part[c]));
|
if (!doc.LoadFile(dir->path))
|
||||||
|
throw ase_exception(&doc);
|
||||||
|
|
||||||
set_alpha_blender();
|
TiXmlHandle handle(&doc);
|
||||||
draw_trans_sprite(m_part[c], m_sheet_bmp, -sheet_info[c].x, -sheet_info[c].y);
|
|
||||||
set_trans_blender(0, 0, 0, 0);
|
|
||||||
|
|
||||||
m_part[c] = ji_apply_guiscale(m_part[c]);
|
// Load cursors
|
||||||
}
|
{
|
||||||
|
TiXmlElement* xmlCursor = handle
|
||||||
|
.FirstChild("skin")
|
||||||
|
.FirstChild("cursors")
|
||||||
|
.FirstChild("cursor").ToElement();
|
||||||
|
while (xmlCursor) {
|
||||||
|
std::string id = xmlCursor->Attribute("id");
|
||||||
|
int x = strtol(xmlCursor->Attribute("x"), NULL, 10);
|
||||||
|
int y = strtol(xmlCursor->Attribute("y"), NULL, 10);
|
||||||
|
int w = strtol(xmlCursor->Attribute("w"), NULL, 10);
|
||||||
|
int h = strtol(xmlCursor->Attribute("h"), NULL, 10);
|
||||||
|
int focusx = strtol(xmlCursor->Attribute("focusx"), NULL, 10);
|
||||||
|
int focusy = strtol(xmlCursor->Attribute("focusy"), NULL, 10);
|
||||||
|
|
||||||
// Load tool icons
|
for (int c=0; c<JI_CURSORS; ++c) {
|
||||||
{
|
if (id != cursors_info[c].id)
|
||||||
DIRS* dirs = filename_in_datadir("skins/default_skin.xml");
|
continue;
|
||||||
for (DIRS* dir=dirs; dir; dir=dir->next) {
|
|
||||||
if ((dir->path) && exists(dir->path)) {
|
|
||||||
|
|
||||||
TiXmlDocument doc;
|
cursors_info[c].focusx = focusx;
|
||||||
if (!doc.LoadFile(dir->path))
|
cursors_info[c].focusy = focusy;
|
||||||
throw ase_exception(&doc);
|
|
||||||
|
|
||||||
TiXmlHandle handle(&doc);
|
m_cursors[c] = cropPartFromSheet(m_cursors[c], x, y, w, h);
|
||||||
|
break;
|
||||||
TiXmlElement* xmlIcon = handle
|
|
||||||
.FirstChild("skin")
|
|
||||||
.FirstChild("tools")
|
|
||||||
.FirstChild("tool").ToElement();
|
|
||||||
while (xmlIcon) {
|
|
||||||
// Get the tool-icon rectangle
|
|
||||||
const char* tool_id = xmlIcon->Attribute("id");
|
|
||||||
int x = strtol(xmlIcon->Attribute("x"), NULL, 10);
|
|
||||||
int y = strtol(xmlIcon->Attribute("y"), NULL, 10);
|
|
||||||
int w = strtol(xmlIcon->Attribute("w"), NULL, 10);
|
|
||||||
int h = strtol(xmlIcon->Attribute("h"), NULL, 10);
|
|
||||||
|
|
||||||
// Crop the tool-icon from the sheet
|
|
||||||
BITMAP* toolicon = create_bitmap(w, h);
|
|
||||||
clear_to_color(toolicon, bitmap_mask_color(toolicon));
|
|
||||||
|
|
||||||
set_alpha_blender();
|
|
||||||
draw_trans_sprite(toolicon, m_sheet_bmp, -x, -y);
|
|
||||||
set_trans_blender(0, 0, 0, 0);
|
|
||||||
|
|
||||||
// Add the tool-icon in the map
|
|
||||||
if (m_toolicon[tool_id]) destroy_bitmap(m_toolicon[tool_id]);
|
|
||||||
m_toolicon[tool_id] = ji_apply_guiscale(toolicon);
|
|
||||||
|
|
||||||
xmlIcon = xmlIcon->NextSiblingElement();
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
xmlCursor = xmlCursor->NextSiblingElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dirs_free(dirs);
|
|
||||||
|
// Load parts
|
||||||
|
for (int c=0; c<PARTS; ++c) {
|
||||||
|
m_part[c] = cropPartFromSheet(m_part[c],
|
||||||
|
sheet_info[c].x, sheet_info[c].y,
|
||||||
|
sheet_info[c].w, sheet_info[c].h);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load tool icons
|
||||||
|
{
|
||||||
|
TiXmlElement* xmlIcon = handle
|
||||||
|
.FirstChild("skin")
|
||||||
|
.FirstChild("tools")
|
||||||
|
.FirstChild("tool").ToElement();
|
||||||
|
while (xmlIcon) {
|
||||||
|
// Get the tool-icon rectangle
|
||||||
|
const char* tool_id = xmlIcon->Attribute("id");
|
||||||
|
int x = strtol(xmlIcon->Attribute("x"), NULL, 10);
|
||||||
|
int y = strtol(xmlIcon->Attribute("y"), NULL, 10);
|
||||||
|
int w = strtol(xmlIcon->Attribute("w"), NULL, 10);
|
||||||
|
int h = strtol(xmlIcon->Attribute("h"), NULL, 10);
|
||||||
|
|
||||||
|
// Crop the tool-icon from the sheet
|
||||||
|
m_toolicon[tool_id] = cropPartFromSheet(m_toolicon[tool_id], x, y, w, h);
|
||||||
|
|
||||||
|
xmlIcon = xmlIcon->NextSiblingElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
dirs_free(dirs);
|
||||||
|
}
|
||||||
|
|
||||||
|
BITMAP* SkinneableTheme::cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h)
|
||||||
|
{
|
||||||
|
if (bmp &&
|
||||||
|
(bmp->w != w ||
|
||||||
|
bmp->h != h ||
|
||||||
|
bitmap_color_depth(bmp) != bitmap_color_depth(screen))) {
|
||||||
|
destroy_bitmap(bmp);
|
||||||
|
bmp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!bmp)
|
||||||
|
bmp = create_bitmap(w, h);
|
||||||
|
|
||||||
|
clear_to_color(bmp, bitmap_mask_color(bmp));
|
||||||
|
|
||||||
|
set_alpha_blender();
|
||||||
|
draw_trans_sprite(bmp, m_sheet_bmp, -x, -y);
|
||||||
|
set_trans_blender(0, 0, 0, 0);
|
||||||
|
|
||||||
|
return ji_apply_guiscale(bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
BITMAP* SkinneableTheme::set_cursor(int type, int* focus_x, int* focus_y)
|
BITMAP* SkinneableTheme::set_cursor(int type, int* focus_x, int* focus_y)
|
||||||
@ -480,9 +511,11 @@ BITMAP* SkinneableTheme::set_cursor(int type, int* focus_x, int* focus_y)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*focus_x = focus_info[type-JI_CURSOR_NORMAL].x*jguiscale();
|
assert(type >= 0 && type < JI_CURSORS);
|
||||||
*focus_y = focus_info[type-JI_CURSOR_NORMAL].y*jguiscale();
|
|
||||||
return m_part[PART_CURSOR_NORMAL+type-JI_CURSOR_NORMAL];
|
*focus_x = cursors_info[type].focusx*jguiscale();
|
||||||
|
*focus_y = cursors_info[type].focusy*jguiscale();
|
||||||
|
return m_cursors[type];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,22 +43,6 @@ private:
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
|
||||||
PART_CURSOR_NORMAL,
|
|
||||||
PART_CURSOR_NORMAL_ADD,
|
|
||||||
PART_CURSOR_FORBIDDEN,
|
|
||||||
PART_CURSOR_HAND,
|
|
||||||
PART_CURSOR_SCROLL,
|
|
||||||
PART_CURSOR_MOVE,
|
|
||||||
PART_CURSOR_SIZE_TL,
|
|
||||||
PART_CURSOR_SIZE_T,
|
|
||||||
PART_CURSOR_SIZE_TR,
|
|
||||||
PART_CURSOR_SIZE_L,
|
|
||||||
PART_CURSOR_SIZE_R,
|
|
||||||
PART_CURSOR_SIZE_BL,
|
|
||||||
PART_CURSOR_SIZE_B,
|
|
||||||
PART_CURSOR_SIZE_BR,
|
|
||||||
PART_CURSOR_EYEDROPPER,
|
|
||||||
|
|
||||||
PART_RADIO_NORMAL,
|
PART_RADIO_NORMAL,
|
||||||
PART_RADIO_SELECTED,
|
PART_RADIO_SELECTED,
|
||||||
PART_RADIO_DISABLED,
|
PART_RADIO_DISABLED,
|
||||||
@ -337,6 +321,7 @@ enum {
|
|||||||
class SkinneableTheme : public jtheme
|
class SkinneableTheme : public jtheme
|
||||||
{
|
{
|
||||||
BITMAP* m_sheet_bmp;
|
BITMAP* m_sheet_bmp;
|
||||||
|
BITMAP* m_cursors[JI_CURSORS];
|
||||||
BITMAP* m_part[PARTS];
|
BITMAP* m_part[PARTS];
|
||||||
std::map<std::string, BITMAP*> m_toolicon;
|
std::map<std::string, BITMAP*> m_toolicon;
|
||||||
|
|
||||||
@ -441,6 +426,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
BITMAP* cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h);
|
||||||
int get_bg_color(JWidget widget);
|
int get_bg_color(JWidget widget);
|
||||||
void draw_textstring(const char *t, int fg_color, int bg_color,
|
void draw_textstring(const char *t, int fg_color, int bg_color,
|
||||||
bool fill_bg, JWidget widget, const JRect rect,
|
bool fill_bg, JWidget widget, const JRect rect,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user