added arlo's zoom control and adjusted the zoom control class to work

added arlo's zoom control and adjusted the zoom control class
	to work properly with a wider range of images.  also added
	a zoom control from Bud to experiment with in the vector theme
This commit is contained in:
Andy Hertzfeld 2000-07-26 05:59:32 +00:00
parent 0b353c1e19
commit 057928a1bf
10 changed files with 93 additions and 11 deletions

View file

@ -1,3 +1,29 @@
2000-07-25 Andy Hertzfeld <andy@eazel.com>
* src/nautilus-zoom-control.c:
(nautilus_zoom_control_class_initialize),
(nautilus_zoom_control_theme_changed), (get_zoom_offset),
(draw_number), (draw_zoom_control_image),
(nautilus_zoom_control_update_offsets),
(nautilus_zoom_control_load_images),
(nautilus_zoom_control_button_press_event),
(nautilus_zoom_control_size_allocate):
made the zoom control work properly with different sets of
images by vertically centering the images and adding a
number offset fetched from the theme.
* icons/arlo/Makefile.am:
* icons/arlo/arlo.xml:
* icons/increment.png:
* icons/decrement.png:
* icons/zoom_body.png:
zoom control pieces for arlo theme
* icons/vector/Makefile.am:
* icons/vector/vector.xml:
* icons/zoom_body.png:
zoom control body from Bud to try out
2000-07-25 Eskil Heyn Olsen <eskil@eazel.com>
* components/services/docs/install-user-settings:

View file

@ -2,9 +2,12 @@ arlodir = $(datadir)/pixmaps/nautilus/arlo
arlo_DATA = \
arlo.xml \
decrement.png \
i-directory.png \
i-regular.png \
increment.png \
sidebar_tab_pieces.png \
theme_preview.png
theme_preview.png \
zoom_body.png
EXTRA_DIST = $(arlo_DATA)

View file

@ -4,5 +4,6 @@
<sidebar SIDEBAR_BACKGROUND_COLOR="rgb:6666/9999/9999-rgb:0000/3333/3333|90-rgb:0000/0000/0000:h" SIDEBAR_BACKGROUND_TILE_IMAGE="backgrounds/.striated.png" TAB_PIECE_IMAGE="sidebar_tab_pieces.png" COMBINE="TRUE"
PIECE_OFFSETS="1,1,20,4:1,13,20,13:1,47,20,61:1,123,20,139:1,212,20,220:1,5,20,8:1,14,20,14:1,62,20,76:1,16,20,30:1,221,20,229:1,9,20,12:1,15,24,15:1,93,24,107:1,157,20,173:1,194,20,194"
LEFT_OFFSET="0" LABEL_COLOR="rgb:FFFF/FFFF/FFFF" TAB_FONT="-*-helvetica-medium-i-normal-*-12-*-*-*-*-*-*-*" />
<zoom_control NUMBER_V_OFFSET="-4"/>
</theme>

BIN
icons/arlo/decrement.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

BIN
icons/arlo/increment.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

BIN
icons/arlo/zoom_body.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

View file

@ -5,6 +5,8 @@ vector_DATA = \
i-directory-accept.svg \
i-regular.svg \
i-regular.xml \
vector.xml
vector.xml \
zoom_body.png
EXTRA_DIST = $(vector_DATA)

View file

@ -3,4 +3,5 @@
<sidebar SIDEBAR_BACKGROUND_TILE_IMAGE="backgrounds/blue_sky.png"/>
<directory BACKGROUND_COLOR="rgb:FFFF/FFFF/3333-rgb:FFFF/9999/3333:h"/>
<toolbar ICON_THEME="eazel"/>
</theme>
<zoom_control NUMBER_V_OFFSET="-4" NUMBER_H_OFFSET="4"/>
</theme>

BIN
icons/vector/zoom_body.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

View file

@ -61,6 +61,7 @@ struct NautilusZoomControlDetails {
double max_zoom_level;
GList *preferred_zoom_levels;
int y_offset;
GdkPixbuf *zoom_body_image;
GdkPixbuf *zoom_decrement_image;
GdkPixbuf *zoom_increment_image;
@ -80,6 +81,8 @@ static gboolean nautilus_zoom_control_button_press_event (GtkWidget *widget,
static void nautilus_zoom_control_load_images (NautilusZoomControl *zoom_control);
static void nautilus_zoom_control_unload_images (NautilusZoomControl *zoom_control);
static void nautilus_zoom_control_theme_changed (gpointer user_data);
static void nautilus_zoom_control_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
void draw_number (GtkWidget *widget,
GdkRectangle *box);
@ -128,7 +131,8 @@ nautilus_zoom_control_class_initialize (NautilusZoomControlClass *class)
widget_class->draw = nautilus_zoom_control_draw;
widget_class->expose_event = nautilus_zoom_control_expose;
widget_class->button_press_event = nautilus_zoom_control_button_press_event;
widget_class->size_allocate = nautilus_zoom_control_size_allocate;
signals[ZOOM_IN] =
gtk_signal_new ("zoom_in",
GTK_RUN_LAST,
@ -242,8 +246,26 @@ nautilus_zoom_control_theme_changed (gpointer user_data)
NautilusZoomControl *zoom_control;
zoom_control = NAUTILUS_ZOOM_CONTROL (user_data);
gtk_widget_hide (GTK_WIDGET (zoom_control));
nautilus_zoom_control_load_images (zoom_control);
gtk_widget_queue_draw (GTK_WIDGET (zoom_control)) ;
gtk_widget_show (GTK_WIDGET (zoom_control));
}
static int
get_zoom_offset (const char *property)
{
char *num_str;
int result;
result = 0;
num_str = nautilus_theme_get_theme_data ("zoom_control", property);
if (num_str) {
result = atoi (num_str);
g_free (num_str);
}
return result;
}
/* draw the current zoom percentage */
@ -253,7 +275,13 @@ void draw_number (GtkWidget *widget, GdkRectangle *box)
GdkFont *label_font;
GdkGC* temp_gc;
int x, y, percent;
NautilusZoomControl *zoom_control = NAUTILUS_ZOOM_CONTROL (widget);
int num_v_offset, num_h_offset;
NautilusZoomControl *zoom_control;
zoom_control = NAUTILUS_ZOOM_CONTROL (widget);
num_v_offset = get_zoom_offset ("NUMBER_V_OFFSET");
num_h_offset = get_zoom_offset ("NUMBER_H_OFFSET");
label_font = gdk_font_load("-bitstream-courier-medium-r-normal-*-9-*-*-*-*-*-*-*");
temp_gc = gdk_gc_new(widget->window);
@ -261,8 +289,8 @@ void draw_number (GtkWidget *widget, GdkRectangle *box)
percent = floor((100.0 * zoom_control->details->zoom_level) + .5);
g_snprintf(buffer, 8, "%d", percent);
x = (box->width - gdk_string_width(label_font, buffer)) >> 1;
y = (box->height >> 1) + 1;
x = num_h_offset + ((box->width - gdk_string_width(label_font, buffer)) >> 1);
y = zoom_control->details->y_offset + 1 + num_v_offset + (box->height >> 1);
gdk_draw_string (widget->window, label_font, temp_gc, x, y, &buffer[0]);
gdk_font_unref(label_font);
@ -293,17 +321,17 @@ draw_zoom_control_image (GtkWidget *widget, GdkRectangle *box)
/* draw the decrement symbol if necessary */
if (zoom_control->details->zoom_level > zoom_control->details->min_zoom_level) {
draw_pixbuf (zoom_control->details->zoom_decrement_image, widget->window, box->x, box->y);
draw_pixbuf (zoom_control->details->zoom_decrement_image, widget->window, box->x, box->y + zoom_control->details->y_offset);
}
offset = gdk_pixbuf_get_width (zoom_control->details->zoom_decrement_image) + GAP_WIDTH;
/* draw the body image */
draw_pixbuf (zoom_control->details->zoom_body_image, widget->window, box->x + offset, box->y);
draw_pixbuf (zoom_control->details->zoom_body_image, widget->window, box->x + offset, box->y + zoom_control->details->y_offset);
offset += gdk_pixbuf_get_width (zoom_control->details->zoom_body_image) + GAP_WIDTH;
/* draw the increment symbol if necessary */
if (zoom_control->details->zoom_level < zoom_control->details->max_zoom_level) {
draw_pixbuf (zoom_control->details->zoom_increment_image, widget->window, box->x + offset, box->y);
draw_pixbuf (zoom_control->details->zoom_increment_image, widget->window, box->x + offset, box->y + zoom_control->details->y_offset);
}
}
@ -374,6 +402,12 @@ load_themed_image (const char *file_name)
return NULL;
}
static void
nautilus_zoom_control_update_offsets (NautilusZoomControl *zoom_control)
{
zoom_control->details->y_offset = (GTK_WIDGET (zoom_control)->allocation.height - gdk_pixbuf_get_height (zoom_control->details->zoom_body_image)) >> 1;
}
static void
nautilus_zoom_control_load_images (NautilusZoomControl *zoom_control)
{
@ -382,6 +416,8 @@ nautilus_zoom_control_load_images (NautilusZoomControl *zoom_control)
zoom_control->details->zoom_body_image = load_themed_image ("zoom_body.png");
zoom_control->details->zoom_decrement_image = load_themed_image ("decrement.png");
zoom_control->details->zoom_increment_image = load_themed_image ("increment.png");
nautilus_zoom_control_update_offsets (zoom_control);
}
/* routines to create and handle the zoom menu */
@ -483,6 +519,19 @@ nautilus_zoom_control_button_press_event (GtkWidget *widget, GdkEventButton *eve
return TRUE;
}
/* handle setting the size */
static void
nautilus_zoom_control_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
NautilusZoomControl *zoom_control = NAUTILUS_ZOOM_CONTROL (widget);
NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
widget->allocation.width = get_zoom_width (zoom_control);
widget->allocation.height = allocation->height;
nautilus_zoom_control_update_offsets (zoom_control);
}
void
nautilus_zoom_control_set_zoom_level (NautilusZoomControl *zoom_control, double zoom_level)
{