Home › Forums › General › Programming › LookAndFeel()
- This topic has 48 replies, 3 voices, and was last updated 8 years, 4 months ago by zeoka.
-
AuthorPosts
-
September 21, 2014 at 9:52 pm #29358
Hello
I try to get variables colors
I see the juce class and then do that :-- -- Called when a component needs repainting -- @comp -- @g http://ctrlr.org/api/class_ctrlr_lua_graphics.html -- see also http://www.rawmaterialsoftware.com/juce/api/classGraphics.html -- panelpainting = function(comp,g) paintval = comp:getOwner():getValue() + 1 lkf = LookAndFeel() lkf:setColour(1,Colour(0xFFFF423E)) lkf:setColour(2,Colour(0xFFFF7442)) lkf:setColour(3,Colour(0xFFFC9824)) lkf:setColour(4,Colour(0xFFFFDD1A)) lkf:setColour(5,Colour(0xFFFFFF19)) lkf:setColour(6,Colour(0xFFA3FF18)) lkf:setColour(7,Colour(0xFF53FF53)) lkf:setColour(8,Colour(0xFF19EAA3)) lkf:setColour(9,Colour(0xFF19EAEB)) lkf:setColour(10,Colour(0xFF18CEFF)) lkf:setColour(11,Colour(0xFF4D94FF)) lkf:setColour(12,Colour(0xFF8472FF)) lkf:setColour(13,Colour(0xFFB66EFF)) lkf:setColour(14,Colour(0xFFDF5FFF)) lkf:setColour(15,Colour(0xFFFF53F0)) lkf:setColour(16,Colour(0xFFFF4880)) T8 = {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448,480} for plte = 1,16,1 do if paintval == plte then g:setColour(Coulour(g:findColour(paintval))) g:fillRect(T8[paintval] + 8,6,16,16) else g:setColour(Coulour(g:findColour(paintval))) g:setOpacity(0.4) g:fillRect(T8[paintval] + 8,6,16,16) end end end
If you’re looking up a colour for use in drawing a component, it’s usually best not to call this directly, but to use the Component::findColour() method instead. That will first check whether a suitable colour has been registered directly with the component, and will fall-back on calling the component’s LookAndFeel’s findColour() method if none is found.
tried…. . tried various syntaxes and I can’t get a variable color identifier
September 21, 2014 at 10:13 pm #29359LookAndFeel is something i’m wroking on right now (it’s done but i’m working on the example demo panel). You need to apply the LookAndFeel to a component for it to work, and just creating a LookAndFeel object won’t really do anything.
A DEMO panel for LookAndFeel is in the works (you can check it out in the repo), once it’s done i’ll let you know.
September 22, 2014 at 11:53 am #29379Ok Thank you Atom
Repo not found , I don’t remember where , searched in the github
I will try like you said and look for the demo panelAll the best
September 22, 2014 at 12:33 pm #29381September 22, 2014 at 1:37 pm #29382It looks like you add cool properties 🙂 on Components but I don’t see the basic commands I would like.
comp:setColour(1,Colour(0xFFFF423E) ?
comp:findColour(x) returns 0xFFFF423E or Colour(0xFFFF423E) ?
I just would define colours when any mods are created and call them in various scripts
Before I tried to do a table ex
CLR = {}
CLR[1] = Colour(0xFFFF423E)
and g:setColour(CLR[clrs] )
or
CLR = {}
CLR[1] = 0xFFFF423E
g:setColour(Colour(CLR[clrs]))September 30, 2014 at 5:56 pm #29820I’m testing the LookAndFeel new possibilities and they are great!! Thanks Atom.
I just messed with the rotary following the M-Brain 11 panel, and apart from the amount of Ctrlr crashes I’m having, it works fine.
Will be possible to have knobs with different LookAndFeel in the same panel?
I suppose other UI elements (combos, buttons…) can be customized in the same way the slider. Where can we find the variables related to each element (p.rotaryStartAngle, p.sliderPosProportional…)?
September 30, 2014 at 5:59 pm #29821It will be all documented when creating a LookAndFeel class from a template (evey parameter will be described what type it has so you’ll know what and how you can use in each method).
I need to actually add all the methods for all other UI elements (again it’s a lot of typing because the old way caused crashes).
Yes you’ll be able to have multiple LookAndFeel objects applied to any number of components.
September 30, 2014 at 10:21 pm #29837Nice 🙂
September 30, 2014 at 10:46 pm #29842Really nice indeed.
For some reason, sliders placed in layers still have the standard Juce knob.
December 22, 2014 at 10:59 pm #34090Really nice indeed.
For some reason, sliders placed in layers still have the standard Juce knob.
BUMP
December 26, 2014 at 10:48 pm #34342My bad, it’s not sliders placed in layers, what is wrong is when you place a slider in a uiTab, it is when the default Juce knob appears.
December 27, 2014 at 12:05 am #34349May be a component of the slider is a child when it is in a group,tab or layer and the script doesn’t work
I notice one thing ( I use it as a feature in a panel )
open a custom comp with knob paint method but using a slider value
place it in a layer
place the slider on another layer (on top) and superpose it
move the knob
Magic : the custom comp is repaint
it is another interferenceDecember 27, 2014 at 2:00 pm #34374May be a component of the slider is a child when it is in a group,tab or layer and the script doesn’t work
Then I would like to have some example, as all I’m trying give me crashes. This is the command we have to change look&feel:
setLookAndFeel (panel:getCanvas(), CustomLookAndFeel()).
To get to sliders inside a tab I’ve tried:
setLookAndFeel (panel:getModulatorByName("My Tab"):getComponent(), CustomLookAndFeel()) -- nothing happens. setLookAndFeel (panel:getModulatorByName("My Tab"):getComponent():getChildComponent(0), CustomLookAndFeel()) -- this change tab L&F setLookAndFeel (panel:getModulatorByName("My Tab"):getComponent():getChildComponent(2), CustomLookAndFeel()) -- this component is a slider, it changes it's L&F, but as soon I enter the slider Ctrlr crashes.
So the L&F code works fine in sliders placed in the panel canvas, but crash when it’s used inside a tab following the approach above.
I notice one thing ( I use it as a feature in a panel )
open a custom comp with knob paint method but using a slider value
place it in a layer
place the slider on another layer (on top) and superpose it
move the knob
Magic : the custom comp is repaint
it is another interferenceI think this is the correct behaviour. Every component that gets repainted must call a repaint to all objects behind.
December 27, 2014 at 4:35 pm #34379may be if you use global
setLookAndFeel (panel:getCanvas(), CustomLookAndFeel()).AND local
setLookAndFeel (panel:getModulatorByName(“My Tab”):getComponent():getChildComponent(2), CustomLookAndFeel())
could create a c stack overflow
if you start to specify for one mod then the method applied to canvas must be removed
for this mod or you had to specify for all mods ??ex mods in group1 ,mods in layer1 , mods in tab1 etc…
December 27, 2014 at 5:22 pm #34382No, I tried each option individually, even modulator by modulator. I’m seing some assertion failure related to drawing the slider, I’ll try to resolve them and see if it’s related.
Atom, I’ve seen another assertion failure related to a memory leak just before crashing Ctrlr (entering edit mode).
Assertion failure in memory/juce_LeakedObjectDetector.h:95
class LeakCounter { public: LeakCounter() noexcept {} ~LeakCounter() { if (numObjects.value > 0) { DBG ("*** Leaked objects detected: " << numObjects.value << " instance(s) of class " << getLeakedObjectClassName()); /** If you hit this, then you've leaked one or more objects of the type specified by the 'OwnerClass' template parameter - the name should have been printed by the line above. If you're leaking, it's probably because you're using old-fashioned, non-RAII techniques for your object management. Tut, tut. Always, always use ScopedPointers, OwnedArrays, ReferenceCountedObjects, etc, and avoid the 'delete' operator at all costs! */ jassertfalse;
December 28, 2014 at 7:30 pm #34427Well if something crashes in Ctrlr, the cleanup is not done well and there might a lot of objects not properly freed from the memory, so you’ll get a lot of those.
I need to re-check the look and feel stuff after some changes i’ve made, i’ll get to that tomorrow and report back.
January 26, 2015 at 6:36 pm #36529I need to re-check the look and feel stuff after some changes i’ve made, i’ll get to that tomorrow and report back.
Bump
January 26, 2015 at 6:52 pm #36532Shit i missed that, sorry about this. I had to move house, and my life got a bit messy lately so i’m not really focused. Keep reminding me i’ll get to that asap, i don’t know when that will be that’s all i can say.
January 29, 2015 at 2:50 pm #36759I was looking into this a little. I found a compiler switch that will make ctrlr not-crash on runtime errors (at least on linux, i might have to upgrade VS2010 to get this working)
and i know why the l&f does noy apply to components in tabs, it’s because tabs use it’s own look and feel, i need to add some logic to l&f switching for components that have their own l&f (a lot of them do). Otherwise it’s a mess.
January 29, 2015 at 8:19 pm #36785Cool you found it.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.