mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-28 06:49:41 +03:00
Redraw favicon when it has been changed.
Improve the window icon / favicon interface.
This commit is contained in:
parent
221cd56826
commit
fa7048d66d
@ -306,6 +306,59 @@ bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t,
|
||||
}
|
||||
assert( gw->root != NULL );
|
||||
return( ( element == gw->root->focus.element && t == gw->root->focus.type) );
|
||||
}
|
||||
|
||||
void window_set_icon(struct gui_window *gw, struct bitmap * bmp )
|
||||
{
|
||||
gw->icon = bmp;
|
||||
/* redraw window when it is iconyfied: */
|
||||
if (gw->icon != NULL) {
|
||||
short info, dummy;
|
||||
WindGet(gw->root->handle, WF_ICONIFY, &info, &dummy, &dummy, &dummy);
|
||||
if (info == 1) {
|
||||
window_redraw_favicon(gw, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redraw the favicon
|
||||
*/
|
||||
void window_redraw_favicon(struct gui_window *gw, GRECT *clip)
|
||||
{
|
||||
GRECT work;
|
||||
|
||||
assert(gw->root);
|
||||
|
||||
WINDOW * bw = gw->root->handle;
|
||||
|
||||
WindClear(bw);
|
||||
WindGet(bw, WF_WORKXYWH, &work.g_x, &work.g_y, &work.g_w, &work.g_h);
|
||||
if (clip == NULL) {
|
||||
clip = &work;
|
||||
}
|
||||
|
||||
if (gw->icon == NULL) {
|
||||
OBJECT * tree;
|
||||
RsrcGaddr( h_gem_rsrc, R_TREE, ICONIFY , &tree);
|
||||
tree->ob_x = work.g_x;
|
||||
tree->ob_y = work.g_y;
|
||||
tree->ob_width = work.g_w;
|
||||
tree->ob_height = work.g_h;
|
||||
objc_draw(tree, 0, 8, clip->g_x, clip->g_y, clip->g_w, clip->g_h);
|
||||
} else {
|
||||
// TODO: consider the clipping rectangle
|
||||
struct rect work_clip = { 0,0,work.g_w,work.g_h };
|
||||
int xoff=0;
|
||||
if (work.g_w > work.g_h) {
|
||||
xoff = ((work.g_w-work.g_h)/2);
|
||||
work.g_w = work.g_h;
|
||||
}
|
||||
plot_set_dimensions( work.g_x+xoff, work.g_y, work.g_w, work.g_h);
|
||||
plot_clip(&work_clip);
|
||||
atari_plotters.bitmap(0, 0, work.g_w, work.g_h, gw->icon, 0xffffff, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -483,35 +536,12 @@ static void __CDECL evnt_window_iconify( WINDOW *win, short buff[8], void * data
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redraw the favicon
|
||||
*/
|
||||
static void __CDECL evnt_window_icondraw( WINDOW *win, short buff[8], void * data )
|
||||
{
|
||||
short x,y,w,h;
|
||||
struct gui_window * gw = (struct gui_window*)data;
|
||||
|
||||
WindClear( win);
|
||||
WindGet( win, WF_WORKXYWH, &x, &y, &w, &h);
|
||||
if( gw->icon == NULL ) {
|
||||
OBJECT * tree;
|
||||
RsrcGaddr( h_gem_rsrc, R_TREE, ICONIFY , &tree );
|
||||
tree->ob_x = x;
|
||||
tree->ob_y = y;
|
||||
tree->ob_width = w;
|
||||
tree->ob_height = h;
|
||||
mt_objc_draw( tree, 0, 8, buff[4], buff[5], buff[6], buff[7], app.aes_global );
|
||||
} else {
|
||||
struct rect clip = { 0,0,w,h };
|
||||
int xoff=0;
|
||||
if (w > h) {
|
||||
xoff = ((w-h)/2);
|
||||
w = h;
|
||||
}
|
||||
plot_set_dimensions( x+xoff,y,w,h );
|
||||
plot_clip(&clip);
|
||||
atari_plotters.bitmap(0, 0, w, h, gw->icon, 0xffffff, 0);
|
||||
}
|
||||
static void __CDECL evnt_window_icondraw(WINDOW *win, short buff[8], void * data)
|
||||
{
|
||||
struct gui_window *gw = (struct gui_window*) data;
|
||||
GRECT clip = {buff[4], buff[5], buff[6], buff[7]};
|
||||
window_redraw_favicon(gw, &clip);
|
||||
}
|
||||
|
||||
/* perform the actual resize */
|
||||
|
@ -59,7 +59,8 @@ bool window_widget_has_focus( struct gui_window * gw, enum focus_element_type t,
|
||||
bool window_url_widget_has_focus( struct gui_window * gw );
|
||||
void window_set_url( struct gui_window * gw, const char * text);
|
||||
void window_set_stauts( struct gui_window * gw , char * text );
|
||||
void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
|
||||
void window_set_icon(struct gui_window * gw, struct bitmap * bmp );
|
||||
void window_redraw_favicon(struct gui_window *gw, GRECT *clip);
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -553,8 +553,12 @@ gui_window_remove_caret(struct gui_window *w)
|
||||
|
||||
void
|
||||
gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
|
||||
{
|
||||
g->icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
|
||||
{
|
||||
struct bitmap *bmp_icon;
|
||||
|
||||
bmp_icon = (icon != NULL) ? content_get_bitmap(icon) : NULL;
|
||||
|
||||
window_set_icon(g, bmp_icon);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user