How to make slider views update the edit tab

I am making a plugin that draws on the foreground and want to use a slider to modify values that affect what is drawn. Currently I am only able to get the drawing to update after clicking off of the context menu.

What is the best way to get the drawing to update as the slider is dragged?

You could call Glyphs.redraw().

I had tried that but for some reason it has no effect.

I am thinking it has to do with the way I am passing the slider information to the foreground method. For reference here is some of the code from inside the class:

sliderView = objc.IBOutlet()
slider = objc.IBOutlet() 

@objc.IBAction
def slider_(self, sender):
	return sender.floatValue()

def foreground(self, layer):
	self.italicValue = self.slider_(self.slider)

	tempInstance = layer.parent.parent.instances[0].copy()
	tempInstance.name = "tempInstance"
	tempInstance.weightValue = 84
	tempInstance.widthValue = 0
	tempInstance.customValue = self.italicValue
	tempInstance.setInterpolationCustom1_(self.italicValue)
	tempInstance.setInterpolationCustom2_(self.italicValue)
	tempInstance.setInterpolationCustom3_(1000)

The def slider_(self, sender): is the method that is called be the slider (when you have set it to be its action. You should do

self.italicValue = self.slider.floatValue()

directly.

And why do you need to have three axis to contain the same value?
And maybe update the instance in the slider_ method?

def slider_(self, sender):
	self.italicValue = self.slider.floatValue()

	tempInstance = layer.parent.parent.instances[0].copy()
	tempInstance.name = "tempInstance"
	tempInstance.weightValue = 84
	tempInstance.widthValue = 0
	tempInstance.customValue = self.italicValue
	tempInstance.setInterpolationCustom1_(self.italicValue)
	tempInstance.setInterpolationCustom2_(self.italicValue)
	tempInstance.setInterpolationCustom3_(1000)
	self.tempInstance = tempInstance
	Glyphs.redraw()
1 Like

The three axis sharing the same value is because I am using HOI, specifically along a cubic curve.

That fixed it. The issues were with my setup and poor understanding of Xcode. Thanks!

then you have to set the slider to be slider.setContinuous_(True)

Or check the Continuous checkbox in Xcode.

1 Like

Hi,

I’m having the same situation but the point is that I’m using vanilla instead of building the UI using Xcode. I have some sliders like this one:

# Slider
self.w.xSkew = vanilla.Slider(
    (margin, linePos, -margin, lineHeight),
    minValue = -1,
    maxValue = 1,
    value = 0,
    continuous = True
            )

And even thought I’m setting continuous to True it still doesn’t apply any change to the current path in Edit View. I haven’t used Glyphs.redraw() so far but maybe this could be an option in this case. I’m not sure how to make this work, though.

Thanks!

There are several was to cause a redraw. Either a value on a Glyphs object is changed and that triggers a redraw internally. Or, if the slider controls your values, then you have to call Glyphs.redraw()

Also your slider is not connected to any callback method.

Thanks @Mark, this is something I had realised a bit after posting this topic. Since I’m using AffineTransform to scale the current layer, now I’m dealing with other kind of issues such as having the original drawing as a reference of the 100% X and Y values. Now, every time I move a slider it resets the 100% of its width (for instance) to the new proportions (narrower or wider) instead of using the original one.

Again, thanks for your previous help!