Sfoglia il codice sorgente

Implemented highlight feature for OpenGL.

naelstrof 9 anni fa
parent
commit
e063690c8d
3 ha cambiato i file con 81 aggiunte e 65 eliminazioni
  1. 1
    1
      CMakeLists.txt
  2. 1
    1
      README.md
  3. 79
    63
      src/glselectrectangle.cpp

+ 1
- 1
CMakeLists.txt Vedi File

@@ -3,7 +3,7 @@ cmake_minimum_required( VERSION 2.8 )
3 3
 project( "slop" )
4 4
 set( slop_VERSION_MAJOR 4 )
5 5
 set( slop_VERSION_MINOR 3 )
6
-set( slop_VERSION_PATCH 20 )
6
+set( slop_VERSION_PATCH 21 )
7 7
 
8 8
 set( CMAKE_OPENGL_SUPPORT FALSE CACHE BOOL "Whether or not to compile with OpenGL, shaders, magnification, and theming support." )
9 9
 

+ 1
- 1
README.md Vedi File

@@ -115,7 +115,7 @@ Feel free to make your own themes and submit a pull request to see if it can be
115 115
 help
116 116
 ----
117 117
 ```text
118
-slop v4.3.20
118
+slop v4.3.21
119 119
 
120 120
 Copyright (C) 2014 Dalton Nell, Slop Contributors
121 121
 (https://github.com/naelstrof/slop/graphs/contributors)

+ 79
- 63
src/glselectrectangle.cpp Vedi File

@@ -543,72 +543,88 @@ void slop::GLSelectRectangle::update( double dt ) {
543 543
 
544 544
     if ( !m_themed ) {
545 545
         glColor4f( m_r, m_g, m_b, m_a );
546
-        glRecti( m_x-m_border, m_y, m_x+m_width+m_border, m_y-m_border );
547
-        glRecti( m_x-m_border, m_y+m_height, m_x+m_width+m_border, m_y+m_height+m_border );
548
-        glRecti( m_x-m_border, m_y, m_x, m_y+m_height );
549
-        glRecti( m_x+m_width, m_y, m_x+m_width+m_border, m_y+m_height );
546
+        if ( m_highlight ) {
547
+            glRecti( m_x-m_border, m_y+m_height+m_border, m_x+m_width+m_border, m_y-m_border );
548
+        } else {
549
+            glRecti( m_x-m_border, m_y, m_x+m_width+m_border, m_y-m_border );
550
+            glRecti( m_x-m_border, m_y+m_height, m_x+m_width+m_border, m_y+m_height+m_border );
551
+            glRecti( m_x-m_border, m_y, m_x, m_y+m_height );
552
+            glRecti( m_x+m_width, m_y, m_x+m_width+m_border, m_y+m_height );
553
+        }
550 554
     } else {
551 555
         glColor4f( m_r, m_g, m_b, m_a );
552 556
         glEnable( GL_TEXTURE_2D );
553
-        glBindTexture( GL_TEXTURE_2D, m_straightid );
554
-        float something = (float)(m_border)/(float)m_straightheight;
555
-        float txoffset = (((float)m_width+m_border)/(float)m_straightwidth)/something;
556
-        float tyoffset = (((float)m_height+m_border)/(float)m_straightwidth)/something;
557
-        //float ratio = ((float)m_straightwidth/(float)m_straightheight);
558
-        glBegin( GL_QUADS );
559
-        // straight top
560
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y-m_border );
561
-        glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y-m_border );
562
-        glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y );
563
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y );
564
-        // straight bot
565
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y+m_height );
566
-        glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height );
567
-        glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height+m_border );
568
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y+m_height+m_border );
569
-        // straight left
570
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y-m_border/2 );
571
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x, m_y-m_border/2 );
572
-        glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x, m_y+m_height+m_border/2 );
573
-        glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x-m_border, m_y+m_height+m_border/2 );
574
-        // straight right
575
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y-m_border/2 );
576
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y-m_border/2 );
577
-        glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border/2 );
578
-        glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x+m_width, m_y+m_height+m_border/2 );
579
-        glEnd();
580
-        // top left corner
581
-        glBindTexture( GL_TEXTURE_2D, m_cornerids[0] );
582
-        glBegin( GL_QUADS );
583
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y-m_border );
584
-        glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y-m_border );
585
-        glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y );
586
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y );
587
-        glEnd();
588
-        // top right
589
-        glBindTexture( GL_TEXTURE_2D, m_cornerids[1] );
590
-        glBegin( GL_QUADS );
591
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y-m_border );
592
-        glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y-m_border );
593
-        glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y );
594
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y );
595
-        glEnd();
596
-        // bottom left
597
-        glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
598
-        glBegin( GL_QUADS );
599
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y+m_height );
600
-        glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y+m_height );
601
-        glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y+m_height+m_border );
602
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y+m_height+m_border );
603
-        glEnd();
604
-        // bottom right
605
-        glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
606
-        glBegin( GL_QUADS );
607
-        glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y+m_height );
608
-        glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height );
609
-        glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border );
610
-        glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y+m_height+m_border );
611
-        glEnd();
557
+        if ( !m_highlight ) {
558
+            glBindTexture( GL_TEXTURE_2D, m_straightid );
559
+            float something = (float)(m_border)/(float)m_straightheight;
560
+            float txoffset = (((float)m_width+m_border)/(float)m_straightwidth)/something;
561
+            float tyoffset = (((float)m_height+m_border)/(float)m_straightwidth)/something;
562
+            //float ratio = ((float)m_straightwidth/(float)m_straightheight);
563
+            glBegin( GL_QUADS );
564
+            // straight top
565
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y-m_border );
566
+            glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y-m_border );
567
+            glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y );
568
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y );
569
+            // straight bot
570
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border/2, m_y+m_height );
571
+            glTexCoord2f(txoffset, 0.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height );
572
+            glTexCoord2f(txoffset, 1.0); glVertex2f( m_x+m_width+m_border/2, m_y+m_height+m_border );
573
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border/2, m_y+m_height+m_border );
574
+            // straight left
575
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y-m_border/2 );
576
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x, m_y-m_border/2 );
577
+            glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x, m_y+m_height+m_border/2 );
578
+            glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x-m_border, m_y+m_height+m_border/2 );
579
+            // straight right
580
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y-m_border/2 );
581
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y-m_border/2 );
582
+            glTexCoord2f(tyoffset, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border/2 );
583
+            glTexCoord2f(tyoffset, 1.0); glVertex2f( m_x+m_width, m_y+m_height+m_border/2 );
584
+            glEnd();
585
+            // top left corner
586
+            glBindTexture( GL_TEXTURE_2D, m_cornerids[0] );
587
+            glBegin( GL_QUADS );
588
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y-m_border );
589
+            glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y-m_border );
590
+            glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y );
591
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y );
592
+            glEnd();
593
+            // top right
594
+            glBindTexture( GL_TEXTURE_2D, m_cornerids[1] );
595
+            glBegin( GL_QUADS );
596
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y-m_border );
597
+            glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y-m_border );
598
+            glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y );
599
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y );
600
+            glEnd();
601
+            // bottom left
602
+            glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
603
+            glBegin( GL_QUADS );
604
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y+m_height );
605
+            glTexCoord2f(1.0, 0.0); glVertex2f( m_x, m_y+m_height );
606
+            glTexCoord2f(1.0, 1.0); glVertex2f( m_x, m_y+m_height+m_border );
607
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y+m_height+m_border );
608
+            glEnd();
609
+            // bottom right
610
+            glBindTexture( GL_TEXTURE_2D, m_cornerids[2] );
611
+            glBegin( GL_QUADS );
612
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x+m_width, m_y+m_height );
613
+            glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y+m_height );
614
+            glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_height+m_border );
615
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x+m_width, m_y+m_height+m_border );
616
+            glEnd();
617
+        } else {
618
+            glBindTexture( GL_TEXTURE_2D, m_cornerids[0] );
619
+            glBegin( GL_QUADS );
620
+            // straight top
621
+            glTexCoord2f(0.0, 1.0); glVertex2f( m_x-m_border, m_y+m_border+m_height );
622
+            glTexCoord2f(1.0, 1.0); glVertex2f( m_x+m_width+m_border, m_y+m_border+m_height );
623
+            glTexCoord2f(1.0, 0.0); glVertex2f( m_x+m_width+m_border, m_y-m_border );
624
+            glTexCoord2f(0.0, 0.0); glVertex2f( m_x-m_border, m_y-m_border );
625
+            glEnd();
626
+        }
627
+        glDisable( GL_TEXTURE_2D );
612 628
     }
613 629
 
614 630
     m_framebuffer->unbind();