From b94df096f0cdff0407e50146ba315427bf2b9274 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Sun, 20 Dec 2009 10:12:47 +0000 Subject: [PATCH] Add highlighted key --- gui.cpp | 10 +++++++++- gui.hh | 6 ++++-- main_menu.cpp | 2 ++ virtual_keyboard.cpp | 10 ++++++++++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/gui.cpp b/gui.cpp index a34c5fa..6295845 100644 --- a/gui.cpp +++ b/gui.cpp @@ -67,6 +67,7 @@ Gui::Gui() /* Create the views */ this->mv = new MainView(); this->dv = new DiscView(); + this->kv = VirtualKeyboard::kbd; this->pushView(mv); } @@ -87,6 +88,9 @@ bool Gui::setTheme(const char *path) this->dialogue_bg = this->loadThemeImage(path, "dialogue_box.png"); this->disc_info = this->loadThemeImage(path, "disc_info.png"); + this->highlighted_key = this->loadThemeImage(path, "highlighted_key.png"); + this->selected_key = this->loadThemeImage(path, "selected_key.png"); + this->default_font = this->loadThemeFont(path, "font.ttf", 18); this->small_font = this->loadThemeFont(path, "font.ttf", 16); @@ -95,6 +99,8 @@ bool Gui::setTheme(const char *path) !this->bg_submenu_middle || !this->dialogue_bg || !this->disc_info || + !this->selected_key || + !this->highlighted_key || !this->default_font || !this->small_font) { @@ -110,6 +116,8 @@ bool Gui::setTheme(const char *path) SDL_FreeSurface(this->dialogue_bg); SDL_FreeSurface(this->disc_info); SDL_FreeSurface(this->textbox); + SDL_FreeSurface(this->selected_key); + SDL_FreeSurface(this->highlighted_key); if (this->default_font) delete this->default_font; @@ -119,9 +127,9 @@ bool Gui::setTheme(const char *path) return false; } - VirtualKeyboard::kbd->setFont(this->default_font); this->mv->updateTheme(); this->dv->updateTheme(); + this->kv->updateTheme(); return true; } diff --git a/gui.hh b/gui.hh index 11a1243..0f9be65 100644 --- a/gui.hh +++ b/gui.hh @@ -10,7 +10,7 @@ class MainView; class DiscView; -class KeyboardView; +class VirtualKeyboard; class Gui { @@ -63,6 +63,8 @@ public: SDL_Surface *disc_info; SDL_Surface *bg_left, *bg_right, *bg_middle, *bg_submenu_left, *bg_submenu_right, *bg_submenu_middle; + SDL_Surface *highlighted_key; + SDL_Surface *selected_key; Font *default_font; Font *small_font; @@ -70,7 +72,7 @@ public: MainView *mv; DiscView *dv; - KeyboardView *kv; + VirtualKeyboard *kv; GuiView **views; int n_views; diff --git a/main_menu.cpp b/main_menu.cpp index d6b5a4f..4bed77e 100644 --- a/main_menu.cpp +++ b/main_menu.cpp @@ -72,6 +72,8 @@ public: } break; case 2: + Gui::gui->pushView(Gui::gui->kv); + Gui::gui->kv->activate(); break; case 11: diff --git a/virtual_keyboard.cpp b/virtual_keyboard.cpp index 1b4f4fc..dca39d4 100644 --- a/virtual_keyboard.cpp +++ b/virtual_keyboard.cpp @@ -13,6 +13,7 @@ #include "virtual_keyboard.hh" #include "utils.hh" +#include "gui.hh" typedef struct virtkey { @@ -113,6 +114,13 @@ void VirtualKeyboard::draw(SDL_Surface *where, int x, int y, int w, int h) if (this->shift_on && shifted_names[which]) what = shifted_names[which]; + if (this->sel_x == x && this->sel_y == y) + { + SDL_Rect dst = (SDL_Rect){x * key_w + border_x - 8, + y * key_h + border_y - 4, 0,0}; + + SDL_BlitSurface(Gui::gui->selected_key, NULL, where, &dst); + } this->font->draw(where, what, x * key_w + border_x, y * key_h + border_y, w, h); } @@ -351,10 +359,12 @@ void VirtualKeyboard::runLogic() void VirtualKeyboard::draw(SDL_Surface *where) { + this->draw(where, 20, 240, 600, 240); } void VirtualKeyboard::updateTheme() { + this->setFont(Gui::gui->small_font); } /* The singleton */