I've been curious whether and how it is possible to change the look of Primefaces' sliders in a way that doesn't ruin the components look, i.e. quite a few styles are applied to these components and thus e.g changing the color to red would require me to also change a bunch of other style attributes.
Is there any smooth way?
Related
I have to update the nodes styling dynamically based on my data. Mostly it will be background, border and font. I cannot define predefined css class names to define background color as the colors will be dynamic. Same as with border and fonts.
I am aware that I can set background to a Region in two ways. By constructing the style string and set in setStyle method
region.setStyle("-fx-background-color:"+getColorStr()+";");
or alternatively I can construct a Background object and set using setBackground.
Background background = new Background(new BackgroundFill(getColor(), new CornerRadii(0), Insets.EMPTY));
region.setBackground(background);
I am a bit confused to choose which option to go with. Mainly worried about the performance issue of one option over other. Can someone let me know which is most preferrable way to go with (considering performance) ?
Just to let you know my CSS file is a heavy file with complete customisation of all controls. Can this be a factor to consider for performance if I go with setStyle method.
The same question when dealing with Border and Font as well.
I'm collaborating on a checkers program for which the first logical step is to draw the initial board. The implementation we are using has one philosophical issue. The squared are formed by calling fillRect with the color of the"dark" squares after initializing the board with the color of the light squares.
My concern is that I now have colors hard coded into the JS, and I would prefer to specify them in the associated CSS. Is there a good way to encode the colors used in drawing the canvas in CSS?
Pick one or the other, and stick to it. Obviously the game logic would still use JS.
If you want to make it easy to style each part of the board, use CSS and render the parts of the board using actual HTML elements with classes on them. This way you can easily make changes to sizes, colours, images, textures, etc., without explicitly re-rendering anything.
If you want/need it to be on a canvas, you can easily expose a method for setting styling options during or after game creation. This way you can include an inline or second script file as you would with CSS.
I want to change the background color of my Vaadin app on the valueChange event of a OptionGroup component.
As there are a fairly big number of layouts on my page, what would be the best is to change every HorizontalLayout and VerticalLayout background-color, but every new component that could be added should have this color too.
How can I achieve that? Thanks.
Two approaches come to mind.
The simplest, conceptually, as well as in terms of implementation, would be to have a single component to serve as the background, and give your HorizontalLayout and VerticalLayout components a transparent background. If you're layout is too complex for this, you can have a number of base 'background' components, again, with your layout components on top being transparent. The idea is to reduce the components whose color you need to change to something manageable.
If that approach doesn't translate to your use case, you can always use JavaScript to select the layout components on the fly and redefine their background. This could be made more manageable by giving all the layout components a common CSS class (eg: 'dynamic-background').
JavaScript.getCurrent().execute("$('.dynamic-background').css('background-color', 'purple')");
Note that this JavaScript depends on JQuery, have a look around for more details on integrating JQuery with Vaadin:
Add javascript/Jquery & client side code in Vaadin 7
Integrating HTML and JavaScript in Vaadin 7
I am using Flex 4.9. I thought that with the newest SDK, they finally made Flex and CSS components tags to work. But they did not.
I tried to set horisontalAlign and verticalAlign of spark HGroup vie CSS style, so I could manage it smoothly and save some code typing. HGroups didnt respond to CSS style I applied, ok, I thought that at least I will set their width. It also did not work! Nor pixel width or percent value.
Does Flex CSS styling is really so limited or am I missing something?
horizontalAlign, verticalAlign, width and height are all properties of the HGroup class, not styles. Hence you cannot set these properties through stylesheets.
What you seem to be missing is that Flex is not HTML and that the same semantics do not apply. In Flex 4 we separate the content from the way it is presented mainly through a process called skinning: we declare components and their logic in one class (usually in ActionScript) and we define its visual representation in another (usually written in MXML).
With this separation already in place there is hardly any need for stylesheets. In fact, if you would put a CSS on top of that, you would kind of artificially try to separate the layout into two separate entities which doesn't make much sense. Not to mention it would make the code much harder to read.
There is a case where CSS comes in handy though, that is when you want to apply a certain visual style throughout your application. A Button could have five different skins, but through CSS you could set the font color of all five to a specific color without repeating that in each skin.
I have a pyqt4 app which should run with arbitrary colorscheme. I would like to make some widgets more visible by making them lighter or darker than their style-predefined color. I would like it to work for any overall style and don't want to hardcode colors in there. What would be the way to call QWidget.setStyleSheet which would make that happen?
I'm not sure this is possible. There is no default stylesheet to query and parse, because its a user-specified value.
Themes can be platform-dependent, so would have to do a bunch of processing on the widgets style -> palette -> attributes, figure out the color values, and generate a modified value to specify in your stylesheet. At that point, you are better off just sticking with the palettes and modifying their values, and not worrying about a stylesheet.