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

gehe zum Quellcode dieser Datei

Makrodefinitionen

#define CELL_SIZE   cellsize
 
#define BORDER_SIZE   6
 
#define CELL_ZOOM   BORDER_SIZE
 
#define DISP_TOP_CHDK   (FONT_HEIGHT + BORDER_SIZE)
 
#define DISP_TOP   disptop
 
#define DISP_LEFT   BORDER_SIZE
 
#define DISP_RIGHT   dispright
 
#define DISP_BOTTOM   dispbottom
 

Funktionen

void gui_module_menu_kbd_process ()
 
int gui_palette_kbd_process ()
 
void gui_palette_draw ()
 
void gui_palette_init (int mode, chdkColor st_color, void(*on_select)(chdkColor clr))
 
static void palette_test ()
 
static void palette_draw ()
 
int _module_can_unload ()
 
int _module_exit_alt ()
 

Variablen

gui_handler GUI_MODE_PALETTE_MODULE
 
static int running = 0
 
static chdkColor cl
 
static int palette_mode
 
static void(* palette_on_select )(chdkColor clr)
 
static int gui_palette_redraw
 
static int test_page
 
libpalette_sym _libpalette
 
ModuleInfo _module_info
 

Makro-Dokumentation

#define BORDER_SIZE   6

Definiert in Zeile 249 der Datei gui_palette.c.

#define CELL_SIZE   cellsize

Definiert in Zeile 248 der Datei gui_palette.c.

#define CELL_ZOOM   BORDER_SIZE

Definiert in Zeile 250 der Datei gui_palette.c.

#define DISP_BOTTOM   dispbottom

Definiert in Zeile 255 der Datei gui_palette.c.

#define DISP_LEFT   BORDER_SIZE

Definiert in Zeile 253 der Datei gui_palette.c.

#define DISP_RIGHT   dispright

Definiert in Zeile 254 der Datei gui_palette.c.

#define DISP_TOP   disptop

Definiert in Zeile 252 der Datei gui_palette.c.

#define DISP_TOP_CHDK   (FONT_HEIGHT + BORDER_SIZE)

Definiert in Zeile 251 der Datei gui_palette.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 358 der Datei gui_palette.c.

359 {
360  return running == 0;
361 }
int _module_exit_alt ( )

Definiert in Zeile 363 der Datei gui_palette.c.

364 {
365  running = 0;
366  return 0;
367 }
void gui_module_menu_kbd_process ( )

Definiert in Zeile 464 der Datei gui_sokoban.c.

465 {
466  running = 0;
468 }
void gui_palette_draw ( )

Definiert in Zeile 338 der Datei gui_palette.c.

339 {
341  palette_test();
342  else
343  palette_draw();
344 }
void gui_palette_init ( int  mode,
chdkColor  st_color,
void(*)(chdkColor clr)  on_select 
)

Definiert in Zeile 31 der Datei gui_palette.c.

32 {
33  running = 1;
34  cl = st_color;
36  palette_on_select = on_select;
38  test_page = 0;
40 }
int gui_palette_kbd_process ( )

Definiert in Zeile 43 der Datei gui_palette.c.

44 {
45  switch (kbd_get_autoclicked_key())
46  {
47  case KEY_DOWN:
49  {
50  if (cl.type)
51  {
52  cl.type = 0;
53  if (cl.col > 15)
54  cl.col = 15;
55  }
56  else
57  {
58  if ((cl.col & 0xF0) == 0xF0)
59  {
60  cl.type = 1;
61  cl.col &= 0x0F;
62  }
63  else
64  {
65  cl.col = (((cl.col+16)&0xf0)|(cl.col&0x0f));
66  }
67  }
69  }
70  break;
71  case KEY_UP:
73  {
74  if (cl.type)
75  {
76  cl.type = 0;
77  if (cl.col > 15)
78  cl.col = 15;
79  cl.col |= 0xF0;
80  }
81  else
82  {
83  if ((cl.col & 0xF0) == 0x00)
84  {
85  cl.type = 1;
86  }
87  else
88  {
89  cl.col = (((cl.col-16)&0xf0)|(cl.col&0x0f));
90  }
91  }
93  }
94  break;
95  case KEY_LEFT:
97  {
98  if (cl.type)
99  {
100  if (cl.col-- == 0) cl.col = IDX_COLOR_MAX;
101  }
102  else
103  {
104  cl.col = ((cl.col&0xf0)|((cl.col-1)&0x0f));
105  }
106  }
107  else
108  {
109  if (--test_page < 0) test_page = 2;
110  }
111  gui_palette_redraw = 1;
112  break;
113  case KEY_RIGHT:
115  {
116  if (cl.type)
117  {
118  if (cl.col++ == IDX_COLOR_MAX) cl.col = 0;
119  }
120  else
121  {
122  cl.col = ((cl.col&0xf0)|((cl.col+1)&0x0f));
123  }
124  }
125  else
126  {
127  if (++test_page > 2) test_page = 0;
128  }
129  gui_palette_redraw = 1;
130  break;
131  case KEY_SET:
133  {
134  if (palette_on_select)
137  }
138  break;
139  }
140  return 0;
141 }
static void palette_draw ( )
static

Definiert in Zeile 257 der Datei gui_palette.c.

258 {
259  unsigned int x, y, xl, xr;
260  color c;
261  static char buf[64];
262  static int cellsize = 0, disptop, dispright, dispbottom;
263 
264  if (!cellsize)
265  {
266  // calculate these only once
267  cellsize = (camera_screen.height - FONT_HEIGHT - 3 * BORDER_SIZE -1 ) / 17;
268  disptop = camera_screen.height + DISP_TOP_CHDK - cellsize * 16 - FONT_HEIGHT - 2 * BORDER_SIZE - 1;
269  dispright = DISP_LEFT + cellsize * 16;
270  dispbottom = DISP_TOP + cellsize * 16;
271  }
272 
275  int *pal = (int*)vid_get_bitmap_active_palette();
276 
277  if (gui_palette_redraw)
278  {
279  // Draw top text line - current color + instructions
281  draw_string(xr-29*FONT_WIDTH, 0, " Use \x18\x19\x1b\x1a to change color ", MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
282  if ( pal )
283  sprintf(buf, " %s: 0x%02hX 0x%08X", lang_str(LANG_PALETTE_TEXT_COLOR), cl.col, pal[chdkColorToCanonColor(cl)]);
284  else
285  sprintf(buf, " %s: 0x%02hX", lang_str(LANG_PALETTE_TEXT_COLOR), cl.col );
287 
288  // Draw gray borders
293 
294  // Draw CHDK Palette color boxes
295  c = 0;
296  for (x=DISP_LEFT; x<DISP_LEFT+CELL_SIZE*(IDX_COLOR_MAX+1); x+=CELL_SIZE, c++)
297  {
299  }
302 
303  // Draw Canon Palette color boxes
304  c = 0;
305  for (y=DISP_TOP; y<DISP_BOTTOM; y+=CELL_SIZE)
306  {
307  for (x=DISP_LEFT; x<DISP_RIGHT; x+=CELL_SIZE, c++)
308  {
310  }
311  }
312  draw_string(xl+DISP_RIGHT+BORDER_SIZE, DISP_TOP+10, "<-- Canon", MAKE_COLOR(COLOR_GREY,COLOR_WHITE));
313 
314  // Co-ordinate of selected color
315  if (cl.type)
316  {
317  y = DISP_TOP_CHDK;
318  x = DISP_LEFT + cl.col * CELL_SIZE;
319  }
320  else
321  {
322  y = DISP_TOP + ((cl.col>>4)&0x0F) * CELL_SIZE;
323  x = DISP_LEFT + (cl.col&0x0F) * CELL_SIZE;
324  }
325 
326  // Highlight selected color
328 
329  // Fill 'sample' area with selected color
331 
332  gui_palette_redraw = 0;
333  }
334 }
static void palette_test ( )
static

Definiert in Zeile 144 der Datei gui_palette.c.

145 {
146  unsigned int x, y, xl, xr, xt, w, h;
147  color c, co;
148  static char buf[64];
149 
152 
153  if (gui_palette_redraw)
154  {
155  // Draw top text line - current color + instructions
157  draw_string(xr-22*FONT_WIDTH, 0, "Use \x1b\x1a to change page", MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
158 
159  color cols[3][20] = {
160  {
164  },
165  {
169  },
170  {
171  3 ,6 ,9 ,12 ,15,
172  4 ,7 ,10 ,13 ,16,
173  5 ,8 ,11 ,14 ,17,
174  1 ,1 ,1 ,18 ,1
175  }
176  };
177 
178  char *nams[3][20] = {
179  {
180  "white", "red", "dark red", "light red",
181  "green", "blue", "light blue", "yellow",
182  "grey", "dark grey", "light grey", "transparent"
183  },
184  {
185  "red", "green", "blue", "cyan", "magenta", "yellow",
186  },
187  {
188  "red", "green", "blue", "grey", "yellow",
189  "dk red", "dk green", "dk blue", "dk grey", "dk yellow",
190  "lt red", "lt green", "lt blue", "lt grey", "lt yellow",
191  "", "", "", "trns grey", ""
192  }
193  };
194 
195  if (test_page == 0)
196  {
197  draw_string(xl, 0, "System Colors", MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
198  c = 0;
199  w = camera_screen.disp_width / 4;
200  h = (camera_screen.height - (2 * FONT_HEIGHT)) / 3;
201  for (y=0; y<3; y++)
202  {
203  for (x=0; x<4; x++, c++)
204  {
205  draw_rectangle(xl+(x*w), (2*FONT_HEIGHT)+(y*h), xl+(x*w)+w-1, (2*FONT_HEIGHT)+(y*h)+h-FONT_HEIGHT-6, MAKE_COLOR(cols[test_page][c],cols[test_page][c]), RECT_BORDER0|DRAW_FILLED);
206  draw_string(xl+(x*w),(2*FONT_HEIGHT)+(y*h)+h-FONT_HEIGHT-3, nams[test_page][c], MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
207  }
208  }
209  }
210  else if (test_page == 1)
211  {
212  draw_string(xl, 0, "Histogram Colors", MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
213  c = 0;
214  w = camera_screen.disp_width / 2;
215  h = (camera_screen.height - (2 * FONT_HEIGHT)) / 3;
216  for (y=0; y<3; y++)
217  {
218  for (x=0; x<2; x++, c++)
219  {
220  draw_rectangle(xl+(x*w), (2*FONT_HEIGHT)+(y*h), xl+(x*w)+w-1, (2*FONT_HEIGHT)+(y*h)+h-FONT_HEIGHT-6, MAKE_COLOR(cols[test_page][c],cols[test_page][c]), RECT_BORDER0|DRAW_FILLED);
221  draw_string(xl+(x*w),(2*FONT_HEIGHT)+(y*h)+h-FONT_HEIGHT-3, nams[test_page][c], MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
222  }
223  }
224  }
225  else if (test_page == 2)
226  {
227  draw_string(xl, 0, "Script/Icon Colors", MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
228  c = 0;
229  w = camera_screen.disp_width / 5;
230  h = (camera_screen.height - (2 * FONT_HEIGHT)) / 4;
231  for (y=0; y<4; y++)
232  {
233  for (x=0; x<5; x++, c++)
234  {
235  draw_rectangle(xl+(x*w), (2*FONT_HEIGHT)+(y*h), xl+(x*w)+w-1, (2*FONT_HEIGHT)+(y*h)+h-FONT_HEIGHT-6,
237  draw_string(xl+(x*w),(2*FONT_HEIGHT)+(y*h)+h-FONT_HEIGHT-3, nams[test_page][c], MAKE_COLOR(COLOR_BLACK, COLOR_WHITE));
238  }
239  }
240  }
241 
242  gui_palette_redraw = 0;
243  }
244 }

Variablen-Dokumentation

libpalette_sym _libpalette
Initialisierung:

Definiert in Zeile 371 der Datei gui_palette.c.

ModuleInfo _module_info
chdkColor cl
static

Definiert in Zeile 24 der Datei gui_palette.c.

gui_handler GUI_MODE_PALETTE_MODULE
Initialisierung:

Definiert in Zeile 19 der Datei gui_palette.c.

int gui_palette_redraw
static

Definiert in Zeile 27 der Datei gui_palette.c.

int palette_mode
static

Definiert in Zeile 25 der Datei gui_palette.c.

void(* palette_on_select)(chdkColor clr)
static

Definiert in Zeile 26 der Datei gui_palette.c.

int running = 0
static

Definiert in Zeile 23 der Datei gui_palette.c.

int test_page
static

Definiert in Zeile 28 der Datei gui_palette.c.