More GTK+ Popover work. I should probably make this a proper widget.
This commit is contained in:
parent
033587601b
commit
d52183c017
|
@ -1,5 +1,9 @@
|
||||||
// 10 october 2014
|
// 10 october 2014
|
||||||
// #qo pkg-config: gtk+-3.0
|
// #qo pkg-config: gtk+-3.0
|
||||||
|
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_32
|
||||||
|
#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_32
|
||||||
|
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_4
|
||||||
|
#define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_4
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
typedef gint LONG;
|
typedef gint LONG;
|
||||||
|
@ -119,10 +123,11 @@ void makePopoverPath(cairo_t *cr, LONG width, LONG height)
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// TODO bypass subpixel rendering
|
// TODO right and bottom edge
|
||||||
cairo_move_to(cr, pt[0].x, pt[0].y);
|
cairo_set_line_width(cr, 1);
|
||||||
|
cairo_move_to(cr, pt[0].x + 0.5, pt[0].y + 0.5);
|
||||||
for (i = 1; i < n; i++)
|
for (i = 1; i < n; i++)
|
||||||
cairo_line_to(cr, pt[i].x, pt[i].y);
|
cairo_line_to(cr, pt[i].x + 0.5, pt[i].y + 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPopoverFrame(GtkWidget *widget, cairo_t *cr, LONG width, LONG height, int forceAlpha)
|
void drawPopoverFrame(GtkWidget *widget, cairo_t *cr, LONG width, LONG height, int forceAlpha)
|
||||||
|
@ -133,6 +138,7 @@ void drawPopoverFrame(GtkWidget *widget, cairo_t *cr, LONG width, LONG height, i
|
||||||
// TODO see what GtkPopover itself does
|
// TODO see what GtkPopover itself does
|
||||||
// TODO drop shadow
|
// TODO drop shadow
|
||||||
context = gtk_widget_get_style_context(widget);
|
context = gtk_widget_get_style_context(widget);
|
||||||
|
gtk_style_context_add_class(widget, GTK_STYLE_CLASS_BACKGROUND);
|
||||||
gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL, &background);
|
gtk_style_context_get_background_color(context, GTK_STATE_FLAG_NORMAL, &background);
|
||||||
gtk_style_context_get_border_color(context, GTK_STATE_FLAG_NORMAL, &border);
|
gtk_style_context_get_border_color(context, GTK_STATE_FLAG_NORMAL, &border);
|
||||||
if (forceAlpha) {
|
if (forceAlpha) {
|
||||||
|
@ -185,8 +191,10 @@ int main(void)
|
||||||
gtk_window_set_decorated(GTK_WINDOW(w), FALSE);
|
gtk_window_set_decorated(GTK_WINDOW(w), FALSE);
|
||||||
gtk_widget_set_app_paintable(w, TRUE);
|
gtk_widget_set_app_paintable(w, TRUE);
|
||||||
g_signal_connect(w, "draw", G_CALLBACK(popoverDraw), NULL);
|
g_signal_connect(w, "draw", G_CALLBACK(popoverDraw), NULL);
|
||||||
|
gtk_widget_set_has_window(w, TRUE);
|
||||||
gtk_widget_realize(w);
|
gtk_widget_realize(w);
|
||||||
popoverSetSize(w, 200, 200);
|
popoverSetSize(w, 200, 200);
|
||||||
|
gtk_window_move(GTK_WINDOW(w), 50, 50);
|
||||||
gtk_widget_show_all(w);
|
gtk_widget_show_all(w);
|
||||||
gtk_main();
|
gtk_main();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue