OXYGENHUB
◆ main openmsx / src / imgui / ImGuiPalette.hh
1.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifndef IMGUI_PALETTE_HH
2
#define IMGUI_PALETTE_HH
3
4
#include "ImGuiCpp.hh"
5
#include "ImGuiPart.hh"
6
7
#include <array>
8
#include <cstdint>
9
#include <span>
10
11
namespace openmsx {
12
13
class VDP;
14
15
class ImGuiPalette final : public ImGuiPart
16
{
17
public:
18
	explicit ImGuiPalette(ImGuiManager& manager_);
19
20
	[[nodiscard]] zstring_view iniName() const override { return "Palette editor"; }
21
	void save(ImGuiTextBuffer& buf) override;
22
	void loadLine(std::string_view name, zstring_view value) override;
23
	void paint(MSXMotherBoard* motherBoard) override;
24
25
	std::array<uint32_t, 16> getPalette(const VDP* vdp) const;
26
27
public:
28
	im::WindowStatus window;
29
	int whichPalette = PALETTE_VDP;
30
31
private:
32
	static constexpr int PALETTE_VDP = 0;
33
	static constexpr int PALETTE_CUSTOM = 1;
34
	static constexpr int PALETTE_FIXED = 2;
35
	int selectedColor = 0;
36
37
	std::array<uint16_t, 16> customPalette; // palette in MSX format: 0GRB nibbles
38
39
	static constexpr auto persistentElements = std::tuple{
40
		PersistentElement   {"show",    &ImGuiPalette::window},
41
		PersistentElementMax{"palette", &ImGuiPalette::whichPalette, 3}
42
		// manually handle "customPalette"
43
	};
44
};
45
46
} // namespace openmsx
47
48
#endif