r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[View] discuss view related issues

amacleod
3-Jul-2007
[7051]
Anton, I'm populating it with some text fields, and a few drop-downs. 
If the drop-down is too close to  the bottom of the panel it will 
not display below and outside the panel even though the app window 
goes a bit lower. As I said before, if there is nothing else in hte 
tab panel except for the drop-down, the drop down gets cut off even 
if there is plenty of room below within hte tab panel. I need to 
fill it withsomething. My solution is a box of the same size as the 
panel but then I need to use "at" for all my other elemnts to place 
themk properly.
Ashley
5-Jul-2007
[7052]
Anyone come up with a nifty way to get the size of vectorial text? 
Something like size-text:

	size-svg-text draw 1000x1000 [text vectorial "Hi"]
Ashley
6-Jul-2007
[7053]
QAD first cut:


size-svg-text: make function! [text [string!] font [object!] /local 
img size i] [

 img: draw size: 200x200 compose [font (font) text vectorial (text)]
	;	determine y
	i: length? img
	while [zero? img/:i] [i: i - 1]
	size/y: i / size/y + 1
	;	determine x
	i: mod i size/x				; x offset of last match
	repeat y size/y [			; scan each line

  repeat x size/x - i [	; start each line scan at point of last match
			unless zero? pick img (y - 1 * size/y) + i + x [
				i: i + x
			]
		]
	]
	size/x: i
	size
]

size-svg-text "Hello World!" make face/font [size: 24]
Anton
6-Jul-2007
[7054]
Ashley, it depends what you want to do.

If you aren't going to transform the text in crazy ways (or maybe 
even if you are), then I would create a "sizing-face" with the same 
text and font, then use just size-text on it. It's going to be faster 
than scanning every pixel.
Henrik
6-Jul-2007
[7055]
kerning is not identical for View text and DRAW text, so you can 
only approximate the size.
Anton
6-Jul-2007
[7056x3]
Yes, there are limitations.
But, you can be pretty precise if you don't use all parameters of 
para object (and font object ?)
Oh hang on, we're talking vectorial text. I don't think I've experimented 
much with that.
Pekr
8-Jul-2007
[7059]
How do I do following?

copy-screen: center-face layout [screen code here]


forever [ if new disk is found .... start screen, call copy routine]


And now I have a problem - if I do view copy-screen, call of copy 
routine is not performed. So I tried to put the copy routine into 
do [call copy routine] into the layout code, but those variables 
are not known yet ...


I would like to have some "delayed" run of 'do section. (view/new 
and do-events is not possible, as my copy routine is recursive and 
do-events would be callled multiple-times. Is there any trick? Timer 
probably? Well, but trouble is, that script sits in the background, 
and copy screen should apper only if new disk with appropriate content 
is found, then it should disapper and go to wait mode into background 
....
Graham
8-Jul-2007
[7060]
poll
Pekr
8-Jul-2007
[7061]
how?
Graham
8-Jul-2007
[7062]
open the gui only when you detect a disk present
Pekr
8-Jul-2007
[7063x3]
simply put I need following - 1) define layout 2) run main loop. 
If device detected, start screen 3) call copy function from the screen 
4) unview screen, back to main loop
I do that ...
where should I call my copy-dir function from?
Graham
8-Jul-2007
[7066x2]
your main routine
not the gui
Pekr
8-Jul-2007
[7068]
if I put it into parens or 'do block into VID, it gets called during 
layout phase ...
Graham
8-Jul-2007
[7069]
why does it have to be in vid??
Pekr
8-Jul-2007
[7070x3]
OK, so I do:

forever [
   if disk is detected [
        view/new copy-screen
        copy-dir source target
]

Now where do I put do-events?
'copy-dir is recursive, I can't start event loop there ..... I need 
to somehow start function from the copy-screen section. It is just 
that I don't want to have it assigned to button :-)
I remember that we did some timer trick in the past, but can't remember 
now ....
Graham
8-Jul-2007
[7073]
view/new copy-screen
hide copy-screen

forever [ if screen detected [ show copy-screen do-stuff hide copy-sceen 
]]
Pekr
8-Jul-2007
[7074]
so no do-events?
Graham
8-Jul-2007
[7075x4]
somewhere :)
run it in the task bar
and when you detect the disk, then bring up the main gui
I mean system tray
Pekr
8-Jul-2007
[7079]
Graham - I used one trick, I defined new style in VID, called init, 
set rate to 1and defined engage block. After first call, I removed 
timer, but it worked in a bit weird way. In my copy routine I used 
little wait, but it did not work properly ...
btiffin
8-Jul-2007
[7080]
Pekr;  did you show the face after changing the rate?  I got caught 
up by that one recently, the timer fires at old rate until show was 
called.  It is documented, but who reads those.  :)
Pekr
8-Jul-2007
[7081]
yes, I used show ...
btiffin
8-Jul-2007
[7082]
Thought so...wanted to mention it...just in case.
Pekr
8-Jul-2007
[7083x2]
but it is possible my code could be messed-up ....
I really miss delayed after-init method in VID. 'do nor parens can 
make it, as those are executed during layout evaluation, not after 
'view is called ...
Gabriele
8-Jul-2007
[7085x2]
petr, while you are busy copying, you are not handling events, so 
no do-events there. you can call wait 0 every iteration if you want 
to respond to events while copying.
delayed after init is the same as doing something AFTER view/new
btiffin
8-Jul-2007
[7087]
And just think...everything is about to change and we get a whole 
new can of worms to dig through.  The one comment Carl made about 
'hard-won knowledge' has me a litlle, umm, exitedly anxious for the 
docs.
Gabriele
8-Jul-2007
[7088]
hmm, don't see much change in a case like this, you still do the 
layout, view/no-wait it (new ref name instead of /new), and do the 
copy. maybe, you'll want to copy in a bg task, but that's another 
story.
btiffin
8-Jul-2007
[7089]
Excitedly anxious for docs...   But, take your time.  "when do we 
get it, when do we..."  :)
Pekr
8-Jul-2007
[7090x2]
Gabriele, I do following:

copy-dir: func [from to][recursive copying function here]
copy-screen: layout [layout of screen code here]

forever [ if new drive is detected and contains particular directory, 
view copy-screen, which should start copy-dir function]


.... somehow can't get it working properly. View/new can't help me 
here imo ....
Gabriele - how could I do it with view/new? I can't start copying 
after it, because I want to update screen. I can show some elements, 
but e.g. buttons will not be active, unless do-events is being run. 
That is why I complicated my script by implementing "delayed" copying 
= view copy-screen, there is an 'init style with rate 1 and engage 
defined. I check if it is a first run, and if so, I set rate to none, 
call show, and that is the place from  where I call my copy-dir function 
.....
Gabriele
8-Jul-2007
[7092x3]
petr, if copy is running, events are not processed, no matter how 
many do-events you put there
you have to do view/new, then inside copy-dir you need to call wait 
0 every now and then (eg. every file you copy) if you need your buttons 
to work.
even if you call copy-dir from engage, events are not processed while 
inside copy-dir unless you call wait
Pekr
8-Jul-2007
[7095]
ah, so wait 0 causes processing of events?
Gabriele
9-Jul-2007
[7096]
those that are pending, yes. you can wait a little more to allow 
more to be processed, if you don't care about slowing down your copy.
amacleod
9-Jul-2007
[7097]
How are you detecting the the disk being inserted. Are you accessing 
the os. Also, would this work for flash disks?
Pekr
9-Jul-2007
[7098x3]
yes, it works ...
it is very simple principle ... well, it is not even a detection. 
When my script runs in the background, it does:

root: %/
drives: read root

later on, I simply check:

forever [
  wait interval
    foreach disk difference read root drives [
    ]
]
... and difference on block will throw you new disk ....