More selection image fixes

This commit is contained in:
GriffinR 2024-01-26 15:55:29 -05:00
parent 0c03676f20
commit d7f25f9ae5
2 changed files with 17 additions and 10 deletions

View file

@ -734,10 +734,10 @@ void MainWindow::refreshMapScene()
ui->graphicsView_Metatiles->setFixedSize(editor->metatile_selector_item->pixmap().width() + 2, editor->metatile_selector_item->pixmap().height() + 2); ui->graphicsView_Metatiles->setFixedSize(editor->metatile_selector_item->pixmap().width() + 2, editor->metatile_selector_item->pixmap().height() + 2);
ui->graphicsView_BorderMetatile->setScene(editor->scene_selected_border_metatiles); ui->graphicsView_BorderMetatile->setScene(editor->scene_selected_border_metatiles);
ui->graphicsView_BorderMetatile->setFixedSize(editor->selected_border_metatiles_item->pixmap().width(), editor->selected_border_metatiles_item->pixmap().height()); ui->graphicsView_BorderMetatile->setFixedSize(editor->selected_border_metatiles_item->pixmap().width() + 2, editor->selected_border_metatiles_item->pixmap().height() + 2);
ui->graphicsView_currentMetatileSelection->setScene(editor->scene_current_metatile_selection); ui->graphicsView_currentMetatileSelection->setScene(editor->scene_current_metatile_selection);
ui->graphicsView_currentMetatileSelection->setFixedSize(editor->current_metatile_selection_item->pixmap().width(), editor->current_metatile_selection_item->pixmap().height()); ui->graphicsView_currentMetatileSelection->setFixedSize(editor->current_metatile_selection_item->pixmap().width() + 2, editor->current_metatile_selection_item->pixmap().height() + 2);
ui->graphicsView_Collision->setScene(editor->scene_collision_metatiles); ui->graphicsView_Collision->setScene(editor->scene_collision_metatiles);
//ui->graphicsView_Collision->setSceneRect(editor->scene_collision_metatiles->sceneRect()); //ui->graphicsView_Collision->setSceneRect(editor->scene_collision_metatiles->sceneRect());
@ -1371,12 +1371,16 @@ double MainWindow::getMetatilesZoomScale() {
} }
void MainWindow::redrawMetatileSelection() { void MainWindow::redrawMetatileSelection() {
QSize size(editor->current_metatile_selection_item->pixmap().width(), editor->current_metatile_selection_item->pixmap().height());
ui->graphicsView_currentMetatileSelection->setSceneRect(0, 0, size.width(), size.height());
auto scale = getMetatilesZoomScale(); auto scale = getMetatilesZoomScale();
QTransform transform; QTransform transform;
transform.scale(scale, scale); transform.scale(scale, scale);
size *= scale;
ui->graphicsView_currentMetatileSelection->setTransform(transform); ui->graphicsView_currentMetatileSelection->setTransform(transform);
ui->graphicsView_currentMetatileSelection->setFixedSize(editor->current_metatile_selection_item->pixmap().width() * scale, editor->current_metatile_selection_item->pixmap().height() * scale); ui->graphicsView_currentMetatileSelection->setFixedSize(size.width() + 2, size.height() + 2);
ui->scrollAreaWidgetContents_SelectedMetatiles->adjustSize(); ui->scrollAreaWidgetContents_SelectedMetatiles->adjustSize();
} }
@ -1394,6 +1398,7 @@ void MainWindow::scrollMetatileSelectorToSelection() {
pos += QPoint(size.x() - 1, size.y() - 1) * 16 / 2; // We want to focus on the center of the whole selection pos += QPoint(size.x() - 1, size.y() - 1) * 16 / 2; // We want to focus on the center of the whole selection
pos *= getMetatilesZoomScale(); pos *= getMetatilesZoomScale();
// TODO: This snaps focus to the position if it's out of view. It should scroll slowly toward this target instead
auto viewport = ui->scrollArea_MetatileSelector->viewport(); auto viewport = ui->scrollArea_MetatileSelector->viewport();
ui->scrollArea_MetatileSelector->ensureVisible(pos.x(), pos.y(), viewport->width() / 2, viewport->height() / 2); ui->scrollArea_MetatileSelector->ensureVisible(pos.x(), pos.y(), viewport->width() / 2, viewport->height() / 2);
} }
@ -2845,8 +2850,8 @@ void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) {
ui->graphicsView_Metatiles->setFixedSize(size.width() + 2, size.height() + 2); ui->graphicsView_Metatiles->setFixedSize(size.width() + 2, size.height() + 2);
ui->graphicsView_BorderMetatile->setTransform(transform); ui->graphicsView_BorderMetatile->setTransform(transform);
ui->graphicsView_BorderMetatile->setFixedSize(ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().width()) * scale), ui->graphicsView_BorderMetatile->setFixedSize(ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().width()) * scale) + 2,
ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().height()) * scale)); ceil(static_cast<double>(editor->selected_border_metatiles_item->pixmap().height()) * scale) + 2);
ui->scrollAreaWidgetContents_MetatileSelector->adjustSize(); ui->scrollAreaWidgetContents_MetatileSelector->adjustSize();
ui->scrollAreaWidgetContents_BorderMetatiles->adjustSize(); ui->scrollAreaWidgetContents_BorderMetatiles->adjustSize();

View file

@ -317,7 +317,6 @@ void TilesetEditor::refresh() {
this->tileSelector->setTilesets(this->primaryTileset, this->secondaryTileset); this->tileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
this->metatileSelector->setTilesets(this->primaryTileset, this->secondaryTileset); this->metatileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
this->metatileSelector->select(this->getSelectedMetatileId()); this->metatileSelector->select(this->getSelectedMetatileId());
this->drawSelectedTiles();
if (metatileSelector) { if (metatileSelector) {
if (metatileSelector->selectorShowUnused || metatileSelector->selectorShowCounts) { if (metatileSelector->selectorShowUnused || metatileSelector->selectorShowCounts) {
@ -333,11 +332,9 @@ void TilesetEditor::refresh() {
} }
} }
this->ui->graphicsView_Tiles->setSceneRect(0, 0, this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height());
this->ui->graphicsView_Metatiles->setSceneRect(0, 0, this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height());
this->ui->graphicsView_selectedTile->setFixedSize(this->selectedTilePixmapItem->pixmap().width() + 2, this->selectedTilePixmapItem->pixmap().height() + 2);
this->redrawTileSelector(); this->redrawTileSelector();
this->redrawMetatileSelector(); this->redrawMetatileSelector();
this->drawSelectedTiles();
} }
void TilesetEditor::drawSelectedTiles() { void TilesetEditor::drawSelectedTiles() {
@ -363,7 +360,10 @@ void TilesetEditor::drawSelectedTiles() {
this->selectedTilePixmapItem = new QGraphicsPixmapItem(QPixmap::fromImage(selectionImage)); this->selectedTilePixmapItem = new QGraphicsPixmapItem(QPixmap::fromImage(selectionImage));
this->selectedTileScene->addItem(this->selectedTilePixmapItem); this->selectedTileScene->addItem(this->selectedTilePixmapItem);
this->ui->graphicsView_selectedTile->setFixedSize(this->selectedTilePixmapItem->pixmap().width() + 2, this->selectedTilePixmapItem->pixmap().height() + 2);
QSize size(this->selectedTilePixmapItem->pixmap().width(), this->selectedTilePixmapItem->pixmap().height());
this->ui->graphicsView_selectedTile->setSceneRect(0, 0, size.width(), size.height());
this->ui->graphicsView_selectedTile->setFixedSize(size.width() + 2, size.height() + 2);
} }
void TilesetEditor::onHoveredMetatileChanged(uint16_t metatileId) { void TilesetEditor::onHoveredMetatileChanged(uint16_t metatileId) {
@ -1193,6 +1193,7 @@ void TilesetEditor::on_horizontalSlider_MetatilesZoom_valueChanged(int value) {
void TilesetEditor::redrawMetatileSelector() { void TilesetEditor::redrawMetatileSelector() {
QSize size(this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height()); QSize size(this->metatileSelector->pixmap().width(), this->metatileSelector->pixmap().height());
this->ui->graphicsView_Metatiles->setSceneRect(0, 0, size.width(), size.height());
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorMetatilesZoom() - 30) / 30.0); double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorMetatilesZoom() - 30) / 30.0);
QTransform transform; QTransform transform;
@ -1217,6 +1218,7 @@ void TilesetEditor::on_horizontalSlider_TilesZoom_valueChanged(int value) {
void TilesetEditor::redrawTileSelector() { void TilesetEditor::redrawTileSelector() {
QSize size(this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height()); QSize size(this->tileSelector->pixmap().width(), this->tileSelector->pixmap().height());
this->ui->graphicsView_Tiles->setSceneRect(0, 0, size.width(), size.height());
double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorTilesZoom() - 30) / 30.0); double scale = pow(3.0, static_cast<double>(porymapConfig.getTilesetEditorTilesZoom() - 30) / 30.0);
QTransform transform; QTransform transform;