diff --git a/src/dearpygui_commands.h b/src/dearpygui_commands.h index e25355bc2..95d37cbf2 100644 --- a/src/dearpygui_commands.h +++ b/src/dearpygui_commands.h @@ -24,7 +24,7 @@ bind_colormap(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* sourceraw; if (!Parse((GetParsers())["bind_colormap"], args, kwargs, __FUNCTION__, &itemraw, &sourceraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -36,7 +36,7 @@ bind_colormap(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_colormap", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (source > 15) @@ -46,7 +46,7 @@ bind_colormap(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_colormap", "Source Item not found: " + std::to_string(source), nullptr); - return GetPyNone(); + return nullptr; } if (asource->type == mvAppItemType::mvColorMap) @@ -86,7 +86,7 @@ bind_colormap(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "bind_colormap", "Incompatible type. Expected types include: mvPlot, mvColorMapScale, mvColorMapButton", aitem); - return GetPyNone(); + return nullptr; } @@ -100,7 +100,7 @@ sample_colormap(PyObject* self, PyObject* args, PyObject* kwargs) float t; if (!Parse((GetParsers())["sample_colormap"], args, kwargs, __FUNCTION__, &itemraw, &t)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -113,7 +113,7 @@ sample_colormap(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "sample_colormap", "Source Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (asource->type == mvAppItemType::mvColorMap) @@ -127,7 +127,7 @@ sample_colormap(PyObject* self, PyObject* args, PyObject* kwargs) if (!GContext->started) { mvThrowPythonError(mvErrorCode::mvNone, "sample_colormap", "This command can only be ran once the app is started.", nullptr); - return GetPyNone(); + return nullptr; } ImVec4 result = ImPlot::SampleColormap(t, (ImPlotColormap)item); @@ -142,7 +142,7 @@ get_colormap_color(PyObject* self, PyObject* args, PyObject* kwargs) int index; if (!Parse((GetParsers())["get_colormap_color"], args, kwargs, __FUNCTION__, &itemraw, &index)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -155,7 +155,7 @@ get_colormap_color(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_colormap_color", "Source Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (asource->type == mvAppItemType::mvColorMap) @@ -177,7 +177,7 @@ get_file_dialog_info(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* file_dialog_raw; if (!Parse((GetParsers())["get_file_dialog_info"], args, kwargs, __FUNCTION__, &file_dialog_raw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -187,13 +187,13 @@ get_file_dialog_info(PyObject* self, PyObject* args, PyObject* kwargs) if (aplot == nullptr) { mvThrowPythonError(mvErrorCode::mvNone, std::to_string(file_dialog) + " plot does not exist."); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvFileDialog) { mvThrowPythonError(mvErrorCode::mvNone, std::to_string(file_dialog) + " is not a plot."); - return GetPyNone(); + return nullptr; } mvFileDialog* graph = static_cast(aplot); @@ -211,7 +211,7 @@ set_x_scroll(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_x_scroll"], args, kwargs, __FUNCTION__, &itemraw, &value, &when)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -222,7 +222,7 @@ set_x_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_x_scroll", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (DearPyGui::GetApplicableState(window->type) & MV_STATE_SCROLL) @@ -234,6 +234,7 @@ set_x_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "set_x_scroll", "Incompatible type. Expected types include: mvWindowAppItem, mvChildWindow, mvTable", window); + return nullptr; } return GetPyNone(); @@ -249,7 +250,7 @@ set_y_scroll(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_y_scroll"], args, kwargs, __FUNCTION__, &itemraw, &value, &when)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -260,7 +261,7 @@ set_y_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_y_scroll", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (DearPyGui::GetApplicableState(window->type) & MV_STATE_SCROLL) @@ -272,6 +273,7 @@ set_y_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "set_y_scroll", "Incompatible type. Expected types include: mvWindowAppItem, mvChildWindow, mvTable", window); + return nullptr; } return GetPyNone(); @@ -285,7 +287,7 @@ get_x_scroll(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["get_x_scroll"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -296,7 +298,7 @@ get_x_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_x_scroll", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (DearPyGui::GetApplicableState(window->type) & MV_STATE_SCROLL) @@ -307,6 +309,7 @@ get_x_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_x_scroll", "Incompatible type. Expected types include: mvWindowAppItem, mvChildWindow, mvTable", window); + return nullptr; } return GetPyNone(); @@ -320,7 +323,7 @@ get_y_scroll(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["get_y_scroll"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -331,7 +334,7 @@ get_y_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_y_scroll", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (DearPyGui::GetApplicableState(window->type) & MV_STATE_SCROLL) @@ -342,6 +345,7 @@ get_y_scroll(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_y_scroll", "Incompatible type. Expected types include: mvWindowAppItem, mvChildWindow, mvTable", window); + return nullptr; } return GetPyNone(); @@ -355,7 +359,7 @@ get_x_scroll_max(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["get_x_scroll_max"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -366,7 +370,7 @@ get_x_scroll_max(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_x_scroll_max", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (DearPyGui::GetApplicableState(window->type) & MV_STATE_SCROLL) @@ -377,6 +381,7 @@ get_x_scroll_max(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_x_scroll_max", "Incompatible type. Expected types include: mvWindowAppItem, mvChildWindow, mvTable", window); + return nullptr; } return GetPyNone(); @@ -390,7 +395,7 @@ get_y_scroll_max(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["get_y_scroll_max"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -401,7 +406,7 @@ get_y_scroll_max(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_y_scroll_max", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (DearPyGui::GetApplicableState(window->type) & MV_STATE_SCROLL) @@ -412,6 +417,7 @@ get_y_scroll_max(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_y_scroll_max", "Incompatible type. Expected types include: mvWindowAppItem, mvChildWindow, mvTable", window); + return nullptr; } return GetPyNone(); @@ -430,7 +436,7 @@ set_clip_space(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_clip_space"], args, kwargs, __FUNCTION__, &itemraw, &topleftx, &toplefty, &width, &height, &mindepth, &maxdepth)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -441,7 +447,7 @@ set_clip_space(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "apply_transform", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (aitem->type == mvAppItemType::mvDrawLayer) @@ -466,7 +472,7 @@ set_clip_space(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "applydrawInfo->transform", "Incompatible type. Expected types include: mvDrawLayer", aitem); - return GetPyNone(); + return nullptr; } @@ -480,7 +486,7 @@ apply_transform(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* transform; if (!Parse((GetParsers())["apply_transform"], args, kwargs, __FUNCTION__, &itemraw, &transform)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -493,7 +499,7 @@ apply_transform(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "apply_transform", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (aitem->type == mvAppItemType::mvDrawNode) @@ -506,7 +512,7 @@ apply_transform(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "apply_transform", "Incompatible type. Expected types include: mvDrawNode", aitem); - return GetPyNone(); + return nullptr; } @@ -521,7 +527,7 @@ create_rotation_matrix(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* axis; if (!Parse((GetParsers())["create_rotation_matrix"], args, kwargs, __FUNCTION__, &angle, &axis)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -547,7 +553,7 @@ create_perspective_matrix(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["create_perspective_matrix"], args, kwargs, __FUNCTION__, &fov, &aspect, &zNear, &zFar)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -573,7 +579,7 @@ create_orthographic_matrix(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["create_orthographic_matrix"], args, kwargs, __FUNCTION__, &left, &right, &bottom, &top, &zNear, &zFar)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -594,7 +600,7 @@ create_translation_matrix(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* axis; if (!Parse((GetParsers())["create_translation_matrix"], args, kwargs, __FUNCTION__, &axis)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -617,7 +623,7 @@ create_scale_matrix(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* axis; if (!Parse((GetParsers())["create_scale_matrix"], args, kwargs, __FUNCTION__, &axis)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -643,7 +649,7 @@ create_lookat_matrix(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["create_lookat_matrix"], args, kwargs, __FUNCTION__, &eye, ¢er, &up)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -671,7 +677,7 @@ create_fps_matrix(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["create_fps_matrix"], args, kwargs, __FUNCTION__, &eye, &pitch, &yaw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -694,7 +700,7 @@ bind_font(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["bind_font"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -712,14 +718,14 @@ bind_font(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_font", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvFont) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "bind_font", "Incompatible type. Expected types include: mvFont", aplot); - return GetPyNone(); + return nullptr; } mvFont* graph = static_cast(aplot); @@ -740,7 +746,7 @@ get_text_size(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["get_text_size"], args, kwargs, __FUNCTION__, &text, &wrap_width, &fontRaw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -760,14 +766,14 @@ get_text_size(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_text_size", "Item not found: " + std::to_string(font), nullptr); - return GetPyNone(); + return nullptr; } if (afont->type != mvAppItemType::mvFont) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_text_size", "Incompatible type. Expected types include: mvFont", afont); - return GetPyNone(); + return nullptr; } mvFont* graph = static_cast(afont); @@ -806,14 +812,14 @@ get_selected_nodes(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_selected_nodes", "Item not found: " + std::to_string(node_editor), nullptr); - return GetPyNone(); + return nullptr; } if (anode_editor->type != mvAppItemType::mvNodeEditor) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_selected_nodes", "Incompatible type. Expected types include: mvNodeEditor", anode_editor); - return GetPyNone(); + return nullptr; } mvNodeEditor* editor = static_cast(anode_editor); @@ -841,14 +847,14 @@ get_selected_links(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_selected_links", "Item not found: " + std::to_string(node_editor), nullptr); - return GetPyNone(); + return nullptr; } if (anode_editor->type != mvAppItemType::mvNodeEditor) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_selected_links", "Incompatible type. Expected types include: mvNodeEditor", anode_editor); - return GetPyNone(); + return nullptr; } mvNodeEditor* editor = static_cast(anode_editor); @@ -875,14 +881,14 @@ clear_selected_links(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "clear_selected_links", "Item not found: " + std::to_string(node_editor), nullptr); - return GetPyNone(); + return nullptr; } if (anode_editor->type != mvAppItemType::mvNodeEditor) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "clear_selected_links", "Incompatible type. Expected types include: mvNodeEditor", anode_editor); - return GetPyNone(); + return nullptr; } mvNodeEditor* editor = static_cast(anode_editor); @@ -909,14 +915,14 @@ clear_selected_nodes(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "clear_selected_nodes", "Item not found: " + std::to_string(node_editor), nullptr); - return GetPyNone(); + return nullptr; } if (anode_editor->type != mvAppItemType::mvNodeEditor) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "clear_selected_nodes", "Incompatible type. Expected types include: mvNodeEditor", anode_editor); - return GetPyNone(); + return nullptr; } mvNodeEditor* editor = static_cast(anode_editor); @@ -933,7 +939,7 @@ get_plot_query_rects(PyObject* self, PyObject* args, PyObject* kwargs) auto tag = "get_plot_query_rects"; if (!Parse((GetParsers())[tag], args, kwargs, __FUNCTION__, &plotraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -943,13 +949,13 @@ get_plot_query_rects(PyObject* self, PyObject* args, PyObject* kwargs) if (aplot == nullptr) { mvThrowPythonError(mvErrorCode::mvItemNotFound, tag, "Item not found: " + std::to_string(plot), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlot) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, tag, "Incompatible type. Expected types include: mvPlot", aplot); - return GetPyNone(); + return nullptr; } mvPlot* graph = static_cast(aplot); @@ -971,7 +977,7 @@ set_axis_ticks(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* label_pairs; if (!Parse((GetParsers())["set_axis_ticks"], args, kwargs, __FUNCTION__, &plotraw, &label_pairs)) - return GetPyNone(); + return nullptr; auto mlabel_pairs = ToVectPairStringFloat(label_pairs); @@ -984,14 +990,14 @@ set_axis_ticks(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_axis_ticks", "Item not found: " + std::to_string(plot), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "set_axis_ticks", "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1026,7 +1032,7 @@ set_axis_limits_constraints(PyObject* self, PyObject* args, PyObject* kwargs) auto tag = "set_axis_limits_constraints"; if (!Parse((GetParsers())[tag], args, kwargs, __FUNCTION__, &axisraw, &vmin, &vmax)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1037,14 +1043,14 @@ set_axis_limits_constraints(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, tag, "Item not found: " + std::to_string(axis), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, tag, "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1060,7 +1066,7 @@ reset_axis_limits_constraints(PyObject* self, PyObject* args, PyObject* kwargs) auto tag = "reset_axis_limits_constraints"; if (!Parse((GetParsers())[tag], args, kwargs, __FUNCTION__, &axisraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1071,14 +1077,14 @@ reset_axis_limits_constraints(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, tag, "Item not found: " + std::to_string(axis), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, tag, "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1095,7 +1101,7 @@ set_axis_zoom_constraints(PyObject* self, PyObject* args, PyObject* kwargs) auto tag = "set_axis_zoom_constraints"; if (!Parse((GetParsers())[tag], args, kwargs, __FUNCTION__, &axisraw, &vmin, &vmax)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1106,14 +1112,14 @@ set_axis_zoom_constraints(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, tag, "Item not found: " + std::to_string(axis), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, tag, "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1130,7 +1136,7 @@ reset_axis_zoom_constraints(PyObject* self, PyObject* args, PyObject* kwargs) auto tag = "reset_axis_zoom_constraints"; if (!Parse((GetParsers())[tag], args, kwargs, __FUNCTION__, &axisraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1141,14 +1147,14 @@ reset_axis_zoom_constraints(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, tag, "Item not found: " + std::to_string(axis), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, tag, "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1165,7 +1171,7 @@ set_axis_limits(PyObject* self, PyObject* args, PyObject* kwargs) float ymax; if (!Parse((GetParsers())["set_axis_limits"], args, kwargs, __FUNCTION__, &axisraw, &ymin, &ymax)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1176,14 +1182,14 @@ set_axis_limits(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_axis_limits", "Item not found: " + std::to_string(axis), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "set_axis_limits", "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1198,7 +1204,7 @@ set_axis_limits_auto(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* axisraw; if (!Parse((GetParsers())["set_axis_limits_auto"], args, kwargs, __FUNCTION__, &axisraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1209,14 +1215,14 @@ set_axis_limits_auto(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_axis_limits", "Item not found: " + std::to_string(axis), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "set_axis_limits", "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1232,7 +1238,7 @@ fit_axis_data(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* axisraw; if (!Parse((GetParsers())["fit_axis_data"], args, kwargs, __FUNCTION__, &axisraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1243,14 +1249,14 @@ fit_axis_data(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "fit_axis_data", "Item not found: " + std::to_string(axis), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "fit_axis_data", "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1268,7 +1274,7 @@ get_axis_limits(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* plotraw; if (!Parse((GetParsers())["get_axis_limits"], args, kwargs, __FUNCTION__, &plotraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1279,14 +1285,14 @@ get_axis_limits(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_axis_limits", "Item not found: " + std::to_string(plot), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "get_axis_limits", "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1301,7 +1307,7 @@ reset_axis_ticks(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* plotraw; if (!Parse((GetParsers())["reset_axis_ticks"], args, kwargs, __FUNCTION__, &plotraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1312,14 +1318,14 @@ reset_axis_ticks(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "reset_axis_ticks", "Item not found: " + std::to_string(plot), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvPlotAxis) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "reset_axis_ticks", "Incompatible type. Expected types include: mvPlotAxis", aplot); - return GetPyNone(); + return nullptr; } mvPlotAxis* graph = static_cast(aplot); @@ -1339,7 +1345,7 @@ highlight_table_column(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* color; if (!Parse((GetParsers())["highlight_table_column"], args, kwargs, __FUNCTION__, &tableraw, &column, &color)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1350,14 +1356,14 @@ highlight_table_column(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "highlight_table_column", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "highlight_table_column", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1366,7 +1372,7 @@ highlight_table_column(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "highlight_table_column", "Column out of range", tablecast); - return GetPyNone(); + return nullptr; } mvColor finalColor = ToColor(color); @@ -1383,7 +1389,7 @@ unhighlight_table_column(PyObject* self, PyObject* args, PyObject* kwargs) int column = 0; if (!Parse((GetParsers())["unhighlight_table_column"], args, kwargs, __FUNCTION__, &tableraw, &column)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1394,14 +1400,14 @@ unhighlight_table_column(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "unhighlight_table_column", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "unhighlight_table_column", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1410,7 +1416,7 @@ unhighlight_table_column(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "unhighlight_table_column", "Column out of range", tablecast); - return GetPyNone(); + return nullptr; } tablecast->_columnColorsSet[column] = false; @@ -1426,7 +1432,7 @@ set_table_row_color(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* color; if (!Parse((GetParsers())["set_table_row_color"], args, kwargs, __FUNCTION__, &tableraw, &row, &color)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1437,14 +1443,14 @@ set_table_row_color(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_table_row_color", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "set_table_row_color", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1453,7 +1459,7 @@ set_table_row_color(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "set_table_row_color", "Row out of range", tablecast); - return GetPyNone(); + return nullptr; } mvColor finalColor = ToColor(color); @@ -1470,7 +1476,7 @@ unset_table_row_color(PyObject* self, PyObject* args, PyObject* kwargs) int row = 0; if (!Parse((GetParsers())["unset_table_row_color"], args, kwargs, __FUNCTION__, &tableraw, &row)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1481,14 +1487,14 @@ unset_table_row_color(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "unset_table_row_color", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "unset_table_row_color", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1497,7 +1503,7 @@ unset_table_row_color(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "set_table_row_color", "Row out of range", tablecast); - return GetPyNone(); + return nullptr; } tablecast->_rowColorsSet[row] = false; @@ -1512,7 +1518,7 @@ highlight_table_row(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* color; if (!Parse((GetParsers())["highlight_table_row"], args, kwargs, __FUNCTION__, &tableraw, &row, &color)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1523,14 +1529,14 @@ highlight_table_row(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "highlight_table_row", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "highlight_table_row", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1539,7 +1545,7 @@ highlight_table_row(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "highlight_table_row", "Row out of range", tablecast); - return GetPyNone(); + return nullptr; } mvColor finalColor = ToColor(color); @@ -1556,7 +1562,7 @@ unhighlight_table_row(PyObject* self, PyObject* args, PyObject* kwargs) int row = 0; if (!Parse((GetParsers())["unhighlight_table_row"], args, kwargs, __FUNCTION__, &tableraw, &row)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1567,14 +1573,14 @@ unhighlight_table_row(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "unhighlight_table_row", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "unhighlight_table_row", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1583,7 +1589,7 @@ unhighlight_table_row(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "unselect_table_row", "Row out of range", tablecast); - return GetPyNone(); + return nullptr; } tablecast->_rowSelectionColorsSet[row] = false; @@ -1600,7 +1606,7 @@ highlight_table_cell(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* color; if (!Parse((GetParsers())["highlight_table_cell"], args, kwargs, __FUNCTION__, &tableraw, &row, &column, &color)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1611,14 +1617,14 @@ highlight_table_cell(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "highlight_table_cell", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "highlight_table_cell", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1627,7 +1633,7 @@ highlight_table_cell(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "highlight_table_cell", "Row/Column out of range", tablecast); - return GetPyNone(); + return nullptr; } mvColor finalColor = ToColor(color); @@ -1645,7 +1651,7 @@ unhighlight_table_cell(PyObject* self, PyObject* args, PyObject* kwargs) int column = 0; if (!Parse((GetParsers())["unhighlight_table_cell"], args, kwargs, __FUNCTION__, &tableraw, &row, &column)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1656,14 +1662,14 @@ unhighlight_table_cell(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "unhighlight_table_cell", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "unhighlight_table_cell", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1672,7 +1678,7 @@ unhighlight_table_cell(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "unhighlight_table_cell", "Row/Column out of range", tablecast); - return GetPyNone(); + return nullptr; } tablecast->_cellColorsSet[row][column] = false; @@ -1688,7 +1694,7 @@ is_table_cell_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) int column = 0; if (!Parse((GetParsers())["is_table_cell_highlighted"], args, kwargs, __FUNCTION__, &tableraw, &row, &column)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1699,14 +1705,14 @@ is_table_cell_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "is_table_cell_highlighted", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "is_table_cell_highlighted", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1715,7 +1721,7 @@ is_table_cell_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "is_table_cell_highlighted", "Row/Column out of range", tablecast); - return GetPyNone(); + return nullptr; } if (tablecast->_cellColorsSet[row][column]) @@ -1735,7 +1741,7 @@ is_table_row_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) int row = 0; if (!Parse((GetParsers())["is_table_row_highlighted"], args, kwargs, __FUNCTION__, &tableraw, &row)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1746,14 +1752,14 @@ is_table_row_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "is_table_row_highlighted", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "is_table_row_highlighted", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1762,7 +1768,7 @@ is_table_row_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "is_table_row_highlighted", "Row out of range", tablecast); - return GetPyNone(); + return nullptr; } return ToPyBool(tablecast->_rowSelectionColorsSet[row]); @@ -1775,7 +1781,7 @@ is_table_column_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) int column = 0; if (!Parse((GetParsers())["is_table_column_highlighted"], args, kwargs, __FUNCTION__, &tableraw, &column)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1786,14 +1792,14 @@ is_table_column_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "is_table_column_highlighted", "Item not found: " + std::to_string(table), nullptr); - return GetPyNone(); + return nullptr; } if (atable->type != mvAppItemType::mvTable) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "is_table_column_highlighted", "Incompatible type. Expected types include: mvTable", atable); - return GetPyNone(); + return nullptr; } mvTable* tablecast = static_cast(atable); @@ -1802,7 +1808,7 @@ is_table_column_highlighted(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvNone, "is_table_column_highlighted", "Column out of range", tablecast); - return GetPyNone(); + return nullptr; } return ToPyBool(tablecast->_columnColorsSet[column]); @@ -1816,7 +1822,7 @@ bind_theme(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["bind_theme"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1834,14 +1840,14 @@ bind_theme(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_theme", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } if (aplot->type != mvAppItemType::mvTheme) { mvThrowPythonError(mvErrorCode::mvIncompatibleType, "bind_theme", "Incompatible type. Expected types include: mvTheme", aplot); - return GetPyNone(); + return nullptr; } mvTheme* graph = static_cast(aplot); @@ -1859,7 +1865,7 @@ set_global_font_scale(PyObject* self, PyObject* args, PyObject* kwargs) float scale; if (!Parse((GetParsers())["set_global_font_scale"], args, kwargs, __FUNCTION__, &scale)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); mvToolManager::GetFontManager().setGlobalFontScale(scale); @@ -1880,7 +1886,7 @@ show_tool(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["show_tool"], args, kwargs, __FUNCTION__, &toolraw)) - return GetPyNone(); + return nullptr; mvUUID tool = GetIDFromPyObject(toolraw); @@ -1916,7 +1922,7 @@ set_frame_callback(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_frame_callback"], args, kwargs, __FUNCTION__, &frame, &callback, &user_data)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -1937,7 +1943,7 @@ set_exit_callback(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_exit_callback"], args, kwargs, __FUNCTION__, &callback, &user_data)) - return GetPyNone(); + return nullptr; *GContext->callbackRegistry->onCloseCallback = mvPyObject(callback == Py_None? nullptr : callback, true); *GContext->callbackRegistry->onCloseCallbackUserData = mvPyObject(user_data, true); @@ -1953,7 +1959,7 @@ set_viewport_resize_callback(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_viewport_resize_callback"], args, kwargs, __FUNCTION__, &callback, &user_data)) - return GetPyNone(); + return nullptr; *GContext->callbackRegistry->resizeCallback = mvPyObject(callback == Py_None? nullptr : callback, true); *GContext->callbackRegistry->resizeCallbackUserData = mvPyObject(user_data, true); @@ -1967,33 +1973,34 @@ get_viewport_configuration(PyObject* self, PyObject* args, PyObject* kwargs) mvPySafeLockGuard lk(GContext->mutex); - PyObject* pdict = PyDict_New(); mvViewport* viewport = GContext->viewport; - if (viewport) + if (!viewport) { - PyDict_SetItemString(pdict, "clear_color", mvPyObject(ToPyColor(viewport->clearColor))); - PyDict_SetItemString(pdict, "small_icon", mvPyObject(ToPyString(viewport->small_icon))); - PyDict_SetItemString(pdict, "large_icon", mvPyObject(ToPyString(viewport->large_icon))); - PyDict_SetItemString(pdict, "x_pos", mvPyObject(ToPyInt(viewport->xpos))); - PyDict_SetItemString(pdict, "y_pos", mvPyObject(ToPyInt(viewport->ypos))); - PyDict_SetItemString(pdict, "width", mvPyObject(ToPyInt(viewport->actualWidth))); - PyDict_SetItemString(pdict, "height", mvPyObject(ToPyInt(viewport->actualHeight))); - PyDict_SetItemString(pdict, "client_width", mvPyObject(ToPyInt(viewport->clientWidth))); - PyDict_SetItemString(pdict, "client_height", mvPyObject(ToPyInt(viewport->clientHeight))); - PyDict_SetItemString(pdict, "resizable", mvPyObject(ToPyBool(viewport->resizable))); - PyDict_SetItemString(pdict, "vsync", mvPyObject(ToPyBool(viewport->vsync))); - PyDict_SetItemString(pdict, "min_width", mvPyObject(ToPyInt(viewport->minwidth))); - PyDict_SetItemString(pdict, "max_width", mvPyObject(ToPyInt(viewport->maxwidth))); - PyDict_SetItemString(pdict, "min_height", mvPyObject(ToPyInt(viewport->minheight))); - PyDict_SetItemString(pdict, "max_height", mvPyObject(ToPyInt(viewport->maxheight))); - PyDict_SetItemString(pdict, "always_on_top", mvPyObject(ToPyBool(viewport->alwaysOnTop))); - PyDict_SetItemString(pdict, "decorated", mvPyObject(ToPyBool(viewport->decorated))); - PyDict_SetItemString(pdict, "title", mvPyObject(ToPyString(viewport->title))); - PyDict_SetItemString(pdict, "disable_close", mvPyObject(ToPyBool(viewport->disableClose))); - } - else mvThrowPythonError(mvErrorCode::mvNone, "No viewport created"); + return nullptr; + } + + PyObject* pdict = PyDict_New(); + + PyDict_SetItemString(pdict, "clear_color", mvPyObject(ToPyColor(viewport->clearColor))); + PyDict_SetItemString(pdict, "small_icon", mvPyObject(ToPyString(viewport->small_icon))); + PyDict_SetItemString(pdict, "large_icon", mvPyObject(ToPyString(viewport->large_icon))); + PyDict_SetItemString(pdict, "x_pos", mvPyObject(ToPyInt(viewport->xpos))); + PyDict_SetItemString(pdict, "y_pos", mvPyObject(ToPyInt(viewport->ypos))); + PyDict_SetItemString(pdict, "width", mvPyObject(ToPyInt(viewport->actualWidth))); + PyDict_SetItemString(pdict, "height", mvPyObject(ToPyInt(viewport->actualHeight))); + PyDict_SetItemString(pdict, "client_width", mvPyObject(ToPyInt(viewport->clientWidth))); + PyDict_SetItemString(pdict, "client_height", mvPyObject(ToPyInt(viewport->clientHeight))); + PyDict_SetItemString(pdict, "resizable", mvPyObject(ToPyBool(viewport->resizable))); + PyDict_SetItemString(pdict, "vsync", mvPyObject(ToPyBool(viewport->vsync))); + PyDict_SetItemString(pdict, "min_width", mvPyObject(ToPyInt(viewport->minwidth))); + PyDict_SetItemString(pdict, "max_width", mvPyObject(ToPyInt(viewport->maxwidth))); + PyDict_SetItemString(pdict, "min_height", mvPyObject(ToPyInt(viewport->minheight))); + PyDict_SetItemString(pdict, "max_height", mvPyObject(ToPyInt(viewport->maxheight))); + PyDict_SetItemString(pdict, "always_on_top", mvPyObject(ToPyBool(viewport->alwaysOnTop))); + PyDict_SetItemString(pdict, "decorated", mvPyObject(ToPyBool(viewport->decorated))); + PyDict_SetItemString(pdict, "title", mvPyObject(ToPyString(viewport->title))); return pdict; } @@ -2046,7 +2053,7 @@ create_viewport(PyObject* self, PyObject* args, PyObject* kwargs) &title, &small_icon, &large_icon, &width, &height, &x_pos, &y_pos, &min_width, &max_width, &min_height, &max_height, &resizable, &vsync, &always_on_top, &decorated, &color, &disable_close )) - return GetPyNone(); + return nullptr; mvViewport* viewport = mvCreateViewport(); if (PyObject* item = PyDict_GetItemString(kwargs, "clear_color")) viewport->clearColor = ToColor(item); @@ -2080,7 +2087,7 @@ show_viewport(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["show_viewport"], args, kwargs, __FUNCTION__, &minimized, &maximized)) - return GetPyNone(); + return nullptr; mvViewport* viewport = GContext->viewport; if (viewport) @@ -2090,7 +2097,11 @@ show_viewport(PyObject* self, PyObject* args, PyObject* kwargs) viewport->shown = true; } else + { mvThrowPythonError(mvErrorCode::mvNone, "No viewport created"); + return nullptr; + } + return GetPyNone(); } @@ -2123,7 +2134,10 @@ configure_viewport(PyObject* self, PyObject* args, PyObject* kwargs) } else + { mvThrowPythonError(mvErrorCode::mvNone, "No viewport created"); + return nullptr; + } return GetPyNone(); } @@ -2170,12 +2184,15 @@ save_init_file(PyObject* self, PyObject* args, PyObject* kwargs) const char* file; if (!Parse((GetParsers())["save_init_file"], args, kwargs, __FUNCTION__, &file)) - return GetPyNone(); + return nullptr; if (GContext->started) ImGui::SaveIniSettingsToDisk(file); else + { mvThrowPythonError(mvErrorCode::mvNone, "Dear PyGui must be started to use \"save_init_file\"."); + return nullptr; + } return GetPyNone(); } @@ -2184,7 +2201,7 @@ static PyObject* split_frame(PyObject* self, PyObject* args, PyObject* kwargs) { if (!Parse((GetParsers())["split_frame"], args, kwargs, __FUNCTION__)) - return GetPyNone(); + return nullptr; if (GContext->running) { @@ -2243,7 +2260,7 @@ load_image(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["load_image"], args, kwargs, __FUNCTION__, &file, &gamma, &gamma_scale)) - return GetPyNone(); + return nullptr; // Vout = (Vin / 255)^v; Where v = gamma @@ -2314,7 +2331,7 @@ save_image(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["save_image"], args, kwargs, __FUNCTION__, &file, &width, &height, &data, &components, &quality)) - return GetPyNone(); + return nullptr; enum ImageType_ { @@ -2338,19 +2355,19 @@ save_image(PyObject* self, PyObject* args, PyObject* kwargs) if (filepathLength < 5) { mvThrowPythonError(mvErrorCode::mvNone, "File path for 'save_image(...)' must be of the form 'name.png'."); - return GetPyNone(); + return nullptr; } if (components > 4 || components < 1) { mvThrowPythonError(mvErrorCode::mvNone, "Component count for 'save_image(...)' must be between 1 and 4."); - return GetPyNone(); + return nullptr; } if (quality < 1 || quality > 100) { mvThrowPythonError(mvErrorCode::mvNone, "Quality must be between 1 and 100."); - return GetPyNone(); + return nullptr; } // TODO: support other formats @@ -2377,7 +2394,7 @@ save_image(PyObject* self, PyObject* args, PyObject* kwargs) else { mvThrowPythonError(mvErrorCode::mvNone, "File path for 'save_image(...)' must be of the form 'name.png'."); - return GetPyNone(); + return nullptr; } switch (imageType) @@ -2426,7 +2443,7 @@ output_frame_buffer(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["output_frame_buffer"], args, kwargs, __FUNCTION__, &file, &callback)) - return GetPyNone(); + return nullptr; size_t filepathLength = strlen(file); @@ -2464,7 +2481,7 @@ output_frame_buffer(PyObject* self, PyObject* args, PyObject* kwargs) if (filepathLength < 5) { mvThrowPythonError(mvErrorCode::mvNone, "File path for 'output_frame_buffer(...)' must be of the form 'name.png'."); - return GetPyNone(); + return nullptr; } // TODO: support other formats @@ -2479,7 +2496,7 @@ output_frame_buffer(PyObject* self, PyObject* args, PyObject* kwargs) else { mvThrowPythonError(mvErrorCode::mvNone, "File path for 'output_frame_buffer(...)' must be of the form 'name.png'."); - return GetPyNone(); + return nullptr; } return GetPyNone(); @@ -2503,7 +2520,7 @@ setup_dearpygui(PyObject* self, PyObject* args, PyObject* kwargs) if (GContext->started) { mvThrowPythonError(mvErrorCode::mvNone, "Cannot call \"setup_dearpygui\" while a Dear PyGUI app is already running."); - return GetPyNone(); + return nullptr; } while (!GContext->itemRegistry->containers.empty()) @@ -2680,7 +2697,7 @@ configure_app(PyObject* self, PyObject* args, PyObject* kwargs) { assert(false); mvThrowPythonError(mvErrorCode::mvNone, "Dictionary keywords must be strings"); - return GetPyNone(); + return nullptr; } mvPySafeLockGuard lk(GContext->mutex); @@ -2760,7 +2777,7 @@ get_mouse_pos(PyObject* self, PyObject* args, PyObject* kwargs) b32 local = true; if (!Parse((GetParsers())["get_mouse_pos"], args, kwargs, __FUNCTION__, &local)) - return GetPyNone(); + return nullptr; auto pos = mvVec2(); @@ -2777,7 +2794,7 @@ get_plot_mouse_pos(PyObject* self, PyObject* args, PyObject* kwargs) { if (!Parse((GetParsers())["get_plot_mouse_pos"], args, kwargs, __FUNCTION__)) - return GetPyNone(); + return nullptr; mvVec2 pos = { (f32)GContext->input.mousePlotPos.x, (f32)GContext->input.mousePlotPos.y }; @@ -2789,7 +2806,7 @@ get_drawing_mouse_pos(PyObject* self, PyObject* args, PyObject* kwargs) { if (!Parse((GetParsers())["get_drawing_mouse_pos"], args, kwargs, __FUNCTION__)) - return GetPyNone(); + return nullptr; mvVec2 pos = { (f32)GContext->input.mouseDrawingPos.x, (f32)GContext->input.mouseDrawingPos.y }; @@ -2810,7 +2827,7 @@ is_key_pressed(PyObject* self, PyObject* args, PyObject* kwargs) ImGuiKey key; if (!Parse((GetParsers())["is_key_pressed"], args, kwargs, __FUNCTION__, &key)) - return GetPyNone(); + return nullptr; return ToPyBool(ImGui::IsKeyPressed(key)); } @@ -2821,7 +2838,7 @@ is_key_released(PyObject* self, PyObject* args, PyObject* kwargs) ImGuiKey key; if (!Parse((GetParsers())["is_key_released"], args, kwargs, __FUNCTION__, &key)) - return GetPyNone(); + return nullptr; return ToPyBool(ImGui::IsKeyReleased(key)); } @@ -2832,7 +2849,7 @@ is_key_down(PyObject* self, PyObject* args, PyObject* kwargs) ImGuiKey key; if (!Parse((GetParsers())["is_key_down"], args, kwargs, __FUNCTION__, &key)) - return GetPyNone(); + return nullptr; return ToPyBool(ImGui::IsKeyDown(key)); } @@ -2844,7 +2861,7 @@ is_mouse_button_dragging(PyObject* self, PyObject* args, PyObject* kwargs) f32 threshold; if (!Parse((GetParsers())["is_mouse_button_dragging"], args, kwargs, __FUNCTION__, &button, &threshold)) - return GetPyNone(); + return nullptr; // TODO: Can this be changed? return ToPyBool((f32)ImGui::GetIO().MouseDownDuration[button] >= threshold); @@ -2856,7 +2873,7 @@ is_mouse_button_down(PyObject* self, PyObject* args, PyObject* kwargs) i32 button; if (!Parse((GetParsers())["is_mouse_button_down"], args, kwargs, __FUNCTION__, &button)) - return GetPyNone(); + return nullptr; return ToPyBool(ImGui::IsMouseDown(button)); } @@ -2867,7 +2884,7 @@ is_mouse_button_clicked(PyObject* self, PyObject* args, PyObject* kwargs) i32 button; if (!Parse((GetParsers())["is_mouse_button_clicked"], args, kwargs, __FUNCTION__, &button)) - return GetPyNone(); + return nullptr; return ToPyBool(ImGui::IsMouseClicked(button)); } @@ -2878,7 +2895,7 @@ is_mouse_button_double_clicked(PyObject* self, PyObject* args, PyObject* kwargs) i32 button; if (!Parse((GetParsers())["is_mouse_button_double_clicked"], args, kwargs, __FUNCTION__, &button)) - return GetPyNone(); + return nullptr; return ToPyBool(ImGui::IsMouseDoubleClicked(button)); } @@ -2889,7 +2906,7 @@ is_mouse_button_released(PyObject* self, PyObject* args, PyObject* kwargs) i32 button; if (!Parse((GetParsers())["is_mouse_button_released"], args, kwargs, __FUNCTION__, &button)) - return GetPyNone(); + return nullptr; return ToPyBool(ImGui::IsMouseReleased(button)); } @@ -2904,7 +2921,7 @@ pop_container_stack(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvContainerStackEmpty, "No container to pop."); assert(false); - return GetPyNone(); + return nullptr; } mvAppItem* item = GContext->itemRegistry->containers.top(); @@ -2971,7 +2988,7 @@ push_container_stack(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["push_container_stack"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -2996,10 +3013,10 @@ set_primary_window(PyObject* self, PyObject* args, PyObject* kwargs) i32 value; if (!VerifyRequiredArguments(GetParsers()["set_primary_window"], args)) - return GetPyNone(); + return GetPyNoneOrError(); if (!Parse((GetParsers())["set_primary_window"], args, kwargs, __FUNCTION__, &itemraw, &value)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3008,7 +3025,14 @@ set_primary_window(PyObject* self, PyObject* args, PyObject* kwargs) { mvWindowAppItem* window = GetWindow(*GContext->itemRegistry, item); - if (window) + if (!window) + { + mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_primary_window", + "Item not found: " + std::to_string(item), nullptr); + assert(false); + return nullptr; + } + else { if (window->configData.mainWindow == (bool)value) return GetPyNone(); @@ -3044,12 +3068,6 @@ set_primary_window(PyObject* self, PyObject* args, PyObject* kwargs) } } } - else - { - mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_primary_window", - "Item not found: " + std::to_string(item), nullptr); - assert(false); - } } // reset other windows @@ -3102,7 +3120,7 @@ move_item(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["move_item"], args, kwargs, __FUNCTION__, &itemraw, &parentraw, &beforeraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3124,7 +3142,7 @@ delete_item(PyObject* self, PyObject* args, PyObject* kwargs) i32 slot = -1; if (!Parse((GetParsers())["delete_item"], args, kwargs, __FUNCTION__, &itemraw, &childrenOnly, &slot)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3144,7 +3162,7 @@ does_item_exist(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["does_item_exist"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3162,7 +3180,7 @@ move_item_up(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["move_item_up"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3181,7 +3199,7 @@ move_item_down(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["move_item_down"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3202,7 +3220,7 @@ reorder_items(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["reorder_items"], args, kwargs, __FUNCTION__, &containerraw, &slot, &new_order)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3239,7 +3257,7 @@ unstage(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw = nullptr; if (!Parse((GetParsers())["unstage"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3271,7 +3289,7 @@ unstage(PyObject* self, PyObject* args, PyObject* kwargs) "Stage not found: " + std::to_string(item), nullptr); assert(false); - return GetPyNone(); + return nullptr; } static PyObject* @@ -3281,7 +3299,7 @@ show_item_debug(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw = nullptr; if (!Parse((GetParsers())["show_item_debug"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3297,6 +3315,7 @@ show_item_debug(PyObject* self, PyObject* args, PyObject* kwargs) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "show_item_debug", "Item not found: " + std::to_string(item), nullptr); + return nullptr; } return GetPyNone(); @@ -3419,7 +3438,7 @@ add_alias(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["add_alias"], args, kwargs, __FUNCTION__, &alias, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3438,7 +3457,7 @@ remove_alias(PyObject* self, PyObject* args, PyObject* kwargs) const char* alias; if (!Parse((GetParsers())["remove_alias"], args, kwargs, __FUNCTION__, &alias)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3455,7 +3474,7 @@ does_alias_exist(PyObject* self, PyObject* args, PyObject* kwargs) const char* alias; if (!Parse((GetParsers())["does_alias_exist"], args, kwargs, __FUNCTION__, &alias)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3471,7 +3490,7 @@ get_alias_id(PyObject* self, PyObject* args, PyObject* kwargs) const char* alias; if (!Parse((GetParsers())["get_alias_id"], args, kwargs, __FUNCTION__, &alias)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3500,7 +3519,7 @@ focus_item(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["focus_item"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3529,8 +3548,11 @@ focus_item(PyObject* self, PyObject* args, PyObject* kwargs) parent->info.focusNextFrame = true; } else + { mvThrowPythonError(mvErrorCode::mvItemNotFound, "focus_item", "Item not found: " + std::to_string(item), nullptr); + return nullptr; + } return GetPyNone(); } @@ -3573,82 +3595,76 @@ get_item_info(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["get_item_info"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); mvUUID item = GetIDFromPyObject(itemraw); mvAppItem* appitem = GetItem((*GContext->itemRegistry), item); - PyObject* pdict = PyDict_New(); - if (appitem) + if (!appitem) { + mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_item_info", + "Item not found: " + std::to_string(item), nullptr); + return nullptr; + } - std::string parserCommand = GetEntityCommand(appitem->type); + PyObject* pdict = PyDict_New(); - auto children = GetItemChildren(*GContext->itemRegistry, appitem->uuid); - if (children.empty()) - PyDict_SetItemString(pdict, "children", mvPyObject(GetPyNone())); - else + std::string parserCommand = GetEntityCommand(appitem->type); + + auto children = GetItemChildren(*GContext->itemRegistry, appitem->uuid); + if (children.empty()) + PyDict_SetItemString(pdict, "children", mvPyObject(GetPyNone())); + else + { + PyObject* pyChildren = PyDict_New(); + i32 i = 0; + for (const auto& slot : children) { - PyObject* pyChildren = PyDict_New(); - i32 i = 0; - for (const auto& slot : children) - { - PyDict_SetItem(pyChildren, ToPyInt(i), mvPyObject(ToPyList(slot))); - i++; - } - PyDict_SetItemString(pdict, "children", mvPyObject(pyChildren)); + PyDict_SetItem(pyChildren, ToPyInt(i), mvPyObject(ToPyList(slot))); + i++; } + PyDict_SetItemString(pdict, "children", mvPyObject(pyChildren)); + } - PyDict_SetItemString(pdict, "type", mvPyObject(ToPyString(DearPyGui::GetEntityTypeString(appitem->type)))); - PyDict_SetItemString(pdict, "target", mvPyObject(ToPyInt(DearPyGui::GetEntityTargetSlot(appitem->type)))); - - if (appitem->info.parentPtr) - PyDict_SetItemString(pdict, "parent", mvPyObject(ToPyUUID(appitem->info.parentPtr->uuid))); - else - PyDict_SetItemString(pdict, "parent", mvPyObject(GetPyNone())); - - if (appitem->theme) - PyDict_SetItemString(pdict, "theme", mvPyObject(ToPyUUID(appitem->theme->uuid))); - else - PyDict_SetItemString(pdict, "theme", mvPyObject(GetPyNone())); - - if (appitem->handlerRegistry) - PyDict_SetItemString(pdict, "handlers", mvPyObject(ToPyUUID(appitem->handlerRegistry->uuid))); - else - PyDict_SetItemString(pdict, "handlers", mvPyObject(GetPyNone())); - - if (appitem->font) - PyDict_SetItemString(pdict, "font", mvPyObject(ToPyUUID(appitem->font->uuid))); - else - PyDict_SetItemString(pdict, "font", mvPyObject(GetPyNone())); + PyDict_SetItemString(pdict, "type", mvPyObject(ToPyString(DearPyGui::GetEntityTypeString(appitem->type)))); + PyDict_SetItemString(pdict, "target", mvPyObject(ToPyInt(DearPyGui::GetEntityTargetSlot(appitem->type)))); - if (DearPyGui::GetEntityDesciptionFlags(appitem->type) & MV_ITEM_DESC_CONTAINER) - PyDict_SetItemString(pdict, "container", mvPyObject(ToPyBool(true))); - else - PyDict_SetItemString(pdict, "container", mvPyObject(ToPyBool(false))); + if (appitem->info.parentPtr) + PyDict_SetItemString(pdict, "parent", mvPyObject(ToPyUUID(appitem->info.parentPtr->uuid))); + else + PyDict_SetItemString(pdict, "parent", mvPyObject(GetPyNone())); - i32 applicableState = DearPyGui::GetApplicableState(appitem->type); - PyDict_SetItemString(pdict, "hover_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_HOVER))); - PyDict_SetItemString(pdict, "active_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_ACTIVE))); - PyDict_SetItemString(pdict, "focus_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_FOCUSED))); - PyDict_SetItemString(pdict, "clicked_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_CLICKED))); - PyDict_SetItemString(pdict, "visible_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_VISIBLE))); - PyDict_SetItemString(pdict, "edited_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_EDITED))); - PyDict_SetItemString(pdict, "activated_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_ACTIVATED))); - PyDict_SetItemString(pdict, "deactivated_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_DEACTIVATED))); - PyDict_SetItemString(pdict, "deactivatedae_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_DEACTIVATEDAE))); - PyDict_SetItemString(pdict, "toggled_open_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_TOGGLED_OPEN))); - PyDict_SetItemString(pdict, "resized_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_RECT_SIZE))); - PyDict_SetItemString(pdict, "scroll_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_SCROLL))); + if (appitem->theme) + PyDict_SetItemString(pdict, "theme", mvPyObject(ToPyUUID(appitem->theme->uuid))); + else + PyDict_SetItemString(pdict, "theme", mvPyObject(GetPyNone())); - } + if (appitem->font) + PyDict_SetItemString(pdict, "font", mvPyObject(ToPyUUID(appitem->font->uuid))); + else + PyDict_SetItemString(pdict, "font", mvPyObject(GetPyNone())); + if (DearPyGui::GetEntityDesciptionFlags(appitem->type) & MV_ITEM_DESC_CONTAINER) + PyDict_SetItemString(pdict, "container", mvPyObject(ToPyBool(true))); else - mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_item_info", - "Item not found: " + std::to_string(item), nullptr); + PyDict_SetItemString(pdict, "container", mvPyObject(ToPyBool(false))); + + i32 applicableState = DearPyGui::GetApplicableState(appitem->type); + PyDict_SetItemString(pdict, "hover_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_HOVER))); + PyDict_SetItemString(pdict, "active_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_ACTIVE))); + PyDict_SetItemString(pdict, "focus_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_FOCUSED))); + PyDict_SetItemString(pdict, "clicked_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_CLICKED))); + PyDict_SetItemString(pdict, "visible_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_VISIBLE))); + PyDict_SetItemString(pdict, "edited_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_EDITED))); + PyDict_SetItemString(pdict, "activated_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_ACTIVATED))); + PyDict_SetItemString(pdict, "deactivated_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_DEACTIVATED))); + PyDict_SetItemString(pdict, "deactivatedae_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_DEACTIVATEDAE))); + PyDict_SetItemString(pdict, "toggled_open_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_TOGGLED_OPEN))); + PyDict_SetItemString(pdict, "resized_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_RECT_SIZE))); + PyDict_SetItemString(pdict, "scroll_handler_applicable", mvPyObject(ToPyBool(applicableState & MV_STATE_SCROLL))); return pdict; } @@ -3659,61 +3675,62 @@ get_item_configuration(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["get_item_configuration"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); mvUUID item = GetIDFromPyObject(itemraw); mvAppItem* appitem = GetItem((*GContext->itemRegistry), item); - PyObject* pdict = PyDict_New(); - - if (appitem) + if (!appitem) { - // config py objects - mvPyObject py_filter_key = ToPyString(appitem->config.filter); - mvPyObject py_payload_type = ToPyString(appitem->config.payloadType); - mvPyObject py_label = ToPyString(appitem->config.specifiedLabel); - mvPyObject py_use_internal_label = ToPyBool(appitem->config.useInternalLabel); - mvPyObject py_source = ToPyUUID(appitem->config.source); - mvPyObject py_show = ToPyBool(appitem->config.show); - mvPyObject py_enabled = ToPyBool(appitem->config.enabled); - mvPyObject py_tracked = ToPyBool(appitem->config.tracked); - mvPyObject py_width = ToPyInt(appitem->config.width); - mvPyObject py_track_offset = ToPyFloat(appitem->config.trackOffset); - mvPyObject py_height = ToPyInt(appitem->config.height); - mvPyObject py_indent = ToPyInt((i32)appitem->config.indent); - - PyDict_SetItemString(pdict, "filter_key", py_filter_key); - PyDict_SetItemString(pdict, "payload_type", py_payload_type); - PyDict_SetItemString(pdict, "label", py_label); - PyDict_SetItemString(pdict, "use_internal_label", py_use_internal_label); - PyDict_SetItemString(pdict, "source", py_source); - PyDict_SetItemString(pdict, "show", py_show); - PyDict_SetItemString(pdict, "enabled", py_enabled); - PyDict_SetItemString(pdict, "tracked", py_tracked); - PyDict_SetItemString(pdict, "width", py_width); - PyDict_SetItemString(pdict, "track_offset", py_track_offset); - PyDict_SetItemString(pdict, "height", py_height); - PyDict_SetItemString(pdict, "indent", py_indent); - - PyObject* callback = appitem->config.callback; - PyDict_SetItemString(pdict, "callback", callback? callback : Py_None); - - PyObject* dropCallback = appitem->config.dropCallback; - PyDict_SetItemString(pdict, "drop_callback", dropCallback? dropCallback : Py_None); - - PyObject* dragCallback = appitem->config.dragCallback; - PyDict_SetItemString(pdict, "drag_callback", dragCallback? dragCallback : Py_None); - - PyObject* user_data = *(appitem->config.user_data); - PyDict_SetItemString(pdict, "user_data", user_data? user_data : Py_None); - - appitem->getSpecificConfiguration(pdict); - } - else mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_item_configuration", "Item not found: " + std::to_string(item), nullptr); + return nullptr; + } + + PyObject* pdict = PyDict_New(); + + // config py objects + mvPyObject py_filter_key = ToPyString(appitem->config.filter); + mvPyObject py_payload_type = ToPyString(appitem->config.payloadType); + mvPyObject py_label = ToPyString(appitem->config.specifiedLabel); + mvPyObject py_use_internal_label = ToPyBool(appitem->config.useInternalLabel); + mvPyObject py_source = ToPyUUID(appitem->config.source); + mvPyObject py_show = ToPyBool(appitem->config.show); + mvPyObject py_enabled = ToPyBool(appitem->config.enabled); + mvPyObject py_tracked = ToPyBool(appitem->config.tracked); + mvPyObject py_width = ToPyInt(appitem->config.width); + mvPyObject py_track_offset = ToPyFloat(appitem->config.trackOffset); + mvPyObject py_height = ToPyInt(appitem->config.height); + mvPyObject py_indent = ToPyInt((i32)appitem->config.indent); + + PyDict_SetItemString(pdict, "filter_key", py_filter_key); + PyDict_SetItemString(pdict, "payload_type", py_payload_type); + PyDict_SetItemString(pdict, "label", py_label); + PyDict_SetItemString(pdict, "use_internal_label", py_use_internal_label); + PyDict_SetItemString(pdict, "source", py_source); + PyDict_SetItemString(pdict, "show", py_show); + PyDict_SetItemString(pdict, "enabled", py_enabled); + PyDict_SetItemString(pdict, "tracked", py_tracked); + PyDict_SetItemString(pdict, "width", py_width); + PyDict_SetItemString(pdict, "track_offset", py_track_offset); + PyDict_SetItemString(pdict, "height", py_height); + PyDict_SetItemString(pdict, "indent", py_indent); + + PyObject* callback = appitem->config.callback; + PyDict_SetItemString(pdict, "callback", callback? callback : Py_None); + + PyObject* dropCallback = appitem->config.dropCallback; + PyDict_SetItemString(pdict, "drop_callback", dropCallback? dropCallback : Py_None); + + PyObject* dragCallback = appitem->config.dragCallback; + PyDict_SetItemString(pdict, "drag_callback", dragCallback? dragCallback : Py_None); + + PyObject* user_data = *(appitem->config.user_data); + PyDict_SetItemString(pdict, "user_data", user_data? user_data : Py_None); + + appitem->getSpecificConfiguration(pdict); return pdict; } @@ -3727,7 +3744,7 @@ set_item_children(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_item_children"], args, kwargs, __FUNCTION__, &itemraw, &sourceraw, &slot)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3755,7 +3772,7 @@ set_item_children(PyObject* self, PyObject* args, PyObject* kwargs) mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_item_children", "Stage item not found: " + std::to_string(item), nullptr); assert(false); - return GetPyNone(); + return nullptr; } @@ -3782,8 +3799,11 @@ set_item_children(PyObject* self, PyObject* args, PyObject* kwargs) } } else + { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_item_children", "Item not found: " + std::to_string(item), nullptr); + return nullptr; + } DeleteItem(*GContext->itemRegistry, source); @@ -3798,7 +3818,7 @@ bind_item_font(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["bind_item_font"], args, kwargs, __FUNCTION__, &itemraw, &fontraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3818,6 +3838,7 @@ bind_item_font(PyObject* self, PyObject* args, PyObject* kwargs) if (appfont) { appitem->font = appfont; + return GetPyNone(); } else { @@ -3829,7 +3850,7 @@ bind_item_font(PyObject* self, PyObject* args, PyObject* kwargs) mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_item_font", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } static PyObject* @@ -3840,7 +3861,7 @@ bind_item_theme(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["bind_item_theme"], args, kwargs, __FUNCTION__, &itemraw, &themeraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3860,13 +3881,14 @@ bind_item_theme(PyObject* self, PyObject* args, PyObject* kwargs) if (apptheme) { - if (apptheme->type != mvAppItemType::mvTheme) + if (apptheme->type == mvAppItemType::mvTheme) { + appitem->theme = *(std::shared_ptr*)(&apptheme); + return GetPyNone(); + } + else mvThrowPythonError(mvErrorCode::mvIncompatibleType, "bind_item_theme", "Item not a theme: " + std::to_string(theme), nullptr); - } - appitem->theme = *(std::shared_ptr*)(&apptheme); - return GetPyNone(); } else mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_item_theme", @@ -3876,7 +3898,7 @@ bind_item_theme(PyObject* self, PyObject* args, PyObject* kwargs) mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_item_theme", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } static PyObject* @@ -3887,7 +3909,7 @@ bind_item_handler_registry(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["bind_item_handler_registry"], args, kwargs, __FUNCTION__, &itemraw, ®raw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3903,18 +3925,19 @@ bind_item_handler_registry(PyObject* self, PyObject* args, PyObject* kwargs) return GetPyNone(); } - auto apptheme = GetRefItem(*GContext->itemRegistry, reg); + auto handler_registry = GetRefItem(*GContext->itemRegistry, reg); - if (apptheme) + if (handler_registry) { - if (apptheme->type != mvAppItemType::mvItemHandlerRegistry) + if (handler_registry->type == mvAppItemType::mvItemHandlerRegistry) { + appitem->handlerRegistry = *(std::shared_ptr*)(&handler_registry); + appitem->handlerRegistry->onBind(appitem); + return GetPyNoneOrError(); + } + else mvThrowPythonError(mvErrorCode::mvIncompatibleType, "bind_item_handler_registry", "Item not handler registry: " + std::to_string(reg), nullptr); - } - appitem->handlerRegistry = *(std::shared_ptr*)(&apptheme); - appitem->handlerRegistry->onBind(appitem); - return GetPyNone(); } else mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_item_handler_registry", @@ -3924,7 +3947,7 @@ bind_item_handler_registry(PyObject* self, PyObject* args, PyObject* kwargs) mvThrowPythonError(mvErrorCode::mvItemNotFound, "bind_item_handler_registry", "Item not found: " + std::to_string(item), nullptr); - return GetPyNone(); + return nullptr; } static PyObject* @@ -3934,7 +3957,7 @@ reset_pos(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["reset_pos"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -3944,8 +3967,11 @@ reset_pos(PyObject* self, PyObject* args, PyObject* kwargs) if (appitem) appitem->info.dirtyPos = false; else + { mvThrowPythonError(mvErrorCode::mvItemNotFound, "reset_pos", "Item not found: " + std::to_string(item), nullptr); + return nullptr; + } return GetPyNone(); } @@ -3956,20 +3982,22 @@ get_item_state(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* itemraw; if (!Parse((GetParsers())["get_item_state"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); mvUUID item = GetIDFromPyObject(itemraw); mvAppItem* appitem = GetItem((*GContext->itemRegistry), item); - PyObject* pdict = PyDict_New(); - - if (appitem) - FillAppItemState(pdict, appitem->state, DearPyGui::GetApplicableState(appitem->type)); - else + if (!appitem) + { mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_item_state", "Item not found: " + std::to_string(item), nullptr); + return nullptr; + } + + PyObject* pdict = PyDict_New(); + FillAppItemState(pdict, appitem->state, DearPyGui::GetApplicableState(appitem->type)); return pdict; } @@ -4003,8 +4031,11 @@ configure_item(PyObject* self, PyObject* args, PyObject* kwargs) appitem->handleKeywordArgs(kwargs, GetEntityCommand(appitem->type)); } else + { mvThrowPythonError(mvErrorCode::mvItemNotFound, "configure_item", "Item not found: " + std::to_string(item), nullptr); + return nullptr; + } return GetPyNone(); } @@ -4015,7 +4046,7 @@ get_value(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* nameraw; if (!Parse((GetParsers())["get_value"], args, kwargs, __FUNCTION__, &nameraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -4033,7 +4064,7 @@ get_values(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* items; if (!Parse((GetParsers())["get_values"], args, kwargs, __FUNCTION__, &items)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -4047,6 +4078,9 @@ get_values(PyObject* self, PyObject* args, PyObject* kwargs) PyList_SetItem(pyvalues, i, item->getPyValue()); else { + // TODO: decide whether we want to raise an exception or return None's. + // These two variants are mutually exclusive. If we raise an exception, + // we must return nullptr, not pyvalues. mvThrowPythonError(mvErrorCode::mvItemNotFound, "get_values", "Item not found: " + std::to_string(aitems[i]), nullptr); PyList_SetItem(pyvalues, i, GetPyNone()); @@ -4063,24 +4097,22 @@ set_value(PyObject* self, PyObject* args, PyObject* kwargs) PyObject* value; if (!Parse((GetParsers())["set_value"], args, kwargs, __FUNCTION__, &nameraw, &value)) - return GetPyNone(); - - if (value) - Py_XINCREF(value); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); mvUUID name = GetIDFromPyObject(nameraw); mvAppItem* item = GetItem(*GContext->itemRegistry, name); - if (item) - item->setPyValue(value); - else + if (!item) { mvThrowPythonError(mvErrorCode::mvItemNotFound, "set_value", "Item not found: " + std::to_string(name), nullptr); + return nullptr; } + Py_XINCREF(value); + item->setPyValue(value); Py_XDECREF(value); return GetPyNone(); @@ -4094,7 +4126,7 @@ set_item_alias(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_item_alias"], args, kwargs, __FUNCTION__, &itemraw, &alias)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -4112,7 +4144,7 @@ get_item_alias(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["get_item_alias"], args, kwargs, __FUNCTION__, &itemraw)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -4131,7 +4163,7 @@ capture_next_item(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["capture_next_item"], args, kwargs, __FUNCTION__, &callable, &user_data)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); @@ -4201,7 +4233,7 @@ set_clipboard_text(PyObject* self, PyObject* args, PyObject* kwargs) if (!Parse((GetParsers())["set_clipboard_text"], args, kwargs, __FUNCTION__, &text)) - return GetPyNone(); + return nullptr; mvPySafeLockGuard lk(GContext->mutex); diff --git a/src/mvPyUtils.cpp b/src/mvPyUtils.cpp index 782bbe684..e44406c91 100644 --- a/src/mvPyUtils.cpp +++ b/src/mvPyUtils.cpp @@ -457,6 +457,12 @@ GetPyNone() Py_RETURN_NONE; } +PyObject* +GetPyNoneOrError() +{ + return (PyErr_Occurred() != nullptr)? nullptr : GetPyNone(); +} + PyObject* ToPyString(const std::string& value) { diff --git a/src/mvPyUtils.h b/src/mvPyUtils.h index 252f71f1d..573f56547 100644 --- a/src/mvPyUtils.h +++ b/src/mvPyUtils.h @@ -136,6 +136,7 @@ bool isPyObject_Any (PyObject* obj); // conversion to python PyObject* GetPyNone (); +PyObject* GetPyNoneOrError (); PyObject* ToPyUUID (mvAppItem* item); PyObject* ToPyUUID (mvUUID value); PyObject* ToPyUUID (mvUUID uuid, const std::string& alias);