Skip to content

Item resize handler handle only increasing of the primary window size #1896

@vanekrus

Description

@vanekrus

Version of Dear PyGui

Version: 1.7.1
Operating System: Windows 10 build 19044.2006

My Issue/Question

Item resize handler (mvAppItemType::mvResizeHandler) calls its callback function in realtime while increasing size of the viewport with primary window. When viewport (as well as primary window) size is decreased callback is called only if mouse button released or if size increased again. Both bind_item_handler_registry and set_viewport_resize_callback have this bug.
The same bug could be seen in this example if the window is set to primary.

Important note: if the window is not primary, than callback is called in realtime both while increasing and decreasing the window size. Therefore for not primary windows resize item handler works as expected.

To Reproduce

  1. Create viewport.
  2. Create window and set it primary.
  3. Define resize callback function with some obvious actions (e. g. print).
  4. Create item resize handler.
  5. Bind handler to window and function.
  6. Set viewport resize callback to defined function.
  7. Run the program and try to change window (not dpg, OS window -- viewport) size in horizontal and vertical directions or both.
  8. Take a look in terminal. Callback do its job only while stretching and only once while size reducing (only when button released or stretching occured).

Expected behavior

I expect exactly the same behaviour in both directions.

Screenshots/Video

Demonstration of this bug can be seen on this video. As can be seen on the video I've used code from example below simply pasted in IPython.

Standalone, minimal, complete and verifiable example

# Here's shortest example which I could make.
import dearpygui.dearpygui as dpg

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

#Variable to show number of calls of the callback function below
i = 0
def resized():
    global i
    i += 1
    print(f"Callback called {i} times.")

with dpg.window(tag="#main_window", label="tutorial"):
    dpg.add_button(label="Press me")
dpg.set_primary_window("#main_window", True)

with dpg.item_handler_registry(tag="#resize_handler"):
    dpg.add_item_resize_handler(callback=resized)
#Next two strings bind function resize to window and viewport resize events.
#Any of two may be commented as it will not affect on the bug     
dpg.bind_item_handler_registry("#main_window", "#resize_handler")
dpg.set_viewport_resize_callback(resized)

dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions