/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #pragma once #include #include #include #include #include #include #include namespace Ui { class TexturePreviewWidget; } namespace ImageProcessingEditor { enum PreviewMode { RGB = 0, RRR, GGG, BBB, Alpha, RGBA, Count }; enum class RefreshMode { Convert, // Convert the whole image from beginning, takes longest time Mip, // Generate a new mip from from converted image Channel, // Generate a new channel image from converted image Repaint, }; class TexturePreviewWidget : public QWidget , protected EditorInternalNotificationBus::Handler { Q_OBJECT public: AZ_CLASS_ALLOCATOR(TexturePreviewWidget, AZ::SystemAllocator, 0); explicit TexturePreviewWidget(EditorTextureSetting& texureSetting, QWidget* parent = 0); ~TexturePreviewWidget(); bool OnQtEvent(QEvent* event); public slots: void OnTiledChanged(bool checked); void OnPrevMip(); void OnNextMip(); void OnChangePreviewMode(int index); void UpdatePreview(); void OnAlwaysRefresh(); void OnRefreshPerClick(); void OnRefreshClicked(); protected: //////////////////////////////////////////////////////////////////////// //EditorInternalNotificationBus void OnEditorSettingsChanged(bool needRefresh, const AZStd::string& platform); //////////////////////////////////////////////////////////////////////// void resizeEvent(QResizeEvent *event) override; bool eventFilter(QObject* obj, QEvent* event) override; private: void SetUpResolutionInfo(); void RefreshUI(bool fullRefresh = false); void RefreshPreviewImage(RefreshMode mode); void GenerateMipmap(int mip); void GenerateChannelImage(PreviewMode channel); void PaintPreviewImage(); void SetImageLabelText(const QString& text, bool busyStatus = true); void RefreshWarning(); AZStd::list m_resolutionInfos; QScopedPointer m_ui; EditorTextureSetting* m_textureSetting; int m_currentMipIndex = 0; bool m_previewTiled = false; float m_imageLabelSize = 0; AZStd::string m_platform; unsigned int m_mipCount = 1; /////////////////////////////////////////// // Preview window PreviewMode m_previewMode = PreviewMode::RGB; QScopedPointer m_previewPopup; AZStd::unique_ptr m_previewConverter; ImageProcessing::IImageObjectPtr m_previewImageRaw; QImage m_previewImages[PreviewMode::Count]; QTimer* m_updateTimer; static const int s_updateInterval = 200; //////////////////////////////////////////// //////////////////////////////////////////// // Refresh button bool m_alwaysRefreshPreview = true; QAction* m_alwaysRefreshAction = nullptr; QAction* m_refreshPerClickAction = nullptr; QIcon m_refreshPerClickIcon; QIcon m_alwaysRefreshIcon; //////////////////////////////////////////// }; } //namespace ImageProcessingEditor