LinkedColor now reflecting changes to the linked color value. Needs set method + RGBA / color properties
This commit is contained in:
parent
41509dfe96
commit
06e24a1b27
4 changed files with 35 additions and 19 deletions
|
|
@ -13,12 +13,12 @@ PyLinkedColor::PyLinkedColor(_PyLinkedColorData d)
|
|||
data = d;
|
||||
}
|
||||
|
||||
PyLinkedColor::PyLinkedColor(sf::Color (*getter)(), void (*setter)(sf::Color), std::weak_ptr<UIDrawable> parent, int index)
|
||||
PyLinkedColor::PyLinkedColor(std::function<void(sf::Color)> _s, std::function<sf::Color()> _g, std::weak_ptr<UIDrawable> parent, int index)
|
||||
{
|
||||
data.index = index;
|
||||
data.setter = _s;
|
||||
data.getter = _g;
|
||||
data.parent = parent;
|
||||
data.setter = setter;
|
||||
data.getter = getter;
|
||||
data.index = index;
|
||||
}
|
||||
|
||||
PyObject* PyLinkedColor::pyObject()
|
||||
|
|
@ -42,6 +42,7 @@ PyLinkedColor PyLinkedColor::fromPy(PyLinkedColorObject* self)
|
|||
|
||||
void PyLinkedColor::set(sf::Color color)
|
||||
{
|
||||
std::cout << "PyLinkedColor: call to set()" << std::endl;
|
||||
auto ptr = data.parent.lock();
|
||||
if (ptr)
|
||||
{
|
||||
|
|
@ -52,6 +53,7 @@ void PyLinkedColor::set(sf::Color color)
|
|||
|
||||
sf::Color PyLinkedColor::get()
|
||||
{
|
||||
std::cout << "PyLinkedColor: call to get()" << std::endl;
|
||||
auto ptr = data.parent.lock();
|
||||
if (ptr)
|
||||
{
|
||||
|
|
@ -92,7 +94,7 @@ Py_hash_t PyLinkedColor::hash(PyObject* obj)
|
|||
auto ptr = self->data.parent.lock();
|
||||
if (ptr)
|
||||
{
|
||||
auto color = PyLinkedColor(self->data);
|
||||
auto linkedcolor = PyLinkedColor(self->data);
|
||||
auto c = linkedcolor.get();
|
||||
value += c.r;
|
||||
value << 8; value += c.g;
|
||||
|
|
@ -114,7 +116,7 @@ PyObject* PyLinkedColor::repr(PyObject* obj)
|
|||
std::ostringstream ss;
|
||||
PyLinkedColor color = PyLinkedColor(self->data);
|
||||
sf::Color c = color.get();
|
||||
ss << "<Color (" << c.r << ", " << c.g << ", " << c.b << ", " << c.a << ") " << color.mode() << ">";
|
||||
ss << "<LinkedColor (" << int(c.r) << ", " << int(c.g) << ", " << int(c.b) << ", " << int(c.a) << ")" << ">";
|
||||
|
||||
std::string repr_str = ss.str();
|
||||
return PyUnicode_DecodeUTF8(repr_str.c_str(), repr_str.size(), "replace");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue