Scale the dial knobs according to the default font size to achieve
authorAlexander Koenig <alex@lisas.de>
Mon, 9 May 2016 21:36:23 +0000 (23:36 +0200)
committerAlexander Koenig <alex@lisas.de>
Mon, 9 May 2016 21:36:23 +0000 (23:36 +0200)
reasonable sizes on high resolution displays.

src/tX_dial.c
src/tX_knobloader.c
src/tX_knobloader.h
src/tX_mastergui.cc

index 18af14cec8ccaf428925aa420f736cf065f8655f..50aeca7b009a118c720767f9ed516a490122bd68 100644 (file)
@@ -226,10 +226,10 @@ static void gtk_tx_dial_realize (GtkWidget *widget)
 }
 
 static void gtk_tx_dial_get_preferred_width (GtkWidget *widget, gint *minimal_width, gint *natural_width) {
-       *minimal_width = *natural_width = KNOB_SIZE;
+       *minimal_width = *natural_width = tX_knob_size;
 }
 static void gtk_tx_dial_get_preferred_height (GtkWidget *widget, gint *minimal_height, gint *natural_height) {
-       *minimal_height = *natural_height = KNOB_SIZE;
+       *minimal_height = *natural_height = tX_knob_size;
 }
 
 static void gtk_tx_dial_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
@@ -248,8 +248,8 @@ static void gtk_tx_dial_size_allocate (GtkWidget *widget, GtkAllocation *allocat
                                  allocation->x, allocation->y,
                                  allocation->width, allocation->height);
                
-               tx_dial->xofs=(allocation->width-KNOB_SIZE)/2;
-               tx_dial->yofs=(allocation->height-KNOB_SIZE)/2;
+               tx_dial->xofs=(allocation->width-tX_knob_size)/2;
+               tx_dial->yofs=(allocation->height-tX_knob_size)/2;
        }
 }
 
@@ -261,7 +261,7 @@ inline void gtk_tx_dial_do_draw (GtkTxDial *tx_dial, GtkWidget *widget, cairo_t
 //                             NULL, //TODO: this needs to be ported to cairo!
 //                             knob_pixmaps[tx_dial->old_image],
 //                             0, 0, tx_dial->xofs, tx_dial->yofs,
-//                                             KNOB_SIZE, KNOB_SIZE, GDK_RGB_DITHER_NORMAL, 0, 0);
+//                                             tX_knob_size, tX_knob_size, GDK_RGB_DITHER_NORMAL, 0, 0);
 
                gdk_cairo_set_source_pixbuf (cr, knob_pixmaps[tx_dial->old_image], 0, 0);
                cairo_paint (cr);
index f4ec2c4c8f26456b476305adc19a273c2e12c1f6..e7cdfbe643180bfd46887cfcf66a562ecccb241c 100644 (file)
 
 #include <gtk/gtk.h>
 #include "tX_knobloader.h"
+#include "tX_global.h"
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #ifdef USE_DIAL
+int tX_knob_size;
 
 const guint8 * knob_pixs[MAX_KNOB_PIX]={
         knob0,
@@ -81,13 +83,18 @@ const guint8 * knob_pixs[MAX_KNOB_PIX]={
 
 GdkPixbuf *knob_pixmaps[MAX_KNOB_PIX];
 
-void load_knob_pixs()
+void load_knob_pixs(int fontHeight, int scaleFactor)
 {
        int i;
        GError *error;
+       tX_knob_size = fontHeight * 3 * scaleFactor;
+       tX_debug("load_knob_pix(): knob size is %i", tX_knob_size);
        
        for (i=0; i<MAX_KNOB_PIX; i++) {
-               knob_pixmaps[i]=gdk_pixbuf_new_from_inline(-1, knob_pixs[i], TRUE, &error);
+               GdkPixbuf *tmpPixbuf=gdk_pixbuf_new_from_inline(-1, knob_pixs[i], TRUE, &error);
+               GdkPixbuf *scaledPixbuf=NULL;
+               scaledPixbuf = gdk_pixbuf_scale_simple(tmpPixbuf, tX_knob_size, tX_knob_size, GDK_INTERP_HYPER);
+               knob_pixmaps[i]=scaledPixbuf;
        }
 }
 
index c26d4ff1d074b7b236fec924cc56561ae8e1d729..2dffb823cd3c5a87ec333fd2f94ae1e680d06e2a 100644 (file)
@@ -40,15 +40,11 @@ extern "C" {
 #define MAX_KNOB_PIX 50
 #define TX_MAX_KNOB_PIX 49
 
-#ifdef USE_BIG_BUTTONS
-#define KNOB_SIZE 51
-#else
-#define KNOB_SIZE 42
-#endif
+extern int tX_knob_size;
 
 extern GdkPixbuf *knob_pixmaps[MAX_KNOB_PIX];
        
-extern void load_knob_pixs();
+extern void load_knob_pixs(int fontHeight, int scaleFactor);
 
 #ifdef __cplusplus
 }
index d24ebfabe54b5da1beb616e99c65541829da8cef..ba8604e6017f2bd5fd386469ba222d35a39a8845 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
+#include <pango/pango.h>
 #include <X11/Xlib.h>
 #include <math.h>
 #include <unistd.h>
@@ -64,6 +65,7 @@
 
 int audioon=0;
 int sequencer_ready=1;
+int fontHeight=16;
 
 bool tX_shutdown=false;
 tx_mouse mouse;
@@ -1398,6 +1400,12 @@ void create_mastergui(int x, int y)
        gtk_widget_show(dummy);
 
        dummy=gtk_label_new("Pos:");
+       PangoRectangle ink_rect;
+       PangoRectangle logical_rect;
+       pango_layout_get_pixel_extents(gtk_label_get_layout(GTK_LABEL(dummy)), &ink_rect, &logical_rect);
+       tX_debug("ink extent: x: %i, y: %i, width: %i, height %i ",  ink_rect.x, ink_rect.y, ink_rect.width, ink_rect.height);
+       tX_debug("logical extent: x: %i, y: %i, width: %i, height %i ",  logical_rect.x, logical_rect.y, logical_rect.width, logical_rect.height);
+       fontHeight = logical_rect.height - logical_rect.y;
        gtk_box_pack_start(GTK_BOX(control_box), dummy, WID_FIX);
        gtk_widget_show(dummy);
        
@@ -1679,7 +1687,7 @@ void display_mastergui()
        GtkWidget *top;
        gtk_widget_realize(main_window);
        tX_set_icon(main_window);
-       load_knob_pixs();
+       load_knob_pixs(fontHeight, gdk_window_get_scale_factor(gtk_widget_get_window(GTK_WIDGET(main_window))));
        gtk_widget_show(main_window);
        fullscreen_setup();     
        top=gtk_widget_get_toplevel(main_window);