gWidgets2 icon indicating copy to clipboard operation
gWidgets2 copied to clipboard

confusing behavior of `size <-` assignments with `expand=T` and `fill=T`

Open landroni opened this issue 10 years ago • 0 comments

This is party related to #69. I'm getting very confused (not for the first time) with how size <- assignments and expand=T and fill=T are supposed to act and interact in gWidgets2.

Consider the following:

##1st batch
w <- gwindow(visible=F)
g <- ggroup(cont=w, horizontal=FALSE, expand=TRUE, use.scrollwindow = TRUE)
pg <- gpanedgroup(cont=g, expand=T, fill=T)

tbl <- gtable(names(mtcars), cont=pg)
dg <- ggroup(cont=pg)

lyt <- glayout(cont=dg, expand=TRUE, fill=T)
lyt[1,1, expand=TRUE, fill=T] <- gframe("Row Fields", 
                                             container=lyt, expand=TRUE, fill=T)
lyt[1,2, expand=TRUE, fill=T] <- gframe("Column Fields", 
                                             container=lyt, expand=TRUE, fill=T)

visible(w) <- T

##2nd batch
svalue(pg) <- 0.25
print(size(lyt))
print(size(lyt[1,1]))

Even though I set expand=TRUE, fill=TRUE everywhere I could think of and:

> print(size(lyt))
width height 
327    278 

(1) why do I get both frames in the GUI effectively of size 0?

Then replace "2nd batch" with:

##3rd batch
size(lyt[1,1]) <- c(130, 100)
svalue(pg) <- 0.25
print(size(lyt))
print(size(lyt[1,1]))

And execute 1st and 3rd batches in one go. Notice that:

>     print(size(lyt[1,1]))
width height 
76     18 

even though visibly the frame is clearly not of size 0 in the GUI. So (2) why is the size being misreported here? (Unfortunately this makes debugging very confusing.)

Now take the same example and execute the following separately. Notice that now:

> print(size(lyt[1,1]))
width height 
134    118 

Why is the reported size different depending on when the calls are being made? And why each time the size is different from the one actually assigned: c(130, 100)?

In the example above, how can I set the height only and leave the width to be automatically set by respecting fill=TRUE? For example if I do

size(lyt[1,1])[2] <- c(100)

seems to work in setting the height to 100 pixels, but then how do I set the width of both frames to take 50% of the available space? Would it be possible to set that using size(lyt[1,1])[2] <- c(100, 0.50) as for gpanedgroup, whereas 100 is in pixels and 0.50 in proportions?

I'm sorry if this is all confusing, but it's very unclear to me how size assignments are expected to work, and for me it's very often a hit and miss approach to get the layout right.

landroni avatar Aug 03 '14 11:08 landroni