Removed guiscale() from ASE and added jguiscale() in Jinete.

With this change we can apply jguiscale() in some places like jalert and jfiles.
This commit is contained in:
David Capello 2010-03-08 00:42:41 -02:00
parent f1128336f4
commit 9535b085fe
17 changed files with 49 additions and 46 deletions

View File

@ -100,7 +100,7 @@ void LayerPropertiesCommand::execute(Context* context)
jlistbox_select_index(list_bm, static_cast<LayerImage*>(layer)->get_blend_mode());
jview_attach(view_bm, list_bm);
jwidget_set_min_size(view_bm, 128*guiscale(), 64*guiscale());
jwidget_set_min_size(view_bm, 128*jguiscale(), 64*jguiscale());
jwidget_expansive(view_bm, true);
}

View File

@ -60,7 +60,7 @@
/* size of the thumbnail in the screen (width x height), the really
size of the thumbnail bitmap is specified in the
'generate_thumbnail' routine */
#define THUMBSIZE (32*guiscale())
#define THUMBSIZE (32*jguiscale())
/* height of the headers */
#define HDRSIZE (3 + text_height(widget->getFont())*2 + 3 + 3)
@ -72,10 +72,10 @@
#define LAYSIZE (3 + MAX(text_height(widget->getFont()), THUMBSIZE) + 4)
/* space between icons and other information in the layer */
#define ICONSEP (2*guiscale())
#define ICONSEP (2*jguiscale())
/* space between the icon-bitmap and the edge of the surrounding button */
#define ICONBORDER (4*guiscale())
#define ICONBORDER (4*jguiscale())
enum {
STATE_STANDBY,
@ -206,7 +206,7 @@ static JWidget anieditor_new(const Sprite* sprite)
anieditor->nlayers = 0;
anieditor->scroll_x = 0;
anieditor->scroll_y = 0;
anieditor->separator_x = 100 * guiscale();
anieditor->separator_x = 100 * jguiscale();
anieditor->separator_w = 1;
anieditor->hot_part = PART_NOTHING;
anieditor->clk_part = PART_NOTHING;
@ -981,7 +981,7 @@ static void anieditor_draw_header_part(JWidget widget, JRect clip, int x1, int y
x = x2 - 3 - text_length(widget->getFont(), line1);
jdraw_text(widget->getFont(), line1, x, y1+3,
fg, face, true, guiscale());
fg, face, true, jguiscale());
}
if (line2 != NULL) {
@ -994,7 +994,7 @@ static void anieditor_draw_header_part(JWidget widget, JRect clip, int x1, int y
jdraw_text(widget->getFont(), line2,
x, y1+3+ji_font_get_size(widget->getFont())+3,
fg, face, true, guiscale());
fg, face, true, jguiscale());
}
}
@ -1100,7 +1100,7 @@ static void anieditor_draw_layer(JWidget widget, JRect clip, int layer_index)
/* draw the layer's name */
jdraw_text(widget->getFont(), layer->get_name().c_str(),
u, y_mid - ji_font_get_size(widget->getFont())/2,
fg, bg, true, guiscale());
fg, bg, true, jguiscale());
/* the background should be underlined */
if (layer->is_background()) {

View File

@ -184,7 +184,7 @@ static Frame* create_alert(char *buf, JList *labels, JList *buttons)
else if (button) {
char button_name[256];
JWidget button_widget = jbutton_new(beg);
jwidget_set_min_size(button_widget, 60, 0);
jwidget_set_min_size(button_widget, 60*jguiscale(), 0);
jlist_append(*buttons, button_widget);
usprintf(button_name, "button-%d", jlist_length(*buttons));

View File

@ -342,11 +342,11 @@ static JWidget convert_xmlelement_to_widget(TiXmlElement* elem)
height || minheight || maxheight) {
int w = (width || minwidth) ? ustrtol(width ? width: minwidth, NULL, 10): 0;
int h = (height || minheight) ? ustrtol(height ? height: minheight, NULL, 10): 0;
jwidget_set_min_size(widget, w, h);
jwidget_set_min_size(widget, w*jguiscale(), h*jguiscale());
w = (width || maxwidth) ? strtol(width ? width: maxwidth, NULL, 10): INT_MAX;
h = (height || maxheight) ? strtol(height ? height: maxheight, NULL, 10): INT_MAX;
jwidget_set_max_size(widget, w, h);
jwidget_set_max_size(widget, w*jguiscale(), h*jguiscale());
}
/* children */

View File

@ -72,6 +72,7 @@ jtheme::jtheme()
this->check_icon_size = 0;
this->radio_icon_size = 0;
this->scrollbar_size = 0;
this->guiscale = 1;
}
jtheme::~jtheme()

View File

@ -48,6 +48,7 @@ public:
int check_icon_size;
int radio_icon_size;
int scrollbar_size;
int guiscale;
jtheme();
virtual ~jtheme();
@ -105,4 +106,11 @@ int ji_color_hotface();
int ji_color_selected();
int ji_color_background();
// This value is a factor to multiply every screen size/coordinate.
// Every icon/graphics/font should be scaled to this factor.
inline int jguiscale()
{
return ji_get_theme() ? ji_get_theme()->guiscale: 1;
}
#endif

View File

@ -43,7 +43,7 @@ static BITMAP* gfx_bmps[GFX_BITMAP_COUNT];
static void convert_data_to_bitmap(DATA *data, BITMAP** bmp)
{
int scale = guiscale();
int scale = jguiscale();
const char *p;
int x, y;
int black = makecol(0, 0, 0);

View File

@ -373,15 +373,6 @@ void exit_module_gui()
remove_mouse();
}
// This value is a factor to multiply every screen size/coordinate.
// Every icon should be scaled to this factor too.
int guiscale()
{
return (screen_scaling == 1 &&
JI_SCREEN_W > 512 &&
JI_SCREEN_H > 256) ? 2: 1;
}
Monitor::Monitor(void (*proc)(void *),
void (*free)(void *), void *data)
{
@ -552,6 +543,11 @@ void gui_setup_screen(bool reload_font)
ji_screen_created = false;
}
// Update gui_scale factor
ji_get_theme()->guiscale = (screen_scaling == 1 &&
JI_SCREEN_W > 512 &&
JI_SCREEN_H > 256) ? 2: 1;
if (reload_font)
reload_default_font();
@ -579,7 +575,7 @@ void reload_default_font()
if ((user_font) && (*user_font))
dirs_add_path(dirs, user_font);
usprintf(buf, "fonts/ase%d.pcx", guiscale());
usprintf(buf, "fonts/ase%d.pcx", jguiscale());
dirs_cat_dirs(dirs, filename_in_datadir(buf));
// Try to load the font
@ -587,7 +583,7 @@ void reload_default_font()
theme->default_font = ji_font_load(dir->path);
if (theme->default_font) {
if (ji_font_is_scalable(theme->default_font))
ji_font_set_size(theme->default_font, 8*guiscale());
ji_font_set_size(theme->default_font, 8*jguiscale());
break;
}
}

View File

@ -64,8 +64,6 @@ typedef std::list<Monitor*> MonitorList;
int init_module_gui();
void exit_module_gui();
int guiscale();
int get_screen_scaling();
void set_screen_scaling(int scaling);

View File

@ -327,7 +327,7 @@ static struct
SkinneableTheme::SkinneableTheme()
{
int scale = guiscale();
int scale = jguiscale();
this->name = "Skinneable Theme";
this->check_icon_size = 8 * scale;
@ -464,7 +464,7 @@ void SkinneableTheme::init_widget(JWidget widget)
widget->border_width.r = (R); \
widget->border_width.b = (B);
int scale = guiscale();
int scale = jguiscale();
switch (widget->type) {
@ -770,7 +770,7 @@ void SkinneableTheme::draw_button(JWidget widget, JRect clip)
}
/* disabled */
else {
_ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1+guiscale(), icon.y1+guiscale(),
_ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1+jguiscale(), icon.y1+jguiscale(),
COLOR_BACKGROUND);
_ji_theme_draw_sprite_color(ji_screen, icon_bmp, icon.x1, icon.y1,
COLOR_DISABLED);
@ -930,7 +930,7 @@ void SkinneableTheme::draw_listitem(JWidget widget, JRect clip)
if (widget->hasText()) {
/* text */
jdraw_text(widget->getFont(), widget->getText(), x, y, fg, bg, true, guiscale());
jdraw_text(widget->getFont(), widget->getText(), x, y, fg, bg, true, jguiscale());
/* background */
jrectexclude
@ -1444,7 +1444,7 @@ void SkinneableTheme::draw_frame(Frame* window, JRect clip)
jdraw_text(window->getFont(), window->getText(),
cpos->x1,
pos->y1+jrect_h(pos)/2-text_height(window->getFont())/2,
COLOR_BACKGROUND, -1, false, guiscale());
COLOR_BACKGROUND, -1, false, jguiscale());
}
// menubox
else {
@ -1539,11 +1539,11 @@ void SkinneableTheme::draw_textstring(const char *t, int fg_color, int bg_color,
if (jwidget_is_disabled (widget)) {
/* TODO avoid this */
if (fill_bg) /* only to draw the background */
jdraw_text(widget->getFont(), t, x, y, 0, bg_color, fill_bg, guiscale());
jdraw_text(widget->getFont(), t, x, y, 0, bg_color, fill_bg, jguiscale());
/* draw white part */
jdraw_text(widget->getFont(), t, x+1, y+1,
COLOR_BACKGROUND, bg_color, fill_bg, guiscale());
COLOR_BACKGROUND, bg_color, fill_bg, jguiscale());
if (fill_bg)
fill_bg = false;
@ -1553,7 +1553,7 @@ void SkinneableTheme::draw_textstring(const char *t, int fg_color, int bg_color,
jwidget_is_disabled(widget) ?
COLOR_DISABLED: (fg_color >= 0 ? fg_color :
COLOR_FOREGROUND),
bg_color, fill_bg, guiscale());
bg_color, fill_bg, jguiscale());
}
}
@ -1692,7 +1692,7 @@ void SkinneableTheme::less_bevel(int *bevel)
BITMAP* SkinneableTheme::apply_gui_scale(BITMAP* original)
{
int scale = guiscale();
int scale = jguiscale();
if (scale > 1) {
BITMAP* scaled = create_bitmap(original->w*scale,
original->h*scale);

View File

@ -47,7 +47,7 @@
#define COLORBAR_MAX_COLORS 256
#define FGBGSIZE (16*guiscale())
#define FGBGSIZE (16*jguiscale())
typedef enum {
HOTCOLOR_NONE = -3,

View File

@ -243,7 +243,7 @@ static void colorbutton_draw(JWidget widget)
rectfill(ji_screen, text.x1, text.y1, text.x2-1, text.y2-1, makecol(0, 0, 0));
jdraw_text(widget->getFont(), widget->getText(), text.x1, text.y1,
makecol(255, 255, 255),
makecol(0, 0, 0), false, guiscale());
makecol(0, 0, 0), false, jguiscale());
}
static void colorbutton_open_tooltip(JWidget widget)

View File

@ -281,8 +281,8 @@ static bool colorselector_msg_proc(JWidget widget, JMessage msg)
int idxlen = ji_font_text_len(idx->getFont(), "Index=888");
jwidget_set_min_size(idx, idxlen, 0);
paledit_set_boxsize(pal, 4*guiscale());
jwidget_set_min_size(grid2, 200*guiscale(), 0);
paledit_set_boxsize(pal, 4*jguiscale());
jwidget_set_min_size(grid2, 200*jguiscale(), 0);
}
break;

View File

@ -143,7 +143,7 @@ static bool colorviewer_msg_proc(JWidget widget, JMessage msg)
jdraw_rectfill(&text, makecol(0, 0, 0));
jdraw_text(widget->getFont(), widget->getText(), text.x1, text.y1,
makecol(255, 255, 255), makecol(0, 0, 0), false, guiscale());
makecol(255, 255, 255), makecol(0, 0, 0), false, jguiscale());
jrect_free(rect);
return true;

View File

@ -273,7 +273,7 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
jdraw_text(widget->getFont(),
"[+]", x, y+2,
fgcolor, bgcolor, true, guiscale());
fgcolor, bgcolor, true, jguiscale());
// background for the icon
jrectexclude(ji_screen,
@ -300,7 +300,7 @@ static bool fileview_msg_proc(JWidget widget, JMessage msg)
// item name
jdraw_text(widget->getFont(),
fileitem_get_displayname(fi).c_str(), x, y+2,
fgcolor, bgcolor, true, guiscale());
fgcolor, bgcolor, true, jguiscale());
// background for the item name
jrectexclude(ji_screen,

View File

@ -275,7 +275,7 @@ static bool tabs_msg_proc(JWidget widget, JMessage msg)
jdraw_text(widget->getFont(), tab->text.c_str(),
box->x1+4,
(box->y1+box->y2)/2-text_height(widget->getFont())/2+1,
text_color, face_color, false, guiscale());
text_color, face_color, false, jguiscale());
}
box->x1 = box->x2;

View File

@ -100,7 +100,7 @@ static Size getToolIconSize(Widget* widget)
if (icon)
return Size(icon->w, icon->h);
else
return Size(16, 16) * guiscale();
return Size(16, 16) * jguiscale();
}
//////////////////////////////////////////////////////////////////////
@ -124,9 +124,9 @@ void toolbar_select_tool(JWidget toolbar, Tool* tool)
ToolBar::ToolBar()
: Widget(JI_WIDGET)
{
this->border_width.l = 1*guiscale();
this->border_width.l = 1*jguiscale();
this->border_width.t = 0;
this->border_width.r = 1*guiscale();
this->border_width.r = 1*jguiscale();
this->border_width.b = 0;
m_hot_tool = NULL;
@ -358,7 +358,7 @@ Rect ToolBar::getToolGroupBounds(int group_index)
group_index < groups-1 ? iconsize.h+1: iconsize.h+2);
else
return Rect(rc->x1+border_width.l,
rc->y1+border_width.t+groups*(iconsize.h-1)+ 8*guiscale(),
rc->y1+border_width.t+groups*(iconsize.h-1)+ 8*jguiscale(),
jrect_w(rc)-border_width.l-border_width.r,
iconsize.h+2);
}