CHDK_DE Vorschauversion  Trunk Rev. 5163
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
gui_grid.c-Dateireferenz
#include "camera_info.h"
#include "stdlib.h"
#include "keyboard.h"
#include "conf.h"
#include "gui.h"
#include "gui_draw.h"
#include "gui_lang.h"
#include "gui_grid.h"
#include "fileutil.h"
#include "module_def.h"
+ Include-Abhängigkeitsdiagramm für gui_grid.c:

gehe zum Quellcode dieser Datei

Datenstrukturen

struct  gline
 

Makrodefinitionen

#define GRID_REDRAW_INTERVAL   4
 

Aufzählungen

enum  grid_elem_type {
  GRID_ELEM_LINE, GRID_ELEM_RECT, GRID_ELEM_FILLED_RECT, GRID_ELEM_ELLIPSE,
  GRID_ELEM_FILLED_ELLIPSE
}
 

Funktionen

static void grid_lines_free_data ()
 
static void process_title (const char *title)
 
static void process_element (const char *str, int n, grid_elem_type type)
 
static int parse_grid_file (char *ptr, int size)
 
void grid_lines_load (const char *fn)
 
void gui_grid_draw_osd (int force)
 
int _module_loader (unsigned int *chdk_export_list)
 
int _module_unloader ()
 
int _module_can_unload ()
 

Variablen

static int grid_loading = 0
 
static int interval = GRID_REDRAW_INTERVAL
 
static struct glinehead =NULL
 
static struct glinetop =NULL
 
static const char * grid_default
 
libgrids_sym _libgrids
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define GRID_REDRAW_INTERVAL   4

Definiert in Zeile 14 der Datei gui_grid.c.

Dokumentation der Aufzählungstypen

Aufzählungswerte
GRID_ELEM_LINE 
GRID_ELEM_RECT 
GRID_ELEM_FILLED_RECT 
GRID_ELEM_ELLIPSE 
GRID_ELEM_FILLED_ELLIPSE 

Definiert in Zeile 17 der Datei gui_grid.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 215 der Datei gui_grid.c.

216 {
217  return (conf.show_grid_lines == 0 && !grid_loading);
218 }
int _module_loader ( unsigned int *  chdk_export_list)

Definiert in Zeile 199 der Datei gui_grid.c.

200 {
202  return 0;
203 }
int _module_unloader ( )

Definiert in Zeile 209 der Datei gui_grid.c.

210 {
212  return 0;
213 }
static void grid_lines_free_data ( )
static

Definiert in Zeile 41 der Datei gui_grid.c.

41  {
42  struct gline *ptr = head, *prev;
43 
44  while (ptr) {
45  prev=ptr;
46  ptr=ptr->next;
47  free(prev);
48  }
49  head=top=NULL;
50 }
void grid_lines_load ( const char *  fn)

Definiert in Zeile 140 der Datei gui_grid.c.

141 {
142  grid_loading = 1;
143  if (process_file(fn, parse_grid_file, 1) > 0) // non-zero length file found?
144  {
145  if (conf.grid_title[0]==0) // use filename if no @title string found
146  {
147  char* c = strrchr(fn, '/');
148  strncpy(conf.grid_title, (c)?c+1:fn, sizeof(conf.grid_title));
149  conf.grid_title[sizeof(conf.grid_title)-1] = 0;
150  }
152  }
153  grid_loading = 0;
154 }
void gui_grid_draw_osd ( int  force)

Definiert in Zeile 157 der Datei gui_grid.c.

158 {
160  {
161  struct gline *ptr;
163 
164  if (force || --interval==0) {
165  for (ptr=head; ptr; ptr=ptr->next) {
166  switch (ptr->type) {
167  case GRID_ELEM_LINE:
168  draw_line(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?FG_COLOR(col):ptr->clf);
169  break;
170  case GRID_ELEM_RECT:
171  draw_rectangle(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?col:MAKE_COLOR(ptr->clb, ptr->clf), RECT_BORDER1);
172  break;
174  draw_rectangle(ptr->x0, ptr->y0, ptr->x1, ptr->y1, (conf.grid_force_color)?col:MAKE_COLOR(ptr->clb, ptr->clf), RECT_BORDER1|DRAW_FILLED);
175  break;
176  case GRID_ELEM_ELLIPSE:
177  draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (conf.grid_force_color)?FG_COLOR(col):ptr->clf, 0);
178  break;
180  draw_ellipse(ptr->x0, ptr->y0, (unsigned int)(ptr->x1), (unsigned int)(ptr->y1), (conf.grid_force_color)?BG_COLOR(col):ptr->clf, DRAW_FILLED);
181  break;
182  }
183  }
185  }
186  }
187 }
static int parse_grid_file ( char *  ptr,
int  size 
)
static

Definiert in Zeile 98 der Datei gui_grid.c.

99 {
100  conf.grid_title[0]=0;
101 
102  if (size > 0)
103  {
105 
106  while (ptr[0])
107  {
108  while (ptr[0]==' ' || ptr[0]=='\t') ++ptr; // whitespaces
109  if (ptr[0]=='@')
110  {
111  if (strncmp("@title", ptr, 6)==0) {
112  ptr+=6;
114  } else if (strncmp("@line", ptr, 5)==0) {
115  ptr+=5;
117  } else if (strncmp("@rectf", ptr, 6)==0) {
118  ptr+=6;
120  } else if (strncmp("@rect", ptr, 5)==0) {
121  ptr+=5;
123  } else if (strncmp("@elpsf", ptr, 6)==0) {
124  ptr+=6;
126  } else if (strncmp("@elps", ptr, 5)==0) {
127  ptr+=5;
129  }
130  }
131  while (ptr[0] && ptr[0]!='\n') ++ptr; // unless end of line
132  if (ptr[0]) ++ptr;
133  }
134  }
135 
136  return size;
137 }
static void process_element ( const char *  str,
int  n,
grid_elem_type  type 
)
static

Definiert in Zeile 66 der Datei gui_grid.c.

66  {
67  register const char *ptr = str;
68  char *nptr;
69  register int i;
70  long nums[6];
71  struct gline *gptr;
72 
73  for (i=0; i<(sizeof(nums)/sizeof(nums[0])) && i<n; ++i) {
74  while (ptr[0]==' ' || ptr[0]=='\t' || ptr[0]==',') ++ptr; // whitespaces
75  nums[i] = strtol(ptr, &nptr, 0);
76  if (nptr == ptr) { // error
77  return;
78  } else {
79  ptr = nptr;
80  }
81  }
82 
83  gptr = malloc(sizeof(struct gline));
84 
85  if (gptr) {
86  gptr->type=type;
87  gptr->x0=nums[0]; gptr->y0=nums[1];
88  gptr->x1=nums[2]; gptr->y1=nums[3];
89  gptr->clf=nums[4]; gptr->clb=nums[5];
90  if (!head) head=gptr;
91  if (top) top->next=gptr;
92  gptr->next=NULL;
93  top=gptr;
94  }
95 }
static void process_title ( const char *  title)
static

Definiert in Zeile 53 der Datei gui_grid.c.

53  {
54  register const char *ptr = title;
55  register int i=0;
56 
57  while (ptr[0]==' ' || ptr[0]=='\t') ++ptr; // whitespaces
58  while (i<(sizeof(conf.grid_title)-1) && ptr[i] && ptr[i]!='\r' && ptr[i]!='\n') {
59  conf.grid_title[i]=ptr[i];
60  ++i;
61  }
62  conf.grid_title[i]=0;
63 }

Variablen-Dokumentation

libgrids_sym _libgrids
Initialisierung:

Definiert in Zeile 222 der Datei gui_grid.c.

ModuleInfo _module_info
Initialisierung:

Definiert in Zeile 232 der Datei gui_grid.c.

const char* grid_default
static
Initialisierung:
=
"@title Default grid\n"
"@line 0,79,359,79,17\n"
"@line 0,160,359,160,17\n"

Definiert in Zeile 35 der Datei gui_grid.c.

int grid_loading = 0
static

Definiert in Zeile 32 der Datei gui_grid.c.

struct gline* head =NULL
static

Definiert in Zeile 34 der Datei gui_grid.c.

int interval = GRID_REDRAW_INTERVAL
static

Definiert in Zeile 33 der Datei gui_grid.c.

struct gline * top =NULL
static

Definiert in Zeile 34 der Datei gui_grid.c.