Squashed commit of the following: [break_up_ui_h]
Closes #43 No segfault found in cos_play after completing the checklist. Maybe I accidentally fixed it...? commit6aa151aba3Author: John McCardle <mccardle.john@gmail.com> Date: Fri Apr 19 21:43:58 2024 -0400 UISprite.h/.cpp cleanup commitec0374ef50Author: John McCardle <mccardle.john@gmail.com> Date: Fri Apr 19 21:37:39 2024 -0400 UIGridPoint.h/.cpp reorganization commit2cb7339535Author: John McCardle <mccardle.john@gmail.com> Date: Fri Apr 19 21:19:25 2024 -0400 UIGrid.h/.cpp cleanup. I have reservations about the UIEntityCollection[Iter] classes + methods living there, but not enough to fix it right now. commit5d6af324bfAuthor: John McCardle <mccardle.john@gmail.com> Date: Thu Apr 18 22:14:57 2024 -0400 UIFrame - moving static method into class namespace; no type object access commit567218cd7bAuthor: John McCardle <mccardle.john@gmail.com> Date: Thu Apr 18 21:23:49 2024 -0400 UIEntity fixes for the UI.h split: There are segfaults in cos_play, I may have missed a type usage or something commit76693acd28Author: John McCardle <mccardle.john@gmail.com> Date: Sat Apr 13 00:18:37 2024 -0400 delete leftover comments commit9efe998a33Author: John McCardle <mccardle.john@gmail.com> Date: Sat Apr 13 00:17:43 2024 -0400 some work on UICaption and UICollection; fixing segfaults resulting from mcrfpydef namepace TypeObject usage commit714965da45Author: John McCardle <mccardle.john@gmail.com> Date: Fri Apr 12 14:15:00 2024 -0400 eliminate extra includes on UICaption commit8efa25878fAuthor: John McCardle <mccardle.john@gmail.com> Date: Wed Apr 10 23:41:14 2024 -0400 remove a lot of stuff commitc186d8c7f3Author: John McCardle <mccardle.john@gmail.com> Date: Wed Apr 10 23:10:15 2024 -0400 We are compiling again! Started refactoring UICaption to be more idiomatic commit1b6e2a709bAuthor: John McCardle <mccardle.john@gmail.com> Date: Tue Apr 9 22:42:02 2024 -0400 Still not quite compiling; as predicted, a lot of interdependency and definition order bugs to untangle commitaa7553a818Author: John McCardle <mccardle.john@gmail.com> Date: Tue Apr 9 22:41:20 2024 -0400 PyTexture clean up scribbles and experiments commitc0201d989aAuthor: John McCardle <mccardle.john@gmail.com> Date: Mon Apr 8 22:55:00 2024 -0400 additional unsaved changes commit83a63a3093Author: John McCardle <mccardle.john@gmail.com> Date: Mon Apr 8 22:45:00 2024 -0400 doesn't compile, but UI.h/.cpp code has been divvy'd up. refs #43 @2h
This commit is contained in:
parent
1a7186f745
commit
ac7f7052cd
20 changed files with 2814 additions and 3052 deletions
81
src/UIDrawable.cpp
Normal file
81
src/UIDrawable.cpp
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
#include "UIDrawable.h"
|
||||
#include "UIFrame.h"
|
||||
#include "UICaption.h"
|
||||
#include "UISprite.h"
|
||||
#include "UIGrid.h"
|
||||
|
||||
UIDrawable::UIDrawable() { click_callable = NULL; }
|
||||
|
||||
void UIDrawable::click_unregister()
|
||||
{
|
||||
click_callable.reset();
|
||||
}
|
||||
|
||||
void UIDrawable::render()
|
||||
{
|
||||
render(sf::Vector2f());
|
||||
}
|
||||
|
||||
PyObject* UIDrawable::get_click(PyObject* self, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure)); // trust me bro, it's an Enum
|
||||
PyObject* ptr;
|
||||
|
||||
switch (objtype)
|
||||
{
|
||||
case PyObjectsEnum::UIFRAME:
|
||||
ptr = ((PyUIFrameObject*)self)->data->click_callable->borrow();
|
||||
break;
|
||||
case PyObjectsEnum::UICAPTION:
|
||||
ptr = ((PyUICaptionObject*)self)->data->click_callable->borrow();
|
||||
break;
|
||||
case PyObjectsEnum::UISPRITE:
|
||||
ptr = ((PyUISpriteObject*)self)->data->click_callable->borrow();
|
||||
break;
|
||||
case PyObjectsEnum::UIGRID:
|
||||
ptr = ((PyUIGridObject*)self)->data->click_callable->borrow();
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "no idea how you did that; invalid UIDrawable derived instance for _get_click");
|
||||
return NULL;
|
||||
}
|
||||
if (ptr && ptr != Py_None)
|
||||
return ptr;
|
||||
else
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
int UIDrawable::set_click(PyObject* self, PyObject* value, void* closure) {
|
||||
PyObjectsEnum objtype = static_cast<PyObjectsEnum>(reinterpret_cast<long>(closure)); // trust me bro, it's an Enum
|
||||
UIDrawable* target;
|
||||
switch (objtype)
|
||||
{
|
||||
case PyObjectsEnum::UIFRAME:
|
||||
target = (((PyUIFrameObject*)self)->data.get());
|
||||
break;
|
||||
case PyObjectsEnum::UICAPTION:
|
||||
target = (((PyUICaptionObject*)self)->data.get());
|
||||
break;
|
||||
case PyObjectsEnum::UISPRITE:
|
||||
target = (((PyUISpriteObject*)self)->data.get());
|
||||
break;
|
||||
case PyObjectsEnum::UIGRID:
|
||||
target = (((PyUIGridObject*)self)->data.get());
|
||||
break;
|
||||
default:
|
||||
PyErr_SetString(PyExc_TypeError, "no idea how you did that; invalid UIDrawable derived instance for _set_click");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (value == Py_None)
|
||||
{
|
||||
target->click_unregister();
|
||||
} else {
|
||||
target->click_register(value);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void UIDrawable::click_register(PyObject* callable)
|
||||
{
|
||||
click_callable = std::make_unique<PyClickCallable>(callable);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue