World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Anton 21-Apr-2009 [1836] | mhinson, if you want to see the SLIDER from which all slider instances are derived, then you can do this: print mold system/view/vid/vid-styles/slider (Instead of printing you could write to a file, etc.) You can easily be overwhelmed with information, however, as faces are complex objects. I usually aim for key facets like: print mold svv/vid-styles/slider/init print mold svv/vid-styles/slider/feel etc. |
mhinson 21-Apr-2009 [1837] | wow & I thought parse was tricky... It seems anything more than drawing results on the screen is is undocumented at a newbie level. I could try to write the documentation myself I suppose, but I still havent managed to understand how to find what value is returned from these things. |
Henrik 21-Apr-2009 [1838x3] | whoa, Anton is showing expert stuff there. it really should not be necessary to work with faces at that level. try settling for VIEW, LAYOUT, SET-FACE and GET-FACE for now. The next level would be events and the FEEL object. Then possibly STYLIZE. |
getting a value from a face is easy-peasy: view layout [field [name: get-face face print name]] | |
but note that VID is lacking a lot in some areas, and that requires expert supervision (like Anton) to extend. it's excellent for smaller projects, though. | |
mhinson 21-Apr-2009 [1841] | ok, thanks. I was sort of hoping to use the GUI for input too, rather than just drawing titles & pictures etc. I know how to do that with slider now, but it seems a bit over the top if I have to ask you guys every time I want to use a function. |
Henrik 21-Apr-2009 [1842] | there is a replacement GUI system available called RebGUI. If you find VID to be lacking what you need, perhaps RebGUI is capable of solving your problem. (but I don't use it myself, so I know nothing about it). |
mhinson 21-Apr-2009 [1843] | I doubt VID is lacking, I am just not able to understand how to use it. |
Henrik 21-Apr-2009 [1844] | VID is actually famous for its speed with which you can write usable GUIs. So it's not hard to learn. |
mhinson 21-Apr-2009 [1845] | I suppose I have only spend an hour or two on it & I can work out how to make stuff appear on the screen, but not how to get stuff from the screen. (except slider). |
Henrik 21-Apr-2009 [1846] | I just wrote above a line of code how to do that... |
mhinson 21-Apr-2009 [1847] | [shakes head]... I am sorry, I am just not able to understand how I use that line of code to find out for example what information is returned from slider for example. Sorry, I must be making no sense to you. Thanks for your patience. |
Sunanda 21-Apr-2009 [1848x3] | This is a good tutorial, with examples of entering values, and the script responding to them: http://www.rebol.org/art-display-article.r?article=pfx654q |
Or browse some of the many Q&As on the mailing list: http://www.rebol.org/ml-topic-index.r?i=view | |
and: http://www.rebol.org/ml-topic-index.r?i=vid | |
Henrik 21-Apr-2009 [1851] | mhinson, have you tried running that line of code? Have you noticed that everytime you type something and press enter in the field, the contents is printed in the console? |
mhinson 21-Apr-2009 [1852] | I have just realised that in your line of code "field" is the name of one of the VID functions, so I understand that one now, thanks. If I use view layout [button "Ok" [name: get-face face print name]] it just returns "none", not down or up or true or false or clicked etc. I tried this view layout [button "Ok2" [name: value print name]] and it returns the text on the button does this mean get-face does not work on button? could I have predicted this? If I try to reference a different value like this view layout [button "Ok2" [name: value/text print name]] I just get an error & I have to restart the console to close the button. is this where I should be able to interpret print mold system/view/vid/vid-styles/button/feel to know how to ask for the parts of the value? Thanks very much for all the help. I am back at work now so can mostly only study this in the evenings. |
Anton 22-Apr-2009 [1853] | A FIELD is a style, just like BUTTON, AREA etc. See the full list of available built-in styles like this: print mold extract svv/vid-styles 2 Check the ACCESS facet of a style to see what GET-FACE returns. For BUTTON, it is: >> print mold svv/vid-styles/button/access make object! [ set-face*: func [face value][face/data: value] get-face*: func [face][face/data] clear-face*: func [face][face/data: false] reset-face*: func [face][face/data: false] ] You can see that using GET-FACE on a BUTTON just returns face/data. Buttons by default don't use their data facet for anything, so it's NONE. (You could use the data facet to relate a button to something else that the button is associated with.) Here's an example where a button does GET-FACE on a field. view layout [button "get-face field" [probe get-face my-field] my-field: field "hello"] |
Henrik 22-Apr-2009 [1854] | mhinson, you've stumbled onto the first limitation. If we take the line of code apart, it does the following: view ; view the created layout layout ; create the layout (object tree of FACES) from the VID dialect block [ ; start of VID dialect block button ; the first element, a BUTTON "ok" ; the text for BUTTON [ ; start of the action block for the button. it's evaluated when the button is clicked. name: get-face face ; get the value of the button through the buttons GET-FACE accessor print name ; print the value (likely none) ] ; end of action block ] ; end of layout block Now when I say limitation, it's because you can't easily check for mouse button up, release, mouse movement, etc. The VID dialect directly uses a block right after the button description to describe what should happen after clicking the button. That's part of the syntax and above I wrote it as: <face style> <face text> [<action>] You can specify size, color, edge size, background image and a few grahpical effects. And with it being a dialect, you can leave things out or swap the ordering of some parameters. If you want more advanced control, you need to use the FEEL object, but you are definitely not ready for that. :-) Settle for working with VID and some layouts like above. VID was designed to be easy and very fast to use. If you go beyond VID, you will need a whole lot more knowledge on how to do things. |
mhinson 22-Apr-2009 [1855] | Thanks for your help again. Trust me to stumble on something ;-) I think I am getting there now. Would this be the right way to identify which button was pressed? view layout [button "ok" [print "button1"] button "ok" [print "button2"]] I was expecting the buttons to have names other than the text on the button. I guess identifying the button by its possition in the code is what I will need to do. Thanks. I have never done any GUI programming before so perhaps I am just in a muddle about how it is done in general terms. I was expecting the event that a button was pressed to pop up in another part of the code (are they called event handlers?) (thus needing to identify which button it was). If Rebol dosn't do it like that I may just be asking the wrong questions. |
Henrik 22-Apr-2009 [1856x2] | I guess identifying the button by its possition in the code is what I will need to do. Not necessary. That is what the set-word! prior to the style name is for. You can do that like this: layout [b: button "Hello!" [print "clicked"]] 'b is now a button face. You can access it like this: >> get-face b == none >> b/text == "Hello!" >> b/color == 44.80.132 >> do-face b none clicked From inside the action block, you can also access it by FACE, e.g.: [get-face face] |
And if you type: ? b You get the entire content for that button face. | |
mhinson 22-Apr-2009 [1858] | AH, this is a bit of a revelation.. Now I know where to find all those values. And I can use this sort of construct view layout [b: button "Hello!" [b/text: "goodbye"]] Thank you thank you thank you very much. |
Henrik 22-Apr-2009 [1859x2] | with that line, you need to know about SHOW and HIDE. If you set b/text like that, you need to do a: show b afterwards, or the face won't update. |
HIDE just hides the face (I guess it's not really necessary to know for the above, but there it is). | |
mhinson 22-Apr-2009 [1861] | Thanks, I will try to make myself an example to understand that further. I have another small stumbling block here that I would appreciate some wisdom on please.. ; This works view layout [a1: area (to-pair rejoin ["80x" random 100]) button "ok" [print a1/size]] ; but not this view layout [ box effect [ draw [ line 20x20 (to-pair rejoin ["80x" random 100])]] ] Is this because the dialect is different in one place to the other? I was heading towards using a slider to manipulate stuff on the screen, so this is a first step towards that. |
Henrik 22-Apr-2009 [1862] | I'm not sure, but the draw block should be composed. If you are only calculating the random position once per view, you can COMPOSE/DEEP the layout block or: pos: as-pair 80 random 100 view layout [box effect [draw [line 20x20 pos]]] (untested) |
Anton 22-Apr-2009 [1863] | view layout [ box effect compose/deep [ draw [ line 20x20 (as-pair 80 random 100) ] ] ] |
mhinson 22-Apr-2009 [1864] | Yes, that works a treat, I suppose I could have found that from the documentation within a week. Now I will change the random for a slider. Then I will try to make it show the line every time it moves position. (don't tell me the answer yet please, I only learn when my brain is a bit overheated). Would it be fair to say that Rebol is a linguist's language in that there are a lot of words, phrases & idioms to learn, rather than a smaller number of concepts that apply to everything but in a cryptic way? |
Sunanda 22-Apr-2009 [1865] | I think it's fair to say that VID and VIEW are built on top of the REBOL Core. They are not intimately part of REBOL itself, and may not always have had the same care lavished on them as the core of the language. So they tend to be a bit messier and fragmented. More of a work in progress than an attempt at the state of the art. |
Henrik 22-Apr-2009 [1866x3] | remember that you can have a very different syntax in dialects, so if you are not separating dialects from rebol code, you will be confused, because of seemingly conflicting syntax. |
in fact you may be confused also by the fact that DRAW is an entirely separate dialect from VID. | |
but IMHO, it's not as bad as having to combine HTML/JS/SQL/PHP/CSS in a 20 line code block. | |
mhinson 22-Apr-2009 [1869] | I can't remember being so excited about learning a new thing for ages. It is a great privilege to have access to such well informed teachers as yourselves. I feel like I have stumbled into first class helicopter travel when I only paid for a slow bus. |
[unknown: 5] 22-Apr-2009 [1870] | Nice to see your excitement mhinson. I think here in this REBOL3 world you will find all the expertise you need to master REBOL. |
mhinson 22-Apr-2009 [1871] | Well, I modified the code from draw-controls.r in the script library to get this. It is more complex than I expected, Is it a reasonable way to do this sort of thing please? pos1: 20x20 pos2: 80x0 view layout [ scrn: box rate 0:0:0.1 feel [ engage: func [face action event] [ if action = 'time [ scrn/effect/draw: copy [] append scrn/effect/draw [line pos1 pos2] show scrn ] ] ] effect [ draw [] ] s1: slider [ ss1: to-integer (100 * get-face s1) pos2: (as-pair 80 ss1) ] ] Next step is to work out how to make the thing that moves leave a trail. |
Anton 22-Apr-2009 [1872x4] | view layout [box: box effect [draw [line 20x20 80x20]] slider [box/effect/draw/3/y: to-integer value * 60 + 20 show box]] |
To leave a trail, you could append to the draw block (without setting it to a new block each time, as you've done above), but that would mean your draw block would get very big over time. So a better thing to do is to draw onto an image!, which serves as a cache of your previous draw commands. For this, you can use an IMAGE instead of a BOX, and use the DRAW function to draw permanently onto the image. (The IMAGE style is very similar to BOX, but its 'image facet is set to an image! for us, ready to use.) | |
Oops! No it doesn't ! IMAGE does *not* come initialize its 'image facet with an image! for us! We need to create one for it... | |
view layout [my-image: image (make image! 100x100) slider [draw my-image/image reduce ['line 20x20 as-pair 80 value * 60 + 20] show my-image]] | |
Anton 23-Apr-2009 [1876x3] | Another way to write that is: |
img: make image! 100x100 draw-blk: [line 20x20 80x20] view layout [my-image: image (img) slider [draw-blk/3/y: value * 60 + 20 draw img draw-blk show my-image]] | |
The difference being we are using another word (IMG) to reference the image!, and the draw block (DRAW-BLK) is not created new each time, it is reused. Only the third value in the draw block is modified. That could become significant with large draw blocks. | |
mhinson 23-Apr-2009 [1879] | Thanks Anton, that looks a lot simpler. It is going to take me a while to digest your suggestions fully. I want to understand it well enough to appreciate exactly how this works & where I can read the code to deduce locations of thing like box/effect/draw/3/y for myself. I have been hunting through the documentation but there is such a lot of it that I may have failed to look in the right place. Thanks. |
Anton 23-Apr-2009 [1880x2] | I advise you to review each facet in the face object: print mold first system/standard/face and compare with the slightly larger vid-face: print mold first system/view/vid/vid-face (Note, here FIRST is being used to return just the words of an object!, without their values. If you just probe a face it will fill up your console...) |
Once you find a specific facet you are interested in, you can then probe it to see its value: print mold get in face 'color ; == 200.200.200 and you can do this, of course, with any face you make, such as the BOX above. | |
mhinson 23-Apr-2009 [1882] | Thanks for the extra information. I am slowly piecing it all together. |
mhinson 28-Apr-2009 [1883] | Hi, I have continued to re-read the documentation for REBOL, and appreciating it more as I understand a bit more. Are there any puzzels I could try to write a solution to, in REBOL, that would be good for a beginner please? |
Brock 28-Apr-2009 [1884] | There is a puzzles group, and the corresponding puzzles answers group. However, I don't believe the puzzles are easy. |
mhinson 28-Apr-2009 [1885] | It is hard for me to judge how hard a puzzle might be. I have some ideas of what I want to program for my self, but I get stuck too quick, so I need to exercise my understanding in a context where I can have a good chance of success. |
older newer | first last |