| 480 | } |
| 481 | |
| 482 | void ScriptTableListModel::setup(juce::TableListBox* t) |
| 483 | { |
| 484 | auto& header = t->getHeader(); |
| 485 | |
| 486 | t->setLookAndFeel(&fallback); |
| 487 | |
| 488 | tableRepainters.add(new TableRepainter(t, *this)); |
| 489 | |
| 490 | int idx = 1; |
| 491 | |
| 492 | if (auto a = columnMetadata.getArray()) |
| 493 | { |
| 494 | for (auto c : *a) |
| 495 | { |
| 496 | auto id = c[scriptnode::PropertyIds::ID].toString(); |
| 497 | auto label = c.getProperty("Label", id); |
| 498 | |
| 499 | auto w = (int)c["Width"]; |
| 500 | auto min = jmax(1, (int)c["MinWidth"]); |
| 501 | auto max = (int)c.getProperty("MaxWidth", -1); |
| 502 | |
| 503 | if (max != -1) |
| 504 | { |
| 505 | auto r = Range<int>(min, max); |
| 506 | w = r.clipValue(w); |
| 507 | } |
| 508 | else |
| 509 | w = jmax(min, w); |
| 510 | |
| 511 | int flag = TableHeaderComponent::ColumnPropertyFlags::visible; |
| 512 | |
| 513 | if(tableMetadata.getProperty("Sortable", false)) |
| 514 | flag |= TableHeaderComponent::ColumnPropertyFlags::sortable; |
| 515 | |
| 516 | header.addColumn(label, idx, w, min, max, flag); |
| 517 | idx++; |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | t->setAutoSizeMenuOptionShown(false); |
| 522 | t->setHeaderHeight(tableMetadata.getProperty("HeaderHeight", 24)); |
| 523 | t->setRowHeight(tableMetadata.getProperty("RowHeight", 20)); |
| 524 | t->setMultipleSelectionEnabled(tableMetadata.getProperty("MultiSelection", false)); |
| 525 | t->getViewport()->setScrollOnDragEnabled(tableMetadata.getProperty("ScrollOnDrag", false)); |
| 526 | |
| 527 | t->setModel(this); |
| 528 | } |
| 529 | |
| 530 | |
| 531 | ScriptTableListModel::LookAndFeelMethods::~LookAndFeelMethods() |
no test coverage detected