11 PictureItem::PictureItem()
24 PictureItem::~PictureItem()
28 void PictureItem::copy_from(PictureItem *src)
30 strcpy(this->name, src->name);
31 this->device_id = src->device_id;
34 this->default_ = src->default_;
35 this->step = src->step;
36 this->type = src->type;
37 this->value = src->value;
40 char* PictureItem::get_default_string(char *string)
42 sprintf(string, "VIDEO_%s_VALUE", name);
43 for(int i = 0; i < strlen(string); i++)
44 string[i] = toupper(string[i]);
55 PictureConfig::PictureConfig(MWindow *mwindow)
57 this->mwindow = mwindow;
71 PictureConfig::~PictureConfig()
73 controls.remove_all_objects();
76 void PictureConfig::copy_settings(PictureConfig *picture)
78 this->brightness = picture->brightness;
79 this->hue = picture->hue;
80 this->color = picture->color;
81 this->contrast = picture->contrast;
82 this->whiteness = picture->whiteness;
85 for(int i = 0; i < picture->controls.total; i++)
87 PictureItem *src_item = picture->controls.values[i];
88 PictureItem *dst_item = 0;
89 for(int j = 0; j < controls.total; j++)
91 if(controls.values[j]->device_id == src_item->device_id)
93 dst_item = controls.values[j];
99 dst_item = new PictureItem;
100 controls.append(dst_item);
102 dst_item->copy_from(src_item);
106 void PictureConfig::copy_usage(PictureConfig *picture)
108 this->use_brightness = picture->use_brightness;
109 this->use_contrast = picture->use_contrast;
110 this->use_color = picture->use_color;
111 this->use_hue = picture->use_hue;
112 this->use_whiteness = picture->use_whiteness;
114 // Add the controls if they don't exists but don't replace existing values.
115 for(int i = 0; i < picture->controls.total; i++)
117 PictureItem *src = picture->controls.values[i];
119 for(int j = 0; j < controls.total; j++)
121 if(controls.values[j]->device_id == src->device_id)
129 PictureItem *dst = new PictureItem;
130 controls.append(dst);
136 void PictureConfig::load_defaults()
140 printf("PictureConfig::load_defaults: mwindow not set.\n");
143 brightness = mwindow->defaults->get("VIDEO_BRIGHTNESS", 0);
144 hue = mwindow->defaults->get("VIDEO_HUE", 0);
145 color = mwindow->defaults->get("VIDEO_COLOR", 0);
146 contrast = mwindow->defaults->get("VIDEO_CONTRAST", 0);
147 whiteness = mwindow->defaults->get("VIDEO_WHITENESS", 0);
149 // The device must be probed first to keep unsupported controls from getting
151 for(int i = 0; i < controls.total; i++)
153 PictureItem *item = controls.values[i];
154 char string[BCTEXTLEN];
155 item->get_default_string(string);
156 item->value = mwindow->defaults->get(string, item->value);
157 //printf("PictureConfig::load_defaults %s %d %d\n", item->name, item->device_id, item->value);
161 void PictureConfig::save_defaults()
165 printf("PictureConfig::save_defaults: mwindow not set.\n");
168 mwindow->defaults->update("VIDEO_BRIGHTNESS", brightness);
169 mwindow->defaults->update("VIDEO_HUE", hue);
170 mwindow->defaults->update("VIDEO_COLOR", color);
171 mwindow->defaults->update("VIDEO_CONTRAST", contrast);
172 mwindow->defaults->update("VIDEO_WHITENESS", whiteness);
173 for(int i = 0; i < controls.total; i++)
175 PictureItem *item = controls.values[i];
176 char string[BCTEXTLEN];
177 item->get_default_string(string);
178 mwindow->defaults->update(string, item->value);
179 //printf("PictureConfig::save_defaults %s %d %d\n", string, item->device_id, item->value);
183 PictureItem* PictureConfig::new_item(const char *name)
185 for(int i = 0; i < controls.total; i++)
187 if(!strcmp(controls.values[i]->name, name)) return controls.values[i];
189 PictureItem *item = new PictureItem;
190 strcpy(item->name, name);
191 controls.append(item);
195 PictureItem* PictureConfig::get_item(const char *name, int id)
197 for(int i = 0; i < controls.total; i++)
199 if(!strcmp(controls.values[i]->name, name) &&
200 controls.values[i]->device_id == id) return controls.values[i];
205 void PictureConfig::set_item(int device_id, int value)
207 for(int i = 0; i < controls.total; i++)
209 if(controls.values[i]->device_id == device_id)
211 controls.values[i]->value = value;