| 472 | } |
| 473 | |
| 474 | unsigned int |
| 475 | LineStyles::add_style (const LineStyleInfo &p) |
| 476 | { |
| 477 | unsigned int oi = 0; |
| 478 | lay::LineStyles::iterator iempty = end (); |
| 479 | for (lay::LineStyles::iterator i = begin_custom (); i != end (); ++i) { |
| 480 | if (i->order_index () == 0) { |
| 481 | iempty = i; |
| 482 | } else if (i->order_index () > oi) { |
| 483 | oi = i->order_index (); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | unsigned int index = std::distance (begin (), iempty); |
| 488 | |
| 489 | // NOTE: doing it this way will enable undo/redo because replace_pattern |
| 490 | // is undo/redo enabled. |
| 491 | LineStyleInfo pdup = p; |
| 492 | pdup.set_order_index (oi + 1); |
| 493 | replace_style (index, pdup); |
| 494 | |
| 495 | return index; |
| 496 | } |
| 497 | |
| 498 | namespace { |
| 499 | struct display_order |
no test coverage detected