forked from mia/Aegisub
Mirror toolbar button images for RTL locales
Some of the toolbar buttons are seriously wrong when mirrored and there doesn't seem to be a way to disable mirroring for the images while using RTL layout for the toolbar itself, so double-mirror them so that they end up with their original appearance. Ideally the button images would be localizable as some of them actually should be mirrored, but that's probably not worth the work involved. See #1354.
This commit is contained in:
parent
3d0e2baf4e
commit
0909d137b0
4 changed files with 15 additions and 11 deletions
|
@ -34,12 +34,12 @@ namespace agi { struct Context; }
|
||||||
#define STR_HELP(a) wxString StrHelp() const { return _(a); }
|
#define STR_HELP(a) wxString StrHelp() const { return _(a); }
|
||||||
#define CMD_TYPE(a) int Type() const { using namespace cmd; return a; }
|
#define CMD_TYPE(a) int Type() const { using namespace cmd; return a; }
|
||||||
|
|
||||||
#define CMD_ICON(icon) wxBitmap Icon(int size) const override { \
|
#define CMD_ICON(icon) wxBitmap Icon(int size, wxLayoutDirection dir = wxLayout_LeftToRight) const override { \
|
||||||
if (size == 64) return GETIMAGE(icon##_64); \
|
if (size == 64) return GETIMAGEDIR(icon##_64, dir); \
|
||||||
if (size == 48) return GETIMAGE(icon##_48); \
|
if (size == 48) return GETIMAGEDIR(icon##_48, dir); \
|
||||||
if (size == 32) return GETIMAGE(icon##_32); \
|
if (size == 32) return GETIMAGEDIR(icon##_32, dir); \
|
||||||
if (size == 24) return GETIMAGE(icon##_24); \
|
if (size == 24) return GETIMAGEDIR(icon##_24, dir); \
|
||||||
return GETIMAGE(icon##_16); \
|
return GETIMAGEDIR(icon##_16, dir); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define COMMAND_GROUP(cname, cmdname, menu, disp, help) \
|
#define COMMAND_GROUP(cname, cmdname, menu, disp, help) \
|
||||||
|
@ -107,7 +107,7 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(CommandNotFound, CommandError, "command/notfound
|
||||||
|
|
||||||
/// Request icon.
|
/// Request icon.
|
||||||
/// @param size Icon size.
|
/// @param size Icon size.
|
||||||
virtual wxBitmap Icon(int size) const { return wxBitmap{}; }
|
virtual wxBitmap Icon(int size, wxLayoutDirection = wxLayout_LeftToRight) const { return wxBitmap{}; }
|
||||||
|
|
||||||
/// Command function
|
/// Command function
|
||||||
virtual void operator()(agi::Context *c)=0;
|
virtual void operator()(agi::Context *c)=0;
|
||||||
|
|
|
@ -17,11 +17,14 @@
|
||||||
#include <wx/bitmap.h>
|
#include <wx/bitmap.h>
|
||||||
#include <wx/icon.h>
|
#include <wx/icon.h>
|
||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
|
#include <wx/intl.h>
|
||||||
#include <wx/mstream.h>
|
#include <wx/mstream.h>
|
||||||
|
|
||||||
wxBitmap libresrc_getimage(const unsigned char *buff, size_t size) {
|
wxBitmap libresrc_getimage(const unsigned char *buff, size_t size, int dir) {
|
||||||
wxMemoryInputStream mem(buff, size);
|
wxMemoryInputStream mem(buff, size);
|
||||||
return wxBitmap(wxImage(mem));
|
if (dir != wxLayout_RightToLeft)
|
||||||
|
return wxBitmap(wxImage(mem));
|
||||||
|
return wxBitmap(wxImage(mem).Mirror());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon libresrc_geticon(const unsigned char *buff, size_t size) {
|
wxIcon libresrc_geticon(const unsigned char *buff, size_t size) {
|
||||||
|
|
|
@ -20,9 +20,10 @@
|
||||||
class wxBitmap;
|
class wxBitmap;
|
||||||
class wxIcon;
|
class wxIcon;
|
||||||
|
|
||||||
wxBitmap libresrc_getimage(const unsigned char *image, size_t size);
|
wxBitmap libresrc_getimage(const unsigned char *image, size_t size, int dir=0);
|
||||||
wxIcon libresrc_geticon(const unsigned char *image, size_t size);
|
wxIcon libresrc_geticon(const unsigned char *image, size_t size);
|
||||||
#define GETIMAGE(a) libresrc_getimage(a, sizeof(a))
|
#define GETIMAGE(a) libresrc_getimage(a, sizeof(a))
|
||||||
|
#define GETIMAGEDIR(a, d) libresrc_getimage(a, sizeof(a), d)
|
||||||
#define GETICON(a) libresrc_geticon(a, sizeof(a))
|
#define GETICON(a) libresrc_geticon(a, sizeof(a))
|
||||||
|
|
||||||
#define GET_DEFAULT_CONFIG(a) std::make_pair(reinterpret_cast<const char *>(a), sizeof(a))
|
#define GET_DEFAULT_CONFIG(a) std::make_pair(reinterpret_cast<const char *>(a), sizeof(a))
|
||||||
|
|
|
@ -142,7 +142,7 @@ namespace {
|
||||||
flags & cmd::COMMAND_TOGGLE ? wxITEM_CHECK :
|
flags & cmd::COMMAND_TOGGLE ? wxITEM_CHECK :
|
||||||
wxITEM_NORMAL;
|
wxITEM_NORMAL;
|
||||||
|
|
||||||
wxBitmap const& bitmap = command->Icon(icon_size);
|
wxBitmap const& bitmap = command->Icon(icon_size, GetLayoutDirection());
|
||||||
AddTool(TOOL_ID_BASE + commands.size(), command->StrDisplay(context), bitmap, GetTooltip(command), kind);
|
AddTool(TOOL_ID_BASE + commands.size(), command->StrDisplay(context), bitmap, GetTooltip(command), kind);
|
||||||
|
|
||||||
commands.push_back(command);
|
commands.push_back(command);
|
||||||
|
|
Loading…
Reference in a new issue