Skip to content

Commit

Permalink
Add the context menu and the tooltip
Browse files Browse the repository at this point in the history
One possible improvement would be to make it work across the entire row
  • Loading branch information
redorav committed Aug 24, 2022
1 parent 38bc9bb commit e0420f5
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 12 deletions.
24 changes: 24 additions & 0 deletions src/tppTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ namespace tpp
void Float::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Float::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Float::RevertToDefault() { currentValue = metadata.defaultValue; }

UInt::UInt(const char* path, uint32_t initialValue, uint32_t minValue, uint32_t maxValue, uint32_t step)
: VariableBase((VariableType)Type, sizeof(currentValue))
, currentValue(initialValue)
Expand All @@ -40,6 +42,8 @@ namespace tpp
void UInt::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void UInt::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void UInt::RevertToDefault() { currentValue = metadata.defaultValue; }

Int::Int(const char* path, int32_t initialValue, int32_t minValue, int32_t maxValue, int32_t step)
: VariableBase((VariableType)Type, sizeof(currentValue))
, currentValue(initialValue)
Expand All @@ -57,6 +61,8 @@ namespace tpp
void Int::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Int::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Int::RevertToDefault() { currentValue = metadata.defaultValue; }

Bool::Bool(const char* path, bool initialValue)
: VariableBase((VariableType)Type, sizeof(currentValue))
, currentValue(initialValue)
Expand All @@ -74,6 +80,8 @@ namespace tpp
void Bool::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Bool::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Bool::RevertToDefault() { currentValue = metadata.defaultValue; }

Color3::Color3(const char* path, float r, float g, float b)
: VariableBase((VariableType)Type, sizeof(currentValue))
, r(r), g(g), b(b)
Expand All @@ -91,6 +99,8 @@ namespace tpp
void Color3::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Color3::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Color3::RevertToDefault() { currentValue = metadata.defaultValue; }

Color4::Color4(const char* path, float r, float g, float b, float a)
: VariableBase((VariableType)Type, sizeof(currentValue))
, r(r), g(g), b(b), a(a)
Expand All @@ -108,6 +118,8 @@ namespace tpp
void Color4::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Color4::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Color4::RevertToDefault() { currentValue = metadata.defaultValue; }

Vector2::Vector2(const char* path, float x, float y)
: VariableBase((VariableType)Type, sizeof(currentValue))
, x(x), y(y)
Expand All @@ -125,6 +137,8 @@ namespace tpp
void Vector2::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Vector2::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Vector2::RevertToDefault() { currentValue = metadata.defaultValue; }

Vector3::Vector3(const char* path, float x, float y, float z)
: VariableBase((VariableType)Type, sizeof(currentValue))
, x(x), y(y), z(z)
Expand All @@ -142,6 +156,8 @@ namespace tpp
void Vector3::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Vector3::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Vector3::RevertToDefault() { currentValue = metadata.defaultValue; }

Vector4::Vector4(const char* path, float x, float y, float z, float w)
: VariableBase((VariableType)Type, sizeof(currentValue))
, x(x), y(y), z(z), w(w)
Expand All @@ -159,6 +175,8 @@ namespace tpp
void Vector4::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Vector4::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Vector4::RevertToDefault() { currentValue = metadata.defaultValue; }

Callback::Callback(const char* path, void(*callback)(void))
: VariableBase((VariableType)Type, 0)
, currentValue(callback)
Expand All @@ -179,6 +197,8 @@ namespace tpp
currentValue();
}

void Callback::RevertToDefault() {}

String::String(const char* path, const char* defaultValue)
: VariableBase((VariableType)Type, 0)
, currentValue(defaultValue)
Expand All @@ -202,6 +222,8 @@ namespace tpp
void String::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void String::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void String::RevertToDefault() { currentValue = defaultValue; }

Enum::Enum(const char* path, int defaultValue, const std::vector<EnumEntry>& entries)
: VariableBase((VariableType)Type, sizeof(currentValue))
, currentValue(defaultValue)
Expand Down Expand Up @@ -230,4 +252,6 @@ namespace tpp

void Enum::SerializeValue(tpp::BinarySerializationWriter& writer) const { writer << currentValue; }
void Enum::DeserializeValue(tpp::BinarySerializationReader& reader) { reader << currentValue; }

void Enum::RevertToDefault() { currentValue = metadata.defaultValue; }
}
18 changes: 18 additions & 0 deletions src/tppTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ namespace tpp
}
}

const std::string& GetPath() const
{
return path;
}

const std::string& GetGroupPath() const
{
return groupPath;
Expand Down Expand Up @@ -91,6 +96,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader & reader) = 0;
virtual void SerializeValue(tpp::BinarySerializationWriter & writer) const = 0;
virtual void DeserializeValue(tpp::BinarySerializationReader & reader) = 0;
virtual void RevertToDefault() = 0;
};

class Float final : public VariableBase
Expand All @@ -106,6 +112,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

operator float()
{
Expand Down Expand Up @@ -148,6 +155,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

operator uint32_t()
{
Expand Down Expand Up @@ -189,6 +197,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

mutable int32_t currentValue = 0;

Expand Down Expand Up @@ -227,6 +236,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

mutable bool currentValue = 0;

Expand Down Expand Up @@ -258,6 +268,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

union
{
Expand Down Expand Up @@ -298,6 +309,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

union
{
Expand Down Expand Up @@ -338,6 +350,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

union
{
Expand Down Expand Up @@ -378,6 +391,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

union
{
Expand Down Expand Up @@ -417,6 +431,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

union
{
Expand Down Expand Up @@ -457,6 +472,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

enum : uint32_t
{
Expand All @@ -479,6 +495,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

std::string defaultValue;

Expand Down Expand Up @@ -510,6 +527,7 @@ namespace tpp
virtual void DeserializeMetadata(tpp::BinarySerializationReader& reader) override;
virtual void SerializeValue(tpp::BinarySerializationWriter& writer) const override;
virtual void DeserializeValue(tpp::BinarySerializationReader& reader) override;
virtual void RevertToDefault() override;

enum : uint32_t
{
Expand Down
Loading

0 comments on commit e0420f5

Please sign in to comment.