Use font shadows for all elements except tooltips

git-svn-id: http://tint2.googlecode.com/svn/trunk@766 121b4492-b84c-0410-8b4c-0d4edfb3f3cc
This commit is contained in:
o9000 2015-04-18 13:22:07 +00:00 committed by mrovi9000@gmail.com
parent 6ba25fa945
commit b4f15db397
10 changed files with 37 additions and 32 deletions

View file

@ -36,13 +36,14 @@ border_color = #999999 100
panel_items = LTSBC
panel_monitor = all
panel_position = bottom center horizontal
panel_size = 95% 30
panel_size = 85% 30
panel_margin = 0 0
panel_padding = 7 0 7
panel_dock = 0
wm_menu = 1
panel_layer = top
panel_background_id = 1
font_shadow = 0
# Panel Autohide
autohide = 0
@ -92,7 +93,6 @@ task_font_color = #FFFFFF 90
task_active_font_color = #FFFFFF 90
task_urgent_font_color = #FFFFFF 90
task_iconified_font_color = #FFFFFF 90
font_shadow = 0
# Mouse
mouse_left = toggle_iconify
@ -129,7 +129,7 @@ tooltip_font_color = #222222 100
# Battery
battery_low_status = 10
battery_low_cmd = notify-send "battery low"
battery_hide = 98
battery_hide = 101
bat1_font = sans 8
bat2_font = sans 6
battery_font_color = #FFFFFF 94

View file

@ -499,8 +499,7 @@ void draw_battery (void *obj, cairo_t *c)
cairo_set_source_rgba(c, battery->font.color[0], battery->font.color[1], battery->font.color[2], battery->font.alpha);
pango_cairo_update_layout(c, layout);
cairo_move_to(c, 0, battery->bat1_posy);
pango_cairo_show_layout(c, layout);
draw_text(layout, c, 0, battery->bat1_posy, &battery->font, ((Panel*)battery->area.panel)->font_shadow);
pango_layout_set_font_description(layout, bat2_font_desc);
pango_layout_set_indent(layout, 0);
@ -508,7 +507,7 @@ void draw_battery (void *obj, cairo_t *c)
pango_layout_set_width(layout, battery->area.width * PANGO_SCALE);
pango_cairo_update_layout(c, layout);
cairo_move_to(c, 0, battery->bat2_posy);
draw_text(layout, c, 0, battery->bat2_posy, &battery->font, ((Panel*)battery->area.panel)->font_shadow);
pango_cairo_show_layout(c, layout);
g_object_unref(layout);

View file

@ -206,8 +206,7 @@ void draw_clock (void *obj, cairo_t *c)
cairo_set_source_rgba (c, clock->font.color[0], clock->font.color[1], clock->font.color[2], clock->font.alpha);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time1_posy);
pango_cairo_show_layout (c, layout);
draw_text(layout, c, 0, clock->time1_posy, &clock->font, ((Panel*)clock->area.panel)->font_shadow);
if (time2_format) {
pango_layout_set_font_description (layout, time2_font_desc);
@ -216,8 +215,7 @@ void draw_clock (void *obj, cairo_t *c)
pango_layout_set_width (layout, clock->area.width * PANGO_SCALE);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, clock->time2_posy);
pango_cairo_show_layout (c, layout);
draw_text(layout, c, 0, clock->time2_posy, &clock->font, ((Panel*)clock->area.panel)->font_shadow);
}
g_object_unref (layout);

View file

@ -287,7 +287,7 @@ void add_entry (char *key, char *value)
}
}
else if (strcmp (key, "font_shadow") == 0)
panel_config.g_task.font_shadow = atoi (value);
panel_config.font_shadow = atoi (value);
else if (strcmp (key, "panel_background_id") == 0) {
int id = atoi (value);
id = (id < backgrounds->len && id >= 0) ? id : 0;

View file

@ -89,6 +89,7 @@ typedef struct {
int pourcentx, pourcenty;
// location of the panel (monitor number)
int monitor;
int font_shadow;
// --------------------------------------------------
// task and taskbar parameter per panel

View file

@ -26,7 +26,6 @@
#include <string.h>
#include <glib.h>
#include <unistd.h>
#include <math.h>
#include "window.h"
#include "task.h"
@ -392,23 +391,7 @@ void draw_task (void *obj, cairo_t *c)
double text_posy = (panel->g_task.area.height - height) / 2.0;
if (panel->g_task.font_shadow) {
const int shadow_size = 3;
const double shadow_edge_alpha = 0.05;
int i, j;
for (i = -shadow_size; i <= shadow_size; i++) {
for (j = -shadow_size; j <= shadow_size; j++) {
cairo_set_source_rgba(c, 0.0, 0.0, 0.0, 1.0 - (1.0 - shadow_edge_alpha) * sqrt((i*i + j*j)/(double)(shadow_size*shadow_size)));
pango_cairo_update_layout(c, layout);
cairo_move_to(c, panel->g_task.text_posx + i, text_posy + j);
pango_cairo_show_layout(c, layout);
}
}
}
cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, panel->g_task.text_posx, text_posy);
pango_cairo_show_layout (c, layout);
draw_text(layout, c, panel->g_task.text_posx, text_posy, config_text, panel->font_shadow);
g_object_unref (layout);
}

View file

@ -40,7 +40,6 @@ typedef struct {
// starting position for text ~ task_padding + task_border + icon_size
double text_posx, text_height;
int font_shadow;
PangoFontDescription *font_desc;
Color font[TASK_STATE_COUNT];
int config_font_mask;

View file

@ -132,8 +132,7 @@ void draw_taskbarname (void *obj, cairo_t *c)
cairo_set_source_rgba (c, config_text->color[0], config_text->color[1], config_text->color[2], config_text->alpha);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, 0, taskbar_name->posy);
pango_cairo_show_layout (c, layout);
draw_text(layout, c, 0, taskbar_name->posy, config_text, ((Panel*)taskbar_name->area.panel)->font_shadow);
g_object_unref (layout);
//printf("draw_taskbarname %s ******************************\n", taskbar_name->name);

View file

@ -25,6 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <unistd.h>
#include <glib.h>
#include "common.h"
@ -381,3 +382,24 @@ void render_image(Drawable d, int x, int y, int w, int h)
XRenderFreePicture(server.dsp, pict_image);
XRenderFreePicture(server.dsp, pict_drawable);
}
void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow)
{
if (font_shadow) {
const int shadow_size = 3;
const double shadow_edge_alpha = 0.0;
int i, j;
for (i = -shadow_size; i <= shadow_size; i++) {
for (j = -shadow_size; j <= shadow_size; j++) {
cairo_set_source_rgba(c, 0.0, 0.0, 0.0, 1.0 - (1.0 - shadow_edge_alpha) * sqrt((i*i + j*j)/(double)(shadow_size*shadow_size)));
pango_cairo_update_layout(c, layout);
cairo_move_to(c, posx + i, posy + j);
pango_cairo_show_layout(c, layout);
}
}
}
cairo_set_source_rgba (c, color->color[0], color->color[1], color->color[2], color->alpha);
pango_cairo_update_layout (c, layout);
cairo_move_to (c, posx, posy);
pango_cairo_show_layout (c, layout);
}

View file

@ -10,6 +10,7 @@
#define WM_CLASS_TINT "panel"
#include <Imlib2.h>
#include <pango/pangocairo.h>
#include "area.h"
/*
@ -64,5 +65,8 @@ void adjust_asb(DATA32 *data, int w, int h, int alpha, float satur, float bright
void createHeuristicMask(DATA32* data, int w, int h);
void render_image(Drawable d, int x, int y, int w, int h);
void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow);
#endif