How to stylize text-list and other elements? - rebol

Default Rebol VID style is eye-searing, put bluntly. I started making my own default, but ran into a snag. Namely, how do I specify styles for a sub-element of an element?
good-looking: stylize [
field: field
edge [size: 1x1]
colors [255.255.255 255.255.255]
area: area
edge [size: 1x1]
colors [255.255.255 255.255.255]
text-list: text-list
;text-list/sub-area/edge [size: 1x1]
]
I want all fields to have a thin border, including text-list and others. But I have no idea how to include that rule in the text-list definition.
Also, how to reduce repetition with styles, like with the colors?

I can partly answer your first question. At the REBOL consol, try this...
>> lo: layout [t: text-list]
That both creates a layout and allows the text-list object (t) to be examined using PROBE...
>> probe first t
== [self type offset size span pane text color image effect data edge font para feel saved-area rate show? options parent-face old-offset old-size line-list changes face-flags action state access style alt-action facets related words colors texts images file var keycode reset styles init multi blinker pane-size dirty? help user-data flags doc xy sz iter sub-area sld sn lc picked cnt act slf lines text-pane update resize]
Notice the SUB-AREA there. That's the list area in a text-list. Probe into that and you get...
>> probe first t/sub-area/edge
== [self color image effect size]
>> probe first t/sub-area/edge/size
== 2
So, change SIZE there and view the layout we made...
>> t/sub-area/edge/size: 1x1
== 1x1
>> view lo
The text-list's edge should be thin now. I'm not sure how you achieve that using style, but hopefully this will put you on the right track.

So, first:
layout [X: field]
type? X/edge
type? X/colors
Objects should get re-made to avoid unexpected side-effects on the shared ones.
good-looking: stylize [
field: field with [
edge: make edge [size: 1x1]
colors: copy [255.255.255 255.255.255]
]
area: area with [
edge: make edge [size: 1x1]
colors: copy [255.255.255 255.255.255]
]
text-list: text-list with [
sub-area: make sub-area [
edge: make edge [size: 1x1]
]
]
]

Related

Border-Shadow and decrease the size of parent element css in cytoscape

I have a following image:
I am trying to add border shadow to the rectangle shape. Is that possible in cytoscape? Also, the parent elements are Customers and order. Can I decrease the size of customers and order parent element?
Here's is the link to the code and the working example:
https://stackblitz.com/edit/angular-kpnys1?file=src%2Fapp%2Fdemo_test.json
Decreasing the parent size:
This is a styling issue, cytoscape.js applies padding to parent elements, if you want your parent element to be as small as possible, you'll have to adjust the padding in the :parent style:
{
selector: ":parent",
css: {
...
"padding": "0px" \\ remove padding completely, parent almost touching inner nodes
}
},
Border shadow
This was a little tricky, cytoscape.js only provides a normal border (like "border": "1px solid black"). You can use these styles:
border-width : The size of the node’s border.
border-style : The style of the node’s border; may be solid, dotted, dashed, or double.
border-color : The colour of the node’s border.
border-opacity : The opacity of the node’s border.
None of this provides us with the ability to apply a one sided border. As an alternative, I used the ghost styles:
ghost : Whether to use the ghost effect; may be yes or no.
ghost-offset-x : The horizontal offset used to position the ghost effect.
ghost-offset-y : The vertical offset used to position the ghost effect.
ghost-opacity : The opacity of the ghost effect.
If you adjust it a little bit, you can use the x offset and a nice opacity value to achieve this box shadow:
ghost: "yes",
"ghost-opacity": 0.5,
"ghost-offset-x": 1
Here is a working stackblitz with both changes applied.

Turn on/off mouseOver attribute in elm-ui

I am trying to make a simple game on Elm with elm-ui for my interest, but I stacked how to turn on/off mouseOver attribute.
I made a sample code for my explanation: https://ellie-app.com/9rvqJxz4ypga1
In this code, model has only two status (Myself|Opposite) which represent the turn of the game.
I would like to turn on changing background color of each tiles with mouseOver when model has the same status as the label of the tile.
viewTile is the main code which contains what I want to do.
viewTile : Player -> Model -> Element Msg
viewTile player model =
let
desc =
if player == Myself then
"Myself"
else
"Opposite"
changeMouseOver =
if player == model then
mouseOver [ Bg.color (rgba 1 0.2 0.3 0.5) ]
else
mouseOver []
in
column [ width (px 100), height (px 100), Border.width 1, changeMouseOver ] [ el [ centerX, centerY] ( text <| desc ) ]
For example, if model has "Myself" status, mouseOver will turn on only the tile labeled "Myself" .
In addition, "Change turn" button can change model like Myself <-> Opposite.
This trial showed good result if you clicked this button one time. However if you clicked again (means to recover model to Myself), mouseOver of "Myself" tile do not work.
I tried move the if code from let-in section to external, but it did not also work well.
How should I change the code to work turn on/off mouseOver?
This issue seems to be browser-specific one, I tried this code with Ellie in Safari 13.0.5. Firefox 78.0.2 works fine.

Rebol font size not working

For some reason when I run my code - or even the example codes from the Rebol website - the font size of the GUI text do not have an effect. I can write:
view layout [ text "This should be big!" font [size: 50] ]
or even:
view layout [ text "This should also be big!" font-size 50 ]
but neither do anything. Peculiarly, however, I can add a color to the text.

How do I create a graphics banner with multiple lines in Rebol (can only create one line)?

This works:
view layout [
box white 728x90 effect reduce [ 'gradient 0x1 sky]
font [align: 'center size: 40 color: red] "Your banner text"
]
But how do I add other lines ?
Thank you.
Include a new line in your text:
view layout [
box white 728x90 effect reduce [ 'gradient 0x1 sky]
font [align: 'center size: 40 color: red] "Your banner text^/on two lines"
]
If you aren't used to "escaping" characters in Rebol, it's pretty similar to doing so in C or Java or JavaScript or .....
This page in the Rebol Core Manual has all the details - http://www.rebol.com/docs/core23/rebolcore-16.html#section-2.11
You should be able to work out how to get multiple lines with different font sizes and colours by reading this - http://www.rebol.com/how-to/subpanels.html

Why do I have Text Shadow on My Graphics Banner in Rebol while I use shadow 0x0?

I use this code:
view layout [
box sky 200x100
font [
shadow 0x0
align: 'center
size: 16
color: blue
colors: [255.255.255 255.255.255]
] "Test Shadow"
]
But still get shadow. Is it possible to get rid off it ? Thanks.
Because there is an error in your code. You might save yourself sometime if you check your code before posting here.
Try
shadow: 0x0