Mercurial > pidgin.yaz
comparison console/libgnt/gntmain.c @ 13878:0d0ab1e39d0a
[gaim-migrate @ 16355]
Change the behaviour of the widgets about how they update themselves.
This makes things a little better, and hopefully easier to build more
stuff on top of this.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 27 Jun 2006 02:33:55 +0000 |
parents | 5642f4658b59 |
children | 582aaa4e287e |
comparison
equal
deleted
inserted
replaced
13877:765bbdf29d04 | 13878:0d0ab1e39d0a |
---|---|
140 GntNode *n = value; | 140 GntNode *n = value; |
141 GntNode *nu = data; | 141 GntNode *nu = data; |
142 | 142 |
143 if (value == NULL) | 143 if (value == NULL) |
144 return; | 144 return; |
145 if (n->me == nu->me) | |
146 return; | |
145 | 147 |
146 if (n->me->priv.x + n->me->priv.width < nu->me->priv.x) | 148 if (n->me->priv.x + n->me->priv.width < nu->me->priv.x) |
147 return; | 149 return; |
148 if (nu->me->priv.x + nu->me->priv.width < n->me->priv.x) | 150 if (nu->me->priv.x + nu->me->priv.width < n->me->priv.x) |
149 return; | 151 return; |
151 if (n->me->priv.y + n->me->priv.height < nu->me->priv.y) | 153 if (n->me->priv.y + n->me->priv.height < nu->me->priv.y) |
152 return; | 154 return; |
153 if (nu->me->priv.y + nu->me->priv.height < n->me->priv.y) | 155 if (nu->me->priv.y + nu->me->priv.height < n->me->priv.y) |
154 return; | 156 return; |
155 | 157 |
156 n->above = g_list_prepend(n->above, nu->me); | 158 n->above = g_list_prepend(n->above, nu); |
157 nu->below = g_list_prepend(nu->below, n->me); | 159 nu->below = g_list_prepend(nu->below, n); |
158 } | 160 } |
159 | 161 |
160 void gnt_screen_occupy(GntWidget *widget) | 162 void gnt_screen_occupy(GntWidget *widget) |
161 { | 163 { |
162 /* XXX: what happens if this is called more than once for the same widget? | 164 GntNode *node; |
163 * perhaps _release first? */ | 165 |
164 GntNode *node = g_new0(GntNode, 1); | 166 if (widget->parent) |
167 { | |
168 while (widget->parent) | |
169 widget = widget->parent; | |
170 } | |
171 | |
172 if (g_hash_table_lookup(nodes, widget)) | |
173 return; /* XXX: perhaps _update instead? */ | |
174 | |
175 node = g_new0(GntNode, 1); | |
165 node->me = widget; | 176 node->me = widget; |
166 | 177 |
167 g_hash_table_foreach(nodes, check_intersection, node); | 178 g_hash_table_foreach(nodes, check_intersection, node); |
168 g_hash_table_replace(nodes, widget, node); | 179 g_hash_table_replace(nodes, widget, node); |
169 } | 180 } |
170 | 181 |
171 void gnt_screen_release(GntWidget *widget) | 182 void gnt_screen_release(GntWidget *widget) |
172 { | 183 { |
184 WINDOW *win; | |
173 GList *iter; | 185 GList *iter; |
174 GntNode *node = g_hash_table_lookup(nodes, widget); | 186 GntNode *node = g_hash_table_lookup(nodes, widget); |
175 if (node == NULL || node->below == NULL) /* Yay! Nothing to do. */ | 187 if (node == NULL || node->below == NULL) /* Yay! Nothing to do. */ |
176 return; | 188 return; |
177 | 189 |
190 win = dupwin(widget->window); | |
191 werase(win); | |
192 | |
178 /* XXX: This is not going to work. | 193 /* XXX: This is not going to work. |
179 * It will be necessary to build a topology and go from there. */ | 194 * It will be necessary to build a topology and go from there. */ |
180 for (iter = node->below; iter; iter = iter->next) | 195 for (iter = node->below; iter; iter = iter->next) |
181 { | 196 { |
182 GntWidget *w = iter->data; | 197 GntNode *n = iter->data; |
198 GntWidget *w = n->me; | |
183 int left, right, top, bottom; | 199 int left, right, top, bottom; |
184 | 200 |
185 left = MAX(widget->priv.x, w->priv.x) - w->priv.x; | 201 left = MAX(widget->priv.x, w->priv.x) - w->priv.x; |
186 right = MIN(widget->priv.x + widget->priv.width, w->priv.x + w->priv.width) - w->priv.x; | 202 right = MIN(widget->priv.x + widget->priv.width, w->priv.x + w->priv.width) - w->priv.x; |
187 | 203 |
188 top = MAX(widget->priv.y, w->priv.y) - w->priv.y; | 204 top = MAX(widget->priv.y, w->priv.y) - w->priv.y; |
189 bottom = MIN(widget->priv.y + widget->priv.height, w->priv.y + w->priv.height) - w->priv.y; | 205 bottom = MIN(widget->priv.y + widget->priv.height, w->priv.y + w->priv.height) - w->priv.y; |
190 | 206 |
191 gnt_widget_expose(w, left, top, right - left, bottom - top); | 207 copywin(w->window, win, top, left, |
192 } | 208 w->priv.y + top, |
209 w->priv.x + left, | |
210 w->priv.y + bottom - top - 1, | |
211 w->priv.x + right - left - 1, FALSE); | |
212 n->above = g_list_remove(n->above, node); | |
213 } | |
214 | |
215 wrefresh(win); | |
216 delwin(win); | |
193 | 217 |
194 g_hash_table_remove(nodes, widget); | 218 g_hash_table_remove(nodes, widget); |
195 } | 219 } |
196 | 220 |
221 void gnt_screen_update(GntWidget *widget) | |
222 { | |
223 GList *iter; | |
224 WINDOW *win; | |
225 GntNode *node; | |
226 | |
227 if (widget->parent) | |
228 { | |
229 while (widget->parent) | |
230 widget = widget->parent; | |
231 } | |
232 | |
233 gnt_box_sync_children(widget); | |
234 node = g_hash_table_lookup(nodes, widget); | |
235 | |
236 win = dupwin(widget->window); | |
237 | |
238 if (node && node->above) | |
239 { | |
240 /* XXX: Same here: need to build a topology first. */ | |
241 for (iter = node->above; iter; iter = iter->next) | |
242 { | |
243 GntNode *n = iter->data; | |
244 GntWidget *w = n->me; | |
245 int left, right, top, bottom; | |
246 | |
247 left = MAX(widget->priv.x, w->priv.x) - w->priv.x; | |
248 right = MIN(widget->priv.x + widget->priv.width, w->priv.x + w->priv.width) - w->priv.x; | |
249 | |
250 top = MAX(widget->priv.y, w->priv.y) - w->priv.y; | |
251 bottom = MIN(widget->priv.y + widget->priv.height, w->priv.y + w->priv.height) - w->priv.y; | |
252 | |
253 copywin(w->window, win, top, left, | |
254 w->priv.y + top, | |
255 w->priv.x + left, | |
256 w->priv.y + bottom - top - 1, | |
257 w->priv.x + right - left - 1, FALSE); | |
258 } | |
259 } | |
260 | |
261 wrefresh(win); | |
262 delwin(win); | |
263 } | |
264 |