Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Aug 13 2016 03:24
    @PeterWAWood banned @Vexercizer
Boleslav Březovský
@rebolek
@pekr I will, but it needs some improvements still, it is less than two hours old code, give it some time ;)
@dockimbel cool!
mikeparr
@mikeparr
I have created a base, and drawn a line on it. I want to add another line to the base (say on a button-click) but preserve the first line. Do I have to save the previous draws in a block and redraw them all, or is there a setting? Not asking for code - I know how to do it. (Sorry if this is an obvious answer!)
Boleslav Březovský
@rebolek
@mikeparr you can append to draw block
You did not want code, but here it is anyway ;)
 view [b: base 100x100 draw [] button "add line" [append b/draw compose [line (random 100x100) (random 100x100)]]]
Petr Krenzelok
@pekr
@rebolek what a long code doing a useful thing :-)
mikeparr
@mikeparr
Thanks @rebolek - basically, the answer is yes - everything has to be re-drawn, then. The 'draw block' is all there is?
Boleslav Březovský
@rebolek
@mikeparr or you can convert draw data to image and draw on it.
 view [b: base 100x100 draw [] button "add line" [b/image: to image! b b/draw: compose [line (random 100x100) (random 100x100)]]]
Petr Krenzelok
@pekr
What is the difference here? In the second case, what is drawn already, is placed on the image (so you can't adapt it anymore) and you only add a new lines, correct?
Boleslav Březovský
@rebolek
@pekr Exactly. In the first example, you can manipulate all lines, in the second one, only the last line.
Petr Krenzelok
@pekr
I do remember Cyphre talking about some caching for Draw at the low level, but not sure how it was supposed to work at all ...
Maxim V
@maximvl
so
since we have all the input events in the view system
is it actually possible to store them and replay at will?
Nenad Rakocevic
@dockimbel
@maximvl Not yet, but it's in the todo-list for View engine (just not sure in which release it will come). Basically, you need the ability to make event! and that requires some changes in the way event! type is implemented currently (we need to move more information from the low-level OS event into the event! datatype).
Petr Krenzelok
@pekr
IIRC, some event related stuff is scheduled for the 0.6.5 Android release ....
Maxim V
@maximvl
@dockimbel great :D
GiuseppeChillemi
@GiuseppeChillemi
@rebolek Great work ! Could I help you implementation with a bounty ? Here is a 250USD bounty for you once completed with cell editing !
Just a note: it will have to support unicode as Italian Language needs special accented characters !
mikeparr
@mikeparr
@rebolek re - drawing - thanks for your input. I'm writing some notes. The official docs - reasonably enough - don't have these idioms, techniques.
Boleslav Březovský
@rebolek
@GiuseppeChillemi cool :) thanks to Red's Unicode support, you will get Italian for free ;) I've spent last hour writing down implementation notes and cell editing is on the list. Contact me privately to let me know what other requirements do you have.
Gregg Irwin
@greggirwin
Go Bolek, Go!
GiuseppeChillemi
@GiuseppeChillemi
@rebolek Mail Sent
GiuseppeChillemi
@GiuseppeChillemi
Another question, is there a way to load a picture, resize and diplay it ?
Sam Neurohack
@tmpbci
to display a picture one solution is box 630x360 %brain.jpg
Nenad Rakocevic
@dockimbel
@GiuseppeChillemi @greggirwin Gregg's image resizing demo is also on red/code (with many other examples): https://github.com/red/code/blob/master/Scripts/resize-image.red
luce80
@luce80
@GiuseppeChillemi here is a reacting version: https://gist.github.com/luce80/e34516e5248b629badfd4016dda6cbb8
Rebol2Red
@Rebol2Red

@luce80

*** Script Error: n1 has no value
*** Where: get
*** Stack: view layout react

What are the values for n1 and n2?

Rebol2Red
@Rebol2Red

My previous post did not work after copying and pasting into the console so i deleted it. This version does.

After selecting an item from a text-list i want to delete it from the list.

thedata: ["a" "b" "c"]
selecteditems: copy []
view [
    te: text-list data thedata [
        t: thedata/(te/selected)
        if not(none? t) [
            append selecteditems t
            thedata/(te/selected): copy ""
        ]
        l: 0
        foreach item thedata [
            if item <> "" [
                l: l + 1
            ]
        ]
        if 0 = l [unview]
    ] 
]
print selecteditems ; this order is not important

This code works but there must be a nicer better way to do this.
Note: The selected items can be chosen random.

Nenad Rakocevic
@dockimbel
@Rebol2Red Here is a simplified version:
list: ["a" "b" "c"]
collected: []

view [
    text-list data list on-down [
        append collected take at face/data face/selected
        if empty? face/data [?? collected unview]
    ]
]
Rebol2Red
@Rebol2Red
@dockimbel Much better. Thank you.
Nenad Rakocevic
@dockimbel
Some comments about your code:
  • if not(none? t) [ is equivalent to if t [ in this case.
  • thedata/(te/selected) is a bit harder to read than pick thedata te/selected or at thedata te/selected.
  • Use shorter words, use hyphen (-) when putting multiple words together as a variable name. Invest into better names, make your code read well enough in English, it will be easier to understand/maintain.
  • Avoid using I, l or O as variable names, as they can often be confused with 1 and 0.
  • Red has a rich API, most of simple actions you need on built-in datatypes are probably covered already. Take some time to study the existing functions (use what from the console and the Rebol/Core manual).
Rebol2Red
@Rebol2Red
@dockimbel Thanks for your comments. I appreciate this a lot! I did study the functions but i do'nt have taken the Red pill after many years of programming in c, basic and many other languages.
Nenad Rakocevic
@dockimbel
@Rebol2Red In such case, I really recommend you reading the Rebol/Core manual, from cover to cover, with a Rebol console opened to copy/paste and play with the examples. That's the best way, for now, to dive into those concepts.
Here is an even more concise version:
list: ["a" "b" "c"]

probe collect [
    view [
        text-list data list on-down [
            keep take at face/data face/selected
            if empty? face/data [unview]
        ]
    ]
]
Rebol2Red
@Rebol2Red
@dockimbel Maybe i am good at providing poor code to learn others and myself to learn how to do it the right way. I have a lot of it :)
Nenad Rakocevic
@dockimbel
Submitting code for improvement by the community is a good way to learn. Though, it should not replace reading in depth the existing docs. Also, asking the community questions about some language concepts or constructs is also very useful. Back in the early days in the Rebol community, we only had the mailing-list for that, and it was very helpful for everyone to ask questions and submit code. Nowadays, we have sophisticated realtime chats and online collaborative tools, so don't be shy. ;-)
Rebol2Red
@Rebol2Red
@dockimbel So expect a lot from me. I'm just kidding. Back to programming :)
Rebol2Red
@Rebol2Red
One more question. How do i get the selected item? Looks simple but
not to me.
list: ["a" "b" "c"]
print collect [
    view [
        text-list data list on-down [

            ; I need the selected item to 
            ; store it into another text-list

            keep take at face/data face/selected
            if empty? face/data [unview]
        ]
    ]
]
Rebol2Red
@Rebol2Red

Wrong:

list: ["a" "b" "c"]
selected: copy []
print collect [
    view [
        text-list data list on-down [
            append selected keep take at face/data face/selected
        ]
        text-list data selected
    ]
]

If i click on "b" i get "a" into the other text-list

Rebol2Red
@Rebol2Red
@dockimbel Also on the concise code you gave me this happens.
For example if i click on "b" it removes "a"
Nenad Rakocevic
@dockimbel
@Rebol2Red Right, I should have used event/picked rather than face/selected. Though, the mouse events seem to not fill event/picked, so that we need to change the event type and add some extra code to ensure that the text-list's selection does not interfere:
list: ["a" "b" "c"]

probe collect [
    view [
        text-list data list 
            on-change [face/selected: none]
            on-select [
                keep take at face/data probe event/picked
                if empty? face/data [unview]

        ]
    ]
]
Rebol2Red
@Rebol2Red
@dockimbel Thanks, now i have a nice way to select items!
Nenad Rakocevic
@dockimbel
@Rebol2Red Selecting items is much simpler than that. The above code is for selecting, removing selected items , and storing them in another list.
I've opened a ticket for the mouse events on text-list, to see if we can improve it.
luce80
@luce80
@Rebol2Red About n1 and n2 of my code: did you just copy-pasted only the piece of code shown by gitter ? If so try to go to the link and copy-paste all the text.
Rebol2Red
@Rebol2Red
@luce80 Yes, i did only copy-pasted. I now have all the text. Thanks.
Rebol2Red
@Rebol2Red
@dockimbel Now i have to find a way to keep the second text-list sorted. A pity "text-list data sort selected" does not work. Any suggestion?
Why did you use probe event/picked not leaving probe out?