mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-23 22:52:34 +01:00
byuu says: Changelog: - synchronizes lots of nall changes - changes displayed program title from tomoko to higan(*) - browser dialog sort is case-insensitive - .sys folders look at user-selected library path; no longer hard-coded Tried to get rid of the file modes from the Windows browser dialog, but it was being a bitch so I left it on for now. - The storage locations and binary still use tomoko. I'm not really sure what to do here. The idea is there may be more than one "higan" UI in the future, but I don't want people to go around calling the entire program by the UI name. For official Windows releases, I can rename the binaries to "higan-{profile}.exe", and by putting the config files with the binary, they won't ever see the tomoko folder. Linux is of course trickier. Note: Windows users will need to edit hiro/components.hpp and comment out these lines: #define Hiro_Console #define Hiro_IconView #define Hiro_SourceView #define Hiro_TreeView I forgot to do that, and too lazy to upload another WIP.
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
namespace phoenix {
|
|
|
|
string pFont::serif(unsigned size, string style) {
|
|
if(size == 0) size = 8;
|
|
if(style == "") style = "Normal";
|
|
return {"Serif, ", size, ", ", style};
|
|
}
|
|
|
|
string pFont::sans(unsigned size, string style) {
|
|
if(size == 0) size = 8;
|
|
if(style == "") style = "Normal";
|
|
return {"Sans, ", size, ", ", style};
|
|
}
|
|
|
|
string pFont::monospace(unsigned size, string style) {
|
|
if(size == 0) size = 8;
|
|
if(style == "") style = "Normal";
|
|
return {"Liberation Mono, ", size, ", ", style};
|
|
}
|
|
|
|
Size pFont::size(string font, string text) {
|
|
return pFont::size(pFont::create(font), text);
|
|
}
|
|
|
|
QFont pFont::create(string description) {
|
|
lstring part = description.split(",", 2L).strip();
|
|
|
|
string family = "Sans";
|
|
unsigned size = 8u;
|
|
bool bold = false;
|
|
bool italic = false;
|
|
|
|
if(part[0] != "") family = part[0];
|
|
if(part.size() >= 2) size = decimal(part[1]);
|
|
if(part.size() >= 3) bold = (bool)part[2].find("Bold");
|
|
if(part.size() >= 3) italic = (bool)part[2].find("Italic");
|
|
|
|
QFont qtFont;
|
|
qtFont.setFamily(family);
|
|
qtFont.setPointSize(size);
|
|
if(bold) qtFont.setBold(true);
|
|
if(italic) qtFont.setItalic(true);
|
|
return qtFont;
|
|
}
|
|
|
|
Size pFont::size(const QFont& qtFont, string text) {
|
|
QFontMetrics metrics(qtFont);
|
|
|
|
lstring lines;
|
|
lines.split("\n", text);
|
|
|
|
unsigned maxWidth = 0;
|
|
for(auto& line : lines) {
|
|
maxWidth = max(maxWidth, metrics.width(line));
|
|
}
|
|
|
|
return {maxWidth, metrics.height() * lines.size()};
|
|
}
|
|
|
|
}
|