Solved Custom UI — button vs. label: 1 pixel x/y image position offset?

Discussion in 'Scripting Workshop' started by Sebastian M. Purfürst, Mar 26, 2020 at 11:27 PM.

  1. Sebastian M. Purfürst

    Sebastian M. Purfürst NI Product Owner

    Messages:
    3
    Hi dear experts,

    I am working on a UI for a new instrument (Kontakt 6 / MacBook Pro/Retina Display/HighSierra). I'd love to blend the background and a couple of buttons seamlessly.

    It seems to me that buttons always have a 1 x/y offset when I try to position them. I did a couple of test, comparing labels and buttons with the same image. I can clearly see the described offset of one pixel in x- and y- position. Am I missing something — or — is this offset something I have to keep in mind when designing buttons / knobs etc. I attached a pic with a very simple comparison. Thanks so much for your help in advance.
    Sebastian
    +++
    Offset.png
     
  2. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    16,081
    Yes, that's how it is unfortunately. There is no workaround for buttons/switches/menus, they will always be offset by (1, 1).
     
  3. medusa

    medusa NI Product Owner

    Messages:
    157
    In my experience only ui_switch does this, not ui_button or ui_label.
     
  4. Sebastian M. Purfürst

    Sebastian M. Purfürst NI Product Owner

    Messages:
    3
    Hi EvilDragon, thanks so much for getting back! Yes, it * is * a bit unfortunate, but at least I can continue working and think about a workaround in the design process… Just out of pure interest — is this some kind of legacy thing?

    AND thanks again for all your amazing support across the forum — you are legend:cool:!
     
  5. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    16,081
    Switch and button and menu all do it. This is very easy to test: instrument header is 68 px tall.

    upload_2020-3-27_14-32-3.png

    upload_2020-3-27_14-32-45.png

    upload_2020-3-27_14-33-49.png
     
  6. EvilDragon

    EvilDragon Moderator Moderator

    Messages:
    16,081
    Yeah this was the case ever since we got pixel positioning of UI controls in Kontakt 4.
     
  7. medusa

    medusa NI Product Owner

    Messages:
    157
    Ah right, sorry.
    Confusing it with another, related issue, in which a switch is one pixel smaller than a button set to the same size.

    Screenshot 2020-03-27 at 09.55.34.png
     
    • Like Like x 1
  8. Sebastian M. Purfürst

    Sebastian M. Purfürst NI Product Owner

    Messages:
    3
    Sure! Thanks anyways!:thumbsup: