|
@@ -222,6 +222,49 @@ void slop::GLSelectRectangle::generateMagnifyingGlass() {
|
222
|
222
|
glDisable(GL_TEXTURE_2D);
|
223
|
223
|
}
|
224
|
224
|
|
|
225
|
+void slop::GLSelectRectangle::setTheme( bool on, std::string name ) {
|
|
226
|
+ if ( !on ) {
|
|
227
|
+ return;
|
|
228
|
+ }
|
|
229
|
+ std::string root = resource->getRealPath( name );
|
|
230
|
+ std::string tl = root + "/corner_tl.png";
|
|
231
|
+ std::string bl = root + "/corner_bl.png";
|
|
232
|
+ std::string tr = root + "/corner_tr.png";
|
|
233
|
+ std::string br = root + "/corner_br.png";
|
|
234
|
+ std::string straight = root + "/straight.png";
|
|
235
|
+ // One of the textures didn't exist, so we cancel the theme.
|
|
236
|
+ if (!resource->validatePath( tl ) ||
|
|
237
|
+ !resource->validatePath( bl ) ||
|
|
238
|
+ !resource->validatePath( tr ) ||
|
|
239
|
+ !resource->validatePath( br ) ||
|
|
240
|
+ !resource->validatePath( straight ) ) {
|
|
241
|
+ fprintf( stderr, "One of the textures was missing in the theme... disabling.\n" );
|
|
242
|
+ return;
|
|
243
|
+ }
|
|
244
|
+ // Otherwise we load each one :)
|
|
245
|
+ ilInit();
|
|
246
|
+ ilutInit();
|
|
247
|
+ ilutRenderer(ILUT_OPENGL);
|
|
248
|
+ ILuint corner;
|
|
249
|
+ ilGenImages( 1, &corner );
|
|
250
|
+ ilBindImage( corner );
|
|
251
|
+ ilLoadImage( tl.c_str() );
|
|
252
|
+ m_cornerids[0] = ilutGLBindMipmaps();
|
|
253
|
+ ilLoadImage( tr.c_str() );
|
|
254
|
+ m_cornerids[1] = ilutGLBindMipmaps();
|
|
255
|
+ ilLoadImage( bl.c_str() );
|
|
256
|
+ m_cornerids[2] = ilutGLBindMipmaps();
|
|
257
|
+ ilLoadImage( br.c_str() );
|
|
258
|
+ m_cornerids[3] = ilutGLBindMipmaps();
|
|
259
|
+ ilLoadImage( straight.c_str() );
|
|
260
|
+ m_straightwidth = ilGetInteger( IL_IMAGE_WIDTH );
|
|
261
|
+ m_straightheight = ilGetInteger( IL_IMAGE_HEIGHT );
|
|
262
|
+ m_straightid = ilutGLBindMipmaps();
|
|
263
|
+ // And clean up after.
|
|
264
|
+ ilDeleteImages( 1, &corner );
|
|
265
|
+ m_themed = on;
|
|
266
|
+}
|
|
267
|
+
|
225
|
268
|
slop::GLSelectRectangle::GLSelectRectangle( int sx, int sy, int ex, int ey, int border, bool highlight, float r, float g, float b, float a ) {
|
226
|
269
|
m_x = std::min( sx, ex );
|
227
|
270
|
m_y = std::min( sy, ey );
|
|
@@ -242,6 +285,7 @@ slop::GLSelectRectangle::GLSelectRectangle( int sx, int sy, int ex, int ey, int
|
242
|
285
|
m_glassSize = 4;
|
243
|
286
|
m_glassBorder = 1;
|
244
|
287
|
m_monitors = xengine->getCRTCS();
|
|
288
|
+ m_themed = false;
|
245
|
289
|
|
246
|
290
|
// If we don't have a border, we don't exist, so just die.
|
247
|
291
|
if ( m_border == 0 ) {
|
|
@@ -352,6 +396,8 @@ slop::GLSelectRectangle::GLSelectRectangle( int sx, int sy, int ex, int ey, int
|
352
|
396
|
if ( !glXMakeContextCurrent( xengine->m_display, m_glxWindow, m_glxWindow, m_renderContext ) ) {
|
353
|
397
|
fprintf( stderr, "Failed to attach GL context to window!\n" );
|
354
|
398
|
}
|
|
399
|
+ glEnable( GL_BLEND );
|
|
400
|
+ glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
|
355
|
401
|
glClearColor( 0, 0, 0, 0 );
|
356
|
402
|
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
357
|
403
|
glXSwapBuffers( xengine->m_display, m_glxWindow );
|
|
@@ -382,11 +428,75 @@ void slop::GLSelectRectangle::update( double dt ) {
|
382
|
428
|
glMatrixMode( GL_MODELVIEW );
|
383
|
429
|
glLoadIdentity();
|
384
|
430
|
|
385
|
|
- glColor4f( m_r, m_g, m_b, m_a );
|
386
|
|
- glRecti( m_x-m_border, m_y, m_x+m_width+m_border, m_y-m_border );
|
387
|
|
- glRecti( m_x-m_border, m_y+m_height, m_x+m_width+m_border, m_y+m_height+m_border );
|
388
|
|
- glRecti( m_x-m_border, m_y, m_x, m_y+m_height );
|
389
|
|
- glRecti( m_x+m_width, m_y, m_x+m_width+m_border, m_y+m_height );
|
|
431
|
+ if ( !m_themed ) {
|
|
432
|
+ glColor4f( m_r, m_g, m_b, m_a );
|
|
433
|
+ glRecti( m_x-m_border, m_y, m_x+m_width+m_border, m_y-m_border );
|
|
434
|
+ glRecti( m_x-m_border, m_y+m_height, m_x+m_width+m_border, m_y+m_height+m_border );
|
|
435
|
+ glRecti( m_x-m_border, m_y, m_x, m_y+m_height );
|
|
436
|
+ glRecti( m_x+m_width, m_y, m_x+m_width+m_border, m_y+m_height );
|
|
437
|
+ } else {
|
|
438
|
+ glColor4f( m_r, m_g, m_b, m_a );
|
|
439
|
+ glEnable( GL_TEXTURE_2D );
|
|
440
|
+ glBindTexture( GL_TEXTURE_2D, m_straightid );
|
|
441
|
+ float something = (float)(m_border)/(float)m_straightheight;
|
|
442
|
+ float txoffset = (((float)m_width+m_border)/(float)m_straightwidth)/something;
|
|
443
|
+ float tyoffset = (((float)m_height+m_border)/(float)m_straightwidth)/something;
|
|
444
|
+ //float ratio = ((float)m_straightwidth/(float)m_straightheight);
|
|
445
|
+ glBegin( GL_QUADS );
|
|
446
|
+ // straight top
|
|
447
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y-m_border );
|
|
448
|
+ glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y-m_border );
|
|
449
|
+ glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y );
|
|
450
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y );
|
|
451
|
+ // straight bot
|
|
452
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y+m_height );
|
|
453
|
+ glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height );
|
|
454
|
+ glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height+m_border );
|
|
455
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y+m_height+m_border );
|
|
456
|
+ // straight left
|
|
457
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y-m_border/2 );
|
|
458
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x, m_y-m_border/2 );
|
|
459
|
+ glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x, m_y+m_height+m_border/2 );
|
|
460
|
+ glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x-m_border, m_y+m_height+m_border/2 );
|
|
461
|
+ // straight right
|
|
462
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y-m_border/2 );
|
|
463
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y-m_border/2 );
|
|
464
|
+ glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border/2 );
|
|
465
|
+ glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x+m_width, m_y+m_height+m_border/2 );
|
|
466
|
+ glEnd();
|
|
467
|
+ // top left corner
|
|
468
|
+ glBindTexture( GL_TEXTURE_2D, m_cornerids[0] );
|
|
469
|
+ glBegin( GL_QUADS );
|
|
470
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y-m_border );
|
|
471
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y-m_border );
|
|
472
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y );
|
|
473
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y );
|
|
474
|
+ glEnd();
|
|
475
|
+ // top right
|
|
476
|
+ glBindTexture( GL_TEXTURE_2D, m_cornerids[1] );
|
|
477
|
+ glBegin( GL_QUADS );
|
|
478
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y-m_border );
|
|
479
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y-m_border );
|
|
480
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y );
|
|
481
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y );
|
|
482
|
+ glEnd();
|
|
483
|
+ // bottom left
|
|
484
|
+ glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
|
|
485
|
+ glBegin( GL_QUADS );
|
|
486
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y+m_height );
|
|
487
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y+m_height );
|
|
488
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y+m_height+m_border );
|
|
489
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y+m_height+m_border );
|
|
490
|
+ glEnd();
|
|
491
|
+ // bottom right
|
|
492
|
+ glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
|
|
493
|
+ glBegin( GL_QUADS );
|
|
494
|
+ glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y+m_height );
|
|
495
|
+ glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_height );
|
|
496
|
+ glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border );
|
|
497
|
+ glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y+m_height+m_border );
|
|
498
|
+ glEnd();
|
|
499
|
+ }
|
390
|
500
|
|
391
|
501
|
if ( m_glassEnabled ) {
|
392
|
502
|
generateMagnifyingGlass();
|