1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-04 21:05:27 +03:00

Renamed ASFont class to just Font

Originally the font implementation was based on SFont, but it was
recently replaced by an SDL_ttf based implementation, so the name
no longer made sense.
This commit is contained in:
Maarten ter Huurne 2013-08-03 22:30:12 +02:00
parent 0046fa9e19
commit 724aefe482
22 changed files with 85 additions and 73 deletions

View File

@ -1,6 +1,6 @@
bin_PROGRAMS = gmenu2x bin_PROGRAMS = gmenu2x
gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \ gmenu2x_SOURCES = font.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \
filelister.cpp gmenu2x.cpp iconbutton.cpp imagedialog.cpp inputdialog.cpp \ filelister.cpp gmenu2x.cpp iconbutton.cpp imagedialog.cpp inputdialog.cpp \
inputmanager.cpp linkapp.cpp link.cpp \ inputmanager.cpp linkapp.cpp link.cpp \
menu.cpp menusettingbool.cpp menusetting.cpp menusettingdir.cpp \ menu.cpp menusettingbool.cpp menusetting.cpp menusettingdir.cpp \
@ -14,7 +14,7 @@ gmenu2x_SOURCES = asfont.cpp button.cpp cpu.cpp dirdialog.cpp filedialog.cpp \
browsedialog.cpp buttonbox.cpp dialog.cpp \ browsedialog.cpp buttonbox.cpp dialog.cpp \
imageio.cpp powersaver.cpp monitor.cpp mediamonitor.cpp clock.cpp imageio.cpp powersaver.cpp monitor.cpp mediamonitor.cpp clock.cpp
noinst_HEADERS = asfont.h button.h cpu.h dirdialog.h \ noinst_HEADERS = font.h button.h cpu.h dirdialog.h \
filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.h \ filedialog.h filelister.h gmenu2x.h gp2x.h iconbutton.h imagedialog.h \
inputdialog.h inputmanager.h linkapp.h link.h \ inputdialog.h inputmanager.h linkapp.h link.h \
menu.h menusettingbool.h menusettingdir.h \ menu.h menusettingbool.h menusettingdir.h \

View File

@ -3,6 +3,7 @@
#include "filelister.h" #include "filelister.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "iconbutton.h" #include "iconbutton.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
using std::string; using std::string;
@ -269,7 +270,7 @@ void BrowseDialog::paint()
} }
icon->blit(gmenu2x->s, 5, offsetY); icon->blit(gmenu2x->s, 5, offsetY);
gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8, gmenu2x->s->write(gmenu2x->font, (*fl)[i], 24, offsetY + 8,
ASFont::HAlignLeft, ASFont::VAlignMiddle); Font::HAlignLeft, Font::VAlignMiddle);
if (ts.available() && ts.pressed() if (ts.available() && ts.pressed()
&& ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) { && ts.inRect(touchRect.x, offsetY + 3, touchRect.w, rowHeight)) {

View File

@ -2,7 +2,7 @@
#include "dialog.h" #include "dialog.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "asfont.h" #include "font.h"
Dialog::Dialog(GMenu2X *gmenu2x) : gmenu2x(gmenu2x) Dialog::Dialog(GMenu2X *gmenu2x) : gmenu2x(gmenu2x)
{ {
@ -31,14 +31,14 @@ void Dialog::writeTitle(const std::string &title, Surface *s)
{ {
if (s==NULL) if (s==NULL)
s = gmenu2x->s; s = gmenu2x->s;
s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"]/4, ASFont::HAlignLeft, ASFont::VAlignMiddle); s->write(gmenu2x->font, title, 40, gmenu2x->skinConfInt["topBarHeight"] / 4, Font::HAlignLeft, Font::VAlignMiddle);
} }
void Dialog::writeSubTitle(const std::string &subtitle, Surface *s) void Dialog::writeSubTitle(const std::string &subtitle, Surface *s)
{ {
if (s==NULL) if (s==NULL)
s = gmenu2x->s; s = gmenu2x->s;
s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"]/4*3, ASFont::HAlignLeft, ASFont::VAlignMiddle); s->write(gmenu2x->font, subtitle, 40, gmenu2x->skinConfInt["topBarHeight"] / 4 * 3, Font::HAlignLeft, Font::VAlignMiddle);
} }

View File

@ -1,4 +1,5 @@
#include "asfont.h" #include "font.h"
#include "debug.h" #include "debug.h"
#include "surface.h" #include "surface.h"
#include "utilities.h" #include "utilities.h"
@ -13,7 +14,7 @@
using namespace std; using namespace std;
ASFont::ASFont(const string &path) Font::Font(const string &path)
{ {
if (!TTF_WasInit() && TTF_Init() < 0) { if (!TTF_WasInit() && TTF_Init() < 0) {
ERROR("Unable to init SDL_ttf library\n"); ERROR("Unable to init SDL_ttf library\n");
@ -29,20 +30,20 @@ ASFont::ASFont(const string &path)
fontheight = TTF_FontHeight(font); fontheight = TTF_FontHeight(font);
} }
ASFont::~ASFont() Font::~Font()
{ {
TTF_CloseFont(font); TTF_CloseFont(font);
TTF_Quit(); TTF_Quit();
} }
int ASFont::getTextWidth(const char *text) int Font::getTextWidth(const char *text)
{ {
int w, h; int w, h;
TTF_SizeUTF8(font, text, &w, &h); TTF_SizeUTF8(font, text, &w, &h);
return w; return w;
} }
void ASFont::write(Surface *surface, const string &text, void Font::write(Surface *surface, const string &text,
int x, int y, HAlign halign, VAlign valign) int x, int y, HAlign halign, VAlign valign)
{ {
if (text.find("\n", 0) == string::npos) { if (text.find("\n", 0) == string::npos) {
@ -59,7 +60,7 @@ void ASFont::write(Surface *surface, const string &text,
} }
} }
void ASFont::writeLine(Surface *surface, const char *text, void Font::writeLine(Surface *surface, const char *text,
int x, int y, HAlign halign, VAlign valign) int x, int y, HAlign halign, VAlign valign)
{ {
switch (halign) { switch (halign) {

View File

@ -1,24 +1,21 @@
// Based on SFont by Karl Bartel. // Original font class was replaced by an SDL_ttf based one by Paul Cercueil.
// Adapted to C++ by Massimiliano Torromeo.
// Refactored by Maarten ter Huurne and several others (see git log).
// License: GPL version 2 or later. // License: GPL version 2 or later.
#ifndef ASFONT_H #ifndef FONT_H
#define ASFONT_H #define FONT_H
#include <SDL_ttf.h> #include <SDL_ttf.h>
#include <string> #include <string>
#include <vector>
class Surface; class Surface;
class ASFont { class Font {
public: public:
enum HAlign { HAlignLeft, HAlignRight, HAlignCenter }; enum HAlign { HAlignLeft, HAlignRight, HAlignCenter };
enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle }; enum VAlign { VAlignTop, VAlignBottom, VAlignMiddle };
ASFont(const std::string &font); Font(const std::string &font);
~ASFont(); ~Font();
int getTextWidth(const char *text); int getTextWidth(const char *text);
@ -44,4 +41,4 @@ private:
unsigned int fontheight; unsigned int fontheight;
}; };
#endif /* ASFONT_H */ #endif /* FONT_H */

View File

@ -20,12 +20,12 @@
#include "gp2x.h" #include "gp2x.h"
#include "asfont.h"
#include "clock.h" #include "clock.h"
#include "cpu.h" #include "cpu.h"
#include "debug.h" #include "debug.h"
#include "filedialog.h" #include "filedialog.h"
#include "filelister.h" #include "filelister.h"
#include "font.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "iconbutton.h" #include "iconbutton.h"
#include "inputdialog.h" #include "inputdialog.h"
@ -314,7 +314,7 @@ void GMenu2X::initBG() {
#else #else
string df = getDiskFree(CARD_ROOT); string df = getDiskFree(CARD_ROOT);
#endif #endif
bgmain->write(font, df, 22, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle); bgmain->write(font, df, 22, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle);
delete sd; delete sd;
cpuX = font->getTextWidth(df)+32; cpuX = font->getTextWidth(df)+32;
@ -367,7 +367,7 @@ void GMenu2X::initFont() {
quit(); quit();
exit(-1); exit(-1);
} }
font = new ASFont(fontFile); font = new Font(fontFile);
} }
void GMenu2X::initMenu() { void GMenu2X::initMenu() {
@ -655,7 +655,7 @@ void GMenu2X::main() {
sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32); sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32);
else else
sc.skinRes("icons/section.png")->blit(s,x-16,sectionLinkPadding); sc.skinRes("icons/section.png")->blit(s,x-16,sectionLinkPadding);
s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, ASFont::HAlignCenter, ASFont::VAlignBottom ); s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, Font::HAlignCenter, Font::VAlignBottom );
} }
//Links //Links
@ -675,10 +675,10 @@ void GMenu2X::main() {
drawScrollBar(linkRows,menu->sectionLinks()->size()/linkColumns + ((menu->sectionLinks()->size()%linkColumns==0) ? 0 : 1),menu->firstDispRow(),43,resY-81); drawScrollBar(linkRows,menu->sectionLinks()->size()/linkColumns + ((menu->sectionLinks()->size()%linkColumns==0) ? 0 : 1),menu->firstDispRow(),43,resY-81);
if (menu->selLink()!=NULL) { if (menu->selLink()!=NULL) {
s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, ASFont::HAlignCenter, ASFont::VAlignBottom ); s->write ( font, menu->selLink()->getDescription(), halfX, resY-19, Font::HAlignCenter, Font::VAlignBottom );
if (menu->selLinkApp()!=NULL) { if (menu->selLinkApp()!=NULL) {
#ifdef ENABLE_CPUFREQ #ifdef ENABLE_CPUFREQ
s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, ASFont::HAlignLeft, ASFont::VAlignMiddle ); s->write ( font, menu->selLinkApp()->clockStr(confInt["maxClock"]), cpuX, bottomBarTextY, Font::HAlignLeft, Font::VAlignMiddle );
#endif #endif
//Manual indicator //Manual indicator
if (!menu->selLinkApp()->getManual().empty()) if (!menu->selLinkApp()->getManual().empty())
@ -708,7 +708,7 @@ void GMenu2X::main() {
s->write(font, Clock::getInstance()->getTime(), s->write(font, Clock::getInstance()->getTime(),
halfX, bottomBarTextY, halfX, bottomBarTextY,
ASFont::HAlignCenter, ASFont::VAlignMiddle); Font::HAlignCenter, Font::VAlignMiddle);
if (helpDisplayed) { if (helpDisplayed) {
s->box(10,50,300,helpBoxHeight+4, skinConfColors[COLOR_MESSAGE_BOX_BG]); s->box(10,50,300,helpBoxHeight+4, skinConfColors[COLOR_MESSAGE_BOX_BG]);
@ -738,7 +738,7 @@ void GMenu2X::main() {
tickFPS = tickNow; tickFPS = tickNow;
drawn_frames = 0; drawn_frames = 0;
} }
s->write( font, fps+" FPS", resX-1,1 ,ASFont::HAlignRight ); s->write(font, fps + " FPS", resX - 1, 1, Font::HAlignRight);
#endif #endif
s->flip(); s->flip();
@ -1098,7 +1098,7 @@ void GMenu2X::contextMenu() {
//draw selection rect //draw selection rect
s->box( selbox.x, selbox.y, selbox.w, selbox.h, skinConfColors[COLOR_MESSAGE_BOX_SELECTION] ); s->box( selbox.x, selbox.y, selbox.w, selbox.h, skinConfColors[COLOR_MESSAGE_BOX_SELECTION] );
for (i=0; i<voices.size(); i++) for (i=0; i<voices.size(); i++)
s->write( font, voices[i].text, box.x+12, box.y+5+(h+2)*i, ASFont::HAlignLeft, ASFont::VAlignTop ); s->write( font, voices[i].text, box.x+12, box.y+5+(h+2)*i, Font::HAlignLeft, Font::VAlignTop );
s->flip(); s->flip();
//touchscreen //touchscreen
@ -1353,7 +1353,7 @@ void GMenu2X::scanner() {
Surface scanbg(bg); Surface scanbg(bg);
drawButton(&scanbg, "cancel", tr["Exit"], drawButton(&scanbg, "cancel", tr["Exit"],
drawButton(&scanbg, "accept", "", 5)-10); drawButton(&scanbg, "accept", "", 5)-10);
scanbg.write(font,tr["Link Scanner"],halfX,7,ASFont::HAlignCenter,ASFont::VAlignMiddle); scanbg.write(font,tr["Link Scanner"],halfX,7,Font::HAlignCenter,Font::VAlignMiddle);
scanbg.convertToDisplayFormat(); scanbg.convertToDisplayFormat();
uint lineY = 42; uint lineY = 42;
@ -1532,7 +1532,7 @@ int GMenu2X::drawButton(Surface *s, const string &btn, const string &text, int x
if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) { if (sc.skinRes("imgs/buttons/"+btn+".png") != NULL) {
sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7);
re.w = sc["imgs/buttons/"+btn+".png"]->width() + 3; re.w = sc["imgs/buttons/"+btn+".png"]->width() + 3;
s->write(font, text, x+re.w, y, ASFont::HAlignLeft, ASFont::VAlignMiddle); s->write(font, text, x+re.w, y, Font::HAlignLeft, Font::VAlignMiddle);
re.w += font->getTextWidth(text); re.w += font->getTextWidth(text);
} }
return x+re.w+6; return x+re.w+6;
@ -1544,7 +1544,7 @@ int GMenu2X::drawButtonRight(Surface *s, const string &btn, const string &text,
x -= 16; x -= 16;
sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7); sc["imgs/buttons/"+btn+".png"]->blit(s, x, y-7);
x -= 3; x -= 3;
s->write(font, text, x, y, ASFont::HAlignRight, ASFont::VAlignMiddle); s->write(font, text, x, y, Font::HAlignRight, Font::VAlignMiddle);
return x-6-font->getTextWidth(text); return x-6-font->getTextWidth(text);
} }
return x-6; return x-6;

View File

@ -32,8 +32,8 @@
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
class ASFont;
class Button; class Button;
class Font;
class MediaMonitor; class MediaMonitor;
class Menu; class Menu;
class Surface; class Surface;
@ -151,7 +151,7 @@ public:
SurfaceCollection sc; SurfaceCollection sc;
Translator tr; Translator tr;
Surface *s, *bg; Surface *s, *bg;
ASFont *font; Font *font;
//Status functions //Status functions
void main(); void main();

View File

@ -1,6 +1,6 @@
#include "iconbutton.h" #include "iconbutton.h"
#include "asfont.h" #include "font.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "surface.h" #include "surface.h"
@ -35,7 +35,7 @@ void IconButton::paint() {
} }
if (label != "") { if (label != "") {
gmenu2x->s->write(gmenu2x->font, label, labelRect.x, labelRect.y, gmenu2x->s->write(gmenu2x->font, label, labelRect.x, labelRect.y,
ASFont::HAlignLeft, ASFont::VAlignMiddle); Font::HAlignLeft, Font::VAlignMiddle);
} }
} }

View File

@ -24,6 +24,7 @@
#include "delegate.h" #include "delegate.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "iconbutton.h" #include "iconbutton.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <SDL_gfxPrimitives.h> #include <SDL_gfxPrimitives.h>
@ -168,7 +169,7 @@ bool InputDialog::exec() {
gmenu2x->skinConfColors[COLOR_SELECTION_BG]); gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
gmenu2x->s->write(gmenu2x->font, input, box.x + 5, box.y + box.h - 2, gmenu2x->s->write(gmenu2x->font, input, box.x + 5, box.y + box.h - 2,
ASFont::HAlignLeft, ASFont::VAlignBottom); Font::HAlignLeft, Font::VAlignBottom);
curTick = SDL_GetTicks(); curTick = SDL_GetTicks();
if (curTick - caretTick >= 600) { if (curTick - caretTick >= 600) {
@ -310,7 +311,7 @@ void InputDialog::drawVirtualKeyboard() {
gmenu2x->s->write(gmenu2x->font, charX, gmenu2x->s->write(gmenu2x->font, charX,
kbLeft + xc * KEY_WIDTH + KEY_WIDTH / 2 - 1, kbLeft + xc * KEY_WIDTH + KEY_WIDTH / 2 - 1,
KB_TOP + l * KEY_HEIGHT + KEY_HEIGHT / 2, KB_TOP + l * KEY_HEIGHT + KEY_HEIGHT / 2,
ASFont::HAlignCenter, ASFont::VAlignMiddle); Font::HAlignCenter, Font::VAlignMiddle);
xc++; xc++;
} }
} }
@ -330,7 +331,7 @@ void InputDialog::drawVirtualKeyboard() {
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"], gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["Cancel"],
(int)(160 - kbLength * KEY_WIDTH / 4), (int)(160 - kbLength * KEY_WIDTH / 4),
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2, KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
ASFont::HAlignCenter, ASFont::VAlignMiddle); Font::HAlignCenter, Font::VAlignMiddle);
re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1; re.x = kbLeft + kbLength * KEY_WIDTH / 2 - 1;
gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); gmenu2x->s->rectangle(re, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
@ -341,5 +342,5 @@ void InputDialog::drawVirtualKeyboard() {
gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"], gmenu2x->s->write(gmenu2x->font, gmenu2x->tr["OK"],
(int)(160 + kbLength * KEY_WIDTH / 4), (int)(160 + kbLength * KEY_WIDTH / 4),
KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2, KB_TOP + kb->size() * KEY_HEIGHT + KEY_HEIGHT / 2,
ASFont::HAlignCenter, ASFont::VAlignMiddle); Font::HAlignCenter, Font::VAlignMiddle);
} }

View File

@ -23,6 +23,7 @@
#include "gmenu2x.h" #include "gmenu2x.h"
#include "menu.h" #include "menu.h"
#include "selector.h" #include "selector.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <fstream> #include <fstream>
@ -47,12 +48,12 @@ void Link::paint() {
if (iconSurface) { if (iconSurface) {
iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32); iconSurface->blit(gmenu2x->s, iconX, rect.y+padding, 32,32);
} }
gmenu2x->s->write( gmenu2x->font, getTitle(), iconX+16, rect.y+gmenu2x->skinConfInt["linkHeight"]-padding, ASFont::HAlignCenter, ASFont::VAlignBottom ); gmenu2x->s->write(gmenu2x->font, getTitle(), iconX+16, rect.y + gmenu2x->skinConfInt["linkHeight"]-padding, Font::HAlignCenter, Font::VAlignBottom);
} }
bool Link::paintHover() { bool Link::paintHover() {
if (gmenu2x->useSelectionPng) if (gmenu2x->useSelectionPng)
gmenu2x->sc["imgs/selection.png"]->blit(gmenu2x->s,rect,ASFont::HAlignCenter,ASFont::VAlignMiddle); gmenu2x->sc["imgs/selection.png"]->blit(gmenu2x->s, rect, Font::HAlignCenter, Font::VAlignMiddle);
else else
gmenu2x->s->box(rect.x, rect.y, rect.w, rect.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]); gmenu2x->s->box(rect.x, rect.y, rect.w, rect.h, gmenu2x->skinConfColors[COLOR_SELECTION_BG]);
return true; return true;

View File

@ -25,6 +25,7 @@
#include "gmenu2x.h" #include "gmenu2x.h"
#include "menu.h" #include "menu.h"
#include "selector.h" #include "selector.h"
#include "surface.h"
#include "textmanualdialog.h" #include "textmanualdialog.h"
#include "utilities.h" #include "utilities.h"
@ -379,7 +380,7 @@ void LinkApp::drawRun() {
else else
gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/ gmenu2x->sc["icons/generic.png"]->blit(gmenu2x->s,x,104);*/
iconSurface->blit(gmenu2x->s,x,gmenu2x->halfY-16); iconSurface->blit(gmenu2x->s,x,gmenu2x->halfY-16);
gmenu2x->s->write( gmenu2x->font, text, x+42, gmenu2x->halfY+1, ASFont::HAlignLeft, ASFont::VAlignMiddle ); gmenu2x->s->write( gmenu2x->font, text, x+42, gmenu2x->halfY+1, Font::HAlignLeft, Font::VAlignMiddle );
gmenu2x->s->flip(); gmenu2x->s->flip();
} }
@ -491,7 +492,7 @@ void LinkApp::showManual() {
ss << page+1; ss << page+1;
ss >> pageStatus; ss >> pageStatus;
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount; pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, ASFont::HAlignRight, ASFont::VAlignMiddle); gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
gmenu2x->s->flip(); gmenu2x->s->flip();
repaint = false; repaint = false;

View File

@ -20,8 +20,9 @@
#include "menusetting.h" #include "menusetting.h"
#include "asfont.h" #include "font.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "surface.h"
using std::string; using std::string;
@ -40,7 +41,7 @@ MenuSetting::~MenuSetting()
void MenuSetting::draw(int y) void MenuSetting::draw(int y)
{ {
gmenu2x->s->write( gmenu2x->font, name, 5, y, ASFont::HAlignLeft, ASFont::VAlignTop ); gmenu2x->s->write( gmenu2x->font, name, 5, y, Font::HAlignLeft, Font::VAlignTop );
} }
void MenuSetting::handleTS() void MenuSetting::handleTS()

View File

@ -23,6 +23,7 @@
#include "delegate.h" #include "delegate.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "iconbutton.h" #include "iconbutton.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <sstream> #include <sstream>
@ -67,7 +68,7 @@ void MenuSettingBool::initButton()
void MenuSettingBool::draw(int y) void MenuSettingBool::draw(int y)
{ {
MenuSetting::draw(y); MenuSetting::draw(y);
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop ); gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, Font::HAlignLeft, Font::VAlignTop );
} }
bool MenuSettingBool::handleButtonPress(InputManager::Button button) bool MenuSettingBool::handleButtonPress(InputManager::Button button)

View File

@ -23,6 +23,7 @@
#include "delegate.h" #include "delegate.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "iconbutton.h" #include "iconbutton.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <sstream> #include <sstream>
@ -69,7 +70,7 @@ MenuSettingInt::MenuSettingInt(
void MenuSettingInt::draw(int y) void MenuSettingInt::draw(int y)
{ {
MenuSetting::draw(y); MenuSetting::draw(y);
gmenu2x->s->write( gmenu2x->font, strvalue, 155, y, ASFont::HAlignLeft, ASFont::VAlignTop ); gmenu2x->s->write(gmenu2x->font, strvalue, 155, y, Font::HAlignLeft, Font::VAlignTop);
} }
bool MenuSettingInt::handleButtonPress(InputManager::Button button) bool MenuSettingInt::handleButtonPress(InputManager::Button button)

View File

@ -22,6 +22,7 @@
#include "gmenu2x.h" #include "gmenu2x.h"
#include "iconbutton.h" #include "iconbutton.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <sstream> #include <sstream>
@ -53,10 +54,10 @@ void MenuSettingRGBA::draw(int y) {
MenuSetting::draw(y); MenuSetting::draw(y);
gmenu2x->s->rectangle( 153, y+1, 11, 11, 0,0,0,255 ); gmenu2x->s->rectangle( 153, y+1, 11, 11, 0,0,0,255 );
gmenu2x->s->box( 154, y+2, 9, 9, value() ); gmenu2x->s->box( 154, y+2, 9, 9, value() );
gmenu2x->s->write( gmenu2x->font, "R: "+strR, 169, y, ASFont::HAlignLeft, ASFont::VAlignTop ); gmenu2x->s->write( gmenu2x->font, "R: "+strR, 169, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y, ASFont::HAlignLeft, ASFont::VAlignTop ); gmenu2x->s->write( gmenu2x->font, "G: "+strG, 205, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y, ASFont::HAlignLeft, ASFont::VAlignTop ); gmenu2x->s->write( gmenu2x->font, "B: "+strB, 241, y, Font::HAlignLeft, Font::VAlignTop );
gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y, ASFont::HAlignLeft, ASFont::VAlignTop ); gmenu2x->s->write( gmenu2x->font, "A: "+strA, 277, y, Font::HAlignLeft, Font::VAlignTop );
} }
void MenuSettingRGBA::handleTS() { void MenuSettingRGBA::handleTS() {

View File

@ -17,8 +17,10 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "menusettingstringbase.h" #include "menusettingstringbase.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "surface.h"
using std::string; using std::string;
@ -39,7 +41,7 @@ void MenuSettingStringBase::draw(int y)
{ {
MenuSetting::draw(y); MenuSetting::draw(y);
gmenu2x->s->write(gmenu2x->font, value(), 155, y, gmenu2x->s->write(gmenu2x->font, value(), 155, y,
ASFont::HAlignLeft, ASFont::VAlignTop); Font::HAlignLeft, Font::VAlignTop);
} }
bool MenuSettingStringBase::handleButtonPress(InputManager::Button button) bool MenuSettingStringBase::handleButtonPress(InputManager::Button button)

View File

@ -20,6 +20,7 @@
#include "messagebox.h" #include "messagebox.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "surface.h"
#include <SDL_gfxPrimitives.h> #include <SDL_gfxPrimitives.h>
@ -77,7 +78,7 @@ int MessageBox::exec() {
//icon+text //icon+text
if (gmenu2x->sc[icon] != NULL) if (gmenu2x->sc[icon] != NULL)
gmenu2x->sc[icon]->blitCenter( &bg, box.x+25, box.y+gmenu2x->font->getHeight()+3 ); gmenu2x->sc[icon]->blitCenter( &bg, box.x+25, box.y+gmenu2x->font->getHeight()+3 );
bg.write( gmenu2x->font, text, box.x+(gmenu2x->sc[icon] != NULL ? 47 : 10), box.y+gmenu2x->font->getHeight()+3, ASFont::HAlignLeft, ASFont::VAlignMiddle ); bg.write( gmenu2x->font, text, box.x+(gmenu2x->sc[icon] != NULL ? 47 : 10), box.y+gmenu2x->font->getHeight()+3, Font::HAlignLeft, Font::VAlignMiddle );
int btnX = gmenu2x->halfX+box.w/2-6; int btnX = gmenu2x->halfX+box.w/2-6;
for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) { for (uint i = 0; i < BUTTON_TYPE_SIZE; i++) {

View File

@ -25,6 +25,7 @@
#include "gmenu2x.h" #include "gmenu2x.h"
#include "linkapp.h" #include "linkapp.h"
#include "menu.h" #include "menu.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <SDL.h> #include <SDL.h>
@ -117,9 +118,9 @@ int Selector::exec(int startSelection) {
iY = i-firstElement; iY = i-firstElement;
if (fl.isDirectory(i)) { if (fl.isDirectory(i)) {
gmenu2x->sc["imgs/folder.png"]->blit(gmenu2x->s, 4, 42+(iY*16)); gmenu2x->sc["imgs/folder.png"]->blit(gmenu2x->s, 4, 42+(iY*16));
gmenu2x->s->write(gmenu2x->font, fl[i], 21, 49+(iY*16), ASFont::HAlignLeft, ASFont::VAlignMiddle); gmenu2x->s->write(gmenu2x->font, fl[i], 21, 49+(iY*16), Font::HAlignLeft, Font::VAlignMiddle);
} else } else
gmenu2x->s->write(gmenu2x->font, titles[i-fl.dirCount()], 4, 49+(iY*16), ASFont::HAlignLeft, ASFont::VAlignMiddle); gmenu2x->s->write(gmenu2x->font, titles[i-fl.dirCount()], 4, 49+(iY*16), Font::HAlignLeft, Font::VAlignMiddle);
} }
gmenu2x->s->clearClipRect(); gmenu2x->s->clearClipRect();

View File

@ -192,25 +192,25 @@ void Surface::setClipRect(SDL_Rect rect) {
SDL_SetClipRect(raw,&rect); SDL_SetClipRect(raw,&rect);
} }
bool Surface::blit(Surface *destination, SDL_Rect container, ASFont::HAlign halign, ASFont::VAlign valign) { bool Surface::blit(Surface *destination, SDL_Rect container, Font::HAlign halign, Font::VAlign valign) {
switch (halign) { switch (halign) {
case ASFont::HAlignLeft: case Font::HAlignLeft:
break; break;
case ASFont::HAlignCenter: case Font::HAlignCenter:
container.x += container.w/2-halfW; container.x += container.w/2-halfW;
break; break;
case ASFont::HAlignRight: case Font::HAlignRight:
container.x += container.w-raw->w; container.x += container.w-raw->w;
break; break;
} }
switch (valign) { switch (valign) {
case ASFont::VAlignTop: case Font::VAlignTop:
break; break;
case ASFont::VAlignMiddle: case Font::VAlignMiddle:
container.y += container.h/2-halfH; container.y += container.h/2-halfH;
break; break;
case ASFont::VAlignBottom: case Font::VAlignBottom:
container.y += container.h-raw->h; container.y += container.h-raw->h;
break; break;
} }

View File

@ -21,7 +21,7 @@
#ifndef SURFACE_H #ifndef SURFACE_H
#define SURFACE_H #define SURFACE_H
#include "asfont.h" #include "font.h"
#include <SDL.h> #include <SDL.h>
#include <string> #include <string>
@ -62,13 +62,13 @@ public:
void setClipRect(SDL_Rect rect); void setClipRect(SDL_Rect rect);
bool blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blit(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
bool blit(Surface *destination, SDL_Rect container, ASFont::HAlign halign = ASFont::HAlignLeft, ASFont::VAlign valign = ASFont::VAlignTop); bool blit(Surface *destination, SDL_Rect container, Font::HAlign halign = Font::HAlignLeft, Font::VAlign valign = Font::VAlignTop);
bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitCenter(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1); bool blitRight(Surface *destination, int x, int y, int w=0, int h=0, int a=-1);
void write(ASFont *font, const std::string &text, int x, int y, void write(Font *font, const std::string &text, int x, int y,
ASFont::HAlign halign = ASFont::HAlignLeft, Font::HAlign halign = Font::HAlignLeft,
ASFont::VAlign valign = ASFont::VAlignTop) { Font::VAlign valign = Font::VAlignTop) {
font->write(this, text, x, y, halign, valign); font->write(this, text, x, y, halign, valign);
} }
@ -92,7 +92,7 @@ private:
int halfW, halfH; int halfW, halfH;
// For direct access to "raw". // For direct access to "raw".
friend class ASFont; friend class Font;
}; };
#endif #endif

View File

@ -21,6 +21,7 @@
#include "textmanualdialog.h" #include "textmanualdialog.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <algorithm> #include <algorithm>
@ -104,7 +105,7 @@ void TextManualDialog::exec() {
ss << page+1; ss << page+1;
ss >> pageStatus; ss >> pageStatus;
pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount; pageStatus = gmenu2x->tr["Page"]+": "+pageStatus+"/"+spagecount;
gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, ASFont::HAlignRight, ASFont::VAlignMiddle); gmenu2x->s->write(gmenu2x->font, pageStatus, 310, 230, Font::HAlignRight, Font::VAlignMiddle);
gmenu2x->s->flip(); gmenu2x->s->flip();

View File

@ -25,6 +25,7 @@
#include "filelister.h" #include "filelister.h"
#include "gmenu2x.h" #include "gmenu2x.h"
#include "iconbutton.h" #include "iconbutton.h"
#include "surface.h"
#include "utilities.h" #include "utilities.h"
#include <iostream> #include <iostream>
@ -105,7 +106,7 @@ bool WallpaperDialog::exec()
gmenu2x->s->setClipRect(0,41,311,179); gmenu2x->s->setClipRect(0,41,311,179);
for (i=firstElement; i<wallpapers.size() && i<firstElement+10; i++) { for (i=firstElement; i<wallpapers.size() && i<firstElement+10; i++) {
iY = i-firstElement; iY = i-firstElement;
gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5, 52+(iY*17), ASFont::HAlignLeft, ASFont::VAlignMiddle); gmenu2x->s->write(gmenu2x->font, wallpapers[i], 5, 52+(iY*17), Font::HAlignLeft, Font::VAlignMiddle);
} }
gmenu2x->s->clearClipRect(); gmenu2x->s->clearClipRect();