CHDK_DE Vorschauversion  Trunk Rev. 6014
 Alle Datenstrukturen Dateien Funktionen Variablen Typdefinitionen Aufzählungen Aufzählungswerte Makrodefinitionen
gui_palette.c-Dateireferenz
#include "camera_info.h"
#include "color.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 248 der Datei gui_palette.c.

#define CELL_SIZE   cellsize

Definiert in Zeile 247 der Datei gui_palette.c.

#define CELL_ZOOM   BORDER_SIZE

Definiert in Zeile 249 der Datei gui_palette.c.

#define DISP_BOTTOM   dispbottom

Definiert in Zeile 254 der Datei gui_palette.c.

#define DISP_LEFT   BORDER_SIZE

Definiert in Zeile 252 der Datei gui_palette.c.

#define DISP_RIGHT   dispright

Definiert in Zeile 253 der Datei gui_palette.c.

#define DISP_TOP   disptop

Definiert in Zeile 251 der Datei gui_palette.c.

#define DISP_TOP_CHDK   (FONT_HEIGHT + BORDER_SIZE)

Definiert in Zeile 250 der Datei gui_palette.c.

Dokumentation der Funktionen

int _module_can_unload ( )

Definiert in Zeile 357 der Datei gui_palette.c.

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

Definiert in Zeile 362 der Datei gui_palette.c.

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

Definiert in Zeile 463 der Datei gui_sokoban.c.

464 {
465  running = 0;
467 }
void gui_palette_draw ( )

Definiert in Zeile 337 der Datei gui_palette.c.

338 {
340  palette_test();
341  else
342  palette_draw();
343 }
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 256 der Datei gui_palette.c.

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

Definiert in Zeile 144 der Datei gui_palette.c.

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

Variablen-Dokumentation

libpalette_sym _libpalette
Initialisierung:

Definiert in Zeile 370 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.