Add special characters to font, to represent checkboxes and radio
buttons. This requires some tools to convert .png images to that, and that I put the characters in a two-dimensional grid in the texture (since one-dimensional strip gets wider than the hardware supports). [git-p4: depot-paths = "//depot/solvespace/": change = 2138]
This commit is contained in:
parent
7a2941d2ea
commit
2dbb21aecd
68
bitmapextra.table
Normal file
68
bitmapextra.table
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 255, 255, 255, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 255, 255, 255, 255, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0, 0, 255, 255, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 0, 255, 255, 255, 0, 0, 0, 0, 255, 255, 255, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
static const BYTE FontTexture[] = {
|
static const BYTE FontTexture[256*16*16] = {
|
||||||
0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0,
|
0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0,
|
||||||
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
||||||
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0,
|
||||||
@ -2175,4 +2175,5 @@ static const BYTE FontTexture[] = {
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
|
||||||
|
#include "bitmapextra.table"
|
||||||
};
|
};
|
||||||
|
43
glhelper.cpp
43
glhelper.cpp
@ -480,6 +480,21 @@ void glxDepthRangeLockToFront(bool yes)
|
|||||||
|
|
||||||
void glxCreateBitmapFont(void)
|
void glxCreateBitmapFont(void)
|
||||||
{
|
{
|
||||||
|
// Place the font in our texture in a two-dimensional grid; 1d would
|
||||||
|
// be simpler, but long skinny textures (256*16 = 4096 pixels wide)
|
||||||
|
// won't work.
|
||||||
|
static BYTE MappedTexture[4*16*64*16];
|
||||||
|
int a, i;
|
||||||
|
for(a = 0; a < 256; a++) {
|
||||||
|
int row = a / 4, col = a % 4;
|
||||||
|
|
||||||
|
for(i = 0; i < 16; i++) {
|
||||||
|
memcpy(MappedTexture + row*4*16*16 + col*16 + i*4*16,
|
||||||
|
FontTexture + a*16*16 + i*16,
|
||||||
|
16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, TEXTURE_BITMAP_FONT);
|
glBindTexture(GL_TEXTURE_2D, TEXTURE_BITMAP_FONT);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
@ -487,22 +502,32 @@ void glxCreateBitmapFont(void)
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
|
||||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
|
||||||
16, 128*16,
|
16*4, 64*16,
|
||||||
0,
|
0,
|
||||||
GL_ALPHA, GL_UNSIGNED_BYTE,
|
GL_ALPHA, GL_UNSIGNED_BYTE,
|
||||||
FontTexture);
|
MappedTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glxBitmapCharQuad(char c, double x, double y)
|
void glxBitmapCharQuad(char c, double x, double y)
|
||||||
{
|
{
|
||||||
int w = SS.TW.CHAR_WIDTH,
|
BYTE b = (BYTE)c;
|
||||||
h = SS.TW.CHAR_HEIGHT;
|
int w, h;
|
||||||
|
|
||||||
if(c != ' ' && c != 0 && c < 128) {
|
if(b & 0x80) {
|
||||||
double s0 = 0,
|
// Special character, like a checkbox or a radio button
|
||||||
s1 = h/16.0,
|
w = h = 16;
|
||||||
t0 = c/128.0,
|
} else {
|
||||||
t1 = t0 + (w/16.0)/128;
|
// Normal character from our font
|
||||||
|
w = SS.TW.CHAR_WIDTH,
|
||||||
|
h = SS.TW.CHAR_HEIGHT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(b != ' ' && b != 0) {
|
||||||
|
int row = b / 4, col = b % 4;
|
||||||
|
double s0 = col/4.0,
|
||||||
|
s1 = (col+1)/4.0,
|
||||||
|
t0 = row/64.0,
|
||||||
|
t1 = t0 + (w/16.0)/64;
|
||||||
|
|
||||||
glTexCoord2d(s1, t0);
|
glTexCoord2d(s1, t0);
|
||||||
glVertex2d(x, y);
|
glVertex2d(x, y);
|
||||||
|
BIN
icons/char-0-check-false.png
Normal file
BIN
icons/char-0-check-false.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 218 B |
BIN
icons/char-1-check-true.png
Normal file
BIN
icons/char-1-check-true.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 243 B |
BIN
icons/char-2-radio-false.png
Normal file
BIN
icons/char-2-radio-false.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 228 B |
BIN
icons/char-3-radio-true.png
Normal file
BIN
icons/char-3-radio-true.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 231 B |
1
png2c.pl
1
png2c.pl
@ -7,6 +7,7 @@ open(OUT, ">$out") or die "$out: $!";
|
|||||||
open(PROTO, ">$proto") or die "$proto: $!";
|
open(PROTO, ">$proto") or die "$proto: $!";
|
||||||
|
|
||||||
for $file (<icons/*.png>) {
|
for $file (<icons/*.png>) {
|
||||||
|
next if $file =~ /char-/;
|
||||||
|
|
||||||
$file =~ m#.*/(.*)\.png#;
|
$file =~ m#.*/(.*)\.png#;
|
||||||
$base = "Icon_$1";
|
$base = "Icon_$1";
|
||||||
|
28
pngchar2c.pl
Normal file
28
pngchar2c.pl
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use GD;
|
||||||
|
|
||||||
|
for $file (sort <icons/char-*.png>) {
|
||||||
|
open(PNG, $file) or die "$file: $!\n";
|
||||||
|
$img = newFromPng GD::Image(\*PNG) or die;
|
||||||
|
$img->trueColor(1);
|
||||||
|
close PNG;
|
||||||
|
|
||||||
|
($width, $height) = $img->getBounds();
|
||||||
|
die "$file: $width, $height" if ($width != 16) or ($height != 16);
|
||||||
|
|
||||||
|
for($x = 0; $x < 16; $x++) {
|
||||||
|
for($y = 0; $y < 16; $y++) {
|
||||||
|
$index = $img->getPixel($x, $y);
|
||||||
|
($r, $g, $b) = $img->rgb($index);
|
||||||
|
if($r + $g + $b < 11) {
|
||||||
|
print " 0, ";
|
||||||
|
} else {
|
||||||
|
print "255, ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
print "\n";
|
||||||
|
}
|
||||||
|
|
@ -20,7 +20,7 @@ int main(void)
|
|||||||
SelectObject(hdc, bitmap);
|
SelectObject(hdc, bitmap);
|
||||||
SelectObject(hdc, font);
|
SelectObject(hdc, font);
|
||||||
|
|
||||||
printf("static const BYTE FontTexture[] = {\n");
|
printf("static const BYTE FontTexture[256*16*16] = {\n");
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
for(c = 0; c < 128; c++) {
|
for(c = 0; c < 128; c++) {
|
||||||
@ -45,7 +45,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
printf("#include \"bitmapextra.table\"\n");
|
||||||
printf("};\n");
|
printf("};\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
5
ui.h
5
ui.h
@ -33,6 +33,11 @@ public:
|
|||||||
static const int LINE_HEIGHT = 20;
|
static const int LINE_HEIGHT = 20;
|
||||||
static const int LEFT_MARGIN = 6;
|
static const int LEFT_MARGIN = 6;
|
||||||
|
|
||||||
|
static const int CHECK_FALSE = 0x80;
|
||||||
|
static const int CHECK_TRUE = 0x81;
|
||||||
|
static const int RADIO_FALSE = 0x82;
|
||||||
|
static const int RADIO_TRUE = 0x83;
|
||||||
|
|
||||||
int scrollPos; // The scrollbar position, in half-row units
|
int scrollPos; // The scrollbar position, in half-row units
|
||||||
int halfRows; // The height of our window, in half-row units
|
int halfRows; // The height of our window, in half-row units
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
add checked/unchecked checkbox and radio button
|
add checked/unchecked checkbox and radio button
|
||||||
fix bug with rotation in plane where green line stays displayed
|
fix bug with rotation in plane where green line stays displayed
|
||||||
expose transformed point stuff in library
|
|
||||||
group option to make dimensions always reference?
|
group option to make dimensions always reference?
|
||||||
more tangencies
|
more tangencies, and rounding (of requests, not parametric)
|
||||||
|
|
||||||
-----
|
-----
|
||||||
rounding, as a special group
|
rounding, as a special group
|
||||||
|
Loading…
Reference in New Issue
Block a user