Home › Forums › General › Programming › LookAndFeel()
- This topic has 48 replies, 3 voices, and was last updated 8 years, 5 months ago by zeoka.
-
AuthorPosts
-
February 13, 2015 at 5:27 pm #37895
The new Ctrlr nightly has a new and improved implementation for LookAndFeel, the JoMoX Mbrane 11 panel shows how to use that, it should be fairly complete. I tested it mostly on Linux so i don’t know how other platforms will react to the change.
Please let me know in case of any errors.
February 14, 2015 at 9:53 am #37936Just looking at your demo, it’s possible to have several designs for sliders, for example?
February 14, 2015 at 1:10 pm #37948Sure, as many as you can implement.
February 14, 2015 at 2:52 pm #37955But how can I assign a different l&f script to each modulator? All I see in the demo is a general call to change l&f, but all sliders use the same script, buttons the same script and so on.
February 16, 2015 at 11:16 am #38058You apply the look and feel definition to a component, in the example it’s applied to the cancas (this is what you or someone wanted, that if you apply the LF to a group/canvas/tab all the child components get the new LF).
But you can pick your component just apply the LF to whatever panel:getComponent() you want, you can have each slider with a different LF object.
February 16, 2015 at 12:12 pm #38060I get it, fantastic. I’ll let you know if it’s all ok.
February 17, 2015 at 1:59 pm #38116Everything working fine, Atom, but I have two doubts:
In the combo example, I can’t use imported fonts.
getComboBoxFont = function(comboBox)
font1 = resources:getResourceAsFont ("blabla")
return Font("Courier New",18.0,1) -- works
return Font(font1,9,1) -- doesn't work
return Font("blabla",9,1) -- doesn't work
end}The second one, I want to add the ticked mark to the item selected, and the mark must be a shape or draw, not an image. How to manage drawableIcon argument?
drawPopupMenuItem = function(g, area, isSeparator, isActive, isHighlighted, isTicked, hasSubMenu, text, shortcutKeyText, drawableIcon, textColourPtr)
February 18, 2015 at 12:32 am #38164this will work:
getComboBoxFont = function(comboBox) font = resources:getResourceAsFont("TR-909") if font ~= nil then return font else return Font("Courier New",18.0,1) end end
there are some methods that modify the font object in this situation, some of them look like new ones that i didn’t add yet, but i will fill this gab for now below is the list of methods that are included:
so something like this should also work
return font:italicised()
.def("setTypefaceName", &Font::setTypefaceName) .def("getTypefaceStyle", &Font::getTypefaceStyle) .def("withTypefaceStyle", &Font::withTypefaceStyle) .def("getHeight", &Font::getHeight) .def("withHeight", &Font::withHeight) .def("withPointHeight", &Font::withPointHeight) .def("setHeightWithoutChangingWidth", &Font::setHeightWithoutChangingWidth) .def("getDescent", &Font::getDescent) .def("withStyle", &Font::withStyle) .def("setBold", &Font::setBold) .def("isBold", &Font::isBold) .def("italicised", &Font::italicised) .def("setUnderline", &Font::setUnderline) .def("getHorizontalScale", &Font::getHorizontalScale) .def("setHorizontalScale", &Font::setHorizontalScale) .def("withExtraKerningFactor", &Font::withExtraKerningFactor) .def("setSizeAndStyle", (void (Font::*)(float, int, float, float))&Font::setSizeAndStyle) .def("setSizeAndStyle", (void (Font::*)(float, const String &, float, float))&Font::setSizeAndStyle) .def("getStringWidth", &Font::getStringWidth) .def("getGlyphPositions", &Font::getGlyphPositions) .def("toString", &Font::toString) .scope [ def("getDefaultSansSerifFontName", &Font::getDefaultSansSerifFontName), def("getDefaultSerifFontName", &Font::getDefaultSerifFontName), def("getDefaultMonospacedFontName ", &Font::getDefaultMonospacedFontName), def("getDefaultStyle", &Font::getDefaultStyle), def("getDefaultTypefaceForFont", &Font::getDefaultTypefaceForFont), def("findAllTypefaceNames", &Font::findAllTypefaceNames), def("findAllTypefaceStyles", &Font::findAllTypefaceStyles), def("getFallbackFontName", &Font::getFallbackFontName), def("setFallbackFontName", &Font::setFallbackFontName), def("getFallbackFontStyle", &Font::getFallbackFontStyle), def("setFallbackFontStyle", &Font::setFallbackFontStyle), def("fromString", &Font::fromString) ] .enum_("FontStyleFlags") [ value("plain", 0), value("bold", 1), value("italic", 2), value("underlined", 3) ]
February 18, 2015 at 2:03 pm #38192Thanks, that worked.
Now I’m stuck trying to draw the thumb of a horizontal slider. I get working drawLinearSlider, but the thumb doesn’t appear.
drawLinearSliderBackground = function (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, SliderStyle, slider)g:fillAll(colourDark)
end,drawLinearSliderThumb = function (g, x, y, width, height, sliderPos, minSliderPos, maxSliderPos, SliderStyle, slider)
g:fillRectangle(x,y,width * 0.5, height * 0.5)
end,getSliderThumbRadius = function(Slider)
return 5.0;
end,createSliderButton = function(slider, isIncrement)
isIncrement = true
end}
February 19, 2015 at 3:14 pm #38284Have a look at your logs fillRectangle does no exist fillRect exists
February 19, 2015 at 4:29 pm #38286It must be something else, because after the correction I still don’t see anything drawn.
February 19, 2015 at 4:51 pm #38289This should work (a white rectangle for a vertical slider, you need to do different calculations for different slider styles:
sliderRadius = 7 kx = x + width * 0.5 ky = sliderPos outlineThickness = 2 g:setColour (Colour (0xffffffff)) g:drawRect (kx - sliderRadius, ky - sliderRadius, sliderRadius * 2.0, sliderRadius * 2.0, outlineThickness)
When i doubt look at the JUCE source code, that’s where all the calculation for the default LookAndFeel are done, it’s a good source of ideas: https://github.com/julianstorer/JUCE/blob/master/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V2.cpp
for the new LookAndFeel you can have a look at:
https://github.com/julianstorer/JUCE/blob/master/modules/juce_gui_basics/lookandfeel/juce_LookAndFeel_V3.cppetc.
February 19, 2015 at 5:21 pm #38290Thanks a lot for the links, I was wondering if they where available.
February 19, 2015 at 6:08 pm #38293The answer was to create function drawLinearSliderThumb outside lf_SliderHorizontal_Impl and call it from drawLinearSlider.
March 25, 2015 at 3:39 pm #41595Hi Atom
It’s possible to have L&F implementation for PopUpMenu objects?
March 31, 2015 at 1:15 pm #42323For all of them or specific ones you create on your own in Lua ?
March 31, 2015 at 1:48 pm #42324Specific ones created in my lua scripts.
April 4, 2015 at 3:36 am #42713Hi
I encounter issue with UIfixedSlider()
the look and fell seems not applied on this type of modulator
just tried to adapt the jomox example .
it works with ui sliderApril 6, 2015 at 4:42 pm #43108Hi
i tried this :
jj = Rectangle( (width * 0.5)-(width*0.04) , (width * 0.5) – (width*0.13)-((width-(width*0.16))- (width * 0.5)) ,width*0.08,width*0.13)
g:excludeClipRegion (jj)
workingnow i would this
jj = Path()
jj:addRectangle((width * 0.5)-(width*0.04),(width * 0.5) – (width*0.13)-( (width-(width*0.16) )- (width * 0.5)) ,width*0.08,width*0.13)hh = jj:getBoundsTransformed(AffineTransform( AffineTransform .rotation (angle,(width * 0.5),(width * 0.5))))
— hh = Rectangle Floatg:excludeClipRegion (hh:toInt()) — i need Rectangle Int
this is not working ,ctrlr doesn’t tell me it’s unregistered
What i doing wrong ?
April 6, 2015 at 11:08 pm #43136There’s no Rectangle:toInt() function. In Juce there is Rectangle:toType() function, but it is not visible doing what(RectangleObject), so maybe it’s not registered.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.