Move <tools> to <parts> in theme.xml

This commit is contained in:
David Capello 2017-03-13 22:55:52 -03:00
parent bc4f8ad3e1
commit 66839529b3
3 changed files with 54 additions and 82 deletions

View File

@ -134,45 +134,6 @@
<cursor id="magnifier" x="80" y="240" w="16" h="16" focusx="5" focusy="5" />
</cursors>
<tools>
<tool id="rectangular_marquee" x="144" y="0" w="16" h="16" />
<tool id="elliptical_marquee" x="160" y="0" w="16" h="16" />
<tool id="lasso" x="176" y="0" w="16" h="16" />
<tool id="polygonal_lasso" x="192" y="0" w="16" h="16" />
<tool id="magic_wand" x="208" y="0" w="16" h="16" />
<tool id="pencil" x="144" y="16" w="16" h="16" />
<tool id="spray" x="160" y="16" w="16" h="16" />
<tool id="eraser" x="144" y="32" w="16" h="16" />
<tool id="eyedropper" x="160" y="32" w="16" h="16" />
<tool id="hand" x="176" y="32" w="16" h="16" />
<tool id="move" x="192" y="32" w="16" h="16" />
<tool id="zoom" x="208" y="32" w="16" h="16" />
<tool id="slice" x="224" y="32" w="16" h="16" />
<tool id="paint_bucket" x="144" y="48" w="16" h="16" />
<tool id="line" x="144" y="64" w="16" h="16" />
<tool id="curve" x="160" y="64" w="16" h="16" />
<tool id="rectangle" x="144" y="80" w="16" h="16" />
<tool id="filled_rectangle" x="160" y="80" w="16" h="16" />
<tool id="ellipse" x="176" y="80" w="16" h="16" />
<tool id="filled_ellipse" x="192" y="80" w="16" h="16" />
<tool id="contour" x="144" y="96" w="16" h="16" />
<tool id="polygon" x="160" y="96" w="16" h="16" />
<!--tool id="shade" x="144" y="112" w="16" h="16" /-->
<tool id="blur" x="160" y="112" w="16" h="16" />
<tool id="jumble" x="176" y="112" w="16" h="16" />
<tool id="configuration" x="144" y="128" w="16" h="16" />
<tool id="minieditor" x="160" y="128" w="16" h="16" />
</tools>
<parts>
<part id="radio_normal" x="64" y="64" w="8" h="8" />
<part id="radio_selected" x="64" y="80" w="8" h="8" />
@ -406,6 +367,32 @@
<part id="icon_save" x="232" y="264" w="8" h="8" />
<part id="icon_save_small" x="240" y="264" w="8" h="8" />
<part id="icon_slice" x="248" y="264" w="8" h="8" />
<part id="tool_rectangular_marquee" x="144" y="0" w="16" h="16" />
<part id="tool_elliptical_marquee" x="160" y="0" w="16" h="16" />
<part id="tool_lasso" x="176" y="0" w="16" h="16" />
<part id="tool_polygonal_lasso" x="192" y="0" w="16" h="16" />
<part id="tool_magic_wand" x="208" y="0" w="16" h="16" />
<part id="tool_pencil" x="144" y="16" w="16" h="16" />
<part id="tool_spray" x="160" y="16" w="16" h="16" />
<part id="tool_eraser" x="144" y="32" w="16" h="16" />
<part id="tool_eyedropper" x="160" y="32" w="16" h="16" />
<part id="tool_hand" x="176" y="32" w="16" h="16" />
<part id="tool_move" x="192" y="32" w="16" h="16" />
<part id="tool_zoom" x="208" y="32" w="16" h="16" />
<part id="tool_slice" x="224" y="32" w="16" h="16" />
<part id="tool_paint_bucket" x="144" y="48" w="16" h="16" />
<part id="tool_line" x="144" y="64" w="16" h="16" />
<part id="tool_curve" x="160" y="64" w="16" h="16" />
<part id="tool_rectangle" x="144" y="80" w="16" h="16" />
<part id="tool_filled_rectangle" x="160" y="80" w="16" h="16" />
<part id="tool_ellipse" x="176" y="80" w="16" h="16" />
<part id="tool_filled_ellipse" x="192" y="80" w="16" h="16" />
<part id="tool_contour" x="144" y="96" w="16" h="16" />
<part id="tool_polygon" x="160" y="96" w="16" h="16" />
<part id="tool_blur" x="160" y="112" w="16" h="16" />
<part id="tool_jumble" x="176" y="112" w="16" h="16" />
<part id="tool_configuration" x="144" y="128" w="16" h="16" />
<part id="tool_minieditor" x="160" y="128" w="16" h="16" />
</parts>
<styles>

View File

@ -202,11 +202,6 @@ SkinTheme::~SkinTheme()
for (size_t c=0; c<m_cursors.size(); ++c)
delete m_cursors[c];
for (std::map<std::string, she::Surface*>::iterator
it = m_toolicon.begin(); it != m_toolicon.end(); ++it) {
it->second->dispose();
}
if (m_sheet)
m_sheet->dispose();
@ -426,30 +421,6 @@ void SkinTheme::loadXml(const std::string& skinId)
}
}
// Load tool icons
{
TiXmlElement* xmlIcon = handle
.FirstChild("theme")
.FirstChild("tools")
.FirstChild("tool").ToElement();
while (xmlIcon) {
// Get the tool-icon rectangle
const char* 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);
LOG(VERBOSE) << "THEME: Loading tool icon " << id << "\n";
// Crop the tool-icon from the sheet
m_toolicon[id] = sliceSheet(
m_toolicon[id], gfx::Rect(x, y, w, h));
xmlIcon = xmlIcon->NextSiblingElement();
}
}
// Load parts
{
TiXmlElement* xmlPart = handle
@ -1610,11 +1581,11 @@ void SkinTheme::drawEntryCaret(ui::Graphics* g, Entry* widget, int x, int y)
she::Surface* SkinTheme::getToolIcon(const char* toolId) const
{
std::map<std::string, she::Surface*>::const_iterator it = m_toolicon.find(toolId);
if (it != m_toolicon.end())
return it->second;
SkinPartPtr part = getPartById(std::string("tool_") + toolId);
if (part)
return part->bitmap(0);
else
return NULL;
return nullptr;
}
void SkinTheme::drawRect(Graphics* g, const Rect& rc,

View File

@ -83,23 +83,38 @@ namespace app {
void drawVline(ui::Graphics* g, const gfx::Rect& rc, SkinPart* skinPart);
void paintProgressBar(ui::Graphics* g, const gfx::Rect& rc, double progress);
ui::Style* getStyleById(const std::string& id) {
return m_styles[id];
ui::Style* getStyleById(const std::string& id) const {
auto it = m_styles.find(id);
if (it != m_styles.end())
return it->second;
else
return nullptr;
}
SkinPartPtr getPartById(const std::string& id) {
return m_parts_by_id[id];
SkinPartPtr getPartById(const std::string& id) const {
auto it = m_parts_by_id.find(id);
if (it != m_parts_by_id.end())
return it->second;
else
return SkinPartPtr(nullptr);
}
int getDimensionById(const std::string& id) {
int getDimensionById(const std::string& id) const {
// Warning! Don't use ui::guiscale(), as CurrentTheme::get()
// is still nullptr when we use this getDimensionById()
return m_dimensions_by_id[id] * this->guiscale();
auto it = m_dimensions_by_id.find(id);
if (it != m_dimensions_by_id.end())
return it->second * this->guiscale();
else
return 0;
}
gfx::Color getColorById(const std::string& id) {
ASSERT(m_colors_by_id.find(id) != m_colors_by_id.end());
return m_colors_by_id[id];
gfx::Color getColorById(const std::string& id) const {
auto it = m_colors_by_id.find(id);
if (it != m_colors_by_id.end())
return it->second;
else
return gfx::ColorNone;
}
void drawEntryCaret(ui::Graphics* g, ui::Entry* widget, int x, int y);
@ -127,7 +142,6 @@ namespace app {
she::Surface* m_sheet;
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;