CHDK_DE Vorschauversion  Trunk Rev. 5830
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
gui_draw.c-Dateireferenz
#include "platform.h"
#include "touchscreen.h"
#include "conf.h"
#include "font.h"
#include "lang.h"
#include "gui_draw.h"
#include "../lib/font/font_8x16_uni_packed.h"
+ Include-Abhängigkeitsdiagramm für gui_draw.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  FontData
 

Makrodefinitionen

#define GET_FONT_COMPRESSION_MODE   1
 
#define GUARD_VAL   COLOR_GREY_DK
 
#define swap(v1, v2)   {v1^=v2; v2^=v1; v1^=v2;}
 

Funktionen

static void draw_pixel_std (unsigned int offset, color cl)
 
unsigned int color_to_rawpx (__attribute__((unused)) color cl, __attribute__((unused)) unsigned int *op)
 
void draw_dblpixel_raw (__attribute__((unused)) unsigned int offset, __attribute__((unused)) unsigned int px, __attribute__((unused)) unsigned int op)
 
void set_transparent (__attribute__((unused)) unsigned int offst, __attribute__((unused)) int n_pixel)
 
void draw_pixel_proc_rotated (unsigned int offset, color cl)
 
void draw_set_draw_proc (void(*pixel_proc)(unsigned int offset, color cl))
 
void update_draw_proc ()
 
void draw_set_guard ()
 
int draw_test_guard ()
 
void draw_init ()
 
void draw_suspend (int ms)
 
int draw_is_suspended (void)
 
void draw_restore ()
 
void draw_pixel (coord x, coord y, color cl)
 
void draw_pixel_unrotated (coord x, coord y, color cl)
 
color draw_get_pixel (coord x, coord y)
 
color draw_get_pixel_unrotated (coord x, coord y)
 
void draw_line (coord x1, coord y1, coord x2, coord y2, color cl)
 
void draw_hline (coord x, coord y, int len, color cl)
 
void draw_vline (coord x, coord y, int len, color cl)
 
void draw_rectangle (coord x1, coord y1, coord x2, coord y2, twoColors cl, int flags)
 
static unsigned char * get_cdata (unsigned int *offset, unsigned int *size, const char ch)
 
void draw_char (coord x, coord y, const char ch, twoColors cl)
 
void draw_char_scaled (coord x, coord y, const char ch, twoColors cl, int xsize, int ysize)
 
int draw_string_clipped (coord x, coord y, const char *s, twoColors cl, int max_width)
 
int draw_string (coord x, coord y, const char *s, twoColors cl)
 
int draw_string_justified (coord x, coord y, const char *s, twoColors cl, int xo, int max_width, int justification)
 
int text_dimensions (const char *s, int width, int max_chars, int *max_lines)
 
int draw_text_justified (coord x, coord y, const char *s, twoColors cl, int max_chars, int max_lines, int justification)
 
void draw_string_scaled (coord x, coord y, const char *s, twoColors cl, int xsize, int ysize)
 
void draw_osd_string (OSD_pos pos, int xo, int yo, char *s, twoColors c, OSD_scale scale)
 
void draw_txt_string (coord col, coord row, const char *str, twoColors cl)
 
void draw_ellipse (coord CX, coord CY, unsigned int XRadius, unsigned int YRadius, color cl, int flags)
 
void draw_button (int x, int y, int w, int str_id, int active)
 
void draw_icon_cmds (coord x, coord y, icon_cmd *cmds)
 
void set_palette ()
 
color get_script_color (int cl)
 
color chdkColorToCanonColor (chdkColor col)
 
twoColors user_color (confColor cc)
 

Variablen

int draw_restore_suspend_tick
 
void(* draw_pixel_proc )(unsigned int offset, color cl)
 
void(* draw_pixel_proc_norm )(unsigned int offset, color cl)
 
static char * frame_buffer [2]
 
unsigned int rotate_base
 
unsigned char ply_colors []
 
unsigned char rec_colors []
 
unsigned char * chdk_colors = ply_colors
 

Makro-Dokumentation

#define GET_FONT_COMPRESSION_MODE   1

Definiert in Zeile 8 der Datei gui_draw.c.

#define GUARD_VAL   COLOR_GREY_DK

Definiert in Zeile 352 der Datei gui_draw.c.

#define swap (   v1,
  v2 
)    {v1^=v2; v2^=v1; v1^=v2;}

Definiert in Zeile 505 der Datei gui_draw.c.

Dokumentation der Funktionen

color chdkColorToCanonColor ( chdkColor  col)

Definiert in Zeile 1478 der Datei gui_draw.c.

1479 {
1480  if (col.type)
1481  return chdk_colors[col.col];
1482  return col.col;
1483 }
unsigned int color_to_rawpx ( __attribute__((unused)) color  cl,
__attribute__((unused)) unsigned int *  op 
)

Definiert in Zeile 143 der Datei gui_draw.c.

144 {
145  return 0;
146 }
void draw_button ( int  x,
int  y,
int  w,
int  str_id,
int  active 
)

Definiert in Zeile 1360 der Datei gui_draw.c.

1361 {
1363  w = w * FONT_WIDTH;
1364 
1365  draw_rectangle(x-2, y-2, x+w+2, y+FONT_HEIGHT+2, cl, RECT_BORDER1|DRAW_FILLED|RECT_SHADOW1); // main box
1366  draw_string(x+((w-(strlen(lang_str(str_id))*FONT_WIDTH))>>1), y, lang_str(str_id), cl);
1367 }
void draw_char ( coord  x,
coord  y,
const char  ch,
twoColors  cl 
)

Definiert in Zeile 696 der Datei gui_draw.c.

697 {
698  unsigned i, ii;
699 
700  unsigned int offset, size;
701  unsigned char *sym = get_cdata(&offset, &size, ch);
702 
703  // First draw blank lines at top
704  for (i=0; i<offset; i++)
706 
707  // Now draw character data
708 
709  unsigned j;
710  for (j=i; i<size;)
711  {
712  unsigned int dsym;
713  int rep;
714 #ifdef BUILTIN_FONT_RLE_COMPRESSED
715  dsym = fontdata_lookup[sym[j] & 0x7f];
716  rep = sym[j] & 0x80;
717 #else
718  dsym = sym[j];
719  rep = 0;
720 #endif
721  for (ii=0; ii<FONT_WIDTH; ii++)
722  {
723  draw_pixel(x+ii, y+i, (dsym & (0x80>>ii))? FG_COLOR(cl) : BG_COLOR(cl));
724  }
725  if (rep)
726  {
727  i++;
728  for (ii=0; ii<FONT_WIDTH; ii++)
729  {
730  draw_pixel(x+ii, y+i, (dsym & (0x80>>ii))? FG_COLOR(cl) : BG_COLOR(cl));
731  }
732  }
733  i++;
734  j++;
735  }
736 
737  // Last draw blank lines at bottom
738  for (; i<FONT_HEIGHT; i++)
739  draw_hline(x, y+i, FONT_WIDTH, BG_COLOR(cl));
740 }
void draw_char_scaled ( coord  x,
coord  y,
const char  ch,
twoColors  cl,
int  xsize,
int  ysize 
)

Definiert in Zeile 899 der Datei gui_draw.c.

900 {
901  unsigned i, ii;
902 
905 
906  unsigned int offset, size;
907  unsigned char *sym = get_cdata(&offset, &size, ch);
908 
909  // First draw blank lines at top
910  if (offset > 0)
911  draw_rectangle(x,y,x+FONT_WIDTH*xsize-1,y+offset*ysize+ysize-1,clb,RECT_BORDER0|DRAW_FILLED);
912 
913  // Now draw character data
914  unsigned j;
915  for (j=i=offset; i<size;)
916  {
917  unsigned int dsym;
918  int rep;
919  unsigned int last;
920  int len;
921 #ifdef BUILTIN_FONT_RLE_COMPRESSED
922  dsym = fontdata_lookup[sym[j] & 0x7f];
923  rep = sym[j] & 0x80;
924 #else
925  dsym = sym[j];
926  rep = 0;
927 #endif
928  while (rep >= 0)
929  {
930  last = dsym & 0x80;
931  len = 1;
932  for (ii=1; ii<FONT_WIDTH; ii++)
933  {
934  if (((dsym << ii) & 0x80) != last)
935  {
936  draw_rectangle(x+(ii-len)*xsize,y+i*ysize,x+ii*xsize-1,y+i*ysize+ysize-1,(last)?clf:clb,RECT_BORDER0|DRAW_FILLED);
937  last = (dsym << ii) & 0x80;
938  len = 1;
939  }
940  else
941  {
942  len++;
943  }
944  }
945  draw_rectangle(x+(ii-len)*xsize,y+i*ysize,x+ii*xsize-1,y+i*ysize+ysize-1,(last)?clf:clb,RECT_BORDER0|DRAW_FILLED);
946  i++;
947  rep -= 0x80;
948  }
949  j++;
950  }
951 
952  // Last draw blank lines at bottom
953  if (i < FONT_HEIGHT)
954  draw_rectangle(x,y+i*ysize,x+FONT_WIDTH*xsize-1,y+FONT_HEIGHT*ysize+ysize-1,clb,RECT_BORDER0|DRAW_FILLED);
955 }
void draw_dblpixel_raw ( __attribute__((unused)) unsigned int  offset,
__attribute__((unused)) unsigned int  px,
__attribute__((unused)) unsigned int  op 
)

Definiert in Zeile 147 der Datei gui_draw.c.

148 {
149 }
void draw_ellipse ( coord  CX,
coord  CY,
unsigned int  XRadius,
unsigned int  YRadius,
color  cl,
int  flags 
)

Definiert in Zeile 1274 der Datei gui_draw.c.

1275 {
1276  // Bresenham fast ellipse algorithm - http://homepage.smc.edu/kennedy_john/BELIPSE.PDF
1277  int X, Y;
1278  int XChange, YChange;
1279  int EllipseError;
1280  int TwoASquare, TwoBSquare;
1281  int StoppingX, StoppingY;
1282  TwoASquare = 2*XRadius*XRadius;
1283  TwoBSquare = 2*YRadius*YRadius;
1284  X = XRadius;
1285  Y = 0;
1286  XChange = YRadius*YRadius*(1-2*XRadius);
1287  YChange = XRadius*XRadius;
1288  EllipseError = 0;
1289  StoppingX = TwoBSquare*XRadius;
1290  StoppingY = 0;
1291  while ( StoppingX >= StoppingY )
1292  {
1293  if (flags & DRAW_FILLED)
1294  {
1295  draw_hline(CX-X,CY-Y,X*2+1,cl);
1296  draw_hline(CX-X,CY+Y,X*2+1,cl);
1297  }
1298  else
1299  {
1300  draw_pixel(CX-X,CY-Y,cl);
1301  draw_pixel(CX-X,CY+Y,cl);
1302  draw_pixel(CX+X,CY-Y,cl);
1303  draw_pixel(CX+X,CY+Y,cl);
1304  }
1305  Y++;
1306  StoppingY += TwoASquare;
1307  EllipseError += YChange;
1308  YChange += TwoASquare;
1309  if ((2*EllipseError + XChange) > 0 )
1310  {
1311  X--;
1312  StoppingX -= TwoBSquare;
1313  EllipseError += XChange;
1314  XChange += TwoBSquare;
1315  }
1316  }
1317  X = 0;
1318  Y = YRadius;
1319  XChange = YRadius*YRadius;
1320  YChange = XRadius*XRadius*(1-2*YRadius);
1321  EllipseError = 0;
1322  StoppingX = 0;
1323  StoppingY = TwoASquare*YRadius;
1324  int lastY = Y + 1;
1325  while ( StoppingX <= StoppingY )
1326  {
1327  if (flags & DRAW_FILLED)
1328  {
1329  // Only draw lines if Y has changed
1330  if (lastY != Y)
1331  {
1332  draw_hline(CX-X,CY-Y,X*2+1,cl);
1333  draw_hline(CX-X,CY+Y,X*2+1,cl);
1334  lastY = Y;
1335  }
1336  }
1337  else
1338  {
1339  draw_pixel(CX-X,CY-Y,cl);
1340  draw_pixel(CX-X,CY+Y,cl);
1341  draw_pixel(CX+X,CY-Y,cl);
1342  draw_pixel(CX+X,CY+Y,cl);
1343  }
1344  X++;
1345  StoppingX += TwoBSquare;
1346  EllipseError += XChange;
1347  XChange += TwoBSquare;
1348  if ((2*EllipseError + YChange) > 0 )
1349  {
1350  Y--;
1351  StoppingY -= TwoASquare;
1352  EllipseError += YChange;
1353  YChange += TwoASquare;
1354  }
1355  }
1356 }
color draw_get_pixel ( coord  x,
coord  y 
)

Definiert in Zeile 461 der Datei gui_draw.c.

462 {
463 #ifndef THUMB_FW
464  if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return 0;
465  if (conf.rotate_osd)
466  {
467 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
469 #else
471 #endif
472  }
473  else
474  {
475 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
477 #else
479 #endif
480  }
481 #else
482  // DIGIC 6 not supported
483  (void)x; (void)y;
484  return 0;
485 #endif
486 }
color draw_get_pixel_unrotated ( coord  x,
coord  y 
)

Definiert in Zeile 488 der Datei gui_draw.c.

489 {
490 #ifndef THUMB_FW
491  if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return 0;
492 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
494 #else
496 #endif
497 #else
498  // DIGIC 6 not supported
499  (void)x; (void)y;
500  return 0;
501 #endif
502 }
void draw_hline ( coord  x,
coord  y,
int  len,
color  cl 
)

Definiert in Zeile 584 der Datei gui_draw.c.

585 {
586  if ((y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return;
587  if (x < 0) { len += x; x = 0; }
588  if ((x + len) > camera_screen.width) len = camera_screen.width - x;
589  if (conf.rotate_osd)
590  {
591  if ((y == camera_screen.height-1) && ((x+len) >= camera_screen.width-1)) { x--; len--; } // Skip guard pixel
592  }
593  else
594  {
595  if ((y == 0) && (x == 0)) { x++; len--; } // Skip guard pixel
596  }
597  register unsigned int offset = y * camera_screen.buffer_width + ASPECT_XCORRECTION(x);
598  len = ASPECT_XCORRECTION(len); // Scale the line length if needed
599  for (; len>0; len--, offset++)
600  draw_pixel_proc(offset, cl);
601 }
void draw_icon_cmds ( coord  x,
coord  y,
icon_cmd cmds 
)

Definiert in Zeile 1372 der Datei gui_draw.c.

1373 {
1374  int x1, y1, x2, y2;
1375 #ifdef THUMB_FW
1376  int thickness = RECT_BORDER2;
1377 #else
1378  int thickness = RECT_BORDER1;
1379 #endif
1380  while (1)
1381  {
1382 #ifdef THUMB_FW
1383  x1 = cmds->x1<<1;
1384  y1 = cmds->y1<<1;
1385  x2 = cmds->x2<<1;
1386  y2 = cmds->y2<<1;
1387 #else
1388  x1 = cmds->x1;
1389  y1 = cmds->y1;
1390  x2 = cmds->x2;
1391  y2 = cmds->y2;
1392 #endif
1393  color cf = chdk_colors[cmds->cf]; // Convert color indexes to actual colors
1394  color cb = chdk_colors[cmds->cb];
1395  switch (cmds->action)
1396  {
1397  default:
1398  case IA_END:
1399  return;
1400  case IA_HLINE:
1401  draw_hline(x+x1, y+y1, x2, cb);
1402 #ifdef THUMB_FW
1403  draw_hline(x+x1, y+y1+1, x2, cb);
1404 #endif
1405  break;
1406  case IA_VLINE:
1407  draw_vline(x+x1, y+y1, y2, cb);
1408 #ifdef THUMB_FW
1409  draw_vline(x+x1+1, y+y1, y2, cb);
1410 #endif
1411  break;
1412  case IA_LINE:
1413 #ifdef THUMB_FW
1414  draw_line_x2(x+x1, y+y1, x+x2, y+y2, cb);
1415 #else
1416  draw_line(x+x1, y+y1, x+x2, y+y2, cb);
1417 #endif
1418  break;
1419  case IA_RECT:
1420 #ifdef THUMB_FW
1421  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness);
1422 #else
1423  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness);
1424 #endif
1425  break;
1426  case IA_FILLED_RECT:
1427 #ifdef THUMB_FW
1428  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED);
1429 #else
1430  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED);
1431 #endif
1432  break;
1433  case IA_ROUND_RECT:
1434 #ifdef THUMB_FW
1435  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness|RECT_ROUND_CORNERS);
1436 #else
1437  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness|RECT_ROUND_CORNERS);
1438 #endif
1439  break;
1440  case IA_FILLED_ROUND_RECT:
1441 #ifdef THUMB_FW
1442  draw_rectangle(x+x1, y+y1, x+x2+1, y+y2+1, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED|RECT_ROUND_CORNERS);
1443 #else
1444  draw_rectangle(x+x1, y+y1, x+x2, y+y2, MAKE_COLOR(cb,cf), thickness|DRAW_FILLED|RECT_ROUND_CORNERS);
1445 #endif
1446  break;
1447  }
1448  cmds++;
1449  }
1450 }
void draw_init ( )

Definiert in Zeile 391 der Datei gui_draw.c.

392 {
393 #ifndef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
396 #endif
398 
399  draw_set_guard();
400 }
int draw_is_suspended ( void  )

Definiert in Zeile 412 der Datei gui_draw.c.

413 {
415 }
void draw_line ( coord  x1,
coord  y1,
coord  x2,
coord  y2,
color  cl 
)

Definiert in Zeile 507 der Datei gui_draw.c.

508 {
509  unsigned char steep = abs(y2 - y1) > abs(x2 - x1);
510  if (steep)
511  {
512  swap(x1, y1);
513  swap(x2, y2);
514  }
515  if (x1 > x2)
516  {
517  swap(x1, x2);
518  swap(y1, y2);
519  }
520  int deltax = x2 - x1;
521  int deltay = abs(y2 - y1);
522  int error = 0;
523  int y = y1;
524  int ystep = (y1 < y2)?1:-1;
525  int x;
526  for (x=x1; x<=x2; ++x)
527  {
528  if (steep) draw_pixel(y, x, cl);
529  else draw_pixel(x, y, cl);
530  error += deltay;
531  if ((error<<1) >= deltax)
532  {
533  y += ystep;
534  error -= deltax;
535  }
536  }
537 }
void draw_osd_string ( OSD_pos  pos,
int  xo,
int  yo,
char *  s,
twoColors  c,
OSD_scale  scale 
)

Definiert in Zeile 1209 der Datei gui_draw.c.

1210 {
1211  if ((scale.x == 0) || (scale.y == 0) || ((scale.x == 1) && (scale.y == 1)))
1212  draw_string(pos.x+xo, pos.y+yo, s, c);
1213  else
1214  draw_string_scaled(pos.x+(xo*scale.x), pos.y+(yo*scale.y), s, c, scale.x, scale.y);
1215 }
void draw_pixel ( coord  x,
coord  y,
color  cl 
)

Definiert in Zeile 432 der Datei gui_draw.c.

433 {
434  // Make sure pixel is on screen. Skip top left pixel if screen erase detection is on to avoid triggering the detector.
435  if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height) || ((x == 0) && (y == 0))) return;
436  else
437  {
438  register unsigned int offset = y * camera_screen.buffer_width + ASPECT_XCORRECTION(x);
439  draw_pixel_proc(offset, cl);
440 #if CAM_USES_ASPECT_CORRECTION
441  draw_pixel_proc(offset+1, cl); // Draw second pixel if screen scaling is needed
442 #endif
443  }
444 }
void draw_pixel_proc_rotated ( unsigned int  offset,
color  cl 
)

Definiert in Zeile 158 der Datei gui_draw.c.

159 {
161 }
static void draw_pixel_std ( unsigned int  offset,
color  cl 
)
static

Definiert in Zeile 55 der Datei gui_draw.c.

56 {
57 #ifndef THUMB_FW
58  // drawing on 8bpp paletted overlay
59 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
61 #else
63 #endif
64 #else
65  // DIGIC 6, drawing on 16bpp YUV overlay
66 
67 #ifndef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
68 #error DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY is required for DIGIC 6 ports
69 #endif
70 
71  int active_buffer_index = active_bitmap_buffer & 1;
72  unsigned char *obu = (unsigned char *)(&opacity_buffer[active_buffer_index][0]);
73  unsigned char *bbu = (unsigned char *)(&bitmap_buffer[active_buffer_index][0]);
74  unsigned int y;
75  unsigned int o;
76  CALC_YUV_LUMA_OPACITY_FOR_COLOR(cl,y,o);
77  obu[offset] = o;
78  register unsigned int offs2 = (offset>>1)<<2;
79  if (offset&1) // x is odd
80  {
81  bbu[offs2+3] = y; // Y
82  }
83  else // x is even
84  {
85  bbu[offs2+1] = y; // Y
86  }
87  unsigned int u;
88  unsigned int v;
89  CALC_YUV_CHROMA_FOR_COLOR(cl,u,v);
90  bbu[offs2+0] = u; // U?
91  bbu[offs2+2] = v; // V?
92 #endif
93 }
void draw_pixel_unrotated ( coord  x,
coord  y,
color  cl 
)

Definiert in Zeile 446 der Datei gui_draw.c.

447 {
448  // Make sure pixel is on screen. Skip top left pixel if screen erase detection is on to avoid triggering the detector.
449  if ((x < 0) || (y < 0) || (x >= camera_screen.width) || (y >= camera_screen.height) || ((x == 0) && (y == 0))) return;
450  else
451  {
452  register unsigned int offset = y * camera_screen.buffer_width + ASPECT_XCORRECTION(x);
453  draw_pixel_proc_norm(offset, cl);
454 #if CAM_USES_ASPECT_CORRECTION
455  draw_pixel_proc_norm(offset+1, cl); // Draw second pixel if screen scaling is needed
456 #endif
457  }
458 }
void draw_rectangle ( coord  x1,
coord  y1,
coord  x2,
coord  y2,
twoColors  cl,
int  flags 
)

Definiert in Zeile 615 der Datei gui_draw.c.

616 {
617  // Normalise values
618  if (x1 > x2)
619  swap(x1, x2);
620  if (y1 > y2)
621  swap(y1, y2);
622 
623  // Check if completely off screen
624  if ((x2 < 0) || (y2 < 0) || (x1 >= camera_screen.width) || (y1 >= camera_screen.height))
625  return;
626 
627  int round = (flags & RECT_ROUND_CORNERS) ? 1 : 0;
628  int thickness;
629  int i;
630 
631  // Shadow (do this first, as edge draw shrinks rectangle for fill)
632  if (flags & RECT_SHADOW_MASK)
633  {
634  thickness = ((flags & RECT_SHADOW_MASK) >> 4);
635  for (i=1; i<=thickness; i++)
636  {
637  draw_vline(x2+i, y1+1, y2 - y1, COLOR_BLACK);
638  draw_hline(x1+1, y2+i, x2 - x1 + thickness, COLOR_BLACK);
639  }
640  }
641 
642  // Edge
643  thickness = flags & RECT_BORDER_MASK;
644  for (i=0; i<thickness; i++)
645  {
646  // Clipping done in draw_hline and draw_vline
647  draw_vline(x1, y1 + round * 2, y2 - y1 - round * 4 + 1, FG_COLOR(cl));
648  draw_vline(x2, y1 + round * 2, y2 - y1 - round * 4 + 1, FG_COLOR(cl));
649  draw_hline(x1 + 1 + round, y1, x2 - x1 - round * 2 - 1, FG_COLOR(cl));
650  draw_hline(x1 + 1 + round, y2, x2 - x1 - round * 2 - 1, FG_COLOR(cl));
651 
652  x1++; x2--;
653  y1++; y2--;
654 
655  round = 0;
656  }
657 
658  // Fill
659  if (flags & DRAW_FILLED)
660  {
661  // Clip values
662  if (x1 < 0) x1 = 0;
663  if (y1 < 0) y1 = 0;
664  if (x2 >= camera_screen.width) x2 = camera_screen.width - 1;
665  if (y2 >= camera_screen.height) y2 = camera_screen.height - 1;
666 
667  coord y;
668  for (y = y1; y <= y2; ++y)
669  draw_hline(x1, y, x2 - x1 + 1, BG_COLOR(cl));
670  }
671 }
void draw_restore ( )

Definiert in Zeile 418 der Datei gui_draw.c.

419 {
420  if(draw_is_suspended()) {
421  return;
422  }
424 
425  draw_set_guard();
426 #ifdef CAM_TOUCHSCREEN_UI
427  redraw_buttons = 1;
428 #endif
429 }
void draw_set_draw_proc ( void(*)(unsigned int offset, color cl pixel_proc)

Definiert in Zeile 163 der Datei gui_draw.c.

164 {
165  draw_pixel_proc_norm = (pixel_proc)?pixel_proc:draw_pixel_std;
166  if (conf.rotate_osd)
167  {
170  }
171  else
172  {
174  }
175 }
void draw_set_guard ( )

Definiert in Zeile 354 der Datei gui_draw.c.

355 {
356 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
357  *((unsigned char*)(bitmap_buffer[0])) = GUARD_VAL;
358  *((unsigned char*)(bitmap_buffer[1])) = GUARD_VAL;
359 #else
360  *((unsigned char*)(frame_buffer[0])) = GUARD_VAL;
361  *((unsigned char*)(frame_buffer[1])) = GUARD_VAL;
362 #endif
363 }
int draw_string ( coord  x,
coord  y,
const char *  s,
twoColors  cl 
)

Definiert in Zeile 1055 der Datei gui_draw.c.

1056 {
1058 }
int draw_string_clipped ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  max_width 
)

Definiert in Zeile 1037 der Datei gui_draw.c.

1038 {
1039  while (*s && (*s != '\n') && (max_width >= FONT_WIDTH))
1040  {
1041  draw_char(x, y, *s, cl);
1042  s++;
1043  max_width -= FONT_WIDTH;
1044  x += FONT_WIDTH;
1045  if ((x>=camera_screen.width) && (*s))
1046  {
1047  draw_char(x-FONT_WIDTH,y, '>', cl);
1048  break;
1049  }
1050  }
1051  return x;
1052 }
int draw_string_justified ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  xo,
int  max_width,
int  justification 
)

Definiert in Zeile 1065 der Datei gui_draw.c.

1066 {
1067  // Get length in pixels
1068  const char *e = strchr(s, '\n');
1069  int l;
1070  if (e)
1071  l = (e - s) * FONT_WIDTH;
1072  else
1073  l = strlen(s) * FONT_WIDTH;
1074  if (l > max_width) l = max_width;
1075 
1076  // Calculate justification offset
1077  switch (justification & 0xF)
1078  {
1079  case TEXT_RIGHT:
1080  xo = (max_width - l);
1081  break;
1082  case TEXT_CENTER:
1083  xo = ((max_width - l) >> 1);
1084  break;
1085  }
1086 
1087  // Fill left side
1088  if ((justification & TEXT_FILL) && (xo > 0))
1090 
1091  // Draw string (get length drawn in pixels)
1092  l = draw_string_clipped(x+xo, y, s, cl, max_width - xo) - x;
1093 
1094  // Fill right side
1095  if ((justification & TEXT_FILL) && (l < max_width))
1096  draw_rectangle(x+l, y, x+max_width-1, y+FONT_HEIGHT-1, cl, RECT_BORDER0|DRAW_FILLED);
1097 
1098  // Return start of first character
1099  return x+xo;
1100 }
void draw_string_scaled ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  xsize,
int  ysize 
)

Definiert in Zeile 1157 der Datei gui_draw.c.

1158 {
1159  while (*s && (*s != '\n'))
1160  {
1161  draw_char_scaled(x, y, *s, cl, xsize, ysize);
1162  s++;
1163  x+=FONT_WIDTH*xsize;
1164  if ((x>=camera_screen.width) && (*s))
1165  {
1166  draw_char_scaled(x-FONT_WIDTH*xsize,y, '>', cl, xsize, ysize);
1167  break;
1168  }
1169  }
1170 }
void draw_suspend ( int  ms)

Definiert in Zeile 403 der Datei gui_draw.c.

404 {
405  int t=get_tick_count() + ms;
406  // only change if not already suspended to a later time
407  if(t > draw_restore_suspend_tick) {
409  }
410 }
int draw_test_guard ( )

Definiert in Zeile 365 der Datei gui_draw.c.

366 {
367 #ifdef DRAW_ON_ACTIVE_BITMAP_BUFFER_ONLY
368  if (*((unsigned char*)(bitmap_buffer[active_bitmap_buffer])) != GUARD_VAL) return 0;
369 #else
370  if (*((unsigned char*)(frame_buffer[0])) != GUARD_VAL) return 0;
371  if (*((unsigned char*)(frame_buffer[1])) != GUARD_VAL) return 0;
372 #endif
373  return 1;
374 }
int draw_text_justified ( coord  x,
coord  y,
const char *  s,
twoColors  cl,
int  max_chars,
int  max_lines,
int  justification 
)

Definiert in Zeile 1138 der Datei gui_draw.c.

1139 {
1140  int rx = 0;
1141  while (s && *s && (max_lines > 0))
1142  {
1143  const char *e = strchr(s, '\n');
1144  if (e) e++;
1145 
1146  rx = draw_string_justified(x, y, s, cl, 0, max_chars*FONT_WIDTH, justification);
1147 
1148  s = e;
1149  y += FONT_HEIGHT;
1150  max_lines--;
1151  }
1152  return rx;
1153 }
void draw_txt_string ( coord  col,
coord  row,
const char *  str,
twoColors  cl 
)

Definiert in Zeile 1239 der Datei gui_draw.c.

1240 {
1242 }
void draw_vline ( coord  x,
coord  y,
int  len,
color  cl 
)

Definiert in Zeile 603 der Datei gui_draw.c.

604 {
605  if ((x < 0) || (x >= camera_screen.width) || (y >= camera_screen.height)) return;
606  if (y < 0) { len += y; y = 0; }
608  for (; len>0; len--, y++)
609  draw_pixel(x, y, cl);
610 }
static unsigned char* get_cdata ( unsigned int *  offset,
unsigned int *  size,
const char  ch 
)
static

Definiert in Zeile 682 der Datei gui_draw.c.

683 {
685 
686  *offset = f->skips >> 4; // # of blank lines at top
687  *size = 16 - (f->skips & 0xF); // last line of non-blank data
688  if (*size == *offset) // special case for blank char (top == 15 && bottom == 1)
689  *offset += 1;
690 
691  return (unsigned char*)f + sizeof(FontData) - *offset;
692 }
color get_script_color ( int  cl)

Definiert in Zeile 1469 der Datei gui_draw.c.

1470 {
1471  if (cl < 256)
1472  return cl;
1473  else
1474  return chdk_colors[cl-256];
1475 }
void set_palette ( )

Definiert in Zeile 1459 der Datei gui_draw.c.

1460 {
1461 #ifndef THUMB_FW
1464  else
1466 #endif
1467 }
void set_transparent ( __attribute__((unused)) unsigned int  offst,
__attribute__((unused)) int  n_pixel 
)

Definiert in Zeile 150 der Datei gui_draw.c.

151 {
152 }
int text_dimensions ( const char *  s,
int  width,
int  max_chars,
int *  max_lines 
)

Definiert in Zeile 1107 der Datei gui_draw.c.

1108 {
1109  int l = 0, n;
1110  while (s && *s && (l < *max_lines))
1111  {
1112  const char *e = strchr(s, '\n');
1113  if (e)
1114  {
1115  n = e - s;
1116  e++;
1117  }
1118  else
1119  {
1120  n = strlen(s);
1121  }
1122 
1123  if (n > width) width = n;
1124 
1125  s = e;
1126  l++;
1127  }
1128  *max_lines = l;
1129  if (width > max_chars) width = max_chars;
1130  return width;
1131 }
void update_draw_proc ( )

Definiert in Zeile 177 der Datei gui_draw.c.

twoColors user_color ( confColor  cc)

Definiert in Zeile 1485 der Datei gui_draw.c.

1486 {
1487  color fg = chdkColorToCanonColor(cc.fg);
1488  color bg = chdkColorToCanonColor(cc.bg);
1489 
1490  return MAKE_COLOR(bg,fg);
1491 }

Variablen-Dokumentation

unsigned char* chdk_colors = ply_colors

Definiert in Zeile 1457 der Datei gui_draw.c.

void(* draw_pixel_proc)(unsigned int offset, color cl)

Definiert in Zeile 44 der Datei gui_draw.c.

void(* draw_pixel_proc_norm)(unsigned int offset, color cl)

Definiert in Zeile 45 der Datei gui_draw.c.

int draw_restore_suspend_tick

Definiert in Zeile 42 der Datei gui_draw.c.

char* frame_buffer[2]
static

Definiert in Zeile 51 der Datei gui_draw.c.

unsigned char ply_colors[]

Definiert in Zeile 8 der Datei platform_palette.c.

unsigned char rec_colors[]

Definiert in Zeile 33 der Datei platform_palette.c.

unsigned int rotate_base

Definiert in Zeile 156 der Datei gui_draw.c.