summaryrefslogtreecommitdiff
path: root/src/gui/panels
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-04-05 08:56:45 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-04-05 08:56:45 (GMT)
commitfd679be33396b0ba85ba6617b33a66d221026d91 (patch)
tree4aae9544c1dcbcacd8077da0ff3bd553b55db422 /src/gui/panels
parentc9391d0a1d42a05c72fd1c909a00774561ac9f81 (diff)
Restored the panel for a glance at the current code view.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@503 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gui/panels')
-rw-r--r--src/gui/panels/glance.c142
1 files changed, 65 insertions, 77 deletions
diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c
index 0cb190a..306281a 100644
--- a/src/gui/panels/glance.c
+++ b/src/gui/panels/glance.c
@@ -44,13 +44,10 @@ struct _GGlancePanel
double scale; /* Ratio de réduction */
cairo_surface_t *cache; /* Cache grandeur nature */
+ GtkAllocation frame; /* Représentation du cadre */
GtkAllocation painting; /* Zone réservée pour l'aperçu */
GtkAllocation visible; /* Sous-partie visible */
- double red; /* Conversion Gdk -> Cairo #1 */
- double green; /* Conversion Gdk -> Cairo #2 */
- double blue; /* Conversion Gdk -> Cairo #3 */
-
gdouble start_x; /* Abscisse du point de souris */
gdouble start_y; /* Ordonnée du point de souris */
bool valid; /* Point de départ visible ? */
@@ -72,6 +69,9 @@ struct _GGlancePanelClass
};
+/* Espace entre le cadre et l'aperçu */
+#define GLANCE_BORDER 3
+
/* Initialise la classe des panneaux d'aperçu rapide. */
static void g_glance_panel_class_init(GGlancePanelClass *);
@@ -85,9 +85,6 @@ static void g_glance_panel_dispose(GGlancePanel *);
/* Procède à la libération totale de la mémoire. */
static void g_glance_panel_finalize(GGlancePanel *);
-/* Définit une fois et au bon moment le fond de l'aperçu rapide. */
-static void define_glance_bg(GtkWidget *, GGlancePanel *);
-
/* Lance une actualisation du fait d'un changement de support. */
static void update_glance_panel_for_view(GGlancePanel *, GtkViewPanel *);
@@ -183,7 +180,6 @@ static void g_glance_panel_init(GGlancePanel *panel)
base->name = _("Glance");
area = gtk_drawing_area_new();
- g_signal_connect(G_OBJECT(area), "realize", G_CALLBACK(define_glance_bg), panel);
gtk_widget_show(area);
base->widget = gtk_event_box_new();
@@ -274,32 +270,6 @@ GEditorItem *g_glance_panel_new(GObject *ref)
/******************************************************************************
* *
-* Paramètres : widget = composant GTK en préparation. *
-* panel = informations liées au panneau associé. *
-* *
-* Description : Définit une fois et au bon moment le fond de l'aperçu rapide.*
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void define_glance_bg(GtkWidget *widget, GGlancePanel *panel)
-{
- /*
- gtk_widget_modify_bg(widget, GTK_STATE_NORMAL,
- &widget->style->mid[GTK_STATE_NORMAL]);
-
- panel->red = widget->style->mid[GTK_STATE_NORMAL].red / USHRT_MAX;
- panel->green = widget->style->mid[GTK_STATE_NORMAL].green / USHRT_MAX;
- panel->blue = widget->style->mid[GTK_STATE_NORMAL].blue / USHRT_MAX;
- */
-}
-
-
-/******************************************************************************
-* *
* Paramètres : ref = espace de référencement global. *
* *
* Description : Construit et intègre un panneau d'affichage des symboles. *
@@ -362,8 +332,8 @@ static void update_glance_panel_for_view(GGlancePanel *panel, GtkViewPanel *view
* Pour le détail de la hiérarchie, se retourner vers les commentaires
* de la fonction mcb_view_change_support().
*/
+
parent = gtk_widget_get_parent(GTK_WIDGET(view));
- parent = gtk_widget_get_parent(parent);
if (!GTK_IS_SCROLLED_WINDOW(parent)) return;
panel->view = view;
@@ -492,56 +462,61 @@ static void on_glance_resize(GtkWidget *widget, GdkRectangle *allocation, GGlanc
static void compute_glance_scale(GGlancePanel *panel)
{
GtkAllocation available; /* Surface disponible totale */
- //gint border; /* Taille de la bordure */
+ GtkAllocation granted; /* Surface totale accordée */
double sx; /* Echelle sur l'axe X */
double sy; /* Echelle sur l'axe Y */
/* Superficies niveau GTK... */
gtk_widget_get_allocation(G_EDITOR_ITEM(panel)->widget, &available);
- /*
- border = MIN(2, G_EDITOR_ITEM(panel)->widget->style->xthickness);
- if (border > 0)
- {
- available.x = border;
- available.width -= 2 * border;
- }
- border = MIN(2, G_EDITOR_ITEM(panel)->widget->style->ythickness);
- if (border > 0)
- {
- available.y = border;
- available.height -= 2 * border;
- }
- */
/* Calcul des ratios et emplacements */
- sx = (1.0 * available.width) / panel->req.width;
- sy = (1.0 * available.height) / panel->req.height;
-
+ granted = available;
- printf(" -- avail :: (%d ; %d)\n", available.width, available.height);
+ if (available.width > 2 * GLANCE_BORDER)
+ granted.width = available.width - 2 * GLANCE_BORDER;
+ else
+ granted.width = 0;
- printf(" -- req :: (%d ; %d)\n", panel->req.width, panel->req.height);
+ if (available.height > 2 * GLANCE_BORDER)
+ granted.height = available.height - 2 * GLANCE_BORDER;
+ else
+ granted.height = 0;
- printf(" -- ratio >> (%g ; %g)\n", sx, sy);
+ sx = (1.0 * granted.width) / panel->req.width;
+ sy = (1.0 * granted.height) / panel->req.height;
+ /* Calcul des dimensions internes */
if (sx < sy)
{
panel->scale = sx;
- panel->painting.width = available.width;
- panel->painting.height = panel->req.height * panel->scale;
+ panel->frame.width = available.width;
+ panel->frame.height = panel->req.height * panel->scale;
}
else
{
panel->scale = sy;
- panel->painting.width = panel->req.width * panel->scale;
- panel->painting.height = available.height;
+ panel->frame.width = panel->req.width * panel->scale;
+ panel->frame.height = available.height;
}
- panel->painting.x = available.x + (available.width - panel->painting.width) / 2;
- panel->painting.y = available.y + (available.height - panel->painting.height) / 2;
+ panel->frame.x = (available.width - panel->frame.width) / 2;
+ panel->frame.y = (available.height - panel->frame.height) / 2;
+
+ panel->painting.x = panel->frame.x + GLANCE_BORDER;
+ panel->painting.y = panel->frame.y + GLANCE_BORDER;
+
+ if (panel->frame.width > 2 * GLANCE_BORDER)
+ panel->painting.width = panel->frame.width - 2 * GLANCE_BORDER;
+ else
+ panel->painting.width = 0;
+
+ if (panel->frame.height > 2 * GLANCE_BORDER)
+ panel->painting.height = panel->frame.height - 2 * GLANCE_BORDER;
+ else
+ panel->painting.height = 0;
}
@@ -656,6 +631,7 @@ static gboolean redraw_glance_area(GtkWidget *widget, cairo_t *cr, GGlancePanel
no_image = NULL;
/* Dessin de cette image */
+
if (no_image != NULL)
{
icon = gtk_icon_info_load_surface(no_image, window, NULL);
@@ -673,36 +649,48 @@ static gboolean redraw_glance_area(GtkWidget *widget, cairo_t *cr, GGlancePanel
/* Si on dispose de graphique à représenter... */
else
{
+ /* Dessin d'un fond */
- /* TODO ... */
+ gtk_style_context_save(context);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_VIEW);
+ gtk_render_background(context, cr,
+ panel->frame.x, panel->frame.y,
+ panel->frame.width, panel->frame.height);
-#if 0
+ gtk_style_context_restore(context);
- cairo = gdk_cairo_create(widget->window);
+ /* Dessin d'un cadre */
- cairo_rectangle(cairo, panel->visible.x, panel->visible.y,
- panel->visible.width, panel->visible.height);
+ gtk_style_context_save(context);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_FRAME);
- cairo_clip(cairo);
+ gtk_render_frame(context, cr,
+ panel->frame.x, panel->frame.y,
+ panel->frame.width, panel->frame.height);
- cairo_set_source_rgb(cairo, 1.0, 1.0, 1.0);
+ gtk_style_context_restore(context);
- cairo_rectangle(cairo, panel->painting.x, panel->painting.y,
- panel->painting.width, panel->painting.height);
+ /* Partie visible */
- cairo_fill(cairo);
+ cairo_rectangle(cr, panel->visible.x, panel->visible.y,
+ panel->visible.width, panel->visible.height);
- cairo_reset_clip(cairo);
+ cairo_clip(cr);
- cairo_set_source_surface(cairo, panel->cache, panel->painting.x, panel->painting.y);
- cairo_paint(cairo);
+ cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+
+ cairo_rectangle(cr, panel->painting.x, panel->painting.y,
+ panel->painting.width, panel->painting.height);
- cairo_destroy(cairo);
+ cairo_fill(cr);
-#endif
+ cairo_reset_clip(cr);
+ /* Aperçu mignature */
+ cairo_set_source_surface(cr, panel->cache, panel->painting.x, panel->painting.y);
+ cairo_paint(cr);
}