/[svn]/gigedit/trunk/src/dimregionchooser.cpp
ViewVC logotype

Contents of /gigedit/trunk/src/dimregionchooser.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1198 - (show annotations) (download)
Fri May 18 17:31:49 2007 UTC (13 years, 11 months ago) by schoenebeck
File size: 26679 byte(s)
- just some code comments

1 /*
2 * Copyright (C) 2006, 2007 Andreas Persson
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with program; see the file COPYING. If not, write to the Free
16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include "dimregionchooser.h"
21 #include <gdkmm/cursor.h>
22
23 DimRegionChooser::DimRegionChooser()
24 {
25 // get_window() would return 0 because the Gdk::Window has not yet been realized
26 // So we can only allocate the colors here - the rest will happen in on_realize().
27 Glib::RefPtr<Gdk::Colormap> colormap = get_default_colormap();
28
29 black = Gdk::Color("black");
30 white = Gdk::Color("white");
31 red = Gdk::Color("#8070ff");
32 blue = Gdk::Color("blue");
33 green = Gdk::Color("green");
34
35 colormap->alloc_color(black);
36 colormap->alloc_color(white);
37 colormap->alloc_color(red);
38 colormap->alloc_color(blue);
39 colormap->alloc_color(green);
40 instrument = 0;
41 region = 0;
42 dimregno = -1;
43 focus_line = 0;
44 resize.active = false;
45 cursor_is_resize = false;
46 h = 20;
47 w = 800;
48 set_flags(Gtk::CAN_FOCUS);
49 add_events(Gdk::BUTTON_PRESS_MASK | Gdk::POINTER_MOTION_MASK |
50 Gdk::POINTER_MOTION_HINT_MASK);
51
52 for (int i = 0 ; i < 256 ; i++) {
53 dimvalue_from[i] = 0;
54 dimvalue_to[i] = 1;
55 }
56 }
57
58 DimRegionChooser::~DimRegionChooser()
59 {
60 }
61
62 void DimRegionChooser::on_realize()
63 {
64 // We need to call the base on_realize()
65 Gtk::DrawingArea::on_realize();
66
67 // Now we can allocate any additional resources we need
68 Glib::RefPtr<Gdk::Window> window = get_window();
69 gc = Gdk::GC::create(window);
70 }
71
72 bool DimRegionChooser::on_expose_event(GdkEventExpose* event)
73 {
74 if (!region) return true;
75
76 // This is where we draw on the window
77 Glib::RefPtr<Gdk::Window> window = get_window();
78 Glib::RefPtr<Pango::Context> context = get_pango_context();
79
80 Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(context);
81
82 window->clear();
83
84 // draw labels on the left (reflecting the dimension type)
85 int y = 0;
86 double maxwidth = 0;
87 for (int i = 0 ; i < region->Dimensions ; i++) {
88 int nbZones = region->pDimensionDefinitions[i].zones;
89 if (nbZones) {
90 char* dstr;
91 char dstrbuf[10];
92 switch (region->pDimensionDefinitions[i].dimension) {
93 case gig::dimension_none: dstr="none"; break;
94 case gig::dimension_samplechannel: dstr="samplechannel"; break;
95 case gig::dimension_layer: dstr="layer"; break;
96 case gig::dimension_velocity: dstr="velocity"; break;
97 case gig::dimension_channelaftertouch: dstr="channelaftertouch"; break;
98 case gig::dimension_releasetrigger: dstr="releasetrigger"; break;
99 case gig::dimension_keyboard: dstr="keyboard"; break;
100 case gig::dimension_roundrobin: dstr="roundrobin"; break;
101 case gig::dimension_random: dstr="random"; break;
102 case gig::dimension_smartmidi: dstr="smartmidi"; break;
103 case gig::dimension_roundrobinkeyboard: dstr="roundrobinkeyboard"; break;
104 case gig::dimension_modwheel: dstr="modwheel"; break;
105 case gig::dimension_breath: dstr="breath"; break;
106 case gig::dimension_foot: dstr="foot"; break;
107 case gig::dimension_portamentotime: dstr="portamentotime"; break;
108 case gig::dimension_effect1: dstr="effect1"; break;
109 case gig::dimension_effect2: dstr="effect2"; break;
110 case gig::dimension_genpurpose1: dstr="genpurpose1"; break;
111 case gig::dimension_genpurpose2: dstr="genpurpose2"; break;
112 case gig::dimension_genpurpose3: dstr="genpurpose3"; break;
113 case gig::dimension_genpurpose4: dstr="genpurpose4"; break;
114 case gig::dimension_sustainpedal: dstr="sustainpedal"; break;
115 case gig::dimension_portamento: dstr="portamento"; break;
116 case gig::dimension_sostenutopedal: dstr="sostenutopedal"; break;
117 case gig::dimension_softpedal: dstr="softpedal"; break;
118 case gig::dimension_genpurpose5: dstr="genpurpose5"; break;
119 case gig::dimension_genpurpose6: dstr="genpurpose6"; break;
120 case gig::dimension_genpurpose7: dstr="genpurpose7"; break;
121 case gig::dimension_genpurpose8: dstr="genpurpose8"; break;
122 case gig::dimension_effect1depth: dstr="effect1depth"; break;
123 case gig::dimension_effect2depth: dstr="effect2depth"; break;
124 case gig::dimension_effect3depth: dstr="effect3depth"; break;
125 case gig::dimension_effect4depth: dstr="effect4depth"; break;
126 case gig::dimension_effect5depth: dstr="effect5depth"; break;
127 default:
128 sprintf(dstrbuf, "%d",
129 region->pDimensionDefinitions[i].dimension);
130 dstr = dstrbuf;
131 break;
132 }
133 layout->set_text(dstr);
134
135 Pango::Rectangle rectangle = layout->get_logical_extents();
136 double text_w = double(rectangle.get_width()) / Pango::SCALE;
137 if (text_w > maxwidth) maxwidth = text_w;
138 double text_h = double(rectangle.get_height()) / Pango::SCALE;
139 Glib::RefPtr<const Gdk::GC> fg = get_style()->get_fg_gc(get_state());
140 window->draw_layout(fg, 4, int(y + (h - text_h) / 2 + 0.5), layout);
141
142 }
143 y += h;
144 }
145
146 // draw dimensions' zones areas
147 y = 0;
148 int bitpos = 0;
149 label_width = int(maxwidth + 10);
150 for (int i = 0 ; i < region->Dimensions ; i++) {
151 int nbZones = region->pDimensionDefinitions[i].zones;
152 if (nbZones) {
153 // draw focus rectangle around dimension's label and zones
154 if (has_focus() && focus_line == i) {
155 Gdk::Rectangle farea(0, y, 150, 20);
156 get_style()->paint_focus(window, get_state(), farea, *this, "",
157 0, y, label_width, 20);
158 }
159
160 Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc();
161 // draw top and bottom lines of dimension's zones
162 window->draw_line(black, label_width, y, w - 1, y);
163 window->draw_line(black, w - 1, y + h - 1, label_width, y + h - 1);
164 // erase whole dimension's zones area
165 window->draw_rectangle(get_style()->get_white_gc(), true,
166 label_width + 1, y + 1, (w - label_width - 2), h - 2);
167
168 int c = 0;
169 if (dimregno >= 0) {
170 int mask = ~(((1 << region->pDimensionDefinitions[i].bits) - 1) << bitpos);
171 c = dimregno & mask; // mask away this dimension
172 }
173 bool customsplits =
174 ((region->pDimensionDefinitions[i].split_type == gig::split_type_normal &&
175 region->pDimensionRegions[c]->DimensionUpperLimits[i]) ||
176 (region->pDimensionDefinitions[i].dimension == gig::dimension_velocity &&
177 region->pDimensionRegions[c]->VelocityUpperLimit));
178
179 // draw dimension's zone borders
180 if (customsplits) {
181 window->draw_line(black, label_width, y + 1, label_width, y + h - 2);
182 for (int j = 0 ; j < nbZones ; j++) {
183 gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
184 int upperLimit = d->DimensionUpperLimits[i];
185 if (!upperLimit) upperLimit = d->VelocityUpperLimit;
186 int v = upperLimit + 1;
187 int x = int((w - label_width - 1) * v / 128.0 + 0.5);
188 window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2);
189 }
190 } else {
191 for (int j = 0 ; j <= nbZones ; j++) {
192 int x = int((w - label_width - 1) * j / double(nbZones) + 0.5);
193 window->draw_line(black, label_width + x, y + 1, label_width + x, y + h - 2);
194 }
195 }
196
197 // draw fill for currently selected zone
198 if (dimregno >= 0) {
199 gc->set_foreground(red);
200 int dr = (dimregno >> bitpos) & ((1 << region->pDimensionDefinitions[i].bits) - 1);
201 if (customsplits) {
202 int x1 = 0;
203 for (int j = 0 ; j < nbZones ; j++) {
204 gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
205 int upperLimit = d->DimensionUpperLimits[i];
206 if (!upperLimit) upperLimit = d->VelocityUpperLimit;
207 int v = upperLimit + 1;
208 int x2 = int((w - label_width - 1) * v / 128.0 + 0.5);
209 if (j == dr && x1 < x2) {
210 window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1,
211 (x2 - x1) - 1, h - 2);
212 break;
213 }
214 x1 = x2;
215 }
216 } else {
217 if (dr < nbZones) {
218 int x1 = int((w - label_width - 1) * dr / double(nbZones) + 0.5);
219 int x2 = int((w - label_width - 1) * (dr + 1) / double(nbZones) + 0.5);
220 window->draw_rectangle(gc, true, label_width + x1 + 1, y + 1,
221 (x2 - x1) - 1, h - 2);
222 }
223 }
224 }
225
226 y += h;
227 }
228 bitpos += region->pDimensionDefinitions[i].bits;
229 }
230
231 return true;
232 }
233
234 void DimRegionChooser::on_size_request(GtkRequisition* requisition)
235 {
236 printf("DimRegionChooser::on_size_request\n");
237 *requisition = GtkRequisition();
238 requisition->height = region ? nbDimensions * 20 : 0;
239 requisition->width = 800;
240 }
241
242 void DimRegionChooser::set_region(gig::Region* region)
243 {
244 this->region = region;
245 dimregno = 0;
246 nbDimensions = 0;
247 if (region) {
248 int bitcount = 0;
249 for (int dim = 0 ; dim < region->Dimensions ; dim++) {
250 if (region->pDimensionDefinitions[dim].bits == 0) continue;
251 nbDimensions++;
252
253 int from = dimvalue_from[region->pDimensionDefinitions[dim].dimension];
254 int to = dimvalue_to[region->pDimensionDefinitions[dim].dimension];
255 int z;
256 switch (region->pDimensionDefinitions[dim].split_type) {
257 case gig::split_type_normal:
258 z = int((to + from) / 2.0 / region->pDimensionDefinitions[dim].zone_size);
259 break;
260 case gig::split_type_bit:
261 z = std::min(from, region->pDimensionDefinitions[dim].zones - 1);
262 break;
263 }
264 int mask =
265 ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) <<
266 bitcount);
267 dimregno &= mask;
268 dimregno |= (z << bitcount);
269 bitcount += region->pDimensionDefinitions[dim].bits;
270 }
271 dimreg = region->pDimensionRegions[dimregno];
272 } else {
273 dimreg = 0;
274 }
275 sel_changed_signal.emit();
276 queue_resize();
277 }
278
279 bool DimRegionChooser::on_button_release_event(GdkEventButton* event)
280 {
281 if (resize.active) {
282 get_window()->pointer_ungrab(event->time);
283 resize.active = false;
284
285 if (region->pDimensionDefinitions[resize.dimension].dimension == gig::dimension_velocity) {
286
287 int bitpos = 0;
288 for (int j = 0 ; j < resize.dimension ; j++) {
289 bitpos += region->pDimensionDefinitions[j].bits;
290 }
291 int mask =
292 ~(((1 << region->pDimensionDefinitions[resize.dimension].bits) - 1) << bitpos);
293 int c = dimregno & mask; // mask away this dimension
294
295 if (region->pDimensionRegions[c]->DimensionUpperLimits[resize.dimension] == 0) {
296 // the velocity dimension didn't previously have
297 // custom v3 splits, so we initialize all splits with
298 // default values
299 int nbZones = region->pDimensionDefinitions[resize.dimension].zones;
300 for (int j = 0 ; j < nbZones ; j++) {
301 gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
302 d->DimensionUpperLimits[resize.dimension] = int(128.0 * (j + 1) / nbZones - 1);
303 }
304 }
305 if (region->pDimensionRegions[c]->VelocityUpperLimit == 0) {
306 // the velocity dimension didn't previously have
307 // custom v2 splits, so we initialize all splits with
308 // default values
309 int nbZones = region->pDimensionDefinitions[resize.dimension].zones;
310 for (int j = 0 ; j < nbZones ; j++) {
311 gig::DimensionRegion *d = region->pDimensionRegions[c + (j << bitpos)];
312 d->VelocityUpperLimit = int(128.0 * (j + 1) / nbZones - 1);
313 }
314 }
315
316 gig::DimensionRegion *d = region->pDimensionRegions[c + resize.offset];
317 // update both v2 and v3 values
318 d->DimensionUpperLimits[resize.dimension] = resize.pos - 1;
319 d->VelocityUpperLimit = resize.pos - 1;
320
321 } else {
322 for (int i = 0 ; i < region->DimensionRegions ; ) {
323
324 if (region->pDimensionRegions[i]->DimensionUpperLimits[resize.dimension] == 0) {
325 // the dimension didn't previously have custom
326 // limits, so we have to set default limits for
327 // all the dimension regions
328 int bitpos = 0;
329 for (int j = 0 ; j < resize.dimension ; j++) {
330 bitpos += region->pDimensionDefinitions[j].bits;
331 }
332 int nbZones = region->pDimensionDefinitions[resize.dimension].zones;
333
334 for (int j = 0 ; j < nbZones ; j++) {
335 gig::DimensionRegion *d = region->pDimensionRegions[i + (j << bitpos)];
336 d->DimensionUpperLimits[resize.dimension] = int(128.0 * (j + 1) / nbZones - 1);
337 }
338 }
339 gig::DimensionRegion *d = region->pDimensionRegions[i + resize.offset];
340 d->DimensionUpperLimits[resize.dimension] = resize.pos - 1;
341
342 int bitpos = 0;
343 int j;
344 for (j = 0 ; j < region->Dimensions ; j++) {
345 if (j != resize.dimension) {
346 int maxzones = 1 << region->pDimensionDefinitions[j].bits;
347 int dimj = (i >> bitpos) & (maxzones - 1);
348 if (dimj + 1 < region->pDimensionDefinitions[j].zones) break;
349 }
350 bitpos += region->pDimensionDefinitions[j].bits;
351 }
352 if (j == region->Dimensions) break;
353 i = (i & ~((1 << bitpos) - 1)) + (1 << bitpos);
354 }
355 }
356
357 if (!is_in_resize_zone(event->x, event->y) && cursor_is_resize) {
358 get_window()->set_cursor();
359 cursor_is_resize = false;
360 }
361 }
362 return true;
363 }
364
365 bool DimRegionChooser::on_button_press_event(GdkEventButton* event)
366 {
367 if (region && event->y < nbDimensions * h &&
368 event->x >= label_width && event->x < w) {
369
370 if (is_in_resize_zone(event->x, event->y)) {
371 Gdk::Cursor double_arrow(Gdk::SB_H_DOUBLE_ARROW);
372 get_window()->pointer_grab(false,
373 Gdk::BUTTON_RELEASE_MASK |
374 Gdk::POINTER_MOTION_MASK |
375 Gdk::POINTER_MOTION_HINT_MASK,
376 double_arrow, event->time);
377 resize.active = true;
378 } else {
379 int ydim = int(event->y / h);
380 int dim;
381 for (dim = 0 ; dim < region->Dimensions ; dim++) {
382 if (region->pDimensionDefinitions[dim].bits == 0) continue;
383 if (ydim == 0) break;
384 ydim--;
385 }
386 int nbZones = region->pDimensionDefinitions[dim].zones;
387
388 int z = -1;
389 int bitpos = 0;
390 for (int i = 0 ; i < dim ; i++) {
391 bitpos += region->pDimensionDefinitions[i].bits;
392 }
393
394 int i = dim;
395 if (dimregno < 0) dimregno = 0;
396 int mask = ~(((1 << region->pDimensionDefinitions[i].bits) - 1) << bitpos);
397 int c = dimregno & mask; // mask away this dimension
398
399 bool customsplits =
400 ((region->pDimensionDefinitions[i].split_type == gig::split_type_normal &&
401 region->pDimensionRegions[c]->DimensionUpperLimits[i]) ||
402 (region->pDimensionDefinitions[i].dimension == gig::dimension_velocity &&
403 region->pDimensionRegions[c]->VelocityUpperLimit));
404 if (customsplits) {
405 int val = int((event->x - label_width) * 128 / (w - label_width - 1));
406
407 if (region->pDimensionRegions[c]->DimensionUpperLimits[i]) {
408 for (z = 0 ; z < nbZones ; z++) {
409 gig::DimensionRegion *d = region->pDimensionRegions[c + (z << bitpos)];
410 if (val <= d->DimensionUpperLimits[i]) break;
411 }
412 } else {
413 for (z = 0 ; z < nbZones ; z++) {
414 gig::DimensionRegion *d = region->pDimensionRegions[c + (z << bitpos)];
415 if (val <= d->VelocityUpperLimit) break;
416 }
417 }
418 } else {
419 z = int((event->x - label_width) * nbZones / (w - label_width - 1));
420 }
421
422 printf("dim=%d z=%d dimensionsource=%d split_type=%d zones=%d zone_size=%f\n", dim, z,
423 region->pDimensionDefinitions[dim].dimension,
424 region->pDimensionDefinitions[dim].split_type,
425 region->pDimensionDefinitions[dim].zones,
426 region->pDimensionDefinitions[dim].zone_size);
427 #if 0
428 switch (region->pDimensionDefinitions[dim].split_type) {
429 case gig::split_type_normal:
430 dimvalue_from[region->pDimensionDefinitions[dim].dimension] =
431 int(z * region->pDimensionDefinitions[dim].zone_size);
432 dimvalue_to[region->pDimensionDefinitions[dim].dimension] =
433 int((z + 1) * region->pDimensionDefinitions[dim].zone_size) - 1;
434 break;
435 case gig::split_type_bit:
436 dimvalue_from[region->pDimensionDefinitions[dim].dimension] = z;
437 dimvalue_to[region->pDimensionDefinitions[dim].dimension] = z + 1;
438 break;
439 }
440 #endif
441
442 dimregno = c | (z << bitpos);
443
444 focus_line = dim;
445 if (has_focus()) queue_draw();
446 else grab_focus();
447 dimreg = region->pDimensionRegions[dimregno];
448 sel_changed_signal.emit();
449 }
450 }
451 return true;
452 }
453
454 bool DimRegionChooser::on_motion_notify_event(GdkEventMotion* event)
455 {
456 Glib::RefPtr<Gdk::Window> window = get_window();
457 int x, y;
458 Gdk::ModifierType state = Gdk::ModifierType(0);
459 window->get_pointer(x, y, state);
460
461 if (resize.active) {
462 int k = int((x - label_width) * 128.0 / (w - label_width - 1) + 0.5);
463
464 if (k < resize.min) k = resize.min;
465 else if (k > resize.max) k = resize.max;
466
467 if (k < 2) k = 2; // k is upper limit + 1, upper limit 0 is forbidden
468
469 if (k != resize.pos) {
470 Glib::RefPtr<const Gdk::GC> black = get_style()->get_black_gc();
471 Glib::RefPtr<const Gdk::GC> white = get_style()->get_white_gc();
472
473 int prevx = int((w - label_width - 1) * resize.pos / 128.0 + 0.5) + label_width;
474 int x = int((w - label_width - 1) * k / 128.0 + 0.5) + label_width;
475 int y = resize.dimension * h;
476
477 if (resize.selected == resize.none) {
478 if (resize.pos != resize.min && resize.pos != resize.max) {
479 window->draw_line(white, prevx, y + 1, prevx, y + h - 2);
480 }
481 } else {
482 gc->set_foreground(red);
483
484 Glib::RefPtr<const Gdk::GC> left;
485 Glib::RefPtr<const Gdk::GC> right;
486 if (resize.selected == resize.left) {
487 left = gc;
488 right = white;
489 } else {
490 left = white;
491 right = gc;
492 }
493
494 if (k > resize.pos) {
495 int xx = resize.pos == resize.min ? 1 : 0;
496 window->draw_rectangle(left, true,
497 prevx + xx, y + 1, x - prevx - xx, h - 2);
498 } else {
499 int xx = resize.pos == resize.max ? 0 : 1;
500 window->draw_rectangle(right, true,
501 x, y + 1, prevx - x + xx, h - 2);
502 }
503 }
504 window->draw_line(black, x, y + 1, x, y + h - 2);
505 resize.pos = k;
506 }
507 } else {
508 if (is_in_resize_zone(x, y)) {
509 if (!cursor_is_resize) {
510 Gdk::Cursor double_arrow(Gdk::SB_H_DOUBLE_ARROW);
511 window->set_cursor(double_arrow);
512 cursor_is_resize = true;
513 }
514 } else if (cursor_is_resize) {
515 window->set_cursor();
516 cursor_is_resize = false;
517 }
518 }
519 return true;
520 }
521
522 bool DimRegionChooser::is_in_resize_zone(double x, double y)
523 {
524 if (region && y < nbDimensions * h && x >= label_width && x < w) {
525 int ydim = int(y / h);
526 int dim;
527 int bitpos = 0;
528 for (dim = 0 ; dim < region->Dimensions ; dim++) {
529 if (region->pDimensionDefinitions[dim].bits == 0) continue;
530 if (ydim == 0) break;
531 ydim--;
532 bitpos += region->pDimensionDefinitions[dim].bits;
533 }
534 int nbZones = region->pDimensionDefinitions[dim].zones;
535
536 int c = 0;
537 if (dimregno >= 0) {
538 int mask = ~(((1 << region->pDimensionDefinitions[dim].bits) - 1) << bitpos);
539 c = dimregno & mask; // mask away this dimension
540 }
541 const bool customsplits =
542 ((region->pDimensionDefinitions[dim].split_type == gig::split_type_normal &&
543 region->pDimensionRegions[c]->DimensionUpperLimits[dim]) ||
544 (region->pDimensionDefinitions[dim].dimension == gig::dimension_velocity &&
545 region->pDimensionRegions[c]->VelocityUpperLimit));
546
547 // dimensions of split_type_bit cannot be resized
548 if (region->pDimensionDefinitions[dim].split_type != gig::split_type_bit) {
549 int prev_limit = 0;
550 for (int iZone = 0 ; iZone < nbZones - 1 ; iZone++) {
551 gig::DimensionRegion *d = region->pDimensionRegions[c + (iZone << bitpos)];
552 const int upperLimit =
553 (customsplits) ?
554 (d->DimensionUpperLimits[dim]) ?
555 d->DimensionUpperLimits[dim] : d->VelocityUpperLimit
556 : (iZone+1) * (int)region->pDimensionDefinitions[dim].zone_size - 1;
557 int limit = upperLimit + 1;
558 int limitx = int((w - label_width - 1) * limit / 128.0 + 0.5) + label_width;
559 if (x <= limitx - 2) break;
560 if (x <= limitx + 2) {
561 resize.dimension = dim;
562 resize.offset = iZone << bitpos;
563 resize.pos = limit;
564 resize.min = prev_limit;
565
566 int dr = (dimregno >> bitpos) &
567 ((1 << region->pDimensionDefinitions[dim].bits) - 1);
568 resize.selected = dr == iZone ? resize.left :
569 dr == iZone + 1 ? resize.right : resize.none;
570
571 iZone++;
572 gig::DimensionRegion *d = region->pDimensionRegions[c + (iZone << bitpos)];
573
574 const int upperLimit =
575 (customsplits) ?
576 (d->DimensionUpperLimits[dim]) ?
577 d->DimensionUpperLimits[dim] : d->VelocityUpperLimit
578 : (iZone+1) * (int)region->pDimensionDefinitions[dim].zone_size - 1;
579
580 int limit = upperLimit + 1;
581 resize.max = limit;
582 return true;
583 }
584 prev_limit = limit;
585 }
586 }
587 }
588 return false;
589 }
590
591 sigc::signal<void> DimRegionChooser::signal_sel_changed()
592 {
593 return sel_changed_signal;
594 }
595
596 bool DimRegionChooser::on_focus(Gtk::DirectionType direction)
597 {
598 // TODO: kolla att region finns osv, dvs att det g�r att s�tta
599 // fokus.
600 if (direction == Gtk::DIR_TAB_FORWARD ||
601 direction == Gtk::DIR_DOWN) {
602 if (!has_focus()) {
603 focus_line = 0;
604 grab_focus();
605 return true;
606 } else {
607 if (focus_line + 1 < region->Dimensions) {
608 focus_line++;
609 queue_draw();
610 return true;
611 } else {
612 return false;
613 }
614 }
615 } else if (direction == Gtk::DIR_TAB_BACKWARD ||
616 direction == Gtk::DIR_UP) {
617 if (!has_focus()) {
618 focus_line = region->Dimensions - 1;
619 grab_focus();
620 return true;
621 } else {
622 if (focus_line > 0) {
623 focus_line--;
624 queue_draw();
625 return true;
626 } else {
627 return false;
628 }
629 }
630 } else if (!has_focus()) {
631 // TODO: kolla att focus_line finns!
632 grab_focus();
633 return true;
634 } else {
635 // TODO: �ka eller minska v�rde!
636 }
637 }

  ViewVC Help
Powered by ViewVC