📄 panel.c
字号:
return; gtk_widget_show(p->hbox); p->shown = TRUE; gkrellm_monitor_height_adjust(p->h); gkrellm_pack_side_frames(); }gbooleangkrellm_is_panel_visible(GkrellmPanel *p) { if (!p) return FALSE; return p->shown; }gbooleangkrellm_panel_enable_visibility(GkrellmPanel *p, gboolean new_vis, gboolean *current_vis) { gboolean changed = FALSE; if (new_vis && ! *current_vis) { gkrellm_panel_show(p); *current_vis = TRUE; changed = TRUE; } if (!new_vis && *current_vis) { gkrellm_panel_hide(p); *current_vis = FALSE; changed = TRUE; } return changed; } /* Called from rebuild. All panels must be cleaned out of things | that will be recreated in the create() routines. GKrellM <= 1.0.x | left it up to plugins to destroy decal/krell lists. Now this is | enforced, but grandfather out the plugins have not upgraded to using | the new gkrellm_panel_create() functions. */voidgkrellm_panel_cleanup(void) { GList *list, *list1; GkrellmPanel *p; for (list = panel_list; list; list = list->next) { p = (GkrellmPanel *) list->data; if (!p->keep_lists) { gkrellm_destroy_krell_list(p); gkrellm_destroy_decal_list(p); /* Also destroys buttons */ if (p->krell_list || p->decal_list || p->button_list) fprintf(stderr, "GKrellM: gkrellm_panel_cleanup krell=%p decal=%p button=%p\n", p->krell_list, p->decal_list, p->button_list); } else { for (list1 = p->decal_list; list1; list1 = list1->next) ((GkrellmDecal *) list1->data)->value = -1; for (list1 = p->krell_list; list1; list1 = list1->next) ((GkrellmKrell *) list1->data)->x_position = -1; } p->h = 0; p->h_configure = 0; p->style = NULL; } } /* Check text_list decals for overlap of other decals and set flag to force | drawing in the push function instead of the normal text pixmap layer */static voidpanel_decal_check_text_overlap(GkrellmDecal *d, GList *decal_list) { GList *list; GkrellmDecal *dcheck; if (!d || (d->state == DS_INVISIBLE)) return; for (list = decal_list; list; list = list->next) { dcheck = (GkrellmDecal *) list->data; if (dcheck->state == DS_INVISIBLE) continue; if ( d->x + d->w > dcheck->x && d->x < dcheck->x + dcheck->w && d->y + d->h > dcheck->y && d->y < dcheck->y + dcheck->h ) { /* text_list decals need push if overlapping any other decal. */ if (d->text_list) d->flags |= DF_TEXT_OVERLAPS; if (dcheck->text_list) dcheck->flags |= DF_TEXT_OVERLAPS; } } } /* Do the Pango text rendering. If called when pixmap is bg_text_layer, | it is a background draw. But if called from push_decal_pixmaps() it is | considered a push operation because it is being done whenever any panel | decals or krells are modified. In this case, Pango does the pixel pushing | instead of gkrellm as was done in pre 2.2.0. */static voidpanel_draw_decal_text_list(GdkPixmap *pixmap, GkrellmDecal *d) { PangoLayout *layout; GdkRectangle rect; GList *list; GkrellmText *tx; GkrellmTextstyle *ts; gchar *s; gint x, y; layout = gtk_widget_create_pango_layout(gkrellm_get_top_window(), NULL); rect.x = d->x; rect.y = d->y; rect.width = d->w; rect.height = d->h; gdk_gc_set_clip_rectangle(_GK.text_GC, &rect); for (list = d->text_list; list; list = list->next) { tx = (GkrellmText *) list->data; if (!*tx->text) continue; ts = &tx->text_style; pango_layout_set_font_description(layout, ts->font); x = tx->x_off; y = tx->y_off; if (d->flags & DF_SCROLL_TEXT_DIVERTED) { if (d->flags & DF_SCROLL_TEXT_CENTER) pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER); if (d->flags & DF_SCROLL_TEXT_H_LOOP) { x %= d->scroll_width; if (x > 0) x -= d->scroll_width; s = g_strconcat(tx->text, tx->text, NULL); if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, s, strlen(s)); else pango_layout_set_text(layout, s, strlen(s)); g_free(s); } else if (d->flags & DF_SCROLL_TEXT_V_LOOP) { y %= d->scroll_height + d->y_ink; if (y > 0) y -= d->scroll_height + d->y_ink; s = g_strconcat(tx->text, "\n", tx->text, NULL); if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, s, strlen(s)); else pango_layout_set_text(layout, s, strlen(s)); g_free(s); } else { if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, tx->text,strlen(tx->text)); else pango_layout_set_text(layout, tx->text, strlen(tx->text)); } } else { if (d->flags & DF_TEXT_USE_MARKUP) pango_layout_set_markup(layout, tx->text, strlen(tx->text)); else pango_layout_set_text(layout, tx->text, strlen(tx->text)); } x += d->x; y += d->y; if (ts->effect) { gdk_gc_set_foreground(_GK.text_GC, &ts->shadow_color); gdk_draw_layout_with_colors(pixmap, _GK.text_GC, x + 1, y + 1, layout, &ts->shadow_color, NULL); } gdk_gc_set_foreground(_GK.text_GC, &ts->color); gdk_draw_layout(pixmap, _GK.text_GC, x, y, layout); } gdk_gc_set_clip_rectangle(_GK.text_GC, NULL); g_object_unref(layout); } /* Draw text decals on a cache text layer to avoid high overhead Pango | drawing of them each time gkrellm_draw_panel_layers() is called. | May draw here if a text decal was found to not overlap any other decal | and if it's not flagged to be drawn on the top layer. | The text layer is then used as the background for push decal and krell | draws. */static voidpanel_draw_decal_text_layer(GkrellmPanel *p) { GList *list; GkrellmDecal *d; for (list = p->decal_list; list; list = list->next) { d = (GkrellmDecal *) list->data; if ( !d->modified || !d->text_list || (d->flags & DF_TOP_LAYER) || (d->flags & DF_TEXT_OVERLAPS) ) continue; if (d->state != DS_INVISIBLE) { if (d->flags & DF_MOVED) { gdk_draw_drawable(p->bg_text_layer_pixmap, _GK.draw1_GC, p->bg_pixmap, d->x_old, d->y_old, d->x_old, d->y_old, d->w, d->h); d->flags &= ~DF_MOVED; } else gdk_draw_drawable(p->bg_text_layer_pixmap, _GK.draw1_GC, p->bg_pixmap, d->x, d->y, d->x, d->y, d->w, d->h); panel_draw_decal_text_list(p->bg_text_layer_pixmap, d); } p->modified = TRUE; } } /* Push decal pixmaps through their stencils onto a Panel expose pixmap */static gbooleanpush_decal_pixmaps(GkrellmPanel *p, gboolean top_layer) { GList *list; GkrellmDecal *d; gint x, y, w, h; gboolean on_top, is_non_overlapping_text_decal; gboolean restore_gc = FALSE, do_top_layer = FALSE; if (!p) return FALSE; for (list = p->decal_list; list; list = list->next) { d = (GkrellmDecal *) list->data; on_top = (d->flags & DF_TOP_LAYER); is_non_overlapping_text_decal = (d->text_list && !(d->flags & DF_TEXT_OVERLAPS)); if (on_top && !top_layer) do_top_layer = TRUE; if ( d->state != DS_VISIBLE || (top_layer && !on_top) || (!top_layer && (on_top || is_non_overlapping_text_decal)) ) continue; if (d->text_list) panel_draw_decal_text_list(p->pixmap, d); else if (d->scroll_text) { x = d->x_off; y = d->y_off; gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap, -x, -y, d->x, d->y, d->w, d->h); if (d->flags & DF_SCROLL_TEXT_H_LOOP) { x %= d->scroll_width; if (x > 0) { gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap, d->scroll_width - x, -y, d->x, d->y, x, d->h); } else if ( x <= 0 && (w = d->scroll_width + x) < d->w ) { gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap, 0, -y, d->x + w, d->y, d->w - w, d->h); } } if (d->flags & DF_SCROLL_TEXT_V_LOOP) { y %= d->scroll_height + d->y_ink; if (y > 0) gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap, -x, d->scroll_height + d->y_ink - y, d->x, d->y, d->w, y); else if ( y <= 0 && (h = d->scroll_height + d->y_ink + y) < d->h ) gdk_draw_drawable(p->pixmap, _GK.draw1_GC, d->pixmap, -x, 0, d->x, d->y + h, d->w, d->h - h); } } else { gdk_gc_set_clip_mask(_GK.draw3_GC, d->stencil); gdk_gc_set_clip_origin(_GK.draw3_GC, d->x, d->y); gdk_draw_drawable(p->pixmap, _GK.draw3_GC, d->pixmap, 0, d->y_src, d->x, d->y, d->w, d->h); restore_gc = TRUE; } } if (restore_gc) { gdk_gc_set_clip_mask(_GK.draw3_GC, NULL); gdk_gc_set_clip_origin(_GK.draw3_GC, 0, 0); } return do_top_layer; } /* Push krell pixmaps through their stencils onto a Panel expose pixmap */static voidpush_krell_pixmaps(GkrellmPanel *p) { GList *list; GkrellmKrell *k; GkrellmDrawrec *dr; gboolean restore_clip_mask = FALSE, restore_clip_origin = FALSE; if (!p) return; for (list = p->krell_list; list; list = list->next) { k = (GkrellmKrell *) list->data; gdk_gc_set_clip_mask(_GK.text_GC, k->stencil); if (k->y0 != 0 || restore_clip_origin) { gdk_gc_set_clip_origin(_GK.text_GC, 0, k->y0); restore_clip_origin = TRUE; } dr = &k->draw; gdk_draw_drawable(p->pixmap, _GK.text_GC, k->pixmap, dr->x_src, dr->y_src, dr->x_dst, dr->y_dst, dr->w, dr->h); restore_clip_mask = TRUE; } if (restore_clip_mask) gdk_gc_set_clip_mask(_GK.text_GC, NULL); if (restore_clip_origin) gdk_gc_set_clip_origin(_GK.text_GC, 0, 0); }voidgkrellm_draw_panel_layers(GkrellmPanel *p) { GList *list; GkrellmKrell *k; GkrellmDecal *d; gboolean do_top_layer_decals; if (!p || !p->drawing_area) return; if (p->need_decal_overlap_check) { gdk_draw_drawable(p->bg_text_layer_pixmap, _GK.draw1_GC, p->bg_pixmap, 0, 0, 0, 0, p->w, p->h); for (list = p->decal_list; list; list = list->next) { d = (GkrellmDecal *) list->data; if (!(d->flags & DF_SCROLL_TEXT_DIVERTED)) d->flags &= ~DF_TEXT_OVERLAPS; d->modified = TRUE; } for (list = p->decal_list; list; list = list->next) { d = (GkrellmDecal *) list->data; panel_decal_check_text_overlap(d, list->next); } } p->need_decal_overlap_check = FALSE; panel_draw_decal_text_layer(p); for (list = p->decal_list; list; list = list->next) { d = (GkrellmDecal *) list->data; if (d->modified) { d->modified = FALSE; p->modified = TRUE; } } for (list = p->krell_list; list; list = list->next) { k = (GkrellmKrell *) list->data; if (k->modified) { k->modified = FALSE; p->modified = TRUE; } } /* For each layer, push new layer image onto the expose pixmap. */ if (p->modified) { gdk_draw_drawable(p->pixmap, _GK.draw1_GC, p->bg_text_layer_pixmap, 0, 0, 0, 0, p->w, p->h); do_top_layer_decals = push_decal_pixmaps(p, FALSE); if (p->label_on_top_of_decals) draw_panel_label(p, FALSE); push_krell_pixmaps(p); if (do_top_layer_decals) push_decal_pixmaps(p, TRUE); if (p->drawing_area->window) gdk_draw_drawable(p->drawing_area->window, _GK.draw1_GC, p->pixmap, 0, 0, 0, 0, p->w, p->h); } p->modified = FALSE; }voidgkrellm_draw_panel_layers_force(GkrellmPanel *p) { GList *list; if (!p) return; for (list = p->decal_list; list; list = list->next) ((GkrellmDecal *) list->data)->modified = TRUE; for (list = p->krell_list; list; list = list->next) ((GkrellmKrell *) list->data)->modified = TRUE; gkrellm_draw_panel_layers(p); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -