fractorium/Source/Fractorium/PaletteEditor/PaletteEditor.h
Person 1dfbd4eff2 --User changes
-Add new preset dimensions to the right click menu of the width and height fields in the editor.
-Change QSS stylesheets to properly handle tabs.
-Make tabs rectangular by default. For some reason, they had always been triangular.

--Bug fixes
 -Incremental rendering times in the editor were wrong.

--Code changes
 -Migrate to Qt6. There is probably more work to be done here.
-Migrate to VS2022.
-Migrate to Wix 4 installer.
-Change installer to install to program files for all users.
-Fix many VS2022 code analysis warnings.
-No longer use byte typedef, because std::byte is now a type. Revert all back to unsigned char.
-Upgrade OpenCL headers to version 3.0 and keep locally now rather than trying to look for system files.
-No longer link to Nvidia or AMD specific OpenCL libraries. Use the generic installer located at OCL_ROOT too.
-Add the ability to change OpenCL grid dimensions. This was attempted for investigating possible performance improvments, but made no difference.

This has not been verified on Linux or Mac yet.
2023-04-25 17:59:54 -06:00

94 lines
3.3 KiB
C++

#pragma once
#include "FractoriumPch.h"
#include "Fractorium.h"
#include "ColorPickerWidget.h"
#include "GradientColorsView.h"
#include "EmberFile.h"
#include "ui_PaletteEditor.h"
namespace Ui
{
class PaletteEditor;
}
/// <summary>
/// Dialog for editing user created palettes.
/// This will load with all available user created palettes populated in the combo
/// box. As the user changes the selected index, the palettes for that file
/// are shown in the list box. The user can click on those and then edit them and either
/// save it back to the same position in the file, or append it to the end.
/// They can also click in the name column to set/rename the palette name.
/// Any changes on this dialog can be "synced". That is, when the Sync checkbox is checked
/// any changes result in a signal being sent back to the main window.
/// </summary>
class PaletteEditor : public QDialog
{
Q_OBJECT
public:
explicit PaletteEditor(QWidget* p = nullptr);
public:
bool Sync();
Palette<float>& GetPalette(int size);
void SetPalette(const Palette<float>& palette);
map<size_t, float> GetColorIndices() const;
map<size_t, float> GetPreviousColorIndices() const;
void SetColorIndices(const map<size_t, float>& indices);
void SetPreviousColorIndices(const map<size_t, float>& indices);
string GetPaletteFile() const;
void SetPaletteFile(const string& filename);
Q_SIGNALS:
void PaletteChanged();
void PaletteFileChanged();
void ColorIndexChanged(size_t index, float value);
private Q_SLOTS:
void OnAddColorButtonClicked();
void OnRemoveColorButtonClicked();
void OnInvertColorsButtonClicked();
void OnRandomColorsButtonClicked();
void OnDistributeColorsButtonClicked();
void OnResetToDefaultButtonClicked();
void OnCreatePaletteFromImageButtonClicked();
void OnCreatePaletteAgainFromImageButton();
void OnColorPickerColorChanged(const QColor& col);
void OnArrowDoubleClicked(const GradientArrow& arrow);
void OnSyncCheckBoxStateChanged(int state);
void OnBlendCheckBoxStateChanged(int state);
void OnArrowMoved(qreal lastPos, const GradientArrow& arrow);
void OnColorIndexMove(size_t index, float value);
void OnPaletteFilenameComboChanged(const QString& text);
void OnPaletteCellClicked(int row, int col);
void OnPaletteCellChanged(int row, int col);
void OnNewPaletteFileButtonClicked();
void OnCopyPaletteFileButtonClicked();
void OnAppendPaletteButtonClicked();
void OnOverwritePaletteButtonClicked();
void OnDeletePaletteButtonClicked();
private:
void EmitPaletteChanged();
void EmitColorIndexChanged(size_t index, float value);
QStringList SetupOpenImagesDialog();
void AddArrow(const QColor& color);
map<float, GradientArrow> GetRandomColorsFromImage(QString filename, int numPoints);
void EnablePaletteFileControls();
void EnablePaletteControls();
bool IsCurrentPaletteAndFileEditable();
bool m_PaletteFileChanged = false;
int m_PaletteIndex = 0;
map<size_t, float> m_PreviousColorIndices;
QString m_Filename;
string m_CurrentPaletteFilePath;
ColorPickerWidget* m_ColorPicker = nullptr;
GradientColorsView* m_GradientColorView = nullptr;
#ifndef __APPLE__
QFileDialog* m_FileDialog = nullptr;
#endif
shared_ptr<PaletteList<float>> m_PaletteList;
std::unique_ptr<Ui::PaletteEditor> ui;
};