mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Add <dimensions> to skin.xml
This commit is contained in:
parent
ebdc2700c1
commit
11386543c8
@ -3,6 +3,11 @@
|
||||
author="Ilija Melentijevic & David Capello"
|
||||
url="http://ilkke.blogspot.com/">
|
||||
|
||||
<dimensions>
|
||||
<dim id="tabs_height" value="17" />
|
||||
<dim id="tabs_empty_height" value="5" />
|
||||
</dimensions>
|
||||
|
||||
<colors>
|
||||
<color id="text" value="#000000" />
|
||||
<color id="disabled" value="#968275" />
|
||||
|
@ -377,6 +377,23 @@ void SkinTheme::onRegenerate()
|
||||
XmlDocumentRef doc = open_xml(rf.filename());
|
||||
TiXmlHandle handle(doc);
|
||||
|
||||
// Load dimension
|
||||
{
|
||||
TiXmlElement* xmlDim = handle
|
||||
.FirstChild("skin")
|
||||
.FirstChild("dimensions")
|
||||
.FirstChild("dim").ToElement();
|
||||
while (xmlDim) {
|
||||
std::string id = xmlDim->Attribute("id");
|
||||
uint32_t value = strtol(xmlDim->Attribute("value"), NULL, 10);
|
||||
|
||||
PRINTF("Loading dimension '%s'...\n", id.c_str());
|
||||
|
||||
m_dimensions_by_id[id] = value;
|
||||
xmlDim = xmlDim->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
// Load colors
|
||||
{
|
||||
TiXmlElement* xmlColor = handle
|
||||
|
@ -108,6 +108,10 @@ namespace app {
|
||||
return m_parts_by_id[id];
|
||||
}
|
||||
|
||||
int getDimensionById(const std::string& id) {
|
||||
return m_dimensions_by_id[id] * ui::guiscale();
|
||||
}
|
||||
|
||||
gfx::Color getColorById(const std::string& id) {
|
||||
return m_colors_by_id[id];
|
||||
}
|
||||
@ -141,6 +145,7 @@ namespace app {
|
||||
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;
|
||||
std::map<std::string, int> m_dimensions_by_id;
|
||||
std::vector<ui::Cursor*> m_cursors;
|
||||
StyleSheet m_stylesheet;
|
||||
she::Font* m_minifont;
|
||||
|
@ -421,11 +421,12 @@ void Tabs::onResize(ResizeEvent& ev)
|
||||
void Tabs::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
SkinTheme* theme = static_cast<SkinTheme*>(this->getTheme());
|
||||
gfx::Size reqsize(0, theme->get_part(PART_TAB_BOTTOM_NORMAL)->height());
|
||||
gfx::Size reqsize(0, 0);
|
||||
|
||||
if (!m_list.empty()) {
|
||||
reqsize.h += theme->get_part(PART_TAB_FILLER)->height();
|
||||
}
|
||||
if (m_list.empty())
|
||||
reqsize.h = theme->dimensions.tabsEmptyHeight();
|
||||
else
|
||||
reqsize.h = theme->dimensions.tabsHeight();
|
||||
|
||||
ev.setPreferredSize(reqsize);
|
||||
}
|
||||
|
@ -14,11 +14,22 @@
|
||||
|
||||
void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
{
|
||||
std::vector<std::string> dimensions;
|
||||
std::vector<std::string> colors;
|
||||
std::vector<std::string> styles;
|
||||
|
||||
TiXmlHandle handle(doc);
|
||||
TiXmlElement* elem = handle
|
||||
.FirstChild("skin")
|
||||
.FirstChild("dimensions")
|
||||
.FirstChild("dim").ToElement();
|
||||
while (elem) {
|
||||
const char* id = elem->Attribute("id");
|
||||
dimensions.push_back(id);
|
||||
elem = elem->NextSiblingElement();
|
||||
}
|
||||
|
||||
elem = handle
|
||||
.FirstChild("skin")
|
||||
.FirstChild("colors")
|
||||
.FirstChild("color").ToElement();
|
||||
@ -54,6 +65,26 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
<< " public:\n"
|
||||
<< "\n";
|
||||
|
||||
// Dimensions sub class
|
||||
std::cout
|
||||
<< " class Dimensions {\n"
|
||||
<< " template<typename T> friend class SkinFile;\n"
|
||||
<< " public:\n";
|
||||
for (auto dimension : dimensions) {
|
||||
std::string id = convert_xmlid_to_cppid(dimension, false);
|
||||
std::cout
|
||||
<< " int " << id << "() const { return m_" << id << "; }\n";
|
||||
}
|
||||
std::cout
|
||||
<< " private:\n";
|
||||
for (auto dimension : dimensions) {
|
||||
std::string id = convert_xmlid_to_cppid(dimension, false);
|
||||
std::cout
|
||||
<< " int m_" << id << ";\n";
|
||||
}
|
||||
std::cout
|
||||
<< " };\n";
|
||||
|
||||
// Colors sub class
|
||||
std::cout
|
||||
<< " class Colors {\n"
|
||||
@ -97,11 +128,17 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
|
||||
std::cout
|
||||
<< "\n"
|
||||
<< " Dimensions dimensions;\n"
|
||||
<< " Colors colors;\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";
|
||||
}
|
||||
for (auto color : colors) {
|
||||
std::string id = convert_xmlid_to_cppid(color, false);
|
||||
std::cout << " colors.m_" << id
|
||||
@ -116,6 +153,9 @@ void gen_skin_class(TiXmlDocument* doc, const std::string& inputFn)
|
||||
<< " }\n"
|
||||
<< "\n"
|
||||
<< " private:\n"
|
||||
<< " int dimensionById(const std::string& id) {\n"
|
||||
<< " return static_cast<T*>(this)->getDimensionById(id);\n"
|
||||
<< " }\n"
|
||||
<< " gfx::Color colorById(const std::string& id) {\n"
|
||||
<< " return static_cast<T*>(this)->getColorById(id);\n"
|
||||
<< " }\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user