Skip to content

Commit 9e45b10

Browse files
authored
Merge branch 'master' into feature/scroll-handler
2 parents 485a90d + cc23d00 commit 9e45b10

17 files changed

Lines changed: 192 additions & 72 deletions

dearpygui/_dearpygui.pyi

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dearpygui/_dearpygui_RTD.py

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dearpygui/dearpygui.py

Lines changed: 19 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dearpygui.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ GetModuleConstants()
7878
ModuleConstants.push_back({"mvScrollDirection_YAxis", mvScrollDirection_YAxis });
7979
ModuleConstants.push_back({"mvScrollDirection_Horizontal", mvScrollDirection_Horizontal });
8080
ModuleConstants.push_back({"mvScrollDirection_Vertical", mvScrollDirection_Vertical });
81+
ModuleConstants.push_back({"mvEventType_Off", mvEventType_Off });
82+
ModuleConstants.push_back({"mvEventType_Enter", mvEventType_Enter });
83+
ModuleConstants.push_back({"mvEventType_On", mvEventType_On });
84+
ModuleConstants.push_back({"mvEventType_Leave", mvEventType_Leave });
8185

8286
ModuleConstants.push_back({"mvPlatform_Windows", 0L });
8387
ModuleConstants.push_back({"mvPlatform_Apple", 1L });

src/dearpygui_commands.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,19 +2183,26 @@ save_init_file(PyObject* self, PyObject* args, PyObject* kwargs)
21832183
static PyObject*
21842184
split_frame(PyObject* self, PyObject* args, PyObject* kwargs)
21852185
{
2186-
i32 delay = 32;
2187-
2188-
if (!Parse((GetParsers())["split_frame"], args, kwargs, __FUNCTION__,
2189-
&delay))
2186+
if (!Parse((GetParsers())["split_frame"], args, kwargs, __FUNCTION__))
21902187
return GetPyNone();
21912188

2192-
// std::lock_guard<std::recursive_mutex> lk(GContext->mutex);
2189+
if (GContext->running)
2190+
{
2191+
Py_BEGIN_ALLOW_THREADS;
2192+
std::unique_lock lk(GContext->frameEndedMutex);
2193+
GContext->frameEnded = false;
2194+
GContext->frameEndedEvent.wait(lk, []{return GContext->frameEnded;});
2195+
lk.unlock();
21932196

2194-
Py_BEGIN_ALLOW_THREADS;
2195-
GContext->waitOneFrame = true;
2196-
while (GContext->waitOneFrame)
2197-
std::this_thread::sleep_for(std::chrono::milliseconds(delay));
2198-
Py_END_ALLOW_THREADS;
2197+
Py_END_ALLOW_THREADS;
2198+
}
2199+
2200+
// Now let's see if it was successful (there's a chance that DPG got stopped while we were waiting)
2201+
if (!GContext->running)
2202+
{
2203+
mvThrowPythonError(mvErrorCode::mvNone, "split_frame is exiting: there is no active rendering loop.");
2204+
return nullptr;
2205+
}
21992206

22002207
return GetPyNone();
22012208
}
@@ -2566,7 +2573,7 @@ destroy_context(PyObject* self, PyObject* args, PyObject* kwargs)
25662573
else
25672574
{
25682575
// Make sure everyone knows we're shutting down, even if stop_dearpygui
2569-
// was not called.
2576+
// was not called. This also releases any waiting split_frame calls.
25702577
StopRendering();
25712578

25722579
Py_BEGIN_ALLOW_THREADS;

src/dearpygui_parsers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ InsertParser_Block1(std::map<std::string, mvPythonParser>& parsers)
564564

565565
{
566566
std::vector<mvPythonDataElement> args;
567-
args.push_back({ mvPyDataType::Integer, "delay", mvArgType::KEYWORD_ARG, "32", "Minimal delay in in milliseconds" });
567+
args.push_back({ mvPyDataType::Integer, "delay", mvArgType::DEPRECATED_REMOVE_KEYWORD_ARG, "32", "Do not use it anymore, it has no effect." });
568568

569569
mvPythonParserSetup setup;
570570
setup.about = "Waits one frame.";

src/mvAppItem.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4903,6 +4903,8 @@ DearPyGui::GetEntityParser(mvAppItemType type)
49034903
MV_PARSER_ARG_CALLBACK)
49044904
);
49054905

4906+
args.push_back({ mvPyDataType::Integer, "event_type", mvArgType::KEYWORD_ARG, "None", "What kind of events to track: mouse-in (mvEventType_Enter), mouse-over (mvEventType_On), mouse-out (mvEventType_Leave). Can be a combination of these flags. Defaults to mouse-over." });
4907+
49064908
setup.about = "Adds a hover handler.";
49074909
setup.category = { "Widgets", "Events" };
49084910
break;
@@ -4929,6 +4931,8 @@ DearPyGui::GetEntityParser(mvAppItemType type)
49294931
MV_PARSER_ARG_CALLBACK)
49304932
);
49314933

4934+
args.push_back({ mvPyDataType::Integer, "event_type", mvArgType::KEYWORD_ARG, "None", "What kind of events to track: just got focus (mvEventType_Enter), currently having focus (mvEventType_On), lost focus (mvEventType_Leave). Can be a combination of these flags. Defaults to mvEventType_On." });
4935+
49324936
setup.about = "Adds a focus handler.";
49334937
setup.category = { "Widgets", "Events" };
49344938
break;

src/mvAppItemState.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ void
88
ResetAppItemState(mvAppItemState& state)
99
{
1010
state.hovered = false;
11+
state.prevHovered = false;
1112
state.active = false;
1213
state.focused = false;
14+
state.prevFocused = false;
1315
state.leftclicked = false;
1416
state.rightclicked = false;
1517
state.middleclicked = false;
@@ -29,8 +31,10 @@ void
2931
UpdateAppItemState(mvAppItemState& state)
3032
{
3133
state.lastFrameUpdate = GContext->frame;
34+
state.prevHovered = state.hovered;
3235
state.hovered = ImGui::IsItemHovered();
3336
state.active = ImGui::IsItemActive();
37+
state.prevFocused = state.focused;
3438
state.focused = ImGui::IsItemFocused();
3539
if (state.focused)
3640
{

src/mvAppItemState.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ inline b8 IsItemDoubleClicked(ImGuiMouseButton mouse_button)
7171
struct mvAppItemState
7272
{
7373
b8 hovered = false;
74+
b8 prevHovered = false;
7475
b8 active = false;
7576
b8 focused = false;
77+
b8 prevFocused = false;
7678
b8 leftclicked = false;
7779
b8 rightclicked = false;
7880
b8 middleclicked = false;

src/mvBasicWidgets.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2642,6 +2642,7 @@ DearPyGui::draw_simple_plot(ImDrawList* drawlist, mvAppItem& item, const mvSimpl
26422642
// * only update if applicable
26432643
//-----------------------------------------------------------------------------
26442644
item.state.lastFrameUpdate = GContext->frame;
2645+
item.state.prevHovered = item.state.hovered;
26452646
item.state.hovered = ImGui::IsItemHovered();
26462647
item.state.leftclicked = ImGui::IsItemClicked();
26472648
item.state.rightclicked = ImGui::IsItemClicked(1);
@@ -4388,26 +4389,7 @@ DearPyGui::draw_radio_button(ImDrawList* drawlist, mvAppItem& item, mvRadioButto
43884389
//-----------------------------------------------------------------------------
43894390
// update state
43904391
//-----------------------------------------------------------------------------
4391-
item.state.lastFrameUpdate = GContext->frame;
4392-
item.state.hovered = ImGui::IsItemHovered();
4393-
item.state.active = ImGui::IsItemActive();
4394-
item.state.focused = ImGui::IsItemFocused();
4395-
item.state.leftclicked = ImGui::IsItemClicked();
4396-
item.state.rightclicked = ImGui::IsItemClicked(1);
4397-
item.state.middleclicked = ImGui::IsItemClicked(2);
4398-
for (int i = 0; i < item.state.doubleclicked.size(); i++)
4399-
{
4400-
item.state.doubleclicked[i] = IsItemDoubleClicked(i);
4401-
}
4402-
item.state.visible = ImGui::IsItemVisible();
4403-
item.state.activated = ImGui::IsItemActivated();
4404-
item.state.deactivated = ImGui::IsItemDeactivated();
4405-
item.state.deactivatedAfterEdit = ImGui::IsItemDeactivatedAfterEdit();
4406-
item.state.toggledOpen = ImGui::IsItemToggledOpen();
4407-
item.state.rectMin = { ImGui::GetItemRectMin().x, ImGui::GetItemRectMin().y };
4408-
item.state.rectMax = { ImGui::GetItemRectMax().x, ImGui::GetItemRectMax().y };
4409-
item.state.rectSize = { ImGui::GetItemRectSize().x, ImGui::GetItemRectSize().y };
4410-
item.state.contextRegionAvail = { ImGui::GetContentRegionAvail().x, ImGui::GetContentRegionAvail().y };
4392+
UpdateAppItemState(item.state);
44114393

44124394
//-----------------------------------------------------------------------------
44134395
// post draw

0 commit comments

Comments
 (0)