]> Dogcows Code - chaz/tint2/commitdiff
adjust tooltip position (mrovi)
authorThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 7 Aug 2010 12:17:56 +0000 (12:17 +0000)
committerThierry Lorthiois <lorthiois@bbsoft.fr>
Sat, 7 Aug 2010 12:17:56 +0000 (12:17 +0000)
src/panel.c
src/tint.c
src/tooltip/tooltip.c
src/tooltip/tooltip.h
src/util/area.c
src/util/area.h

index 662c6c5d1f5406e85ce4fafaf5d1efe7e9dc263a..5ca3afc764891222127a47ea33dae3f5fb9bc634 100644 (file)
@@ -303,6 +303,7 @@ void init_panel_size_and_position(Panel *panel)
 void resize_panel(void *obj)
 {
        Panel *panel = (Panel*)obj;
+//printf("resize_panel : taskbar\n");
 
        if (panel_horizontal) {
                int taskbar_width, modulo_width = 0;
index 67cb81ca20ddbd5eea0bee9f9c461b6391ad4eb1..6d65ea3f4628d3cd85743dcdfad8bbb2d41197bb 100644 (file)
@@ -845,7 +845,7 @@ start:
                                                Panel* panel = get_panel(e.xmotion.window);
                                                Area* area = click_area(panel, e.xmotion.x, e.xmotion.y);
                                                if (area->_get_tooltip_text)
-                                                       tooltip_trigger_show(area, panel, e.xmotion.x_root, e.xmotion.y_root);
+                                                       tooltip_trigger_show(area, panel, &e);
                                                else
                                                        tooltip_trigger_hide();
                                                break;
index a724473c397cf4b7cc5ecda5cb8a0c56f65110a9..eb880dd721107574544e8029ec4b487f673bd5b5 100644 (file)
@@ -75,10 +75,11 @@ void init_tooltip()
 }
 
 
-void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root)
+void tooltip_trigger_show(Area* area, Panel* p, XEvent *e)
 {
-       x = x_root;
-       y = y_root;
+       // Position the tooltip in the center of the area
+       x = area->posx + area->width / 2 + e->xmotion.x_root - e->xmotion.x;
+       y = area->posy + area->height / 2 + e->xmotion.y_root - e->xmotion.y;
        g_tooltip.panel = p;
        if (g_tooltip.mapped && g_tooltip.area != area) {
                tooltip_copy_text(area);
@@ -93,10 +94,10 @@ void tooltip_trigger_show(Area* area, Panel* p, int x_root, int y_root)
 
 void tooltip_show(void* arg)
 {
-  int mx, my;
-  Window w;
-  XTranslateCoordinates( server.dsp, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w);
-  Area* area = click_area(g_tooltip.panel, mx, my);
+       int mx, my;
+       Window w;
+       XTranslateCoordinates( server.dsp, server.root_win, g_tooltip.panel->main_win, x, y, &mx, &my, &w);
+       Area* area = click_area(g_tooltip.panel, mx, my);
        stop_tooltip_timeout();
        if (!g_tooltip.mapped && area->_get_tooltip_text) {
                tooltip_copy_text(area);
index fbf71b5794e17139ebe86afa1651329558f86a9d..d575773bac753ef8db25e82da3d544b42cf5c8ef 100644 (file)
@@ -50,7 +50,7 @@ void default_tooltip();
 void cleanup_tooltip();
 
 void init_tooltip();
-void tooltip_trigger_show(Area* area, Panel* p, int x, int y);
+void tooltip_trigger_show(Area* area, Panel* p, XEvent *e);
 void tooltip_show(void* /*arg*/);
 void tooltip_update();
 void tooltip_trigger_hide();
index 61bf4fcc0b59eecc1baa02ded5019b3a197c516f..498df86ee2234ed16b7a3bf69647b2d876051696 100644 (file)
 #include "panel.h"
 
 
-// 1) resize child
-// 2) resize parent
-// 3) redraw parent
-// 4) redraw child
+/*
+// TODO : layering & drawing loop
+1) browse tree and calculate 'size' for SIZE_BY_CONTENT
+       - SIZE_BY_CONTENT loop calculate child first
+       - if 'size' changed then 'resize = 1' on the parent (tester resize aprés la boucle)
+       - size == width on horizontal panel and == height on vertical panel
+2) browse tree and calculate 'size' for SIZE_BY_LAYOUT
+       - SIZE_BY_LAYOUT loop calculate parent first
+       - if 'size' changed then 'resize = 1' on childs with SIZE_BY_LAYOUT
+       - calculate width = size - somme(child_with_of_SIZE_BY_CONTENT) modulo(number of child_SIZE_BY_LAYOUT)
+       - calculate modulo = 
+3) calculate posx of all objects
+4) redraw needed objects
+*/
+
 void refresh (Area *a)
 {
        // don't draw and resize hide objects
@@ -137,9 +148,9 @@ void draw_background (Area *a, cairo_t *c)
                draw_rect(c, a->bg->border.width/2.0, a->bg->border.width/2.0, a->width - a->bg->border.width, a->height - a->bg->border.width, a->bg->border.rounded);
                /*
                // convert : radian = degre * M_PI/180
-               // définir le dégradé dans un carré de (0,0) (100,100)
-               // ensuite ce dégradé est extrapolé selon le ratio width/height
-               // dans repère (0, 0) (100, 100)
+               // dÃ\83©finir le dÃ\83©gradÃ\83© dans un carrÃ\83© de (0,0) (100,100)
+               // ensuite ce dÃ\83©gradÃ\83© est extrapolÃ\83© selon le ratio width/height
+               // dans repÃ\83¨re (0, 0) (100, 100)
                double X0, Y0, X1, Y1, degre;
                // x = X * (a->width / 100), y = Y * (a->height / 100)
                double x0, y0, x1, y1;
@@ -148,13 +159,13 @@ void draw_background (Area *a, cairo_t *c)
                X1 = 100;
                Y1 = 0;
                degre = 45;
-               // et ensuite faire la changement d'unité du repère
-               // car ce qui doit resté inchangée est les traits et pas la direction
+               // et ensuite faire la changement d'unitÃ\83© du repÃ\83¨re
+               // car ce qui doit restÃ\83© inchangÃ\83©e est les traits et pas la direction
 
-               // il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur à 180°)
-               // ceci peut Ãªtre appliqué une fois pour toute au départ
-               // ensuite calculer l'angle dans le nouveau repère
-               // puis faire une rotation de 90°
+               // il faut d'abord appliquer une rotation de 90° (et -180° si l'angle est supérieur Ã  180°)
+               // ceci peut Ã\83ªtre appliquÃ\83© une fois pour toute au dÃ\83©part
+               // ensuite calculer l'angle dans le nouveau repÃ\83¨re
+               // puis faire une rotation de 90°
                x0 = X0 * ((double)a->width / 100);
                x1 = X1 * ((double)a->width / 100);
                y0 = Y0 * ((double)a->height / 100);
index fc294f3ea7fdd69358f2a12d32da8637b7f536cf..be81b79cd88c783c4f8199c0f4e9daf0e6bd6ae9 100644 (file)
@@ -47,6 +47,10 @@ typedef struct
 } Background;
 
 
+// way to calculate the size
+// SIZE_BY_LAYOUT objects : taskbar and task
+// SIZE_BY_CONTENT objects : clock, battery, launcher, systray
+enum { SIZE_BY_LAYOUT, SIZE_BY_CONTENT };
 
 typedef struct {
        // coordinate relative to panel window
@@ -59,8 +63,11 @@ typedef struct {
        // list of child : Area object
        GSList *list;
 
+       // object visible on screen
        int on_screen;
-       // need compute position and width
+       // way to calculate the size (SIZE_BY_CONTENT or SIZE_BY_LAYOUT)
+       int size_mode;
+       // need to calculate position and width
        int resize;
        // need redraw Pixmap
        int redraw;
This page took 0.026791 seconds and 4 git commands to generate.