Remove jtheme and JTheme types, use Theme class directly.

+ Added CurrentTheme namespace.
+ Rename Theme::regen() to Theme::onRegenerate().
+ ji_regen_theme() is in Theme::regenerate() member function.
This commit is contained in:
David Capello 2011-01-21 17:50:04 -03:00
parent fc263ddb88
commit e9f7a035b1
35 changed files with 119 additions and 132 deletions

View File

@ -25,8 +25,8 @@
#include <psapi.h> #include <psapi.h>
#endif #endif
#include "gui/jtheme.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/theme.h"
#include "app.h" #include "app.h"
#include "commands/command.h" #include "commands/command.h"
@ -62,9 +62,9 @@ void RefreshCommand::onExecute(Context* context)
// Reload skin // Reload skin
{ {
SkinTheme* theme = (SkinTheme*)ji_get_theme(); SkinTheme* theme = (SkinTheme*)CurrentTheme::get();
theme->reload_skin(); theme->reload_skin();
ji_regen_theme(); theme->regenerate();
} }
{ {

View File

@ -37,11 +37,11 @@ add_library(gui-lib
jstream.cpp jstream.cpp
jsystem.cpp jsystem.cpp
jtextbox.cpp jtextbox.cpp
jtheme.cpp
jtooltips.cpp jtooltips.cpp
jview.cpp jview.cpp
label.cpp label.cpp
preferred_size_event.cpp preferred_size_event.cpp
property.cpp property.cpp
slider.cpp slider.cpp
theme.cpp
widget.cpp) widget.cpp)

View File

@ -13,14 +13,14 @@
#include <queue> #include <queue>
#include "gui/button.h" #include "gui/button.h"
#include "gui/frame.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jmanager.h" #include "gui/jmanager.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jtheme.h"
#include "gui/widget.h"
#include "gui/frame.h"
#include "gui/preferred_size_event.h" #include "gui/preferred_size_event.h"
#include "gui/theme.h"
#include "gui/widget.h"
ButtonBase::ButtonBase(const char* text, int type, int behaviorType, int drawType) ButtonBase::ButtonBase(const char* text, int type, int behaviorType, int drawType)
: Widget(type) : Widget(type)

View File

@ -18,8 +18,8 @@
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h"
#include "gui/preferred_size_event.h" #include "gui/preferred_size_event.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length((f), (c))) #define CHARACTER_LENGTH(f, c) ((f)->vtable->char_length((f), (c)))

View File

@ -47,10 +47,10 @@ struct jlist;
union jmessage; union jmessage;
struct jrect; struct jrect;
struct jregion; struct jregion;
class jtheme;
class Widget;
class Frame; class Frame;
class Theme;
class Widget;
/* alignment */ /* alignment */
#define JI_HORIZONTAL 0x0001 #define JI_HORIZONTAL 0x0001
@ -203,7 +203,6 @@ typedef union jmessage* JMessage;
typedef struct jstream* JStream; typedef struct jstream* JStream;
typedef struct jrect* JRect; typedef struct jrect* JRect;
typedef struct jregion* JRegion; typedef struct jregion* JRegion;
typedef class jtheme* JTheme;
typedef class Widget* JWidget; typedef class Widget* JWidget;
typedef struct jxml* JXml; typedef struct jxml* JXml;
typedef struct jxmlattr* JXmlAttr; typedef struct jxmlattr* JXmlAttr;

View File

@ -8,12 +8,12 @@
#include "config.h" #include "config.h"
#include "gfx/size.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "gui/jtheme.h"
#include "gfx/size.h"
using namespace gfx; using namespace gfx;

View File

@ -43,7 +43,7 @@ ComboBox::ComboBox()
m_entry->user_data[0] = this; m_entry->user_data[0] = this;
m_button->user_data[0] = this; m_button->user_data[0] = this;
/* TODO this separation should be from the JTheme */ // TODO this separation should be from the Theme*
this->child_spacing = 0; this->child_spacing = 0;
jwidget_focusrest(this, true); jwidget_focusrest(this, true);

View File

@ -15,7 +15,7 @@
#include "gui/jfont.h" #include "gui/jfont.h"
#include "gui/jintern.h" #include "gui/jintern.h"
#include "gui/jtheme.h" #include "gui/theme.h"
FONT* ji_font_load(const char* filepathname) FONT* ji_font_load(const char* filepathname)
{ {

View File

@ -10,12 +10,12 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "gfx/size.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "gui/jtheme.h"
#include "gfx/size.h"
using namespace gfx; using namespace gfx;

View File

@ -13,7 +13,7 @@
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
static bool image_msg_proc(JWidget widget, JMessage msg); static bool image_msg_proc(JWidget widget, JMessage msg);

View File

@ -7,8 +7,8 @@
#include "config.h" #include "config.h"
#include "gui/jbase.h" #include "gui/jbase.h"
#include "gui/jtheme.h"
#include "gui/jclipboard.h" #include "gui/jclipboard.h"
#include "gui/theme.h"
#ifdef MEMLEAK #ifdef MEMLEAK
void _jmemleak_init(); void _jmemleak_init();
@ -24,9 +24,6 @@ void _ji_system_exit();
int _ji_font_init(); int _ji_font_init();
void _ji_font_exit(); void _ji_font_exit();
int _ji_theme_init();
void _ji_theme_exit();
/** /**
* Initializes the Jinete library. * Initializes the Jinete library.
*/ */
@ -40,19 +37,17 @@ Jinete::Jinete()
_ji_system_init(); _ji_system_init();
_ji_font_init(); _ji_font_init();
_ji_widgets_init(); _ji_widgets_init();
_ji_theme_init();
} }
Jinete::~Jinete() Jinete::~Jinete()
{ {
// finish theme // finish theme
ji_set_theme(NULL); CurrentTheme::set(NULL);
// destroy clipboard // destroy clipboard
jclipboard_set_text(NULL); jclipboard_set_text(NULL);
// shutdown system // shutdown system
_ji_theme_exit();
_ji_widgets_exit(); _ji_widgets_exit();
_ji_font_exit(); _ji_font_exit();
_ji_system_exit(); _ji_system_exit();

View File

@ -37,11 +37,11 @@
#include "gui/jstream.h" #include "gui/jstream.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtextbox.h" #include "gui/jtextbox.h"
#include "gui/jtheme.h"
#include "gui/jtooltips.h" #include "gui/jtooltips.h"
#include "gui/jview.h" #include "gui/jview.h"
#include "gui/label.h" #include "gui/label.h"
#include "gui/slider.h" #include "gui/slider.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#endif #endif

View File

@ -8,10 +8,10 @@
#include <vector> #include <vector>
#include "gui/jmanager.h"
#include "gui/jtheme.h"
#include "gui/widget.h"
#include "gui/frame.h" #include "gui/frame.h"
#include "gui/jmanager.h"
#include "gui/theme.h"
#include "gui/widget.h"
static std::vector<JWidget>* widgets; static std::vector<JWidget>* widgets;
@ -105,7 +105,7 @@ void _ji_reinit_theme_in_all_widgets()
// Then we can reinitialize the theme of each widget // Then we can reinitialize the theme of each widget
for (c=0; c<widgets->size(); c++) for (c=0; c<widgets->size(); c++)
if (_ji_is_valid_widget((*widgets)[c])) { if (_ji_is_valid_widget((*widgets)[c])) {
(*widgets)[c]->theme = ji_get_theme(); (*widgets)[c]->theme = CurrentTheme::get();
jwidget_init_theme((*widgets)[c]); jwidget_init_theme((*widgets)[c]);
} }

View File

@ -38,7 +38,7 @@ void _jmanager_open_window(JWidget manager, Frame* frame);
void _jmanager_close_window(JWidget manager, Frame* frame, bool redraw_background); void _jmanager_close_window(JWidget manager, Frame* frame, bool redraw_background);
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// jtheme.c // theme.cpp
void _ji_theme_draw_sprite_color(struct BITMAP *bmp, struct BITMAP *sprite, void _ji_theme_draw_sprite_color(struct BITMAP *bmp, struct BITMAP *sprite,
int x, int y, int color); int x, int y, int color);

View File

@ -9,8 +9,8 @@
#include "gui/jlink_label.h" #include "gui/jlink_label.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jtheme.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/theme.h"
#include "launcher.h" #include "launcher.h"
LinkLabel::LinkLabel(const char* urlOrText) LinkLabel::LinkLabel(const char* urlOrText)

View File

@ -8,15 +8,15 @@
#include <allegro/keyboard.h> #include <allegro/keyboard.h>
#include "gfx/size.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jmanager.h" #include "gui/jmanager.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h"
#include "gui/jview.h" #include "gui/jview.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "gfx/size.h"
using namespace gfx; using namespace gfx;

View File

@ -6,13 +6,13 @@
#include "config.h" #include "config.h"
#include "gfx/size.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "gfx/size.h"
typedef struct Panel typedef struct Panel
{ {

View File

@ -6,12 +6,12 @@
#include "config.h" #include "config.h"
#include "gfx/size.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "gfx/size.h"
using namespace gfx; using namespace gfx;

View File

@ -18,7 +18,7 @@
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jregion.h" #include "gui/jregion.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
/* Global output bitmap. */ /* Global output bitmap. */
@ -210,7 +210,7 @@ int jmouse_set_cursor(int type)
if (m_cursor == type) if (m_cursor == type)
return type; return type;
else { else {
JTheme theme = ji_get_theme(); Theme* theme = CurrentTheme::get();
int old = m_cursor; int old = m_cursor;
m_cursor = type; m_cursor = type;

View File

@ -15,8 +15,8 @@
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h"
#include "gui/jview.h" #include "gui/jview.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
static bool textbox_msg_proc(JWidget widget, JMessage msg); static bool textbox_msg_proc(JWidget widget, JMessage msg);

View File

@ -6,16 +6,16 @@
#include "config.h" #include "config.h"
#include "gfx/size.h"
#include "gui/jintern.h" #include "gui/jintern.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jregion.h" #include "gui/jregion.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h"
#include "gui/jview.h" #include "gui/jview.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "gfx/size.h"
#define BAR_SIZE widget->theme->scrollbar_size #define BAR_SIZE widget->theme->scrollbar_size

View File

@ -6,9 +6,9 @@
#include "config.h" #include "config.h"
#include "gui/label.h"
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jtheme.h" #include "gui/label.h"
#include "gui/theme.h"
Label::Label(const char *text) Label::Label(const char *text)
: Widget(JI_LABEL) : Widget(JI_LABEL)

View File

@ -13,9 +13,9 @@
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h"
#include "gui/preferred_size_event.h" #include "gui/preferred_size_event.h"
#include "gui/slider.h" #include "gui/slider.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
static int slider_press_x; static int slider_press_x;

View File

@ -14,33 +14,19 @@
#include "gui/jmanager.h" #include "gui/jmanager.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h"
#include "gui/jview.h" #include "gui/jview.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
static JTheme ji_current_theme = NULL; static Theme* current_theme = NULL;
static JTheme ji_standard_theme = NULL;
static void draw_text(BITMAP *bmp, FONT *f, const char *text, int x, int y, static void draw_text(BITMAP *bmp, FONT *f, const char *text, int x, int y,
int fg_color, int bg_color, bool fill_bg); int fg_color, int bg_color, bool fill_bg);
int _ji_theme_init() Theme::Theme()
{
return 0;
}
void _ji_theme_exit()
{
if (ji_standard_theme) {
delete ji_standard_theme;
ji_standard_theme = NULL;
}
}
jtheme::jtheme()
{ {
this->name = "Theme"; this->name = "Theme";
this->default_font = font; /* default Allegro font */ this->default_font = font; // Default Allegro font
this->desktop_color = 0; this->desktop_color = 0;
this->textbox_fg_color = 0; this->textbox_fg_color = 0;
this->textbox_bg_color = 0; this->textbox_bg_color = 0;
@ -50,58 +36,56 @@ jtheme::jtheme()
this->guiscale = 1; this->guiscale = 1;
} }
jtheme::~jtheme() Theme::~Theme()
{ {
if (ji_current_theme == this) if (current_theme == this)
ji_set_theme(NULL); CurrentTheme::set(NULL);
} }
/**********************************************************************/ void Theme::regenerate()
{
int type = jmouse_get_cursor();
jmouse_set_cursor(JI_CURSOR_NULL);
void ji_set_theme(JTheme theme) onRegenerate();
jmouse_set_cursor(type);
}
//////////////////////////////////////////////////////////////////////
void CurrentTheme::set(Theme* theme)
{ {
JWidget manager = ji_get_default_manager(); JWidget manager = ji_get_default_manager();
ji_current_theme = theme; current_theme = theme;
if (ji_current_theme) { if (current_theme) {
ji_regen_theme(); current_theme->regenerate();
if (manager && jwidget_get_theme(manager) == NULL) if (manager && jwidget_get_theme(manager) == NULL)
jwidget_set_theme(manager, theme); jwidget_set_theme(manager, theme);
} }
} }
JTheme ji_get_theme() Theme* CurrentTheme::get()
{ {
return ji_current_theme; return current_theme;
}
void ji_regen_theme()
{
if (ji_current_theme) {
int type = jmouse_get_cursor();
jmouse_set_cursor(JI_CURSOR_NULL);
ji_current_theme->regen();
jmouse_set_cursor(type);
}
} }
int ji_color_foreground() int ji_color_foreground()
{ {
return ji_current_theme->color_foreground(); return current_theme->color_foreground();
} }
int ji_color_disabled() int ji_color_disabled()
{ {
return ji_current_theme->color_disabled(); return current_theme->color_disabled();
} }
int ji_color_face() int ji_color_face()
{ {
return ji_current_theme->color_face(); return current_theme->color_face();
} }
int ji_color_facelight() int ji_color_facelight()
@ -122,17 +106,17 @@ int ji_color_faceshadow()
int ji_color_hotface() int ji_color_hotface()
{ {
return ji_current_theme->color_hotface(); return current_theme->color_hotface();
} }
int ji_color_selected() int ji_color_selected()
{ {
return ji_current_theme->color_selected(); return current_theme->color_selected();
} }
int ji_color_background() int ji_color_background()
{ {
return ji_current_theme->color_background(); return current_theme->color_background();
} }
BITMAP* ji_apply_guiscale(BITMAP* original) BITMAP* ji_apply_guiscale(BITMAP* original)

View File

@ -4,8 +4,8 @@
// This source file is ditributed under a BSD-like license, please // This source file is ditributed under a BSD-like license, please
// read LICENSE.txt for more information. // read LICENSE.txt for more information.
#ifndef GUI_JTHEME_H_INCLUDED #ifndef GUI_THEME_H_INCLUDED
#define GUI_JTHEME_H_INCLUDED #define GUI_THEME_H_INCLUDED
#include "gui/jbase.h" #include "gui/jbase.h"
@ -16,7 +16,7 @@ class ButtonBase;
class Entry; class Entry;
class Slider; class Slider;
class jtheme class Theme
{ {
public: public:
const char* name; const char* name;
@ -29,10 +29,11 @@ public:
int scrollbar_size; int scrollbar_size;
int guiscale; int guiscale;
jtheme(); Theme();
virtual ~jtheme(); virtual ~Theme();
void regenerate();
virtual void regen() = 0;
virtual BITMAP* set_cursor(int type, int *focus_x, int *focus_y) = 0; virtual BITMAP* set_cursor(int type, int *focus_x, int *focus_y) = 0;
virtual void init_widget(JWidget widget) = 0; virtual void init_widget(JWidget widget) = 0;
virtual JRegion get_window_mask(JWidget widget) = 0; virtual JRegion get_window_mask(JWidget widget) = 0;
@ -68,11 +69,16 @@ public:
virtual void draw_view_viewport(JWidget widget, JRect clip) = 0; virtual void draw_view_viewport(JWidget widget, JRect clip) = 0;
virtual void draw_frame(Frame* frame, JRect clip) = 0; virtual void draw_frame(Frame* frame, JRect clip) = 0;
protected:
virtual void onRegenerate() = 0;
}; };
void ji_set_theme(JTheme theme); namespace CurrentTheme
JTheme ji_get_theme(); {
void ji_regen_theme(); void set(Theme* theme);
Theme* get();
}
int ji_color_foreground(); int ji_color_foreground();
int ji_color_disabled(); int ji_color_disabled();
@ -89,7 +95,7 @@ BITMAP* ji_apply_guiscale(BITMAP* original);
// Every icon/graphics/font should be scaled to this factor. // Every icon/graphics/font should be scaled to this factor.
inline int jguiscale() inline int jguiscale()
{ {
return ji_get_theme() ? ji_get_theme()->guiscale: 1; return CurrentTheme::get() ? CurrentTheme::get()->guiscale: 1;
} }
#endif #endif

View File

@ -59,7 +59,7 @@ Widget::Widget(int type)
this->max_h = INT_MAX; this->max_h = INT_MAX;
this->children = jlist_new(); this->children = jlist_new();
this->parent = NULL; this->parent = NULL;
this->theme = ji_get_theme(); this->theme = CurrentTheme::get();
this->hooks = jlist_new(); this->hooks = jlist_new();
this->m_align = 0; this->m_align = 0;
@ -858,7 +858,7 @@ int jwidget_get_bg_color(JWidget widget)
return widget->getBgColor(); return widget->getBgColor();
} }
JTheme jwidget_get_theme(JWidget widget) Theme* jwidget_get_theme(JWidget widget)
{ {
ASSERT_VALID_WIDGET(widget); ASSERT_VALID_WIDGET(widget);
@ -1054,7 +1054,7 @@ void jwidget_set_bg_color(JWidget widget, int color)
widget->setBgColor(color); widget->setBgColor(color);
} }
void jwidget_set_theme(JWidget widget, JTheme theme) void jwidget_set_theme(JWidget widget, Theme* theme)
{ {
ASSERT_VALID_WIDGET(widget); ASSERT_VALID_WIDGET(widget);

View File

@ -82,7 +82,7 @@ JRect jwidget_get_child_rect(JWidget widget);
JRegion jwidget_get_region(JWidget widget); JRegion jwidget_get_region(JWidget widget);
JRegion jwidget_get_drawable_region(JWidget widget, int flags); JRegion jwidget_get_drawable_region(JWidget widget, int flags);
int jwidget_get_bg_color(JWidget widget); int jwidget_get_bg_color(JWidget widget);
JTheme jwidget_get_theme(JWidget widget); Theme* jwidget_get_theme(JWidget widget);
int jwidget_get_text_length(JWidget widget); int jwidget_get_text_length(JWidget widget);
int jwidget_get_text_height(JWidget widget); int jwidget_get_text_height(JWidget widget);
void jwidget_get_texticon_info(JWidget widget, void jwidget_get_texticon_info(JWidget widget,
@ -96,7 +96,7 @@ void jwidget_set_rect(JWidget widget, JRect rect);
void jwidget_set_min_size(JWidget widget, int w, int h); void jwidget_set_min_size(JWidget widget, int w, int h);
void jwidget_set_max_size(JWidget widget, int w, int h); void jwidget_set_max_size(JWidget widget, int w, int h);
void jwidget_set_bg_color(JWidget widget, int color); void jwidget_set_bg_color(JWidget widget, int color);
void jwidget_set_theme(JWidget widget, JTheme theme); void jwidget_set_theme(JWidget widget, Theme* theme);
/* drawing methods */ /* drawing methods */
@ -149,7 +149,7 @@ public:
/* structures */ /* structures */
JList children; /* sub-objects */ JList children; /* sub-objects */
JWidget parent; /* who is the parent? */ JWidget parent; /* who is the parent? */
JTheme theme; /* widget's theme */ Theme* theme; // Widget's theme
/* virtual properties */ /* virtual properties */
JList hooks; /* hooks with msg_proc and specific data */ JList hooks; /* hooks with msg_proc and specific data */
@ -167,7 +167,7 @@ public:
/* more properties... */ /* more properties... */
/* for JTheme */ // Extra data for the theme
void *theme_data[4]; void *theme_data[4];
/* for user */ /* for user */

View File

@ -24,7 +24,7 @@
#include "gui/jintern.h" #include "gui/jintern.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "app.h" #include "app.h"
#include "app/color_utils.h" #include "app/color_utils.h"
@ -497,7 +497,7 @@ void draw_color_button(BITMAP* bmp,
bool outer_se, bool outer_s, bool outer_sw, bool outer_w, bool outer_se, bool outer_s, bool outer_sw, bool outer_w,
int imgtype, const Color& color, bool hot, bool drag) int imgtype, const Color& color, bool hot, bool drag)
{ {
SkinTheme* theme = (SkinTheme*)ji_get_theme(); SkinTheme* theme = (SkinTheme*)CurrentTheme::get();
int scale = jguiscale(); int scale = jguiscale();
// Draw background (the color) // Draw background (the color)

View File

@ -135,7 +135,7 @@ struct Monitor
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
static JWidget manager = NULL; static JWidget manager = NULL;
static JTheme ase_theme = NULL; static Theme* ase_theme = NULL;
static int monitor_timer = -1; static int monitor_timer = -1;
static MonitorList* monitors = NULL; static MonitorList* monitors = NULL;
@ -296,8 +296,8 @@ gfx_done:;
manager = jmanager_new(); manager = jmanager_new();
jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL); jwidget_add_hook(manager, JI_WIDGET, manager_msg_proc, NULL);
/* setup the standard jinete theme for widgets */ // Setup the GUI theme for all widgets
ji_set_theme(ase_theme = new SkinTheme()); CurrentTheme::set(ase_theme = new SkinTheme());
// Setup the handler for window-resize events // Setup the handler for window-resize events
set_resize_callback(resize_callback); set_resize_callback(resize_callback);
@ -369,7 +369,7 @@ void exit_module_gui()
destroy_default_font(); destroy_default_font();
// Now we can destroy theme // Now we can destroy theme
ji_set_theme(NULL); CurrentTheme::set(NULL);
delete ase_theme; delete ase_theme;
remove_keyboard(); remove_keyboard();
@ -575,7 +575,7 @@ void gui_setup_screen(bool reload_font)
// Update guiscale factor // Update guiscale factor
int old_guiscale = jguiscale(); int old_guiscale = jguiscale();
ji_get_theme()->guiscale = (screen_scaling == 1 && CurrentTheme::get()->guiscale = (screen_scaling == 1 &&
JI_SCREEN_W > 512 && JI_SCREEN_W > 512 &&
JI_SCREEN_H > 256) ? 2: 1; JI_SCREEN_H > 256) ? 2: 1;
@ -592,7 +592,7 @@ void gui_setup_screen(bool reload_font)
// Regenerate the theme // Regenerate the theme
if (regen) { if (regen) {
ji_regen_theme(); CurrentTheme::get()->regenerate();
reinit = true; reinit = true;
} }
@ -605,7 +605,7 @@ void gui_setup_screen(bool reload_font)
static void destroy_default_font() static void destroy_default_font()
{ {
JTheme theme = ji_get_theme(); Theme* theme = CurrentTheme::get();
// No font for now // No font for now
if (theme->default_font && theme->default_font != font) if (theme->default_font && theme->default_font != font)
@ -616,7 +616,7 @@ static void destroy_default_font()
static void reload_default_font() static void reload_default_font()
{ {
JTheme theme = ji_get_theme(); Theme* theme = CurrentTheme::get();
SkinTheme* skin_theme = static_cast<SkinTheme*>(theme); SkinTheme* skin_theme = static_cast<SkinTheme*>(theme);
const char *user_font; const char *user_font;
@ -1288,7 +1288,7 @@ static bool manager_msg_proc(JWidget widget, JMessage msg)
static void on_palette_change_signal() static void on_palette_change_signal()
{ {
// Regenerate the theme // Regenerate the theme
ji_regen_theme(); CurrentTheme::get()->regenerate();
// Fixup the icons // Fixup the icons
JLink link; JLink link;

View File

@ -190,7 +190,7 @@ std::string SkinTheme::get_font_filename() const
return "skins/" + m_selected_skin + "/font.pcx"; return "skins/" + m_selected_skin + "/font.pcx";
} }
void SkinTheme::regen() void SkinTheme::onRegenerate()
{ {
check_icon_size = 8 * jguiscale(); check_icon_size = 8 * jguiscale();
radio_icon_size = 8 * jguiscale(); radio_icon_size = 8 * jguiscale();

View File

@ -25,8 +25,8 @@
#include "gfx/rect.h" #include "gfx/rect.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jtheme.h"
#include "gui/property.h" #include "gui/property.h"
#include "gui/theme.h"
// Property to show widgets with a special look (e.g.: buttons or sliders with mini-borders) // Property to show widgets with a special look (e.g.: buttons or sliders with mini-borders)
class SkinProperty : public Property class SkinProperty : public Property
@ -420,7 +420,7 @@ enum {
// This is the GUI theme used by ASE (which use images from data/skins // This is the GUI theme used by ASE (which use images from data/skins
// directory). // directory).
class SkinTheme : public jtheme class SkinTheme : public Theme
{ {
std::string m_selected_skin; std::string m_selected_skin;
BITMAP* m_sheet_bmp; BITMAP* m_sheet_bmp;
@ -436,7 +436,6 @@ public:
std::string get_font_filename() const; std::string get_font_filename() const;
void regen();
BITMAP* set_cursor(int type, int* focus_x, int* focus_y); BITMAP* set_cursor(int type, int* focus_x, int* focus_y);
void init_widget(JWidget widget); void init_widget(JWidget widget);
JRegion get_window_mask(JWidget widget); JRegion get_window_mask(JWidget widget);
@ -537,6 +536,10 @@ public:
draw_bounds_nw(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, nw, bg); draw_bounds_nw(bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, nw, bg);
} }
protected:
void onRegenerate();
private: private:
BITMAP* cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h, bool cursor = false); BITMAP* cropPartFromSheet(BITMAP* bmp, int x, int y, int w, int h, bool cursor = false);

View File

@ -26,7 +26,7 @@
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"

View File

@ -22,12 +22,12 @@
#include <stdarg.h> #include <stdarg.h>
#include "base/bind.h" #include "base/bind.h"
#include "gui/jbox.h"
#include "gui/button.h" #include "gui/button.h"
#include "gui/jbox.h"
#include "gui/jhook.h" #include "gui/jhook.h"
#include "gui/jlist.h" #include "gui/jlist.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "widgets/groupbut.h" #include "widgets/groupbut.h"

View File

@ -27,8 +27,8 @@
#include "gui/jmessage.h" #include "gui/jmessage.h"
#include "gui/jrect.h" #include "gui/jrect.h"
#include "gui/jsystem.h" #include "gui/jsystem.h"
#include "gui/jtheme.h"
#include "gui/jview.h" #include "gui/jview.h"
#include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "modules/gui.h" #include "modules/gui.h"
#include "modules/palettes.h" #include "modules/palettes.h"

View File

@ -24,10 +24,10 @@
#include "base/bind.h" #include "base/bind.h"
#include "core/cfg.h" #include "core/cfg.h"
#include "effect/effect.h" #include "effect/effect.h"
#include "gui/jbox.h"
#include "gui/button.h" #include "gui/button.h"
#include "gui/jbox.h"
#include "gui/jhook.h" #include "gui/jhook.h"
#include "gui/jtheme.h" #include "gui/theme.h"
#include "gui/widget.h" #include "gui/widget.h"
#include "modules/gfx.h" #include "modules/gfx.h"
#include "modules/gui.h" #include "modules/gui.h"