Author: cazfi Date: Wed Dec 24 20:59:09 2014 New Revision: 27401 URL: http://svn.gna.org/viewcvs/freeciv?rev=27401&view=rev Log: Added new create_frame() function for sdl2-client to be used in the future where putframe() has been used in sdl-client but cannot be used in sdl2-client.
See patch #5589 Modified: trunk/client/gui-sdl2/graphics.c trunk/client/gui-sdl2/graphics.h trunk/client/gui-sdl2/sprite.c trunk/client/gui-sdl2/widget.c trunk/client/gui-sdl2/widget_icon.c Modified: trunk/client/gui-sdl2/graphics.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/graphics.c?rev=27401&r1=27400&r2=27401&view=diff ============================================================================== --- trunk/client/gui-sdl2/graphics.c (original) +++ trunk/client/gui-sdl2/graphics.c Wed Dec 24 20:59:09 2014 @@ -38,6 +38,7 @@ #include "tilespec.h" /* gui-sdl2 */ +#include "colors.h" #include "gui_tilespec.h" #include "mapview.h" #include "themebackgrounds.h" @@ -3391,3 +3392,34 @@ { /* nothing */ } + +/************************************************************************** + Create colored frame +**************************************************************************/ +void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, + Sint16 width, Sint16 height, + SDL_Color *pcolor) +{ + struct color gsdl2_color = { .color = pcolor }; + struct sprite *vertical = create_sprite(1, height, &gsdl2_color); + struct sprite *horizontal = create_sprite(width, 1, &gsdl2_color); + SDL_Rect tmp,dst = { left, top, 0, 0 }; + + tmp = dst; + alphablit(vertical->psurface, NULL, dest, &tmp, 255); + + dst.x += width - 1; + tmp = dst; + alphablit(vertical->psurface, NULL, dest, &tmp, 255); + + dst.x = left; + tmp = dst; + alphablit(horizontal->psurface, NULL, dest, &tmp, 255); + + dst.y += height - 1; + tmp = dst; + alphablit(horizontal->psurface, NULL, dest, &tmp, 255); + + free_sprite(horizontal); + free_sprite(vertical); +} Modified: trunk/client/gui-sdl2/graphics.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/graphics.h?rev=27401&r1=27400&r2=27401&view=diff ============================================================================== --- trunk/client/gui-sdl2/graphics.h (original) +++ trunk/client/gui-sdl2/graphics.h Wed Dec 24 20:59:09 2014 @@ -277,6 +277,10 @@ ((Uint32) pcolor->b << 8) | ((Uint32) pcolor->a)); } + +void create_frame(SDL_Surface *dest, Sint16 left, Sint16 top, + Sint16 right, Sint16 bottom, + SDL_Color *pcolor); /* SDL */ void init_sdl(int f); Modified: trunk/client/gui-sdl2/sprite.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/sprite.c?rev=27401&r1=27400&r2=27401&view=diff ============================================================================== --- trunk/client/gui-sdl2/sprite.c (original) +++ trunk/client/gui-sdl2/sprite.c Wed Dec 24 20:59:09 2014 @@ -53,7 +53,7 @@ entire image file, which may later be broken up into individual sprites with crop_sprite. ****************************************************************************/ -struct sprite * load_gfxfile(const char *filename) +struct sprite *load_gfxfile(const char *filename) { SDL_Surface *pNew = NULL; SDL_Surface *pBuf = NULL; @@ -123,19 +123,25 @@ struct sprite *create_sprite(int width, int height, struct color *pcolor) { SDL_Surface *mypixbuf = NULL; - /* SDL_Surface *pmask = NULL; */ fc_assert_ret_val(width > 0, NULL); fc_assert_ret_val(height > 0, NULL); fc_assert_ret_val(pcolor != NULL, NULL); mypixbuf = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, - 0x00ff0000, 0x0000ff00, 0x000000ff, - 0xff000000); -#if 0 - pmask = SDL_DisplayFormatAlpha(mypixbuf); - SDL_FillRect(mypixbuf, NULL, map_rgba(pmask->format, *pcolor->color)); -#endif /* 0 */ +#if SDL_BYTEORDER != SDL_LIL_ENDIAN + 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF +#else + 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 +#endif + ); + + SDL_FillRect(mypixbuf, NULL, + SDL_MapRGBA(mypixbuf->format, + pcolor->color->r, + pcolor->color->g, + pcolor->color->b, + 255)); return ctor_sprite(mypixbuf); } @@ -164,7 +170,7 @@ /************************************************************************** Create a sprite struct and fill it with SDL_Surface pointer **************************************************************************/ -static struct sprite * ctor_sprite(SDL_Surface *pSurface) +static struct sprite *ctor_sprite(SDL_Surface *pSurface) { struct sprite *result = fc_malloc(sizeof(struct sprite)); Modified: trunk/client/gui-sdl2/widget.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/widget.c?rev=27401&r1=27400&r2=27401&view=diff ============================================================================== --- trunk/client/gui-sdl2/widget.c (original) +++ trunk/client/gui-sdl2/widget.c Wed Dec 24 20:59:09 2014 @@ -1119,9 +1119,9 @@ void draw_frame(SDL_Surface *pDest, Sint16 start_x, Sint16 start_y, Uint16 w, Uint16 h) { - SDL_Surface *pTmpLeft = + SDL_Surface *pTmpLeft = ResizeSurface(pTheme->FR_Left, pTheme->FR_Left->w, h, 1); - SDL_Surface *pTmpRight = + SDL_Surface *pTmpRight = ResizeSurface(pTheme->FR_Right, pTheme->FR_Right->w, h, 1); SDL_Surface *pTmpTop = ResizeSurface(pTheme->FR_Top, w, pTheme->FR_Top->h, 1); Modified: trunk/client/gui-sdl2/widget_icon.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-sdl2/widget_icon.c?rev=27401&r1=27400&r2=27401&view=diff ============================================================================== --- trunk/client/gui-sdl2/widget_icon.c (original) +++ trunk/client/gui-sdl2/widget_icon.c Wed Dec 24 20:59:09 2014 @@ -75,7 +75,6 @@ { int ret; SDL_Rect dest; - /* Uint32 state; */ ret = (*baseclass_redraw)(pIcon); if (ret != 0) { @@ -90,40 +89,41 @@ return -4; } - /* state = get_wstate(pIcon); */ - dest.x = pIcon->size.x; dest.y = pIcon->size.y; dest.w = pIcon->theme->w; - dest.h = pIcon->theme->h; - -#if 0 - if (state == FC_WS_SELECTED) { - putframe(pIcon->dst->surface, - dest.x + 1, dest.y + 1, - dest.x + dest.w + adj_size(2), dest.y + dest.h + adj_size(2), - get_theme_color(COLOR_THEME_CUSTOM_WIDGET_SELECTED_FRAME)); - } - - if (state == FC_WS_PRESSED) { - putframe(pIcon->dst->surface, - dest.x + 1, dest.y + 1, - dest.x + dest.w + adj_size(2), dest.y + dest.h + adj_size(2), - get_theme_color(COLOR_THEME_CUSTOM_WIDGET_SELECTED_FRAME)); - - putframe(pIcon->dst->surface, - dest.x, dest.y, - dest.x + dest.w + adj_size(3), dest.y + dest.h + adj_size(3), - get_theme_color(COLOR_THEME_CUSTOM_WIDGET_PRESSED_FRAME)); - } - - if (state == FC_WS_DISABLED) { - putframe(pIcon->dst->surface, - dest.x + 1, dest.y + 1, - dest.x + dest.w + adj_size(2), dest.y + dest.h + adj_size(2), - get_theme_color(COLOR_THEME_WIDGET_DISABLED_TEXT)); - } -#endif /* 0 */ + dest.h = pIcon->theme->h; + + switch (get_wstate(pIcon)) { + case FC_WS_SELECTED: + create_frame(pIcon->dst->surface, + dest.x + 1, dest.y + 1, + dest.w + adj_size(2), dest.h + adj_size(2), + get_theme_color(COLOR_THEME_CUSTOM_WIDGET_SELECTED_FRAME)); + break; + + case FC_WS_PRESSED: + create_frame(pIcon->dst->surface, + dest.x + 1, dest.y + 1, + dest.w + adj_size(2), dest.h + adj_size(2), + get_theme_color(COLOR_THEME_CUSTOM_WIDGET_SELECTED_FRAME)); + + create_frame(pIcon->dst->surface, + dest.x, dest.y, + dest.w + adj_size(3), dest.h + adj_size(3), + get_theme_color(COLOR_THEME_CUSTOM_WIDGET_PRESSED_FRAME)); + break; + + case FC_WS_DISABLED: + create_frame(pIcon->dst->surface, + dest.x + 1, dest.y + 1, + dest.w + adj_size(2), dest.h + adj_size(2), + get_theme_color(COLOR_THEME_WIDGET_DISABLED_TEXT)); + break; + case FC_WS_NORMAL: + /* No frame by default */ + break; + } dest.x += adj_size(2); dest.y += adj_size(2); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits