Mark2Mark / Synced-Tabs

10 stars 3 forks source link

Horizontal Position of Preview Panel no longer synched #11

Closed weiweihuanghuang closed 3 years ago

weiweihuanghuang commented 3 years ago

Now that in G3 you can freely drag around the horizontal position in the preview panel, this should ideally be synched I think when the plugin is running.

Mark2Mark commented 3 years ago

You mean the height of the bottom Preview?

That’s actually not new in G3, what do you mean then?

However, syncing the riszing of the bottom Preview height seems to be broken now, so I’ll see how I can fix that.

weiweihuanghuang commented 3 years ago

No I mean how you can drag the horizontal position of whats in the preview panel, like drag it left and right

weiweihuanghuang commented 3 years ago

I also noticed the preview panel height doesn't synch, it seems to be 0.5 off when I use similar code

Mark2Mark commented 3 years ago

I also noticed the preview panel height doesn't synch, it seems to be 0.5 off when I use similar code

Yea, that's what I referred to in my previous answer. That worked before but seems broken now. What do you mean by 0.5 off? Off of what?

Thanks for reporting. Didn't know about the horizontal content panning.

schriftgestalt commented 3 years ago

The measurement of the preview height sometimes includes then height of the drag separator and sometimes not. So you need to adjust for that in this case.

schriftgestalt commented 3 years ago

You should be able to

offset = previewView.valueForKey_("selectionOffset")

and

previewView.setValue_ForKey_(offset, "selectionOffset")
previewView.setNeedsDisplay_(True)
weiweihuanghuang commented 3 years ago

The measurement of the preview height sometimes includes then height of the drag separator and sometimes not. So you need to adjust for that in this case.

How do you find out if this needs to be adjusted for?

weiweihuanghuang commented 3 years ago

When I try to run: Glyphs.fonts[1].currentTab.previewView.setValue_ForKey_(currentOffset, "selectionOffset") I get this: AttributeError: 'objc.native_selector' object has no attribute 'setValue_ForKey_'

or if I run: Glyphs.fonts[1].currentTab.previewView().setValue_ForKey_(currentOffset, "selectionOffset") I get: AttributeError: 'NSKVONotifying_GSGlyphsPreview' object has no attribute 'setValue_ForKey_'

Am I doing this right?

schriftgestalt commented 3 years ago

sorry, I mistyped it:

Glyphs.fonts[1].currentTab.previewView().setValue_forKey_(currentOffset, "selectionOffset")
weiweihuanghuang commented 3 years ago

@schriftgestalt what's the code for getting the horizontal dragging offset in the preview panel (attached, not the window) and synching that?

schriftgestalt commented 3 years ago

Can you try this:

currentOffset = font.currentTab.previewView().offset()
font.currentTab.previewView().setOffset_(newOffset)
weiweihuanghuang commented 3 years ago

Thanks I just tried it but it doesn't work

weiweihuanghuang commented 3 years ago

setOffset_() doesn't seem to do anything

schriftgestalt commented 3 years ago

Sorry for the mess. I had another look and testes it this time:

from Foundation import NSPoint, NSValue
currentOffset = Font.currentTab.previewView().valueForKey_("userOffset")
print(currentOffset)
Font.currentTab.previewView().setValue_forKey_(NSValue.valueWithPoint_(NSPoint(-200, 0)), "userOffset")
Font.currentTab.previewView().setNeedsDisplay_(True)
weiweihuanghuang commented 3 years ago

Thanks Georg!