mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-25 02:36:07 +00:00
More work on task 1588.
* libnautilus-extensions/nautilus-scalable-font.c: (nautilus_scalable_font_draw_text), (nautilus_scalable_font_measure_text_lines), (nautilus_scalable_font_draw_text_lines): * libnautilus-extensions/nautilus-scalable-font.h: Change text rendering api to take in x,y coordinates along with a clip_area. Remove some #if 0 code i left in before. Also change the text lines rendering api to optionally do its own line measuring - for the convenience of the caller. * libnautilus-extensions/nautilus-label.c: (render_buffer_pixbuf): Update for text rendering changes. Fix the justification bug. Fix the multiple newlines bug. * src/nautilus-about.c: (draw_aa_string): Update for text rendering changes. * src/nautilus-sidebar-tabs.c: (draw_one_tab_plain), (draw_one_tab_themed): Update for text rendering changes. * test/test-nautilus-font.c: (main): Update for text rendering changes. Also add multiple new lines test and clipping test. * test/test-nautilus-label.c: (main): Update for text rendering changes.
This commit is contained in:
parent
af9196b510
commit
4025fec57a
36
ChangeLog
36
ChangeLog
|
@ -1,3 +1,39 @@
|
|||
2000-09-05 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
More work on task 1588.
|
||||
|
||||
* libnautilus-extensions/nautilus-scalable-font.c:
|
||||
(nautilus_scalable_font_draw_text),
|
||||
(nautilus_scalable_font_measure_text_lines),
|
||||
(nautilus_scalable_font_draw_text_lines):
|
||||
* libnautilus-extensions/nautilus-scalable-font.h:
|
||||
Change text rendering api to take in x,y coordinates along with a
|
||||
clip_area.
|
||||
|
||||
Remove some #if 0 code i left in before.
|
||||
|
||||
Also change the text lines rendering api to optionally do its own
|
||||
line measuring - for the convenience of the caller.
|
||||
|
||||
* libnautilus-extensions/nautilus-label.c: (render_buffer_pixbuf):
|
||||
Update for text rendering changes.
|
||||
Fix the justification bug.
|
||||
Fix the multiple newlines bug.
|
||||
|
||||
* src/nautilus-about.c: (draw_aa_string):
|
||||
Update for text rendering changes.
|
||||
|
||||
* src/nautilus-sidebar-tabs.c: (draw_one_tab_plain),
|
||||
(draw_one_tab_themed):
|
||||
Update for text rendering changes.
|
||||
|
||||
* test/test-nautilus-font.c: (main):
|
||||
Update for text rendering changes.
|
||||
Also add multiple new lines test and clipping test.
|
||||
|
||||
* test/test-nautilus-label.c: (main):
|
||||
Update for text rendering changes.
|
||||
|
||||
2000-09-05 Ramiro Estrugo <ramiro@eazel.com>
|
||||
|
||||
* librsvg/rsvg-ft.c: (rsvg_ft_render_string):
|
||||
|
|
|
@ -307,9 +307,11 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
{
|
||||
NautilusLabel *label;
|
||||
GtkWidget *widget;
|
||||
ArtIRect area;
|
||||
ArtIRect clip_area;
|
||||
guint total_text_width;
|
||||
guint total_text_height;
|
||||
int text_x;
|
||||
int text_y;
|
||||
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_LABEL (buffered_widget));
|
||||
|
@ -329,30 +331,37 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
|
||||
|
||||
if (total_text_width <= widget->allocation.width) {
|
||||
area.x0 = ((int) widget->allocation.width - (int) total_text_width) / 2;
|
||||
clip_area.x0 = ((int) widget->allocation.width - (int) total_text_width) / 2;
|
||||
}
|
||||
else {
|
||||
area.x0 = - ((int) total_text_width - (int) widget->allocation.width) / 2;
|
||||
clip_area.x0 = - ((int) total_text_width - (int) widget->allocation.width) / 2;
|
||||
}
|
||||
|
||||
if (total_text_height <= widget->allocation.height) {
|
||||
area.y0 = ((int) widget->allocation.height - (int) total_text_height) / 2;
|
||||
clip_area.y0 = ((int) widget->allocation.height - (int) total_text_height) / 2;
|
||||
}
|
||||
else {
|
||||
area.y0 = - ((int) total_text_height - (int) widget->allocation.height) / 2;
|
||||
clip_area.y0 = - ((int) total_text_height - (int) widget->allocation.height) / 2;
|
||||
}
|
||||
|
||||
area.x0 += horizontal_offset;
|
||||
area.y0 += vertical_offset;
|
||||
clip_area.x0 = 0;
|
||||
clip_area.y0 = 0;
|
||||
|
||||
area.x1 = area.x0 + total_text_width + label->detail->drop_shadow_offset;
|
||||
area.y1 = area.y0 + total_text_width + label->detail->drop_shadow_offset;
|
||||
clip_area.x1 = widget->allocation.width;
|
||||
clip_area.y1 = widget->allocation.height;
|
||||
|
||||
text_x = 0;
|
||||
text_y = 0;
|
||||
|
||||
if (label->detail->num_text_lines > 0) {
|
||||
if (label->detail->drop_shadow_offset > 0) {
|
||||
text_x += label->detail->drop_shadow_offset;
|
||||
text_y += label->detail->drop_shadow_offset;
|
||||
nautilus_scalable_font_draw_text_lines (label->detail->font,
|
||||
buffer,
|
||||
&area,
|
||||
text_x,
|
||||
text_y,
|
||||
&clip_area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
label->detail->text,
|
||||
|
@ -364,16 +373,15 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
label->detail->drop_shadow_color,
|
||||
label->detail->text_alpha);
|
||||
|
||||
area.x0 -= label->detail->drop_shadow_offset;
|
||||
area.y0 -= label->detail->drop_shadow_offset;
|
||||
|
||||
area.x1 -= label->detail->drop_shadow_offset;
|
||||
area.y1 -= label->detail->drop_shadow_offset;
|
||||
text_x -= label->detail->drop_shadow_offset;
|
||||
text_y -= label->detail->drop_shadow_offset;
|
||||
}
|
||||
|
||||
nautilus_scalable_font_draw_text_lines (label->detail->font,
|
||||
buffer,
|
||||
&area,
|
||||
text_x,
|
||||
text_y,
|
||||
&clip_area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
label->detail->text,
|
||||
|
|
|
@ -653,7 +653,9 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
void
|
||||
nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
|
@ -678,9 +680,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
||||
|
@ -690,6 +690,11 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
g_return_if_fail (text_length <= strlen (text));
|
||||
|
||||
if (clip_area != NULL) {
|
||||
g_return_if_fail (clip_area->x1 > clip_area->x0);
|
||||
g_return_if_fail (clip_area->y1 > clip_area->y0);
|
||||
}
|
||||
|
||||
art_affine_identity (affine);
|
||||
|
||||
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
|
||||
|
@ -726,22 +731,27 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
art_render_image_solid (art_render, art_color_array);
|
||||
|
||||
glyph_area.x0 = glyph_xy[0] + destination_area->x0;
|
||||
glyph_area.y0 = glyph_xy[1] + destination_area->y0;
|
||||
glyph_area.x0 = glyph_xy[0] + x;
|
||||
glyph_area.y0 = glyph_xy[1] + y;
|
||||
|
||||
glyph_area.x1 = glyph_area.x0 + glyph->width;
|
||||
glyph_area.y1 = glyph_area.y0 + glyph->height;
|
||||
|
||||
art_irect_union (&area, &glyph_area, destination_area);
|
||||
|
||||
if (clip_area != NULL) {
|
||||
art_irect_intersect (&area, &glyph_area, clip_area);
|
||||
}
|
||||
else {
|
||||
area = glyph_area;
|
||||
}
|
||||
|
||||
/* glyph_xy[0] += destination_point->x; */
|
||||
/* glyph_xy[1] += destination_point->y; */
|
||||
|
||||
art_render_mask (art_render,
|
||||
glyph_area.x0,
|
||||
glyph_area.y0,
|
||||
glyph_area.x1,
|
||||
glyph_area.y1,
|
||||
area.x0,
|
||||
area.y0,
|
||||
area.x1,
|
||||
area.y1,
|
||||
glyph->buf,
|
||||
glyph->rowstride);
|
||||
|
||||
|
@ -750,152 +760,8 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
rsvg_ft_glyph_unref (glyph);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
GtkJustification justification,
|
||||
const guint num_text_lines,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
guchar overall_alpha)
|
||||
{
|
||||
guint i;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
guint available_width;
|
||||
guint available_height;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (justification >= GTK_JUSTIFY_LEFT && justification <= GTK_JUSTIFY_FILL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
|
||||
x = destination_area->x0;
|
||||
y = destination_area->y0;
|
||||
|
||||
available_width = destination_area->x1 - destination_area->x0;
|
||||
available_height = destination_area->y1 - destination_area->y0;
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
ArtIRect area;
|
||||
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
if (text_line_widths[i] == 0 && text_line_heights[i] == 0) {
|
||||
y += font_height;
|
||||
}
|
||||
else {
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
|
@ -984,13 +850,15 @@ nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
|||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
const guint *text_line_widths,
|
||||
const guint *text_line_heights,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
|
@ -999,30 +867,62 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
guint i;
|
||||
const char *line;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
guint *temp_text_line_widths = NULL;
|
||||
guint *temp_text_line_heights = NULL;
|
||||
|
||||
guint available_width;
|
||||
guint available_height;
|
||||
|
||||
guint max_num_text_lines;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (clip_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (justification >= GTK_JUSTIFY_LEFT && justification <= GTK_JUSTIFY_FILL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
g_return_if_fail (clip_area->x1 > clip_area->x0);
|
||||
g_return_if_fail (clip_area->y1 > clip_area->y0);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (num_text_lines <= (nautilus_str_count_characters (text, '\n') + 1));
|
||||
|
||||
x = destination_area->x0;
|
||||
y = destination_area->y0;
|
||||
available_width = clip_area->x1 - clip_area->x0;
|
||||
available_height = clip_area->y1 - clip_area->y0;
|
||||
|
||||
available_width = destination_area->x1 - destination_area->x0;
|
||||
available_height = destination_area->y1 - destination_area->y0;
|
||||
if (text_line_widths) {
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
}
|
||||
|
||||
if (text_line_heights) {
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
}
|
||||
|
||||
max_num_text_lines = (available_height / font_height);
|
||||
|
||||
if (text_line_widths == NULL && text_line_heights == NULL) {
|
||||
temp_text_line_widths = g_new (guint, num_text_lines);
|
||||
temp_text_line_heights = g_new (guint, num_text_lines);
|
||||
|
||||
nautilus_scalable_font_measure_text_lines (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
num_text_lines,
|
||||
temp_text_line_widths,
|
||||
temp_text_line_heights,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
text_line_widths = temp_text_line_widths;
|
||||
text_line_heights = temp_text_line_heights;
|
||||
}
|
||||
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
|
||||
// x = clip_area->x0;
|
||||
// y = clip_area->y0;
|
||||
|
||||
line = text;
|
||||
|
||||
|
@ -1051,38 +951,39 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
y += font_height;
|
||||
}
|
||||
else {
|
||||
ArtIRect area;
|
||||
|
||||
int text_x;
|
||||
int text_y;
|
||||
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
text_x = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
text_x = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
text_x = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
text_x = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
text_y = y;
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
text_x,
|
||||
text_y,
|
||||
clip_area,
|
||||
font_width,
|
||||
font_height,
|
||||
line,
|
||||
|
@ -1100,8 +1001,15 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
line = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp_text_line_widths != NULL) {
|
||||
g_free (temp_text_line_widths);
|
||||
}
|
||||
|
||||
if (temp_text_line_heights != NULL) {
|
||||
g_free (temp_text_line_heights);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
guint
|
||||
nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
|
|
|
@ -86,14 +86,16 @@ void nautilus_scalable_font_measure_text (const N
|
|||
guint *text_height_out);
|
||||
void nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha);
|
||||
void nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
void nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
|
@ -104,13 +106,15 @@ void nautilus_scalable_font_measure_text_lines (Nautilu
|
|||
guint *total_height_out);
|
||||
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
const guint *text_line_widths,
|
||||
const guint *text_line_heights,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
|
|
|
@ -307,9 +307,11 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
{
|
||||
NautilusLabel *label;
|
||||
GtkWidget *widget;
|
||||
ArtIRect area;
|
||||
ArtIRect clip_area;
|
||||
guint total_text_width;
|
||||
guint total_text_height;
|
||||
int text_x;
|
||||
int text_y;
|
||||
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_LABEL (buffered_widget));
|
||||
|
@ -329,30 +331,37 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
|
||||
|
||||
if (total_text_width <= widget->allocation.width) {
|
||||
area.x0 = ((int) widget->allocation.width - (int) total_text_width) / 2;
|
||||
clip_area.x0 = ((int) widget->allocation.width - (int) total_text_width) / 2;
|
||||
}
|
||||
else {
|
||||
area.x0 = - ((int) total_text_width - (int) widget->allocation.width) / 2;
|
||||
clip_area.x0 = - ((int) total_text_width - (int) widget->allocation.width) / 2;
|
||||
}
|
||||
|
||||
if (total_text_height <= widget->allocation.height) {
|
||||
area.y0 = ((int) widget->allocation.height - (int) total_text_height) / 2;
|
||||
clip_area.y0 = ((int) widget->allocation.height - (int) total_text_height) / 2;
|
||||
}
|
||||
else {
|
||||
area.y0 = - ((int) total_text_height - (int) widget->allocation.height) / 2;
|
||||
clip_area.y0 = - ((int) total_text_height - (int) widget->allocation.height) / 2;
|
||||
}
|
||||
|
||||
area.x0 += horizontal_offset;
|
||||
area.y0 += vertical_offset;
|
||||
clip_area.x0 = 0;
|
||||
clip_area.y0 = 0;
|
||||
|
||||
area.x1 = area.x0 + total_text_width + label->detail->drop_shadow_offset;
|
||||
area.y1 = area.y0 + total_text_width + label->detail->drop_shadow_offset;
|
||||
clip_area.x1 = widget->allocation.width;
|
||||
clip_area.y1 = widget->allocation.height;
|
||||
|
||||
text_x = 0;
|
||||
text_y = 0;
|
||||
|
||||
if (label->detail->num_text_lines > 0) {
|
||||
if (label->detail->drop_shadow_offset > 0) {
|
||||
text_x += label->detail->drop_shadow_offset;
|
||||
text_y += label->detail->drop_shadow_offset;
|
||||
nautilus_scalable_font_draw_text_lines (label->detail->font,
|
||||
buffer,
|
||||
&area,
|
||||
text_x,
|
||||
text_y,
|
||||
&clip_area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
label->detail->text,
|
||||
|
@ -364,16 +373,15 @@ render_buffer_pixbuf (NautilusBufferedWidget *buffered_widget,
|
|||
label->detail->drop_shadow_color,
|
||||
label->detail->text_alpha);
|
||||
|
||||
area.x0 -= label->detail->drop_shadow_offset;
|
||||
area.y0 -= label->detail->drop_shadow_offset;
|
||||
|
||||
area.x1 -= label->detail->drop_shadow_offset;
|
||||
area.y1 -= label->detail->drop_shadow_offset;
|
||||
text_x -= label->detail->drop_shadow_offset;
|
||||
text_y -= label->detail->drop_shadow_offset;
|
||||
}
|
||||
|
||||
nautilus_scalable_font_draw_text_lines (label->detail->font,
|
||||
buffer,
|
||||
&area,
|
||||
text_x,
|
||||
text_y,
|
||||
&clip_area,
|
||||
label->detail->font_size,
|
||||
label->detail->font_size,
|
||||
label->detail->text,
|
||||
|
|
|
@ -653,7 +653,9 @@ nautilus_scalable_font_measure_text (const NautilusScalableFont *font,
|
|||
void
|
||||
nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
|
@ -678,9 +680,7 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
|
||||
|
@ -690,6 +690,11 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
g_return_if_fail (text_length <= strlen (text));
|
||||
|
||||
if (clip_area != NULL) {
|
||||
g_return_if_fail (clip_area->x1 > clip_area->x0);
|
||||
g_return_if_fail (clip_area->y1 > clip_area->y0);
|
||||
}
|
||||
|
||||
art_affine_identity (affine);
|
||||
|
||||
glyph = rsvg_ft_render_string (global_rsvg_ft_context,
|
||||
|
@ -726,22 +731,27 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
|
||||
art_render_image_solid (art_render, art_color_array);
|
||||
|
||||
glyph_area.x0 = glyph_xy[0] + destination_area->x0;
|
||||
glyph_area.y0 = glyph_xy[1] + destination_area->y0;
|
||||
glyph_area.x0 = glyph_xy[0] + x;
|
||||
glyph_area.y0 = glyph_xy[1] + y;
|
||||
|
||||
glyph_area.x1 = glyph_area.x0 + glyph->width;
|
||||
glyph_area.y1 = glyph_area.y0 + glyph->height;
|
||||
|
||||
art_irect_union (&area, &glyph_area, destination_area);
|
||||
|
||||
if (clip_area != NULL) {
|
||||
art_irect_intersect (&area, &glyph_area, clip_area);
|
||||
}
|
||||
else {
|
||||
area = glyph_area;
|
||||
}
|
||||
|
||||
/* glyph_xy[0] += destination_point->x; */
|
||||
/* glyph_xy[1] += destination_point->y; */
|
||||
|
||||
art_render_mask (art_render,
|
||||
glyph_area.x0,
|
||||
glyph_area.y0,
|
||||
glyph_area.x1,
|
||||
glyph_area.y1,
|
||||
area.x0,
|
||||
area.y0,
|
||||
area.x1,
|
||||
area.y1,
|
||||
glyph->buf,
|
||||
glyph->rowstride);
|
||||
|
||||
|
@ -750,152 +760,8 @@ nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
|||
rsvg_ft_glyph_unref (glyph);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
guint num_text_lines,
|
||||
guint text_line_widths[],
|
||||
guint text_line_heights[],
|
||||
guint *max_width_out,
|
||||
guint *total_height_out)
|
||||
{
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
|
||||
if (max_width_out != NULL) {
|
||||
*max_width_out = 0;
|
||||
}
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
nautilus_scalable_font_measure_text (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
&text_line_widths[i],
|
||||
&text_line_heights[i]);
|
||||
|
||||
if (total_height_out != NULL) {
|
||||
*total_height_out += text_line_heights[i];
|
||||
}
|
||||
|
||||
if ((max_width_out != NULL) && (text_line_widths[i] > *max_width_out)) {
|
||||
*max_width_out = text_line_widths[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text_lines[],
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
GtkJustification justification,
|
||||
const guint num_text_lines,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
guchar overall_alpha)
|
||||
{
|
||||
guint i;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
guint available_width;
|
||||
guint available_height;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_lines != NULL);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (justification >= GTK_JUSTIFY_LEFT && justification <= GTK_JUSTIFY_FILL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
|
||||
x = destination_area->x0;
|
||||
y = destination_area->y0;
|
||||
|
||||
available_width = destination_area->x1 - destination_area->x0;
|
||||
available_height = destination_area->y1 - destination_area->y0;
|
||||
|
||||
for (i = 0; i < num_text_lines; i++) {
|
||||
ArtIRect area;
|
||||
|
||||
g_assert (text_lines[i] != NULL);
|
||||
|
||||
if (text_line_widths[i] == 0 && text_line_heights[i] == 0) {
|
||||
y += font_height;
|
||||
}
|
||||
else {
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
font_width,
|
||||
font_height,
|
||||
text_lines[i],
|
||||
strlen (text_lines[i]),
|
||||
color,
|
||||
overall_alpha);
|
||||
|
||||
y += (line_offset + text_line_heights[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void
|
||||
nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
|
@ -984,13 +850,15 @@ nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
|||
void
|
||||
nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
const guint *text_line_widths,
|
||||
const guint *text_line_heights,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
|
@ -999,30 +867,62 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
guint i;
|
||||
const char *line;
|
||||
|
||||
gint x;
|
||||
gint y;
|
||||
guint *temp_text_line_widths = NULL;
|
||||
guint *temp_text_line_heights = NULL;
|
||||
|
||||
guint available_width;
|
||||
guint available_height;
|
||||
|
||||
guint max_num_text_lines;
|
||||
|
||||
g_return_if_fail (NAUTILUS_IS_SCALABLE_FONT (font));
|
||||
g_return_if_fail (destination_pixbuf != NULL);
|
||||
g_return_if_fail (destination_area != NULL);
|
||||
g_return_if_fail (gdk_pixbuf_get_has_alpha (destination_pixbuf));
|
||||
g_return_if_fail (clip_area != NULL);
|
||||
g_return_if_fail (font_width > 0);
|
||||
g_return_if_fail (font_height > 0);
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
g_return_if_fail (justification >= GTK_JUSTIFY_LEFT && justification <= GTK_JUSTIFY_FILL);
|
||||
g_return_if_fail (destination_area->x1 > destination_area->x0);
|
||||
g_return_if_fail (destination_area->y1 > destination_area->y0);
|
||||
g_return_if_fail (clip_area->x1 > clip_area->x0);
|
||||
g_return_if_fail (clip_area->y1 > clip_area->y0);
|
||||
g_return_if_fail (num_text_lines > 0);
|
||||
g_return_if_fail (num_text_lines <= (nautilus_str_count_characters (text, '\n') + 1));
|
||||
|
||||
x = destination_area->x0;
|
||||
y = destination_area->y0;
|
||||
available_width = clip_area->x1 - clip_area->x0;
|
||||
available_height = clip_area->y1 - clip_area->y0;
|
||||
|
||||
available_width = destination_area->x1 - destination_area->x0;
|
||||
available_height = destination_area->y1 - destination_area->y0;
|
||||
if (text_line_widths) {
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
}
|
||||
|
||||
if (text_line_heights) {
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
}
|
||||
|
||||
max_num_text_lines = (available_height / font_height);
|
||||
|
||||
if (text_line_widths == NULL && text_line_heights == NULL) {
|
||||
temp_text_line_widths = g_new (guint, num_text_lines);
|
||||
temp_text_line_heights = g_new (guint, num_text_lines);
|
||||
|
||||
nautilus_scalable_font_measure_text_lines (font,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
num_text_lines,
|
||||
temp_text_line_widths,
|
||||
temp_text_line_heights,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
text_line_widths = temp_text_line_widths;
|
||||
text_line_heights = temp_text_line_heights;
|
||||
}
|
||||
|
||||
g_return_if_fail (text_line_widths != NULL);
|
||||
g_return_if_fail (text_line_heights != NULL);
|
||||
|
||||
// x = clip_area->x0;
|
||||
// y = clip_area->y0;
|
||||
|
||||
line = text;
|
||||
|
||||
|
@ -1051,38 +951,39 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
y += font_height;
|
||||
}
|
||||
else {
|
||||
ArtIRect area;
|
||||
|
||||
int text_x;
|
||||
int text_y;
|
||||
|
||||
switch (justification) {
|
||||
case GTK_JUSTIFY_LEFT:
|
||||
area.x0 = x;
|
||||
text_x = x;
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_CENTER:
|
||||
case GTK_JUSTIFY_FILL:
|
||||
if (text_line_widths[i] <= available_width) {
|
||||
area.x0 = x + ((available_width - text_line_widths[i]) / 2);
|
||||
text_x = x + ((available_width - text_line_widths[i]) / 2);
|
||||
}
|
||||
else {
|
||||
area.x0 = x - ((text_line_widths[i] - available_width) / 2);
|
||||
text_x = x - ((text_line_widths[i] - available_width) / 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case GTK_JUSTIFY_RIGHT:
|
||||
area.x0 = x + available_width - text_line_widths[i];
|
||||
text_x = x + available_width - text_line_widths[i];
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
area.x1 = area.x0 + text_line_widths[i];
|
||||
area.y0 = y;
|
||||
area.y1 = area.y0 + text_line_heights[i];
|
||||
text_y = y;
|
||||
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
destination_pixbuf,
|
||||
&area,
|
||||
text_x,
|
||||
text_y,
|
||||
clip_area,
|
||||
font_width,
|
||||
font_height,
|
||||
line,
|
||||
|
@ -1100,8 +1001,15 @@ nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
|||
line = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (temp_text_line_widths != NULL) {
|
||||
g_free (temp_text_line_widths);
|
||||
}
|
||||
|
||||
if (temp_text_line_heights != NULL) {
|
||||
g_free (temp_text_line_heights);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
guint
|
||||
nautilus_scalable_font_largest_fitting_font_size (const NautilusScalableFont *font,
|
||||
|
|
|
@ -86,14 +86,16 @@ void nautilus_scalable_font_measure_text (const N
|
|||
guint *text_height_out);
|
||||
void nautilus_scalable_font_draw_text (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint text_length,
|
||||
guint32 color,
|
||||
guchar overall_alpha);
|
||||
void nautilus_scalable_font_measure_text_lines (NautilusScalableFont *font,
|
||||
void nautilus_scalable_font_measure_text_lines (const NautilusScalableFont *font,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
|
@ -104,13 +106,15 @@ void nautilus_scalable_font_measure_text_lines (Nautilu
|
|||
guint *total_height_out);
|
||||
void nautilus_scalable_font_draw_text_lines (const NautilusScalableFont *font,
|
||||
GdkPixbuf *destination_pixbuf,
|
||||
const ArtIRect *destination_area,
|
||||
int x,
|
||||
int y,
|
||||
const ArtIRect *clip_area,
|
||||
guint font_width,
|
||||
guint font_height,
|
||||
const char *text,
|
||||
guint num_text_lines,
|
||||
const guint text_line_widths[],
|
||||
const guint text_line_heights[],
|
||||
const guint *text_line_widths,
|
||||
const guint *text_line_heights,
|
||||
GtkJustification justification,
|
||||
guint line_offset,
|
||||
guint32 color,
|
||||
|
|
|
@ -189,28 +189,16 @@ nautilus_about_repaint (GtkWidget *widget, GdkEventExpose *event, NautilusAbout
|
|||
static void
|
||||
draw_aa_string (NautilusScalableFont *font, GdkPixbuf *pixbuf, int font_size, int x_pos, int y_pos, uint color, uint shadow_color, const char* text, int shadow_offset)
|
||||
{
|
||||
ArtIRect dest_rect;
|
||||
int text_width, text_height;
|
||||
|
||||
nautilus_scalable_font_measure_text (font, font_size, font_size, text, strlen (text), &text_width, &text_height);
|
||||
|
||||
/* draw the title in shadowed text*/
|
||||
|
||||
dest_rect.x0 = x_pos;
|
||||
dest_rect.x1 = dest_rect.x0 + text_width;
|
||||
dest_rect.y0 = y_pos;
|
||||
dest_rect.y1 = dest_rect.y0 + text_height;
|
||||
|
||||
if (shadow_offset) {
|
||||
dest_rect.x0 += shadow_offset;
|
||||
dest_rect.y0 += shadow_offset;
|
||||
nautilus_scalable_font_draw_text (font, pixbuf, &dest_rect, font_size, font_size, text, strlen (text), shadow_color, 255);
|
||||
|
||||
dest_rect.x0 -= shadow_offset;
|
||||
dest_rect.y0 -= shadow_offset;
|
||||
nautilus_scalable_font_draw_text (font, pixbuf,
|
||||
x_pos + shadow_offset, y_pos + shadow_offset,
|
||||
NULL,
|
||||
font_size, font_size,
|
||||
text, strlen (text),
|
||||
shadow_color, 255);
|
||||
}
|
||||
|
||||
nautilus_scalable_font_draw_text (font, pixbuf, &dest_rect, font_size, font_size, text, strlen (text), color, 255);
|
||||
nautilus_scalable_font_draw_text (font, pixbuf, x_pos, y_pos, NULL, font_size, font_size, text, strlen (text), color, 255);
|
||||
}
|
||||
|
||||
/* draw the information onto the pixbuf */
|
||||
|
|
|
@ -484,7 +484,6 @@ draw_one_tab_plain (NautilusSidebarTabs *sidebar_tabs, GdkGC *gc,
|
|||
int total_width;
|
||||
GtkWidget *widget;
|
||||
GdkPixbuf *temp_pixbuf;
|
||||
ArtIRect text_rect;
|
||||
|
||||
g_assert (NAUTILUS_IS_SIDEBAR_TABS (sidebar_tabs));
|
||||
|
||||
|
@ -533,19 +532,16 @@ draw_one_tab_plain (NautilusSidebarTabs *sidebar_tabs, GdkGC *gc,
|
|||
temp_pixbuf = make_colored_pixbuf (name_width + 1, name_height + 1, prelight_flag ? &sidebar_tabs->details->prelight_color : &sidebar_tabs->details->tab_color);
|
||||
|
||||
/* draw the name into the pixbuf using anti-aliased text */
|
||||
text_rect.x0 = 1;
|
||||
text_rect.x1 = text_rect.x0 + name_width;
|
||||
text_rect.y0 = 1;
|
||||
text_rect.y1 = text_rect.y0 + name_height;
|
||||
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, temp_pixbuf, &text_rect,
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, temp_pixbuf,
|
||||
1, 1,
|
||||
NULL,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, strlen (tab_name),
|
||||
prelight_flag ? NAUTILUS_RGB_COLOR_WHITE : NAUTILUS_RGB_COLOR_BLACK, 255);
|
||||
|
||||
text_rect.x0 -= 1;
|
||||
text_rect.y0 -= 1;
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, temp_pixbuf, &text_rect,
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, temp_pixbuf,
|
||||
0, 0,
|
||||
NULL,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, strlen (tab_name),
|
||||
prelight_flag ? NAUTILUS_RGB_COLOR_BLACK : NAUTILUS_RGB_COLOR_WHITE, 255);
|
||||
|
@ -639,7 +635,8 @@ draw_one_tab_themed (NautilusSidebarTabs *sidebar_tabs, GdkPixbuf *tab_pixbuf,
|
|||
int current_pos, right_edge_pos;
|
||||
int text_x_pos, left_width;
|
||||
int highlight_offset;
|
||||
ArtIRect text_rect;
|
||||
int text_x;
|
||||
int text_y;
|
||||
|
||||
widget = GTK_WIDGET (sidebar_tabs);
|
||||
/* FIXME bugzilla.eazel.com 2504: can't prelight active state yet */
|
||||
|
@ -678,18 +675,21 @@ draw_one_tab_themed (NautilusSidebarTabs *sidebar_tabs, GdkPixbuf *tab_pixbuf,
|
|||
text_x_pos += text_h_offset;
|
||||
}
|
||||
|
||||
text_rect.x0 = text_x_pos + 1;
|
||||
text_rect.y0 = y - widget->allocation.y + (name_height >> 1);
|
||||
text_rect.x1 = text_x_pos + 1 + name_width;
|
||||
text_rect.y1 = y + sidebar_tabs->details->tab_height;
|
||||
text_x = text_x_pos + 1;
|
||||
text_y = y - widget->allocation.y + (name_height >> 1);
|
||||
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, tab_pixbuf, &text_rect,
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, tab_pixbuf,
|
||||
text_x, text_y,
|
||||
NULL,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, strlen (tab_name),
|
||||
NAUTILUS_RGB_COLOR_BLACK, 255);
|
||||
text_rect.x0 -= 1;
|
||||
text_rect.y0 -= 1;
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, tab_pixbuf, &text_rect,
|
||||
text_x -= 1;
|
||||
text_y -= 1;
|
||||
|
||||
nautilus_scalable_font_draw_text (sidebar_tabs->details->tab_font, tab_pixbuf,
|
||||
text_x, text_y,
|
||||
NULL,
|
||||
sidebar_tabs->details->font_size, sidebar_tabs->details->font_size,
|
||||
tab_name, strlen (tab_name),
|
||||
NAUTILUS_RGB_COLOR_WHITE, 255);
|
||||
|
|
|
@ -24,10 +24,8 @@ int
|
|||
main (int argc, char* argv[])
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
ArtIRect area;
|
||||
NautilusScalableFont *font;
|
||||
guint num_text_lines;
|
||||
char **text_lines;
|
||||
guint *text_line_widths;
|
||||
guint *text_line_heights;
|
||||
guint max_width_out;
|
||||
|
@ -40,6 +38,9 @@ main (int argc, char* argv[])
|
|||
const guint pixbuf_width = 500;
|
||||
const guint pixbuf_height = 700;
|
||||
|
||||
GdkRectangle blue_area;
|
||||
ArtIRect clip_area;
|
||||
|
||||
gtk_init (&argc, &argv);
|
||||
gdk_rgb_init ();
|
||||
|
||||
|
@ -48,20 +49,19 @@ main (int argc, char* argv[])
|
|||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf_width, pixbuf_height);
|
||||
g_assert (pixbuf != NULL);
|
||||
|
||||
area.x0 = 0;
|
||||
area.y0 = 0;
|
||||
|
||||
area.x1 = pixbuf_width;
|
||||
area.y1 = pixbuf_height;
|
||||
|
||||
blue_area.x = 20;
|
||||
blue_area.y = 20;
|
||||
blue_area.width = 100;
|
||||
blue_area.height = 400;
|
||||
|
||||
nautilus_gdk_pixbuf_fill_rectangle_with_color (pixbuf, &blue_area, NAUTILUS_RGBA_COLOR_PACK (0, 0, 255, 255));
|
||||
|
||||
num_text_lines = nautilus_str_count_characters (text, '\n') + 1;
|
||||
|
||||
text_lines = g_strsplit (text, "\n", -1);
|
||||
|
||||
text_line_widths = g_new (guint, num_text_lines);
|
||||
text_line_heights = g_new (guint, num_text_lines);
|
||||
|
||||
|
||||
nautilus_scalable_font_measure_text_lines (font,
|
||||
font_width,
|
||||
font_height,
|
||||
|
@ -74,9 +74,17 @@ main (int argc, char* argv[])
|
|||
|
||||
g_print ("max_width = %d, total_height = %d\n", max_width_out, total_height_out);
|
||||
|
||||
clip_area.x0 = blue_area.x;
|
||||
clip_area.y0 = blue_area.y;
|
||||
clip_area.x1 = blue_area.x + blue_area.width;
|
||||
clip_area.y1 = blue_area.y + blue_area.height;
|
||||
|
||||
#if 0
|
||||
nautilus_scalable_font_draw_text_lines (font,
|
||||
pixbuf,
|
||||
&area,
|
||||
0,
|
||||
0,
|
||||
&clip_area,
|
||||
font_width,
|
||||
font_height,
|
||||
text,
|
||||
|
@ -87,7 +95,20 @@ main (int argc, char* argv[])
|
|||
2,
|
||||
NAUTILUS_RGB_COLOR_RED,
|
||||
255);
|
||||
|
||||
#else
|
||||
nautilus_scalable_font_draw_text (font,
|
||||
pixbuf,
|
||||
10,
|
||||
30,
|
||||
&clip_area,
|
||||
font_width,
|
||||
font_height,
|
||||
"Something",
|
||||
strlen ("Something"),
|
||||
NAUTILUS_RGB_COLOR_RED,
|
||||
255);
|
||||
#endif
|
||||
|
||||
nautilus_gdk_pixbuf_save_to_file (pixbuf, "font_test.png");
|
||||
|
||||
g_print ("saving test png file to font_test.png\n");
|
||||
|
|
|
@ -753,7 +753,7 @@ main (int argc, char* argv[])
|
|||
main_box = gtk_vbox_new (FALSE, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), main_box);
|
||||
|
||||
label = nautilus_label_new ("Label that\n\ndoesn't\n\nsuck");
|
||||
label = nautilus_label_new ("Label that\n\ndoesn't\n\nsuck");
|
||||
|
||||
bottom_box = gtk_vbox_new (FALSE, 4);
|
||||
|
||||
|
|
Loading…
Reference in a new issue