@@ -203,14 +203,17 @@ void litehtml::tooltips::create( HWND parent )
203
203
}
204
204
}
205
205
206
- void litehtml::tooltips::show ( unsigned int id, int top )
206
+ void litehtml::tooltips::show ( unsigned int id, int top, bool is_update )
207
207
{
208
208
tool::map::iterator ti = m_tools.find (id);
209
209
if (ti != m_tools.end ())
210
210
{
211
211
m_show_tool = id;
212
212
m_last_shown_tool = id;
213
- clear_images ();
213
+ if (!is_update)
214
+ {
215
+ clear_images ();
216
+ }
214
217
if (m_html)
215
218
{
216
219
m_html = NULL ;
@@ -448,7 +451,44 @@ void litehtml::tooltips::draw_background(tip_layout* layout)
448
451
}
449
452
break ;
450
453
}
454
+
455
+ CTxDIB img;
456
+ img._copy (m_dib.bits (), m_dib.width (), m_dib.height (), TRUE );
457
+
458
+ RGBQUAD* pixels = img.getBits ();
459
+ int sz = img.getWidth () * img.getHeight ();
460
+
461
+ for (int i=0 ; i < sz; i++)
462
+ {
463
+ pixels[i].rgbRed = 0 ;
464
+ pixels[i].rgbGreen = 0 ;
465
+ pixels[i].rgbBlue = 0 ;
466
+ }
467
+
468
+ // draw shadow at the right side
469
+ {
470
+ CTxDIB img_shadow;
471
+ img.crop (img.getWidth () - shadow_width, 0 , img.getWidth (), img.getHeight (), &img_shadow);
472
+ img_shadow.resample (img_shadow.getWidth () - 5 , img_shadow.getHeight () - 5 );
473
+
474
+ cairo_surface_t * img_sf = cairo_image_surface_create_for_data ((unsigned char *) img.getBits (), CAIRO_FORMAT_ARGB32, img.getWidth (), img.getHeight (), img.getWidth () * 4 );
475
+
476
+ simpledib::dib shadow;
477
+ shadow.create (m_dib.width (), m_dib.height (), true );
478
+ cairo_dev cr_shadow (&shadow);
479
+ cairo_set_source_surface (cr_shadow, img_sf, 5 , 5 );
480
+ cairo_paint (cr_shadow);
481
+ fastbluralpha (shadow.bits (), shadow.width (), shadow.height (), 5 );
482
+
483
+ cairo_set_operator (m_cr, CAIRO_OPERATOR_DEST_OVER);
484
+
485
+ cairo_set_source_surface (m_cr, cr_shadow, 0 , 0 );
486
+ cairo_paint (m_cr);
487
+
488
+ cairo_surface_destroy (img_sf);
489
+ }
451
490
491
+ /*
452
492
simpledib::dib shadow;
453
493
454
494
CTxDIB img;
@@ -480,6 +520,7 @@ void litehtml::tooltips::draw_background(tip_layout* layout)
480
520
cairo_paint(m_cr);
481
521
482
522
cairo_surface_destroy(img_sf);
523
+ */
483
524
484
525
if (m_alpha != 255 )
485
526
{
@@ -1234,20 +1275,27 @@ void litehtml::tooltips::update( unsigned int id )
1234
1275
{
1235
1276
if (id == m_show_tool && IsWindowVisible (m_hWnd))
1236
1277
{
1237
- show (id, m_top);
1278
+ show (id, m_top, true );
1238
1279
}
1239
1280
}
1240
1281
1241
1282
void litehtml::tooltips::create_dib ( int width, int height )
1242
1283
{
1243
- if (m_surface) cairo_surface_destroy (m_surface);
1244
- if (m_cr) cairo_destroy (m_cr);
1284
+ if (!m_cr || !m_dib.hdc () || m_dib.width () != width || m_dib.height () != height)
1285
+ {
1286
+ if (m_surface) cairo_surface_destroy (m_surface);
1287
+ if (m_cr) cairo_destroy (m_cr);
1288
+
1289
+ m_dib.clear ();
1290
+ m_dib.create (width, height, true );
1245
1291
1246
- m_dib.clear ();
1247
- m_dib.create (width, height, true );
1292
+ m_surface = cairo_image_surface_create_for_data ((unsigned char *) m_dib.bits (), CAIRO_FORMAT_ARGB32, m_dib.width (), m_dib.height (), m_dib.width () * 4 );
1293
+ m_cr = cairo_create (m_surface);
1294
+ } else
1295
+ {
1296
+ m_dib.clear ();
1297
+ }
1248
1298
1249
- m_surface = cairo_image_surface_create_for_data ((unsigned char *) m_dib.bits (), CAIRO_FORMAT_ARGB32, m_dib.width (), m_dib.height (), m_dib.width () * 4 );
1250
- m_cr = cairo_create (m_surface);
1251
1299
}
1252
1300
1253
1301
void litehtml::tooltips::draw_window (BOOL clr)
0 commit comments