MCPcopy Create free account
hub / github.com/Tom94/tev / insertImage

Method insertImage

src/ImageViewer.cpp:1557–1602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1555}
1556
1557void ImageViewer::insertImage(shared_ptr<Image> image, size_t index, bool shallSelect) {
1558 if (!image) {
1559 throw invalid_argument{"Image may not be null."};
1560 }
1561
1562 if (mDragType == EMouseDragType::ImageButtonDrag && index <= mDraggedImageButtonId) {
1563 ++mDraggedImageButtonId;
1564 }
1565
1566 auto button = new ImageButton{nullptr, image->name(), true};
1567 button->set_font_size(15);
1568 button->setId(index + 1);
1569 button->set_tooltip(image->toString());
1570
1571 button->setSelectedCallback([this, image]() { selectImage(image); });
1572
1573 button->setReferenceCallback([this, image](bool isReference) {
1574 if (!isReference) {
1575 selectReference(nullptr);
1576 } else {
1577 selectReference(image);
1578 }
1579 });
1580
1581 button->setCaptionChangeCallback([this]() { mRequiresFilterUpdate = true; });
1582
1583 mImageButtonContainer->add_child((int)index, button);
1584 mImages.insert(begin(mImages) + index, image);
1585
1586 mShouldFooterBeVisible |= image->channelGroups().size() > 1;
1587 // The following call will make sure the footer becomes visible if the previous line enabled it.
1588 setUiVisible(isUiVisible());
1589
1590 // Ensure the new image button will have the correct visibility state.
1591 setFilter(mFilter->value());
1592
1593 requestLayoutUpdate();
1594
1595 // First image got added, let's select it.
1596 if ((index == 0 && mImages.size() == 1) || shallSelect) {
1597 selectImage(image);
1598 if (!isMaximized() && resizeWindowToFitImageOnLoad()) {
1599 resizeToFit(sizeToFitImage(image));
1600 }
1601 }
1602}
1603
1604void ImageViewer::moveImageInList(size_t oldIndex, size_t newIndex) {
1605 if (oldIndex == newIndex) {

Callers

nothing calls this directly

Calls 9

setIdMethod · 0.80
setSelectedCallbackMethod · 0.80
setReferenceCallbackMethod · 0.80
channelGroupsMethod · 0.80
valueMethod · 0.80
nameMethod · 0.45
toStringMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected