fury-gl / fury

FURY - Free Unified Rendering in pYthon.
https://fury.gl
Other
226 stars 165 forks source link

UI Bug fixes for Horizon #863

Closed maharshi-gor closed 4 months ago

maharshi-gor commented 4 months ago

This PR solves the issues for the UI bugs that appear for Horizon.

Following is fixed in this PR

  1. Solution for disks not appearing in the right position.
  2. Combo Box being out of the bounds of the tabs and with a huge size down button.

Methodology Used

  1. The _set_position (Initial position set method used by panel (TabUI)) method was setting the coordinates of the handles differently than the set_position method invoked when slider is moved. Making them consistent solved the issue.
  2. Combo Box was calculating its location from end of the drop_down_menu instead of the selected text. While passing the values in _set_position method. We just subtracted the y coordinate with the size of dropdown menu

Experiment results

Intital opening Screenshot from 2024-02-20 09-57-34

Opened Combo Box Screenshot from 2024-02-20 09-57-44

Selected Combo Box Screenshot from 2024-02-20 09-57-55

Code to experiment

from fury import ui, window

# Create scene
scene = window.Scene()

# Create show manager
show_m = window.ShowManager(
    scene,
    size=(1200, 900),
    reset_camera=False
)

d_slider = ui.LineDoubleSlider2D(
    min_value=-100,
    max_value=100,
    line_width=3,
    length=450,
    outer_radius=8,
    font_size=16
)
slider = ui.LineSlider2D(
    min_value=-100,
    max_value=100,
    line_width=3,
    length=450,
    outer_radius=8,
    font_size=16
)

d_slider.default_color = (1., .5, .0)
d_slider.track.color = (.8, .3, .0)
d_slider.active_color = (.9, .4, .0)

slider.default_color = (1., .5, .0)
slider.track.color = (.8, .3, .0)
slider.active_color = (.9, .4, .0)

d_slider.handles[0].color = (1., .5, .0)
d_slider.handles[1].color = (1., .5, .0)

slider.handle.color = (1., .5, .0)

c_box = ui.ComboBox2D(
    items=['red', 'green', 'blue', 'pink', 'white', 'orange'],
    selection_bg_color=(0, 0, 0),
    selection_text_color=(0.7, 0.7, 0.7), draggable=False,
    position=(200, 200))

tab_ui = ui.TabUI(
        position=(5, 5), size=(1000, 240), nb_tabs=1,
        active_color=(1, 1, 1), inactive_color=(0.5, 0.5, 0.5),
        draggable=True)

tab_ui.add_element(0, d_slider, (.52, .35))
tab_ui.add_element(0, slider, (.52, .65))
tab_ui.add_element(0, c_box, (.52, .85))

scene.add(tab_ui)
# scene.add(d_slider)
# scene.add(c_box)

show_m.render()
show_m.start()
skoudoro commented 4 months ago

Hi @maharshi-gor,

Thank you for this, Can you also update the unittests? thanks !

skoudoro commented 4 months ago

There is still some tests failing. Can you rebase your PR. I fixed main so you will be able to see the issue

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 84.37%. Comparing base (b24a274) to head (1357fc8). Report is 44 commits behind head on master.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/fury-gl/fury/pull/863/graphs/tree.svg?width=650&height=150&src=pr&token=wrshJ6dyDs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fury-gl)](https://app.codecov.io/gh/fury-gl/fury/pull/863?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fury-gl) ```diff @@ Coverage Diff @@ ## master #863 +/- ## ========================================== - Coverage 84.49% 84.37% -0.13% ========================================== Files 44 44 Lines 10454 10455 +1 Branches 1411 1411 ========================================== - Hits 8833 8821 -12 - Misses 1252 1265 +13 Partials 369 369 ``` | [Files](https://app.codecov.io/gh/fury-gl/fury/pull/863?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fury-gl) | Coverage Δ | | |---|---|---| | [fury/ui/elements.py](https://app.codecov.io/gh/fury-gl/fury/pull/863?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fury-gl#diff-ZnVyeS91aS9lbGVtZW50cy5weQ==) | `89.76% <100.00%> (-0.44%)` | :arrow_down: | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/fury-gl/fury/pull/863/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=fury-gl)
Garyfallidis commented 4 months ago

Thank you @maharshi-gor !