hoffstadt / hoffstadt/DearPyGui

Draw list placed below title bar in window but rectangle pmin [0, 0] is placed correctly

Open
#1,550 6 comments 0 reactions 0 assignees View on GitHub
state: pending type: bug
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## Version of Dear PyGui

Version: 1.2.3
Operating System: Windows 10

## My Issue/Question

The draw list is placed underneath the windows titlebar. But the rectangle with pmin [0, 0] is correctly draw in top left corner just below the title bar. So there is a mismatch between draw list and rectangle coordinates.
Problem disappears when there is no title bar.
The coordinates in the bottom left corner is of the drawlist when mouse is on title bar.

## Screenshots/Video

![image](https://user-images.githubusercontent.com/12169958/150011000-0fe8be75-0d53-4d5a-9b80-32d5c3753294.png)

## Standalone, minimal, complete and verifiable example

```python
import dearpygui.dearpygui as dpg

SUITABLE_STATUSBAR_HEIGHT = 36 # centers the default font vertically, 2022-01-14
STATUSBAR_OFFSET_FROM_BOTTOM = 72 # offset from viewport bottom, 2022-01-14

def viewport_resize_callback(sender, app_data, user_data):
dpg.set_item_pos('statusbar', [0, dpg.get_viewport_height()-72])
dpg.set_item_width('statusbar', dpg.get_viewport_width())

def mouse_move_callback(sender, app_data, user_data):
# for showing mouse pos only when cursor in drawing area
mouse_x, mouse_y = app_data
pos_x, pos_y = dpg.get_item_pos(item='draw_window')

x = mouse_x - pos_x
y = mouse_y - pos_y

# if outside draw list then don't show coordinates
if x < 0 or y < 0 or x > dpg.get_item_width(item='drawlist') or y > dpg.get_item_height(item='drawlist'):
x = ''
y = ''

dpg.set_value(item='statbartext', value=f'x: {x} , y: {y}')

if __name__ == '__main__':
dpg.create_context()
dpg.create_viewport(title='Bombus', width=500, height=500)

dpg.set_viewport_resize_callback(viewport_resize_callback)

with dpg.window(tag='draw_window', width=400.0, height=400.0, pos=[20.0, 20.0], no_title_bar=True):
with dpg.drawlist(width=400.0, height=400.0, tag='drawlist', parent='draw_window'):
dpg.draw_rectangle(pmin=[0.0, 0.0], pmax=[400.0, 400.0])

with dpg.window(width=100, height=SUITABLE_STATUSBAR_HEIGHT,
tag='statusbar',
min_size=[dpg.get_viewport_width(), SUITABLE_STATUSBAR_HEIGHT],
max_size=[2560, SUITABLE_STATUSBAR_HEIGHT],
no_title_bar=True,
no_move=True):
dpg.add_text(default_value='', tag='statbartext')

with dpg.handler_registry():
dpg.add_mouse_move_handler(callback=mouse_move_callback)

# dpg.bind_item_handler_registry(item='drawarea', handler_registry='mouse_move')

dpg.show_style_editor()

dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.