diff --git a/qrenderdoc/Widgets/RDDoubleSpinBox.cpp b/qrenderdoc/Widgets/RDDoubleSpinBox.cpp new file mode 100644 index 000000000..03de9dd25 --- /dev/null +++ b/qrenderdoc/Widgets/RDDoubleSpinBox.cpp @@ -0,0 +1,39 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2016 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include "RDDoubleSpinBox.h" + +RDDoubleSpinBox::RDDoubleSpinBox(QWidget *parent) : QDoubleSpinBox(parent) +{ +} + +RDDoubleSpinBox::~RDDoubleSpinBox() +{ +} + +void RDDoubleSpinBox::keyPressEvent(QKeyEvent *e) +{ + emit keyPress(e); + QDoubleSpinBox::keyPressEvent(e); +} diff --git a/qrenderdoc/Widgets/RDDoubleSpinBox.h b/qrenderdoc/Widgets/RDDoubleSpinBox.h new file mode 100644 index 000000000..5cf6e2382 --- /dev/null +++ b/qrenderdoc/Widgets/RDDoubleSpinBox.h @@ -0,0 +1,42 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2016 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#pragma once + +#include + +class RDDoubleSpinBox : public QDoubleSpinBox +{ +private: + Q_OBJECT +public: + explicit RDDoubleSpinBox(QWidget *parent = 0); + ~RDDoubleSpinBox(); + +signals: + void keyPress(QKeyEvent *e); + +private: + void keyPressEvent(QKeyEvent *e) override; +}; diff --git a/qrenderdoc/Widgets/TextureGoto.cpp b/qrenderdoc/Widgets/TextureGoto.cpp new file mode 100644 index 000000000..228631fe8 --- /dev/null +++ b/qrenderdoc/Widgets/TextureGoto.cpp @@ -0,0 +1,118 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2016 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#include "TextureGoto.h" +#include +#include +#include +#include +#include +#include "Widgets/RDDoubleSpinBox.h" + +TextureGoto::TextureGoto(QWidget *parent, std::function callback) : QDialog(parent) +{ + m_Callback = callback; + + setWindowFlags(Qt::Window | Qt::FramelessWindowHint); + + QHBoxLayout *hbox = new QHBoxLayout(this); + hbox->setSpacing(5); + hbox->setMargin(0); + + QFrame *frame = new QFrame(this); + frame->setGeometry(geometry()); + frame->setFrameShadow(QFrame::Raised); + frame->setFrameStyle(QFrame::StyledPanel); + + hbox->addWidget(frame); + + QGridLayout *gridLayout = new QGridLayout(frame); + gridLayout->setSpacing(4); + gridLayout->setContentsMargins(3, 3, 3, 3); + QLabel *label = new QLabel(this); + label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); + label->setText(tr("Goto Location")); + label->setAlignment(Qt::AlignCenter); + + gridLayout->addWidget(label, 0, 0, 1, 2); + + m_X = new RDDoubleSpinBox(frame); + m_X->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); + m_X->setMinimumSize(QSize(40, 0)); + m_X->setDecimals(0); + m_X->setSingleStep(1.0); + m_X->setRange(0.0, 65536.0); + m_X->setValue(10); + + gridLayout->addWidget(m_X, 1, 0, 1, 1); + + m_Y = new RDDoubleSpinBox(frame); + m_Y->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); + m_Y->setMinimumSize(QSize(40, 0)); + m_Y->setDecimals(0); + m_Y->setSingleStep(1.0); + m_Y->setRange(0.0, 65536.0); + m_Y->setValue(20); + + QObject::connect(m_X, &RDDoubleSpinBox::keyPress, this, &TextureGoto::location_keyPress); + QObject::connect(m_Y, &RDDoubleSpinBox::keyPress, this, &TextureGoto::location_keyPress); + + gridLayout->addWidget(m_Y, 1, 1, 1, 1); + + setTabOrder(m_X, m_Y); + setTabOrder(m_Y, m_X); +} + +QPoint TextureGoto::point() +{ + return QPoint(m_X->value(), m_Y->value()); +} + +void TextureGoto::show(QWidget *showParent, QPoint p) +{ + m_X->setValue(p.x()); + m_Y->setValue(p.y()); + + move(showParent->mapToGlobal(showParent->geometry().topLeft()) + showParent->rect().center() - + rect().center()); + + QDialog::show(); + + m_Y->setFocus(Qt::TabFocusReason); + m_X->setFocus(Qt::TabFocusReason); +} + +void TextureGoto::leaveEvent(QEvent *event) +{ + QDialog::hide(); +} + +void TextureGoto::location_keyPress(QKeyEvent *event) +{ + if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) + { + m_Callback(point()); + QDialog::hide(); + } +} diff --git a/qrenderdoc/Widgets/TextureGoto.h b/qrenderdoc/Widgets/TextureGoto.h new file mode 100644 index 000000000..5fd94e948 --- /dev/null +++ b/qrenderdoc/Widgets/TextureGoto.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2016 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +#pragma once + +#include +#include + +class RDDoubleSpinBox; + +class TextureGoto : public QDialog +{ + Q_OBJECT +public: + explicit TextureGoto(QWidget *parent, std::function callback); + + QPoint point(); + void show(QWidget *showParent, QPoint p); + +signals: + +public slots: + void location_keyPress(QKeyEvent *); + +private: + void leaveEvent(QEvent *event) override; + + RDDoubleSpinBox *m_X, *m_Y; + std::function m_Callback; +}; diff --git a/qrenderdoc/Windows/EventBrowser.ui b/qrenderdoc/Windows/EventBrowser.ui index 907354292..b6475d3aa 100644 --- a/qrenderdoc/Windows/EventBrowser.ui +++ b/qrenderdoc/Windows/EventBrowser.ui @@ -78,9 +78,6 @@ :/Resources/find.png:/Resources/find.png - - Ctrl+F - false @@ -101,9 +98,6 @@ :/Resources/flag_green.png:/Resources/flag_green.png - - Ctrl+G - true @@ -118,9 +112,6 @@ :/Resources/time.png:/Resources/time.png - - Ctrl+T - true @@ -135,9 +126,6 @@ :/Resources/asterisk_orange.png:/Resources/asterisk_orange.png - - Ctrl+B - true diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 33dcbfe1d..216784f5c 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -30,6 +30,7 @@ #include "3rdparty/toolwindowmanager/ToolWindowManagerArea.h" #include "Code/CaptureContext.h" #include "Widgets/ResourcePreview.h" +#include "Widgets/TextureGoto.h" #include "FlowLayout.h" #include "ui_TextureViewer.h" @@ -402,6 +403,8 @@ TextureViewer::TextureViewer(CaptureContext *ctx, QWidget *parent) ui->outputThumbs->setWindowTitle(tr("Outputs")); ui->inputThumbs->setWindowTitle(tr("Inputs")); + m_Goto = new TextureGoto(this, [this](QPoint p) { GotoLocation(p.x(), p.y()); }); + QVBoxLayout *vertical = new QVBoxLayout(this); vertical->setSpacing(3); @@ -478,12 +481,13 @@ TextureViewer::~TextureViewer() void TextureViewer::RT_FetchCurrentPixel(uint32_t x, uint32_t y, PixelValue &pickValue, PixelValue &realValue) { - // FetchTexture tex = CurrentTexture; + FetchTexture *texptr = GetCurrentTexture(); - // if (tex == null) return; + if(texptr == NULL) + return; - // if (m_TexDisplay.FlipY) - // y = (tex.height - 1) - y; + if(m_TexDisplay.FlipY) + y = (texptr->height - 1) - y; m_Output->PickPixel(m_TexDisplay.texid, true, x, y, m_TexDisplay.sliceFace, m_TexDisplay.mip, m_TexDisplay.sampleIdx, &pickValue); @@ -1403,6 +1407,31 @@ void TextureViewer::UI_CreateThumbnails() UI_CreateThumbnail(ui->inputThumbs); } +void TextureViewer::GotoLocation(int x, int y) +{ + if(!m_Ctx->LogLoaded()) + return; + + FetchTexture *tex = GetCurrentTexture(); + + if(tex == NULL) + return; + + m_PickedPoint = QPoint(x, y); + + uint32_t mipHeight = qMax(1U, tex->height >> (int)m_TexDisplay.mip); + if(m_Ctx->APIProps().pipelineType == eGraphicsAPI_OpenGL) + m_PickedPoint.setY((int)(mipHeight - 1) - m_PickedPoint.y()); + if(m_TexDisplay.FlipY) + m_PickedPoint.setY((int)(mipHeight - 1) - m_PickedPoint.x()); + + if(m_Output != NULL) + INVOKE_MEMFN(RT_PickPixelsAndUpdate); + INVOKE_MEMFN(RT_UpdateAndDisplay); + + UI_UpdateStatusText(); +} + void TextureViewer::ViewTexture(ResourceId ID, bool focus) { if(QThread::currentThread() != QCoreApplication::instance()->thread()) @@ -2003,6 +2032,11 @@ void TextureViewer::render_keyPress(QKeyEvent *e) if(!m_Ctx->LogLoaded()) return; + if((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_G) + { + ShowGotoPopup(); + } + bool nudged = false; int increment = 1 << (int)m_TexDisplay.mip; @@ -2671,3 +2705,39 @@ void TextureViewer::on_sliceFace_currentIndexChanged(int index) INVOKE_MEMFN(RT_UpdateAndDisplay); } + +void TextureViewer::on_locationGoto_clicked() +{ + ShowGotoPopup(); +} + +void TextureViewer::ShowGotoPopup() +{ + FetchTexture *texptr = GetCurrentTexture(); + + if(texptr) + { + QPoint p = m_PickedPoint; + + uint32_t mipHeight = qMax(1U, texptr->height >> (int)m_TexDisplay.mip); + + if(m_Ctx->APIProps().pipelineType == eGraphicsAPI_OpenGL) + p.setY((int)(mipHeight - 1) - p.y()); + if(m_TexDisplay.FlipY) + p.setY((int)(mipHeight - 1) - p.y()); + + m_Goto->show(ui->render, p); + } +} + +void TextureViewer::on_viewTexBuffer_clicked() +{ +} + +void TextureViewer::on_texListShow_clicked() +{ +} + +void TextureViewer::on_saveTex_clicked() +{ +} diff --git a/qrenderdoc/Windows/TextureViewer.h b/qrenderdoc/Windows/TextureViewer.h index ff88640da..35a2b0efd 100644 --- a/qrenderdoc/Windows/TextureViewer.h +++ b/qrenderdoc/Windows/TextureViewer.h @@ -36,6 +36,7 @@ class TextureViewer; class ResourcePreview; class ThumbnailStrip; +class TextureGoto; enum struct FollowType { @@ -127,6 +128,7 @@ public: void OnLogfileClosed(); void OnEventSelected(uint32_t eventID); + void GotoLocation(int x, int y); void ViewTexture(ResourceId ID, bool focus); QVariant persistData(); @@ -173,6 +175,11 @@ private slots: void channelsWidget_toggled(bool checked) { UI_UpdateChannels(); } void channelsWidget_selected(int index) { UI_UpdateChannels(); } + void on_locationGoto_clicked(); + void on_viewTexBuffer_clicked(); + void on_texListShow_clicked(); + void on_saveTex_clicked(); + private: void RT_FetchCurrentPixel(uint32_t x, uint32_t y, PixelValue &pickValue, PixelValue &realValue); void RT_PickPixelsAndUpdate(IReplayRenderer *); @@ -222,6 +229,8 @@ private: FetchTexture *GetCurrentTexture(); + void ShowGotoPopup(); + void UI_UpdateFittedScale(); void UI_SetScale(float s); void UI_SetScale(float s, int x, int y); @@ -252,6 +261,8 @@ private: ResourceId m_LockedId; QMap m_LockedTabs; + TextureGoto *m_Goto; + Ui::TextureViewer *ui; CaptureContext *m_Ctx = NULL; IReplayOutput *m_Output = NULL; diff --git a/qrenderdoc/Windows/TextureViewer.ui b/qrenderdoc/Windows/TextureViewer.ui index cecfc66d2..c4104c545 100644 --- a/qrenderdoc/Windows/TextureViewer.ui +++ b/qrenderdoc/Windows/TextureViewer.ui @@ -454,7 +454,7 @@ - + diff --git a/qrenderdoc/qrenderdoc.pro b/qrenderdoc/qrenderdoc.pro index c5ccdf811..310ed2ad7 100644 --- a/qrenderdoc/qrenderdoc.pro +++ b/qrenderdoc/qrenderdoc.pro @@ -96,7 +96,9 @@ SOURCES += Code/qrenderdoc.cpp \ Widgets/ResourcePreview.cpp \ Widgets/RDLabel.cpp \ Widgets/ThumbnailStrip.cpp \ - Code/CommonPipelineState.cpp + Code/CommonPipelineState.cpp \ + Widgets/TextureGoto.cpp \ + Widgets/RDDoubleSpinBox.cpp HEADERS += Windows/MainWindow.h \ Windows/EventBrowser.h \ @@ -114,7 +116,9 @@ HEADERS += Windows/MainWindow.h \ Widgets/ResourcePreview.h \ Widgets/RDLabel.h \ Widgets/ThumbnailStrip.h \ - Code/CommonPipelineState.h + Code/CommonPipelineState.h \ + Widgets/TextureGoto.h \ + Widgets/RDDoubleSpinBox.h FORMS += Windows/MainWindow.ui \ Windows/EventBrowser.ui \ diff --git a/qrenderdoc/qrenderdoc_local.vcxproj b/qrenderdoc/qrenderdoc_local.vcxproj index 760218152..3cc6644ad 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj +++ b/qrenderdoc/qrenderdoc_local.vcxproj @@ -282,18 +282,22 @@ + + + + @@ -326,8 +330,10 @@ + + diff --git a/qrenderdoc/qrenderdoc_local.vcxproj.filters b/qrenderdoc/qrenderdoc_local.vcxproj.filters index 67761a401..7b68db6cf 100644 --- a/qrenderdoc/qrenderdoc_local.vcxproj.filters +++ b/qrenderdoc/qrenderdoc_local.vcxproj.filters @@ -136,6 +136,18 @@ Generated Files + + Widgets + + + Generated Files + + + Generated Files + + + Widgets + @@ -195,6 +207,12 @@ Generated Files + + Widgets + + + Widgets +