aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2004-10-27 06:07:35 +0000
committerKeith Packard <keithp@keithp.com>2004-10-27 06:07:35 +0000
commit4e67aeb9a6aaf0852ab9b6aba46c21cb483cdf54 (patch)
tree6427b01e01f84eff7f846aa5f7d087d3b4b25f9f
parent1b19cddc722e1a4e1d2a7f8d4a8565ee1551d6a9 (diff)
downloadlibtwin-4e67aeb9a6aaf0852ab9b6aba46c21cb483cdf54.tar.gz
Move bevel routine to twin_widget for sharing
Change order of timeout vs work, making work come last as that's where redisplay occurs. Oops. Argument order wrong in twin_pixmap_damage call Make button italic to test Change names of formals to match prototype
-rw-r--r--ChangeLog20
-rw-r--r--twin_button.c43
-rw-r--r--twin_dispatch.c2
-rw-r--r--twin_draw.c2
-rw-r--r--twin_hello.c2
-rw-r--r--twin_pixmap.c14
-rw-r--r--twin_widget.c44
-rw-r--r--twinint.h5
8 files changed, 82 insertions, 50 deletions
diff --git a/ChangeLog b/ChangeLog
index 6dd0067..3992356 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,26 @@
2004-10-26 Keith Packard <keithp@keithp.com>
* twin_button.c: (_twin_button_paint):
+ * twin_widget.c: (_twin_widget_bevel):
+ * twinint.h:
+ Move bevel routine to twin_widget for sharing
+
+ * twin_dispatch.c: (twin_dispatch):
+ Change order of timeout vs work, making work come last as
+ that's where redisplay occurs.
+
+ * twin_draw.c: (twin_fill):
+ Oops. Argument order wrong in twin_pixmap_damage call
+
+ * twin_hello.c: (twin_hello_start):
+ Make button italic to test
+
+ * twin_pixmap.c: (twin_pixmap_damage):
+ Change names of formals to match prototype
+
+2004-10-26 Keith Packard <keithp@keithp.com>
+
+ * twin_button.c: (_twin_button_paint):
Paint polygons instead of stroked lines for button edges
* twin_font.c: (_twin_text_compute_info):
diff --git a/twin_button.c b/twin_button.c
index 4e44376..a308abb 100644
--- a/twin_button.c
+++ b/twin_button.c
@@ -29,46 +29,9 @@
static void
_twin_button_paint (twin_button_t *button)
{
- twin_path_t *path = twin_path_create ();
- twin_coord_t w = button->label.widget.extents.right - button->label.widget.extents.left;
- twin_coord_t h = button->label.widget.extents.bottom - button->label.widget.extents.top;
- twin_fixed_t wf = twin_int_to_fixed (w);
- twin_fixed_t hf = twin_int_to_fixed (h);
- twin_fixed_t bf = _twin_button_bw (button);
- twin_argb32_t top_color, bot_color;
- twin_pixmap_t *pixmap = button->label.widget.window->pixmap;
-
- if (path)
- {
- if (button->active)
- {
- top_color = 0x80000000;
- bot_color = 0x80808080;
- }
- else
- {
- top_color = 0x80808080;
- bot_color = 0x80000000;
- }
- twin_path_move (path, 0, 0);
- twin_path_draw (path, wf, 0);
- twin_path_draw (path, wf-bf, bf);
- twin_path_draw (path, bf, bf);
- twin_path_draw (path, bf, hf-bf);
- twin_path_draw (path, 0, hf);
- twin_path_close (path);
- twin_paint_path (pixmap, top_color, path);
- twin_path_empty (path);
- twin_path_move (path, bf, hf-bf);
- twin_path_draw (path, wf-bf, hf-bf);
- twin_path_draw (path, wf-bf, bf);
- twin_path_draw (path, wf, 0);
- twin_path_draw (path, wf, hf);
- twin_path_draw (path, 0, hf);
- twin_path_close (path);
- twin_paint_path (pixmap, bot_color, path);
- twin_path_destroy (path);
- }
+ _twin_widget_bevel (&button->label.widget,
+ _twin_button_bw(button),
+ button->active);
}
static void
diff --git a/twin_dispatch.c b/twin_dispatch.c
index f8a00bc..eba00df 100644
--- a/twin_dispatch.c
+++ b/twin_dispatch.c
@@ -29,8 +29,8 @@ twin_dispatch (void)
{
for (;;)
{
- _twin_run_work ();
_twin_run_timeout ();
+ _twin_run_work ();
_twin_run_file (_twin_timeout_delay ());
}
}
diff --git a/twin_draw.c b/twin_draw.c
index 146c5c3..a4d7fe3 100644
--- a/twin_draw.c
+++ b/twin_draw.c
@@ -402,5 +402,5 @@ twin_fill (twin_pixmap_t *dst,
op = fill[operator][dst->format];
for (iy = top; iy < bottom; iy++)
(*op) (twin_pixmap_pointer (dst, left, iy), src, right - left);
- twin_pixmap_damage (dst, left, right, top, bottom);
+ twin_pixmap_damage (dst, left, top, right, bottom);
}
diff --git a/twin_hello.c b/twin_hello.c
index d29b6cd..ad78029 100644
--- a/twin_hello.c
+++ b/twin_hello.c
@@ -65,7 +65,7 @@ twin_hello_start (twin_screen_t *screen, const char *name, int x, int y, int w,
"Button",
0xff800000,
twin_int_to_fixed (18),
- TWIN_TEXT_BOLD);
+ TWIN_TEXT_BOLD|TWIN_TEXT_OBLIQUE);
twin_widget_set (&labela->widget, 0xc0c0c0c0);
(void) widget;
twin_widget_set (&labelb->widget, 0xc0c0c0c0);
diff --git a/twin_pixmap.c b/twin_pixmap.c
index c30b27c..5a5adf8 100644
--- a/twin_pixmap.c
+++ b/twin_pixmap.c
@@ -226,16 +226,16 @@ twin_pixmap_reset_clip (twin_pixmap_t *pixmap)
}
void
-twin_pixmap_damage (twin_pixmap_t *pixmap,
- twin_coord_t x1, twin_coord_t y1,
- twin_coord_t x2, twin_coord_t y2)
+twin_pixmap_damage (twin_pixmap_t *pixmap,
+ twin_coord_t left, twin_coord_t top,
+ twin_coord_t right, twin_coord_t bottom)
{
if (pixmap->screen)
twin_screen_damage (pixmap->screen,
- x1 + pixmap->x,
- y1 + pixmap->y,
- x2 + pixmap->x,
- y2 + pixmap->y);
+ left + pixmap->x,
+ top + pixmap->y,
+ right + pixmap->x,
+ bottom + pixmap->y);
}
static twin_argb32_t
diff --git a/twin_widget.c b/twin_widget.c
index 4d5cd4e..cc0e12a 100644
--- a/twin_widget.c
+++ b/twin_widget.c
@@ -122,6 +122,50 @@ _twin_widget_contains (twin_widget_t *widget,
0 <= y && y < _twin_widget_height(widget));
}
+void
+_twin_widget_bevel (twin_widget_t *widget,
+ twin_fixed_t b,
+ twin_bool_t down)
+{
+ twin_path_t *path = twin_path_create ();
+ twin_fixed_t w = twin_int_to_fixed (_twin_widget_width (widget));
+ twin_fixed_t h = twin_int_to_fixed (_twin_widget_height (widget));
+ twin_argb32_t top_color, bot_color;
+ twin_pixmap_t *pixmap = widget->window->pixmap;
+
+ if (path)
+ {
+ if (down)
+ {
+ top_color = 0x80000000;
+ bot_color = 0x80808080;
+ }
+ else
+ {
+ top_color = 0x80808080;
+ bot_color = 0x80000000;
+ }
+ twin_path_move (path, 0, 0);
+ twin_path_draw (path, w, 0);
+ twin_path_draw (path, w-b, b);
+ twin_path_draw (path, b, b);
+ twin_path_draw (path, b, h-b);
+ twin_path_draw (path, 0, h);
+ twin_path_close (path);
+ twin_paint_path (pixmap, top_color, path);
+ twin_path_empty (path);
+ twin_path_move (path, b, h-b);
+ twin_path_draw (path, w-b, h-b);
+ twin_path_draw (path, w-b, b);
+ twin_path_draw (path, w, 0);
+ twin_path_draw (path, w, h);
+ twin_path_draw (path, 0, h);
+ twin_path_close (path);
+ twin_paint_path (pixmap, bot_color, path);
+ twin_path_destroy (path);
+ }
+}
+
twin_widget_t *
twin_widget_create (twin_box_t *parent,
twin_argb32_t background,
diff --git a/twinint.h b/twinint.h
index 30bb235..4063948 100644
--- a/twinint.h
+++ b/twinint.h
@@ -485,6 +485,11 @@ _twin_widget_contains (twin_widget_t *widget,
twin_coord_t y);
void
+_twin_widget_bevel (twin_widget_t *widget,
+ twin_fixed_t bevel_width,
+ twin_bool_t down);
+
+void
_twin_label_init (twin_label_t *label,
twin_box_t *parent,
const char *value,