mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-01 01:13:40 +00:00
Add mnemonics attribute for font and styles to enable/disable accelerators underlining
This commit is contained in:
parent
195a8d0e92
commit
dded1f6eae
@ -6,7 +6,7 @@
|
||||
</authors>
|
||||
<fonts>
|
||||
<font id="default" font="Aseprite" />
|
||||
<font id="mini" font="Aseprite Mini" />
|
||||
<font id="mini" font="Aseprite Mini" mnemonics="off" />
|
||||
</fonts>
|
||||
<dimensions>
|
||||
<dim id="scrollbar_size" value="12" />
|
||||
|
@ -409,8 +409,11 @@ void SkinTheme::loadXml(BackwardCompatibility* backward)
|
||||
if (sizeStr)
|
||||
size = std::strtol(sizeStr, nullptr, 10);
|
||||
|
||||
const char* mnemonicsStr = xmlFont->Attribute("mnemonics");
|
||||
bool mnemonics = mnemonicsStr ? (std::string(mnemonicsStr) != "off") : true;
|
||||
|
||||
os::FontRef font = fontData->getFont(size);
|
||||
m_themeFonts[idStr] = font;
|
||||
m_themeFonts[idStr] = ThemeFont(font, mnemonics);
|
||||
|
||||
if (id == "default")
|
||||
m_defaultFont = font;
|
||||
@ -624,8 +627,16 @@ void SkinTheme::loadXml(BackwardCompatibility* backward)
|
||||
{
|
||||
const char* fontId = xmlStyle->Attribute("font");
|
||||
if (fontId) {
|
||||
os::FontRef font = m_themeFonts[fontId];
|
||||
style->setFont(font);
|
||||
auto themeFont = m_themeFonts[fontId];
|
||||
style->setFont(themeFont.font());
|
||||
style->setMnemonics(themeFont.mnemonics());
|
||||
}
|
||||
|
||||
// Override mnemonics value if it is defined for this style.
|
||||
const char* mnemonicsStr = xmlStyle->Attribute("mnemonics");
|
||||
if (mnemonicsStr) {
|
||||
bool mnemonics = mnemonicsStr ? (std::string(mnemonicsStr) != "off") : true;
|
||||
style->setMnemonics(mnemonics);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,17 @@ namespace app {
|
||||
|
||||
class FontData;
|
||||
|
||||
class ThemeFont {
|
||||
public:
|
||||
ThemeFont() {}
|
||||
ThemeFont(os::FontRef font, bool mnemonics) : m_font(font), m_mnemonics(mnemonics) {}
|
||||
os::FontRef font() { return m_font; }
|
||||
bool mnemonics() { return m_mnemonics; }
|
||||
private:
|
||||
os::FontRef m_font;
|
||||
bool m_mnemonics;
|
||||
};
|
||||
|
||||
// This is the GUI theme used by Aseprite (which use images from
|
||||
// data/skins directory).
|
||||
class SkinTheme : public ui::Theme
|
||||
@ -161,7 +172,7 @@ namespace app {
|
||||
std::array<ui::Cursor*, ui::kCursorTypes> m_standardCursors;
|
||||
std::map<std::string, ui::Style*> m_styles;
|
||||
std::map<std::string, FontData*> m_fonts;
|
||||
std::map<std::string, os::FontRef> m_themeFonts;
|
||||
std::map<std::string, ThemeFont> m_themeFonts;
|
||||
os::FontRef m_defaultFont;
|
||||
os::FontRef m_miniFont;
|
||||
int m_preferredScreenScaling;
|
||||
|
@ -27,6 +27,7 @@ Style::Style(const Style* base)
|
||||
, m_border(base ? base->border(): Style::UndefinedBorder())
|
||||
, m_padding(base ? base->padding(): Style::UndefinedBorder())
|
||||
, m_font(nullptr)
|
||||
, m_mnemonics(base ? base->mnemonics() : true)
|
||||
{
|
||||
if (base)
|
||||
m_layers = base->layers();
|
||||
|
@ -105,6 +105,7 @@ namespace ui {
|
||||
const gfx::Border& border() const { return m_border; }
|
||||
const gfx::Border& padding() const { return m_padding; }
|
||||
os::Font* font() const { return m_font.get(); }
|
||||
const bool mnemonics() const { return m_mnemonics; }
|
||||
const Layers& layers() const { return m_layers; }
|
||||
Layers& layers() { return m_layers; }
|
||||
|
||||
@ -113,6 +114,7 @@ namespace ui {
|
||||
void setBorder(const gfx::Border& value) { m_border = value; }
|
||||
void setPadding(const gfx::Border& value) { m_padding = value; }
|
||||
void setFont(const os::FontRef& font);
|
||||
void setMnemonics(const bool enabled) { m_mnemonics = enabled; }
|
||||
void addLayer(const Layer& layer);
|
||||
|
||||
private:
|
||||
@ -123,6 +125,7 @@ namespace ui {
|
||||
gfx::Border m_border;
|
||||
gfx::Border m_padding;
|
||||
os::FontRef m_font;
|
||||
bool m_mnemonics;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
|
@ -464,7 +464,7 @@ void Theme::paintLayer(Graphics* g,
|
||||
g->drawUIText(text,
|
||||
layer.color(),
|
||||
bgColor,
|
||||
pt, mnemonic);
|
||||
pt, style->mnemonics() ? mnemonic : 0);
|
||||
}
|
||||
|
||||
if (style->font())
|
||||
|
Loading…
x
Reference in New Issue
Block a user