[Freeciv-Dev] (PR#13014) use color struct in the canvas interface
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13014 >
This patch changes the canvas interface to use the color struct instead
of the color enum. This means that colors other than the
one-dimensional enumerated ones can (someday) be used by the canvas
functions.
-jason
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.233
diff -u -r1.233 mapview_common.c
--- client/mapview_common.c 5 May 2005 18:32:46 -0000 1.233
+++ client/mapview_common.c 9 May 2005 19:37:49 -0000
@@ -1366,42 +1366,42 @@
owner_color = player_color(city_owner(pcity));
if (line1) {
canvas_put_sprite_full(pcanvas, flag_rect.x, flag_rect.y, flag);
- canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
+ canvas_put_line(pcanvas, get_color(owner_color), LINE_NORMAL,
flag_rect.x + flag_rect.w - 1, canvas_y,
0, height1);
canvas_put_sprite_full(pcanvas, occupy_rect.x, occupy_rect.y, occupy);
canvas_put_text(pcanvas, name_rect.x, name_rect.y,
- FONT_CITY_NAME, COLOR_STD_WHITE, name);
+ FONT_CITY_NAME, get_color(COLOR_STD_WHITE), name);
- canvas_put_rectangle(pcanvas, owner_color,
+ canvas_put_rectangle(pcanvas, get_color(owner_color),
size_rect.x - border / 2, canvas_y,
size_rect.w + border, height1);
canvas_put_text(pcanvas, size_rect.x, size_rect.y,
- FONT_CITY_NAME, COLOR_STD_WHITE, size);
+ FONT_CITY_NAME, get_color(COLOR_STD_WHITE), size);
}
if (line2) {
canvas_put_sprite_full(pcanvas, shield_rect.x, shield_rect.y,
citybar->shields);
canvas_put_text(pcanvas, prod_rect.x, prod_rect.y,
- FONT_CITY_PROD, COLOR_STD_WHITE, prod);
+ FONT_CITY_PROD, get_color(COLOR_STD_WHITE), prod);
canvas_put_sprite_full(pcanvas, food_rect.x, food_rect.y, citybar->food);
canvas_put_text(pcanvas, growth_rect.x, growth_rect.y,
- FONT_CITY_PROD, growth_color, growth);
+ FONT_CITY_PROD, get_color(growth_color), growth);
}
- canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
+ canvas_put_line(pcanvas, get_color(owner_color), LINE_NORMAL,
canvas_x - *width / 2, canvas_y,
*width, 0);
- canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
+ canvas_put_line(pcanvas, get_color(owner_color), LINE_NORMAL,
canvas_x - *width / 2, canvas_y,
0, *height);
- canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
+ canvas_put_line(pcanvas, get_color(owner_color), LINE_NORMAL,
canvas_x - *width / 2, canvas_y + *height - 1,
*width, 0);
- canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
+ canvas_put_line(pcanvas, get_color(owner_color), LINE_NORMAL,
canvas_x - *width / 2 + *width, canvas_y,
0, *height);
if (line1 && line2) {
- canvas_put_line(pcanvas, owner_color, LINE_NORMAL,
+ canvas_put_line(pcanvas, get_color(owner_color), LINE_NORMAL,
canvas_x - *width / 2, canvas_y + height1 - 1,
*width, 0);
}
@@ -1443,13 +1443,13 @@
total_width = name_rect.w + extra_width + growth_rect.w;
total_height = MAX(name_rect.h, growth_rect.h);
canvas_put_text(pcanvas,
- canvas_x - total_width / 2, canvas_y,
- FONT_CITY_NAME, COLOR_STD_WHITE, name);
+ canvas_x - total_width / 2, canvas_y,
+ FONT_CITY_NAME, get_color(COLOR_STD_WHITE), name);
if (growth[0] != '\0') {
canvas_put_text(pcanvas,
- canvas_x - total_width / 2 + name_rect.w + extra_width,
- canvas_y + total_height - growth_rect.h,
- FONT_CITY_PROD, growth_color, growth);
+ canvas_x - total_width / 2 + name_rect.w + extra_width,
+ canvas_y + total_height - growth_rect.h,
+ FONT_CITY_PROD, get_color(growth_color), growth);
}
canvas_y += total_height + 3;
@@ -1464,7 +1464,7 @@
total_height = prod_rect.h;
canvas_put_text(pcanvas, canvas_x - total_width / 2, canvas_y,
- FONT_CITY_PROD, COLOR_STD_WHITE, prod);
+ FONT_CITY_PROD, get_color(COLOR_STD_WHITE), prod);
canvas_y += total_height;
*width = MAX(*width, total_width);
@@ -1610,7 +1610,7 @@
map_to_gui_vector(tileset, &canvas_dx, &canvas_dy, DIR_DX[dir], DIR_DY[dir]);
/* Draw the segment. */
- canvas_put_line(mapview.store, COLOR_STD_CYAN, LINE_GOTO,
+ canvas_put_line(mapview.store, get_color(COLOR_STD_CYAN), LINE_GOTO,
canvas_x, canvas_y, canvas_dx, canvas_dy);
/* The actual area drawn will extend beyond the base rectangle, since
Index: client/overview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/overview_common.c,v
retrieving revision 1.7
diff -u -r1.7 overview_common.c
--- client/overview_common.c 5 May 2005 18:32:46 -0000 1.7
+++ client/overview_common.c 9 May 2005 19:37:49 -0000
@@ -176,7 +176,7 @@
int dst_x = x[(i + 1) % 4];
int dst_y = y[(i + 1) % 4];
- canvas_put_line(overview.window, COLOR_STD_WHITE, LINE_NORMAL,
+ canvas_put_line(overview.window, get_color(COLOR_STD_WHITE), LINE_NORMAL,
src_x, src_y, dst_x - src_x, dst_y - src_y);
}
@@ -332,7 +332,7 @@
/* This tile is shown half on the left and half on the right
* side of the overview. So we have to draw it in two parts. */
canvas_put_rectangle(overview.map,
- overview_tile_color(ptile),
+ get_color(overview_tile_color(ptile)),
overview_x - overview.width, overview_y,
OVERVIEW_TILE_WIDTH, OVERVIEW_TILE_HEIGHT);
}
@@ -344,7 +344,7 @@
}
canvas_put_rectangle(overview.map,
- overview_tile_color(ptile),
+ get_color(overview_tile_color(ptile)),
overview_x, overview_y,
OVERVIEW_TILE_WIDTH, OVERVIEW_TILE_HEIGHT);
@@ -394,7 +394,7 @@
}
overview.map = canvas_create(overview.width, overview.height);
overview.window = canvas_create(overview.width, overview.height);
- canvas_put_rectangle(overview.map, COLOR_STD_BLACK,
+ canvas_put_rectangle(overview.map, get_color(COLOR_STD_BLACK),
0, 0, overview.width, overview.height);
update_map_canvas_scrollbars_size();
Index: client/reqtree.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/reqtree.c,v
retrieving revision 1.3
diff -u -r1.3 reqtree.c
--- client/reqtree.c 5 May 2005 18:32:47 -0000 1.3
+++ client/reqtree.c 9 May 2005 19:37:50 -0000
@@ -786,7 +786,7 @@
width = node->node_width;
height = node->node_height;
- canvas_put_rectangle(pcanvas, COLOR_STD_BLACK,
+ canvas_put_rectangle(pcanvas, get_color(COLOR_STD_BLACK),
startx, starty, width, height);
if (!node->is_dummy) {
@@ -794,7 +794,7 @@
int text_w, text_h;
/* Print color rectangle with text inside. */
- canvas_put_rectangle(pcanvas, node_color(node),
+ canvas_put_rectangle(pcanvas, get_color(node_color(node)),
startx + 1, starty + 1,
width - 2, height - 2);
get_text_size(&text_w, &text_h, FONT_REQTREE_TEXT, text);
Index: client/gui-gtk-2.0/canvas.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/canvas.c,v
retrieving revision 1.4
diff -u -r1.4 canvas.c
--- client/gui-gtk-2.0/canvas.c 9 May 2005 18:42:19 -0000 1.4
+++ client/gui-gtk-2.0/canvas.c 9 May 2005 19:37:50 -0000
@@ -168,10 +168,10 @@
Draw a filled-in colored rectangle onto the mapview or citydialog canvas.
****************************************************************************/
void canvas_put_rectangle(struct canvas *pcanvas,
- enum color_std color,
+ struct color *pcolor,
int canvas_x, int canvas_y, int width, int height)
{
- GdkColor *col = &get_color(color)->color;
+ GdkColor *col = &pcolor->color;
switch (pcanvas->type) {
case CANVAS_PIXMAP:
@@ -196,13 +196,14 @@
Fill the area covered by the sprite with the given color.
****************************************************************************/
void canvas_fill_sprite_area(struct canvas *pcanvas,
- struct sprite *psprite, enum color_std color,
+ struct sprite *psprite,
+ struct color *pcolor,
int canvas_x, int canvas_y)
{
if (pcanvas->type == CANVAS_PIXMAP) {
gdk_gc_set_clip_origin(fill_bg_gc, canvas_x, canvas_y);
gdk_gc_set_clip_mask(fill_bg_gc, sprite_get_mask(psprite));
- gdk_gc_set_foreground(fill_bg_gc, &get_color(color)->color);
+ gdk_gc_set_foreground(fill_bg_gc, &pcolor->color);
gdk_draw_rectangle(pcanvas->v.pixmap, fill_bg_gc, TRUE,
canvas_x, canvas_y, psprite->width, psprite->height);
@@ -234,7 +235,8 @@
/****************************************************************************
Draw a colored line onto the mapview or citydialog canvas.
****************************************************************************/
-void canvas_put_line(struct canvas *pcanvas, enum color_std color,
+void canvas_put_line(struct canvas *pcanvas,
+ struct color *pcolor,
enum line_type ltype, int start_x, int start_y,
int dx, int dy)
{
@@ -256,7 +258,7 @@
break;
}
- gdk_gc_set_foreground(gc, &get_color(color)->color);
+ gdk_gc_set_foreground(gc, &pcolor->color);
gdk_draw_line(pcanvas->v.pixmap, gc,
start_x, start_y, start_x + dx, start_y + dy);
}
@@ -304,7 +306,8 @@
take care of this manually. The text will not be NULL but may be empty.
****************************************************************************/
void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y,
- enum client_font font, enum color_std color,
+ enum client_font font,
+ struct color *pcolor,
const char *text)
{
PangoRectangle rect;
@@ -316,7 +319,7 @@
layout = pango_layout_new(gdk_pango_context_get());
}
- gdk_gc_set_foreground(civ_gc, &get_color(color)->color);
+ gdk_gc_set_foreground(civ_gc, &pcolor->color);
pango_layout_set_font_description(layout, *fonts[font].font);
pango_layout_set_text(layout, text, -1);
Index: client/include/canvas_g.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/canvas_g.h,v
retrieving revision 1.5
diff -u -r1.5 canvas_g.h
--- client/include/canvas_g.h 9 May 2005 18:42:19 -0000 1.5
+++ client/include/canvas_g.h 9 May 2005 19:37:50 -0000
@@ -15,9 +15,9 @@
#include "shared.h" /* bool type */
-#include "colors_g.h"
-
+struct color;
struct sprite;
+
struct canvas; /* opaque type, real type is gui-dep */
enum line_type {
@@ -43,14 +43,16 @@
struct sprite *psprite,
bool fog, int fog_x, int fog_y);
void canvas_put_rectangle(struct canvas *pcanvas,
- enum color_std color,
+ struct color *pcolor,
int canvas_x, int canvas_y, int width, int height);
void canvas_fill_sprite_area(struct canvas *pcanvas,
- struct sprite *psprite, enum color_std color,
+ struct sprite *psprite,
+ struct color *pcolor,
int canvas_x, int canvas_y);
void canvas_fog_sprite_area(struct canvas *pcanvas, struct sprite *psprite,
int canvas_x, int canvas_y);
-void canvas_put_line(struct canvas *pcanvas, enum color_std color,
+void canvas_put_line(struct canvas *pcanvas,
+ struct color *pcolor,
enum line_type ltype, int start_x, int start_y,
int dx, int dy);
@@ -64,7 +66,8 @@
void get_text_size(int *width, int *height,
enum client_font font, const char *text);
void canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y,
- enum client_font font, enum color_std color,
+ enum client_font font,
+ struct color *pcolor,
const char *text);
#endif /* FC__CANVAS_G_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#13014) use color struct in the canvas interface,
Jason Short <=
|
|