Browse Source

gestilter text kann jetzt zu textfeldern hinzugefügt werden

Kolja Strohm 5 years ago
parent
commit
c31b33cb5e
6 changed files with 163 additions and 72 deletions
  1. 15 15
      DX12PixelShader.h
  2. 21 21
      DX12VertexShader.h
  3. 82 0
      TextFeld.cpp
  4. 10 1
      TextFeld.h
  5. 16 16
      UIPixelShader.h
  6. 19 19
      UIVertexShader.h

+ 15 - 15
DX12PixelShader.h

@@ -92,10 +92,10 @@ ret
 
 const BYTE DX12PixelShaderBytes[] =
 {
-     68,  88,  66,  67, 178,  79, 
-     30,   8, 173, 134,  50, 192, 
-    175, 227,  20,  54,  17, 223, 
-    171,  63,   1,   0,   0,   0, 
+     68,  88,  66,  67, 253,  56, 
+     46, 191,  75, 172, 204, 146, 
+     32,  16, 250,  26,  17, 248, 
+     96, 164,   1,   0,   0,   0, 
     184,  91,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      36,   2,   0,   0, 188,   2, 
@@ -763,11 +763,11 @@ const BYTE DX12PixelShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0, 148,  46, 
-     49,   1,  63, 205, 146,  92, 
-      1,   0,   0,   0,  87,  84, 
-    149, 222,  37,  76,  41,  75, 
-    167,  71, 143, 147,  51,  58, 
-     40, 251,   0,   0,   0,   0, 
+     49,   1, 103, 124, 151,  92, 
+      1,   0,   0,   0, 253, 110, 
+    247,  96, 231, 192, 241,  72, 
+    145, 174, 167,  96,  19,  75, 
+    108,  58,   0,   0,   0,   0, 
       0,   0,   0,   0,   1,   0, 
       0,   0,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1788,7 +1788,7 @@ const BYTE DX12PixelShaderBytes[] =
      32,  32,  32,  32,  32,  32, 
      32,  32,  32,  32,  27, 226, 
      48,   1, 128,   0,   0,   0, 
-    207,  28, 109,   0, 117, 223, 
+     66,  13,  82, 193,  63, 226, 
     212,   1,   1,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -3427,7 +3427,7 @@ const BYTE DX12PixelShaderBytes[] =
       2,   0,   9,   0, 220,   4, 
       0,   0,   0,   0,   0,   0, 
     156,   1,   0,   0,   1,   0, 
-      0,   0,   0, 123, 108,   3, 
+      0,   0,  96, 123, 106,   3, 
       0,   0,   0,   0,   0,   0, 
       0,   0, 109,  97, 105, 110, 
       0, 110, 111, 110, 101,   0, 
@@ -3494,10 +3494,10 @@ const BYTE DX12PixelShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0, 148,  46,  49,   1, 
-     63, 205, 146,  92,   1,   0, 
-      0,   0,  87,  84, 149, 222, 
-     37,  76,  41,  75, 167,  71, 
-    143, 147,  51,  58,  40, 251, 
+    103, 124, 151,  92,   1,   0, 
+      0,   0, 253, 110, 247,  96, 
+    231, 192, 241,  72, 145, 174, 
+    167,  96,  19,  75, 108,  58, 
     137,   0,   0,   0,  47,  76, 
     105, 110, 107,  73, 110, 102, 
     111,   0,  47, 110,  97, 109, 

+ 21 - 21
DX12VertexShader.h

@@ -129,10 +129,10 @@ ret
 
 const BYTE DX12VertexShaderBytes[] =
 {
-     68,  88,  66,  67, 105,  96, 
-    138,  45, 149, 106,  57,  74, 
-    193,  86, 238,  91,  81,  44, 
-    134, 211,   1,   0,   0,   0, 
+     68,  88,  66,  67,  37, 124, 
+     72,  44,  57,  92, 253,  32, 
+    192, 110,  69, 219, 152, 212, 
+    203,  46,   1,   0,   0,   0, 
     108,  78,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     124,   2,   0,   0,  16,   3, 
@@ -915,11 +915,11 @@ const BYTE DX12VertexShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-    148,  46,  49,   1,  63, 205, 
-    146,  92,   1,   0,   0,   0, 
-     43,  12,  30, 149, 130, 195, 
-    203,  72, 189, 194,  60,  57, 
-    153,  97,  60, 196,   0,   0, 
+    148,  46,  49,   1, 103, 124, 
+    151,  92,   1,   0,   0,   0, 
+     69,  62, 138,  69,  76, 169, 
+    245,  73, 147, 147, 129,  83, 
+    183,  67, 164, 104,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       1,   0,   0,   0,   1,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -1095,7 +1095,7 @@ const BYTE DX12VertexShaderBytes[] =
       0,   0, 103, 159,   1,   0, 
     179, 120,   1,   0, 238,  97, 
       2,   0,  90,  28,   0,   0, 
-     99,  81,   1,   0,  53, 174, 
+    186, 102,   1,   0,  53, 174, 
       3,   0, 206,  21,   0,   0, 
     193, 205,   3,   0, 207, 193, 
       1,   0,  62,   3,   3,   0, 
@@ -1684,8 +1684,8 @@ const BYTE DX12VertexShaderBytes[] =
     111, 110,  59,  13,  10, 125, 
      59,  13,  10,  13,  10,  47, 
      27, 226,  48,   1, 128,   0, 
-      0,   0, 218, 159, 177,   0, 
-    117, 223, 212,   1,   1,   0, 
+      0,   0,   3, 125, 140, 193, 
+     63, 226, 212,   1,   1,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2200,7 +2200,7 @@ const BYTE DX12VertexShaderBytes[] =
      12,  16,   0,   0,   1,   0, 
       1,   0,  14,   0,  23,  21, 
      13,  16,   0,   0,  36,   2, 
-    160, 120,   0,   0, 242, 241, 
+     64, 123,   0,   0, 242, 241, 
      10,   0,  24,  21,  14,  16, 
       0,   0,   1,   0,   0,   2, 
      18,   0,  22,  21,  10,  16, 
@@ -3148,19 +3148,19 @@ const BYTE DX12VertexShaderBytes[] =
       1,   0,   0,   0,   0,   0, 
       0,   0,  24,   4,   0,   0, 
      32,   0,   0,  96,   0,   0, 
-     60, 196,   0,   0,   0,   0, 
+    164, 104,   0,   0,   0,   0, 
       0,   0,   0,   0,   2,   0, 
       9,   0, 132,   5,   0,   0, 
       0,   0,   0,   0, 236,   2, 
       0,   0,   1,   0,   0,   0, 
-      0, 122, 133,   3,   0,   0, 
+     96, 122, 205,   3,   0,   0, 
       0,   0,   0,   0,   0,   0, 
     109,  97, 105, 110,   0, 110, 
     111, 110, 101,   0,   0,   0, 
      45, 186,  46, 241,   1,   0, 
       0,   0,   0,   0,   0,   0, 
      24,   4,   0,   0,  32,   0, 
-      0,  96,   0,   0,  60, 196, 
+      0,  96,   0,   0, 164, 104, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   2,   0,   2,   0, 
       7,   0,   0,   0,   0,   0, 
@@ -3219,11 +3219,11 @@ const BYTE DX12VertexShaderBytes[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-    148,  46,  49,   1,  63, 205, 
-    146,  92,   1,   0,   0,   0, 
-     43,  12,  30, 149, 130, 195, 
-    203,  72, 189, 194,  60,  57, 
-    153,  97,  60, 196, 138,   0, 
+    148,  46,  49,   1, 103, 124, 
+    151,  92,   1,   0,   0,   0, 
+     69,  62, 138,  69,  76, 169, 
+    245,  73, 147, 147, 129,  83, 
+    183,  67, 164, 104, 138,   0, 
       0,   0,  47,  76, 105, 110, 
     107,  73, 110, 102, 111,   0, 
      47, 110,  97, 109, 101, 115, 

+ 82 - 0
TextFeld.cpp

@@ -369,6 +369,88 @@ void TextFeld::setText( const char *txt ) // setzt den angezeigten Text
     unlockZeichnung();
 }
 
+// setzt den Text mit styles
+//  txt: der Text
+//  format: \x1: toggle underline
+//          \x2\xY: setzt die schriftgröße auf y für den folgenden text
+//          \x3\xA\xR\xG\xB: setzt die schriftfarbe auf ARGB
+//          \x4\xA\xR\xG\xB: setzt die farbe des ausgewählten textes
+//          \x5\xA\xR\xG\xB: setzt die hintergrundfarbe des ausgewählten textes
+//          \x6\xY: setzt text renderer index auf y
+void TextFeld::setFormattedText( const char *txt )
+{
+    lockZeichnung();
+    if( !tm->text )
+        tm->text = new Text();
+    tm->textStyle.leeren();
+    TextStyle current;
+    current.beginIndex = 0;
+    current.fontColor = 0xFFFFFFFF;
+    current.fontSize = 12;
+    current.selected = 0;
+    current.selectedColor = 0xFFFFFFFF;
+    current.selectedBackcroundColor = 0xFF0000FF;
+    current.underlined = 0;
+    current.onClick = 0;
+    current.rendererIndex = 0;
+    tm->textStyle.add( current );
+    Text result = "";
+    int len = textLength( txt );
+    for( int i = 0; i < len; i++ )
+    {
+        current.beginIndex = result.getLength();
+        switch( txt[ i ] )
+        {
+        case 1:
+            current.underlined = !current.underlined;
+            tm->textStyle.add( current );
+            break;
+        case 2:
+            current.fontSize = (unsigned char)txt[ ++i ];
+            tm->textStyle.add( current );
+            break;
+        case 3:
+            current.fontColor = 0;
+            current.fontColor |= (unsigned char)txt[ ++i ] << 24;
+            current.fontColor |= (unsigned char)txt[ ++i ] << 16;
+            current.fontColor |= (unsigned char)txt[ ++i ] << 8;
+            current.fontColor |= (unsigned char)txt[ ++i ];
+            tm->textStyle.add( current );
+            break;
+        case 4:
+            current.selectedColor = 0;
+            current.selectedColor |= (unsigned char)txt[ ++i ] << 24;
+            current.selectedColor |= (unsigned char)txt[ ++i ] << 16;
+            current.selectedColor |= (unsigned char)txt[ ++i ] << 8;
+            current.selectedColor |= (unsigned char)txt[ ++i ];
+            tm->textStyle.add( current );
+            break;
+        case 5:
+            current.selectedBackcroundColor = 0;
+            current.selectedBackcroundColor |= (unsigned char)txt[ ++i ] << 24;
+            current.selectedBackcroundColor |= (unsigned char)txt[ ++i ] << 16;
+            current.selectedBackcroundColor |= (unsigned char)txt[ ++i ] << 8;
+            current.selectedBackcroundColor |= (unsigned char)txt[ ++i ];
+            tm->textStyle.add( current );
+            break;
+        case 6:
+            current.rendererIndex = (unsigned char)txt[ ++i ];
+            tm->textStyle.add( current );
+            break;
+        default:
+            result.append( txt[ i ] );
+        }
+    }
+    tm->text->setText( result );
+    tm->cleanupStyles();
+    if( hatStyle( Style::VScroll ) )
+        updateVScroll();
+    if( hatStyle( Style::HScroll ) )
+        updateHScroll();
+    rend = 1;
+    unlockZeichnung();
+}
+
 // Setzt den Style eines Textabschnittes
 //  begin: die startposition des Abschnittes
 //  end: die endposition des Abschnittes (nicht enthalten)

+ 10 - 1
TextFeld.h

@@ -29,7 +29,7 @@ namespace Framework
             bool underlined;
             bool selected;
             MausAktion onClick;
-            char rendererIndex;
+            unsigned char rendererIndex;
             __declspec( dllexport ) bool operator==( const TextStyle& rhs );
         };
 
@@ -120,6 +120,15 @@ namespace Framework
         // setzt den Text des Textfeldes
         //  txt: der Text
         __declspec( dllexport ) void setText( const char *txt );
+        // setzt den Text mit styles
+        //  txt: der Text
+        //  format: \x1: toggle underline
+        //          \x2\xY: setzt die schriftgröße auf y für den folgenden text
+        //          \x3\xA\xR\xG\xB: setzt die schriftfarbe auf ARGB
+        //          \x4\xA\xR\xG\xB: setzt die farbe des ausgewählten textes
+        //          \x5\xA\xR\xG\xB: setzt die hintergrundfarbe des ausgewählten textes
+        //          \x6\xY: setzt text renderer index auf y
+        __declspec( dllexport ) void setFormattedText( const char *txt );
         // Setzt den Style eines Textabschnittes
         //  begin: die startposition des Abschnittes
         //  end: die endposition des Abschnittes (nicht enthalten)

+ 16 - 16
UIPixelShader.h

@@ -262,10 +262,10 @@ ret
 
 const BYTE UIPixelShader[] =
 {
-     68,  88,  66,  67, 228,  89, 
-    255, 199, 110, 134, 244, 235, 
-    253,  53, 150, 109, 175,  59, 
-    130, 134,   1,   0,   0,   0, 
+     68,  88,  66,  67,  90,  78, 
+     11, 246,  77,  81,  79, 211, 
+     80,  66, 178, 176, 250, 224, 
+     17,  16,   1,   0,   0,   0, 
     136, 104,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
     124,   5,   0,   0,  12,   6, 
@@ -1480,10 +1480,10 @@ const BYTE UIPixelShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0, 148,  46,  49,   1, 
-     63, 205, 146,  92,   1,   0, 
-      0,   0, 113, 129,  86, 182, 
-    229, 198, 154,  70, 144, 184, 
-     67, 176,  40,  19, 166,  30, 
+    104, 124, 151,  92,   1,   0, 
+      0,   0, 172,   8, 167, 210, 
+    115, 135, 236,  65, 128, 177, 
+    105, 209,  70, 211,  82, 191, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       1,   0,   0,   0,   0,   0, 
@@ -2419,8 +2419,8 @@ const BYTE UIPixelShader[] =
      32,  32,  32,  32,  32,  32, 
      32,  32,  32,  32,  32,  32, 
      27, 226,  48,   1, 128,   0, 
-      0,   0,  13, 141, 214,   0, 
-    117, 223, 212,   1,   1,   0, 
+      0,   0, 147,  10, 176, 193, 
+     63, 226, 212,   1,   1,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -4400,7 +4400,7 @@ const BYTE UIPixelShader[] =
       9,   0, 160,   7,   0,   0, 
       0,   0,   0,   0, 244,   9, 
       0,   0,   1,   0,   0,   0, 
-    176, 122,  30,   0,   0,   0, 
+    192, 122, 213,   3,   0,   0, 
       0,   0,   0,   0,   0,   0, 
      84, 101, 120, 116, 117, 114, 
     101,  80, 105, 120, 101, 108, 
@@ -4466,11 +4466,11 @@ const BYTE UIPixelShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
-    148,  46,  49,   1,  63, 205, 
-    146,  92,   1,   0,   0,   0, 
-    113, 129,  86, 182, 229, 198, 
-    154,  70, 144, 184,  67, 176, 
-     40,  19, 166,  30, 137,   0, 
+    148,  46,  49,   1, 104, 124, 
+    151,  92,   1,   0,   0,   0, 
+    172,   8, 167, 210, 115, 135, 
+    236,  65, 128, 177, 105, 209, 
+     70, 211,  82, 191, 137,   0, 
       0,   0,  47,  76, 105, 110, 
     107,  73, 110, 102, 111,   0, 
      47, 110,  97, 109, 101, 115, 

+ 19 - 19
UIVertexShader.h

@@ -119,10 +119,10 @@ ret
 
 const BYTE UIVertexShader[] =
 {
-     68,  88,  66,  67,  61,  65, 
-    250,  39, 181, 236, 220, 196, 
-     69, 214,  76, 113, 237, 236, 
-    131, 239,   1,   0,   0,   0, 
+     68,  88,  66,  67, 238,  63, 
+    206,  77, 117, 222,  22,  10, 
+    168, 102, 164,  76,  66, 141, 
+     39, 219,   1,   0,   0,   0, 
     168,  77,   0,   0,   6,   0, 
       0,   0,  56,   0,   0,   0, 
      20,   2,   0,   0, 168,   2, 
@@ -873,10 +873,10 @@ const BYTE UIVertexShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0, 148,  46,  49,   1, 
-     64, 205, 146,  92,   1,   0, 
-      0,   0, 162, 152, 100, 168, 
-    213, 218,  97,  79, 168, 249, 
-    172, 105,  10, 185, 122, 210, 
+    104, 124, 151,  92,   1,   0, 
+      0,   0,  98, 206, 169,  84, 
+    242,  31,  77,  68, 159, 181, 
+      6,  71, 229,  70,  40, 134, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   1,   0,   0,   0, 
       1,   0,   0,   0,   0,   0, 
@@ -1556,8 +1556,8 @@ const BYTE UIVertexShader[] =
      32,  32,  32,  32,  32,  32, 
      32,  32,  32,  32,  32,  32, 
      27, 226,  48,   1, 128,   0, 
-      0,   0, 188, 150,  28,   1, 
-    117, 223, 212,   1,   1,   0, 
+      0,   0,  53,   2, 236, 193, 
+     63, 226, 212,   1,   1,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
@@ -2934,13 +2934,13 @@ const BYTE UIVertexShader[] =
       0,   0,   0,   0,   1,   0, 
       0,   0,   0,   0,   0,   0, 
     196,   3,   0,   0,  32,   0, 
-      0,  96,   0,   0, 122, 210, 
+      0,  96,   0,   0,  40, 134, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   2,   0,   9,   0, 
      80,   5,   0,   0,   0,   0, 
       0,   0, 236,   2,   0,   0, 
-      1,   0,   0,   0,  32, 122, 
-    117,   3,   0,   0,   0,   0, 
+      1,   0,   0,   0, 224, 122, 
+    150,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,  84, 101, 
     120, 116, 117, 114, 101,  86, 
     101, 114, 116, 101, 120,  83, 
@@ -2950,7 +2950,7 @@ const BYTE UIVertexShader[] =
       1,   0,   0,   0,   0,   0, 
       0,   0, 196,   3,   0,   0, 
      32,   0,   0,  96,   0,   0, 
-    122, 210,   0,   0,   0,   0, 
+     40, 134,   0,   0,   0,   0, 
       0,   0,   0,   0,   2,   0, 
       2,   0,   7,   0,   0,   0, 
       0,   0,   1,   0, 255, 255, 
@@ -3006,11 +3006,11 @@ const BYTE UIVertexShader[] =
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0,   0,   0, 
       0,   0,   0,   0, 148,  46, 
-     49,   1,  64, 205, 146,  92, 
-      1,   0,   0,   0, 162, 152, 
-    100, 168, 213, 218,  97,  79, 
-    168, 249, 172, 105,  10, 185, 
-    122, 210, 138,   0,   0,   0, 
+     49,   1, 104, 124, 151,  92, 
+      1,   0,   0,   0,  98, 206, 
+    169,  84, 242,  31,  77,  68, 
+    159, 181,   6,  71, 229,  70, 
+     40, 134, 138,   0,   0,   0, 
      47,  76, 105, 110, 107,  73, 
     110, 102, 111,   0,  47, 110, 
      97, 109, 101, 115,   0,  47,