Skip to content

Commit

Permalink
config: rename and restrict CLayoutValueData::fromAny to fromAnyPv
Browse files Browse the repository at this point in the history
This is only for casting `any` variables that represent a void * to a
CLayoutValueData*, not just any any.
  • Loading branch information
PaideiaDilemma committed Nov 3, 2024
1 parent 683220f commit 742c4fc
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/config/ConfigDataValues.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class CLayoutValueData : ICustomConfigValueData {
return std::format("{}{},{}{}", m_vValues.x, (m_sIsRelative.x) ? "%" : "px", m_vValues.y, (m_sIsRelative.y) ? "%" : "px");
}

static CLayoutValueData* fromAny(const std::any& v) {
static CLayoutValueData* fromAnyPv(const std::any& v) {
RASSERT(v.type() == typeid(void*), "Invalid config value type");
const auto P = (CLayoutValueData*)std::any_cast<void*>(v);
RASSERT(P, "Empty config value");
return P;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/widgets/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ CImage::CImage(const Vector2D& viewport_, COutput* output_, const std::string& r
rounding = std::any_cast<Hyprlang::INT>(props.at("rounding"));
border = std::any_cast<Hyprlang::INT>(props.at("border_size"));
color = std::any_cast<Hyprlang::INT>(props.at("border_color"));
pos = CLayoutValueData::fromAny(props.at("position"))->getAbsolute(viewport_);
pos = CLayoutValueData::fromAnyPv(props.at("position"))->getAbsolute(viewport_);
halign = std::any_cast<Hyprlang::STRING>(props.at("halign"));
valign = std::any_cast<Hyprlang::STRING>(props.at("valign"));
angle = std::any_cast<Hyprlang::FLOAT>(props.at("rotate"));
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/widgets/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void CLabel::plantTimer() {
CLabel::CLabel(const Vector2D& viewport_, const std::unordered_map<std::string, std::any>& props, const std::string& output) :
outputStringPort(output), shadow(this, props, viewport_) {
try {
pos = CLayoutValueData::fromAny(props.at("position"))->getAbsolute(viewport_);
pos = CLayoutValueData::fromAnyPv(props.at("position"))->getAbsolute(viewport_);
labelPreFormat = std::any_cast<Hyprlang::STRING>(props.at("text"));
halign = std::any_cast<Hyprlang::STRING>(props.at("halign"));
valign = std::any_cast<Hyprlang::STRING>(props.at("valign"));
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/widgets/PasswordInputField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ using namespace Hyprutils::String;
CPasswordInputField::CPasswordInputField(const Vector2D& viewport_, const std::unordered_map<std::string, std::any>& props, const std::string& output) :
viewport(viewport_), outputStringPort(output), shadow(this, props, viewport_) {
try {
pos = CLayoutValueData::fromAny(props.at("position"))->getAbsolute(viewport_);
size = CLayoutValueData::fromAny(props.at("size"))->getAbsolute(viewport_);
pos = CLayoutValueData::fromAnyPv(props.at("position"))->getAbsolute(viewport_);
size = CLayoutValueData::fromAnyPv(props.at("size"))->getAbsolute(viewport_);
halign = std::any_cast<Hyprlang::STRING>(props.at("halign"));
valign = std::any_cast<Hyprlang::STRING>(props.at("valign"));
outThick = std::any_cast<Hyprlang::INT>(props.at("outline_thickness"));
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/widgets/Shape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
CShape::CShape(const Vector2D& viewport_, const std::unordered_map<std::string, std::any>& props) : shadow(this, props, viewport_) {

try {
size = CLayoutValueData::fromAny(props.at("size"))->getAbsolute(viewport_);
size = CLayoutValueData::fromAnyPv(props.at("size"))->getAbsolute(viewport_);
rounding = std::any_cast<Hyprlang::INT>(props.at("rounding"));
border = std::any_cast<Hyprlang::INT>(props.at("border_size"));
color = std::any_cast<Hyprlang::INT>(props.at("color"));
borderColor = std::any_cast<Hyprlang::INT>(props.at("border_color"));
pos = CLayoutValueData::fromAny(props.at("position"))->getAbsolute(viewport_);
pos = CLayoutValueData::fromAnyPv(props.at("position"))->getAbsolute(viewport_);
halign = std::any_cast<Hyprlang::STRING>(props.at("halign"));
valign = std::any_cast<Hyprlang::STRING>(props.at("valign"));
angle = std::any_cast<Hyprlang::FLOAT>(props.at("rotate"));
Expand Down

0 comments on commit 742c4fc

Please sign in to comment.