Sign up

Gtk paned + drawing area

I have a drawing area inside a paned.

When the paned is shrunk the drawing area shrinks and my drawing is properly scaled since my code is based on the width of the drawing area.

If I shrink it below, around 50 pixels I guess, then the drawing no longer shrinks and is clipped as if the drawing area has a minimum height. That is not the behavior I want.

I'm using

auto h = DA.getAllocatedHeight();

In the inspector I see it limits it to 50. In the inspecter I see something like A x B + 0 + Y for "allocation".

B gets stuck at 50 and Y becomes negative. It knows the "real height" but how do I get this? The information is there but I have no idea what

If I use getHeight it's always 50.

I can't find anything else to get the right value nor what "allocation" is in the inspector.

Re: Gtk paned + drawing area

On Tue, 04 Jun 2019 02:42:24 GMT, Alex X wrote:

I have a drawing area inside a paned.

When the paned is shrunk the drawing area shrinks and my drawing is properly scaled since my code is based on the width of the drawing area.

If I shrink it below, around 50 pixels I guess, then the drawing no longer shrinks and is clipped as if the drawing area has a minimum height. That is not the behavior I want.

I'm using

auto h = DA.getAllocatedHeight();

In the inspector I see it limits it to 50. In the inspecter I see something like A x B + 0 + Y for "allocation".

B gets stuck at 50 and Y becomes negative. It knows the "real height" but how do I get this? The information is there but I have no idea what

If I use getHeight it's always 50.

I can't find anything else to get the right value nor what "allocation" is in the inspector.

If I get the size of the parent it works... but I still get strange issues. Seems that the paned's "2nd half" always shows and when the size get to small(< 50) it will split the size between the two parts.

A

B

If A+B is large enough but not too large then only A will be shown, If A+B is too small or too large then both A and B are shown. I'm ok when it is too large as it does what I want(show both A and B) but when it is too small I want it to only show A. B is a scrolled window and so maybe that is causing the problem... I'll have to explore a bit more.

Re: Gtk paned + drawing area

On Tue, 04 Jun 2019 03:31:42 GMT, Alex X wrote:

On Tue, 04 Jun 2019 02:42:24 GMT, Alex X wrote:

I have a drawing area inside a paned.

When the paned is shrunk the drawing area shrinks and my drawing is properly scaled since my code is based on the width of the drawing area.

If I shrink it below, around 50 pixels I guess, then the drawing no longer shrinks and is clipped as if the drawing area has a minimum height. That is not the behavior I want.

I'm using

auto h = DA.getAllocatedHeight();

In the inspector I see it limits it to 50. In the inspecter I see something like A x B + 0 + Y for "allocation".

B gets stuck at 50 and Y becomes negative. It knows the "real height" but how do I get this? The information is there but I have no idea what

If I use getHeight it's always 50.

I can't find anything else to get the right value nor what "allocation" is in the inspector.

If I get the size of the parent it works... but I still get strange issues. Seems that the paned's "2nd half" always shows and when the size get to small(< 50) it will split the size between the two parts.

[------]
A
[------]
B
[------]

If A+B is large enough but not too large then only A will be shown, If A+B is too small or too large then both A and B are shown. I'm ok when it is too large as it does what I want(show both A and B) but when it is too small I want it to only show A. B is a scrolled window and so maybe that is causing the problem... I'll have to explore a bit more.

If I remove the 2nd element then everything works. So either this is how expander lays things out or it has to do with the 2nd element itself.

Re: Gtk paned + drawing area

What I believe is the problem is that I'm using a 3-box in a paned and the 3rd box is not allowed to reduce it's height to 0 which is what I need so it does not effect the others when the height is too small.(essentially the other boxes need to "rob" the 3rd one of it's height).

Any time I add any widget it seems to get a min height value of around 20 or 30 and will never reduce beyond that. In fact, I want the height to be infinite but visually it will never effect the height of the other boxes.

I guess I will have to some how programmatically make this work out or figure out some combination of widgets that might allow it to work?

[ Paned
[ Box 1]
[ Box 2]
[ Box 3]
]

Box 3 should have infinite virtual height but show 0 height for the other box heights.

Re: Gtk paned + drawing area

On 04-06-2019 06:14, Alex X wrote:

What I believe is the problem is that I'm using a 3-box in a paned and the 3rd box is not allowed to reduce it's height to 0 which is what I need so it does not effect the others when the height is too small.(essentially the other boxes need to "rob" the 3rd one of it's height).

Any time I add any widget it seems to get a min height value of around 20 or 30 and will never reduce beyond that. In fact, I want the height to be infinite but visually it will never effect the height of the other boxes.

I guess I will have to some how programmatically make this work out or figure out some combination of widgets that might allow it to work?

[ Paned
[ Box 1]
[ Box 2]
[ Box 3]
]

Box 3 should have infinite virtual height but show 0 height for the other box heights.

I'm not entirely sure if i am following you.

But what happens when you set the shrink child property of the Box to
true?

paned.childSetProperty(box, "shrink", new Value(true));

Re: Gtk paned + drawing area

On Tue, 4 Jun 2019 19:59:13 +0200, Mike Wey wrote:

On 04-06-2019 06:14, Alex X wrote:

What I believe is the problem is that I'm using a 3-box in a paned and the 3rd box is not allowed to reduce it's height to 0 which is what I need so it does not effect the others when the height is too small.(essentially the other boxes need to "rob" the 3rd one of it's height).

Any time I add any widget it seems to get a min height value of around 20 or 30 and will never reduce beyond that. In fact, I want the height to be infinite but visually it will never effect the height of the other boxes.

I guess I will have to some how programmatically make this work out or figure out some combination of widgets that might allow it to work?

[ Paned
[ Box 1]
[ Box 2]
[ Box 3]
]

Box 3 should have infinite virtual height but show 0 height for the other box heights.

I'm not entirely sure if i am following you.

But what happens when you set the shrink child property of the Box to
true?

paned.childSetProperty(box, "shrink", new Value(true));

Unfortunately it does not work ;/

With a paned it crashes, if I use the parent box it does not crash but seems to have no effect. Does every child of of the one I want to shrink need to have the property set?

I simply have a gtkBox, 3 rows. The first row is fixed in size, the second row's size should vary from 0 to 100 depending on how much space. Last last row should take up any remaining space.

the gtkBox can grow in size over all set by the user.
It's sort of like a drop down box.

It fact, it really has nothing to do with a paned, I suppose. That is a top level container that lets me size the boxes.

It's simply that I have a 3-Box and the 3rd row should shrink down to 0 before the two top boxes are shrunk.

It's also can be thought of as a 2-box.

[[[Row 1]]]
[[[Row 2]]]

Row 1's height can vary. Row 2's height can vary. The overall box containing these will change based on the outside. It's height is H.

The height is split up between row 1 and row 2.

Min max of row 1 is 0 and 100, min max of row 2 is 0 and infinity(or screen height)

I always want row 1 to dominant row 2. If H <= 100 then row 1 is only shown and row 2 is completely hidden. If H > 100, say, 110 then row 2's height is 10, if H = 300 then row 2's height is 300-100 = 200.

If H = 30, row 1's height is 30, row 2's height is 0.

the formulas would be

row1Height = min(100, max(0, H))
row2Height = max(0, H - row1Height)

e.g., if H = 200 then

row1Height = min(100, max(0, 200)) = 100
row2Height = max(0, H - row1Height) = 100

And they are split evenly,

but if H = 100, then

row1Height = min(100, max(0, H)) = 100
row2Height = max(0, H - row1Height) = 0

But what is happening is that when H <= 100, the height is split evenly, which I don't want.

I end up with

row1Height = 50
row2Height = 50

and row1height + row2Height = H.

That is the default algorithm, I suppose, equally distributing the height among the children but it is not what I want. I'm not sure how to get it to work.

Re: Gtk paned + drawing area

On 04-06-2019 23:59, Alex X wrote:

On Tue, 4 Jun 2019 19:59:13 +0200, Mike Wey wrote:

I'm not entirely sure if i am following you.

But what happens when you set the shrink child property of the Box to
true?

paned.childSetProperty(box, "shrink", new Value(true));

Unfortunately it does not work ;/

With a paned it crashes, if I use the parent box it does not crash but seems to have no effect. Does every child of of the one I want to shrink need to have the property set?

This would be the same as passing the value when calling packStart.

I simply have a gtkBox, 3 rows. The first row is fixed in size, the second row's size should vary from 0 to 100 depending on how much space. Last last row should take up any remaining space.

the gtkBox can grow in size over all set by the user.
It's sort of like a drop down box.

It fact, it really has nothing to do with a paned, I suppose. That is a top level container that lets me size the boxes.

It's simply that I have a 3-Box and the 3rd row should shrink down to 0 before the two top boxes are shrunk.

It's also can be thought of as a 2-box.

[[[Row 1]]]
[[[Row 2]]]

Row 1's height can vary. Row 2's height can vary. The overall box containing these will change based on the outside. It's height is H.

The height is split up between row 1 and row 2.

Min max of row 1 is 0 and 100, min max of row 2 is 0 and infinity(or screen height)

I always want row 1 to dominant row 2. If H <= 100 then row 1 is only shown and row 2 is completely hidden. If H > 100, say, 110 then row 2's height is 10, if H = 300 then row 2's height is 300-100 = 200.

If H = 30, row 1's height is 30, row 2's height is 0.

the formulas would be

row1Height = min(100, max(0, H))
row2Height = max(0, H - row1Height)

e.g., if H = 200 then

row1Height = min(100, max(0, 200)) = 100
row2Height = max(0, H - row1Height) = 100

And they are split evenly,

but if H = 100, then

row1Height = min(100, max(0, H)) = 100
row2Height = max(0, H - row1Height) = 0

But what is happening is that when H <= 100, the height is split evenly, which I don't want.

I end up with

row1Height = 50
row2Height = 50

and row1height + row2Height = H.

That is the default algorithm, I suppose, equally distributing the height among the children but it is not what I want. I'm not sure how to get it to work.

I see what you are trying to do, no solution yet though.

Re: Gtk paned + drawing area

On Wed, 5 Jun 2019 22:47:49 +0200, Mike Wey wrote:

On 04-06-2019 23:59, Alex X wrote:

On Tue, 4 Jun 2019 19:59:13 +0200, Mike Wey wrote:

I'm not entirely sure if i am following you.

But what happens when you set the shrink child property of the Box to
true?

paned.childSetProperty(box, "shrink", new Value(true));

Unfortunately it does not work ;/

With a paned it crashes, if I use the parent box it does not crash but seems to have no effect. Does every child of of the one I want to shrink need to have the property set?

This would be the same as passing the value when calling packStart.

I simply have a gtkBox, 3 rows. The first row is fixed in size, the second row's size should vary from 0 to 100 depending on how much space. Last last row should take up any remaining space.

the gtkBox can grow in size over all set by the user.
It's sort of like a drop down box.

It fact, it really has nothing to do with a paned, I suppose. That is a top level container that lets me size the boxes.

It's simply that I have a 3-Box and the 3rd row should shrink down to 0 before the two top boxes are shrunk.

It's also can be thought of as a 2-box.

[[[Row 1]]]
[[[Row 2]]]

Row 1's height can vary. Row 2's height can vary. The overall box containing these will change based on the outside. It's height is H.

The height is split up between row 1 and row 2.

Min max of row 1 is 0 and 100, min max of row 2 is 0 and infinity(or screen height)

I always want row 1 to dominant row 2. If H <= 100 then row 1 is only shown and row 2 is completely hidden. If H > 100, say, 110 then row 2's height is 10, if H = 300 then row 2's height is 300-100 = 200.

If H = 30, row 1's height is 30, row 2's height is 0.

the formulas would be

row1Height = min(100, max(0, H))
row2Height = max(0, H - row1Height)

e.g., if H = 200 then

row1Height = min(100, max(0, 200)) = 100
row2Height = max(0, H - row1Height) = 100

And they are split evenly,

but if H = 100, then

row1Height = min(100, max(0, H)) = 100
row2Height = max(0, H - row1Height) = 0

But what is happening is that when H <= 100, the height is split evenly, which I don't want.

I end up with

row1Height = 50
row2Height = 50

and row1height + row2Height = H.

That is the default algorithm, I suppose, equally distributing the height among the children but it is not what I want. I'm not sure how to get it to work.

I see what you are trying to do, no solution yet though.

Is there any way to modify the way the children are arranged in a box without creating an entirely new class?

Or, is there a away to create a derived class easily?

e.g.,

class NewBox : Box
{
Box OldBox;
override arranger....

this(Box box) { OldBox = box; }

// Dispatches everything to old box except arranger
Wrap!(Box, OldBox);
}

oldBox = new NewBox(box);

The idea is to just modify the behavior we want for the box and let everything else get dispatched back to the original.

Re: Gtk paned + drawing area

On 06-06-2019 02:33, Alex X wrote:

On Wed, 5 Jun 2019 22:47:49 +0200, Mike Wey wrote:

On 04-06-2019 23:59, Alex X wrote:

On Tue, 4 Jun 2019 19:59:13 +0200, Mike Wey wrote:

I'm not entirely sure if i am following you.

But what happens when you set the shrink child property of the Box to
true?

paned.childSetProperty(box, "shrink", new Value(true));

Unfortunately it does not work ;/

With a paned it crashes, if I use the parent box it does not crash but seems to have no effect. Does every child of of the one I want to shrink need to have the property set?

This would be the same as passing the value when calling packStart.

I simply have a gtkBox, 3 rows. The first row is fixed in size, the second row's size should vary from 0 to 100 depending on how much space. Last last row should take up any remaining space.

the gtkBox can grow in size over all set by the user.
It's sort of like a drop down box.

It fact, it really has nothing to do with a paned, I suppose. That is a top level container that lets me size the boxes.

It's simply that I have a 3-Box and the 3rd row should shrink down to 0 before the two top boxes are shrunk.

It's also can be thought of as a 2-box.

[[[Row 1]]]
[[[Row 2]]]

Row 1's height can vary. Row 2's height can vary. The overall box containing these will change based on the outside. It's height is H.

The height is split up between row 1 and row 2.

Min max of row 1 is 0 and 100, min max of row 2 is 0 and infinity(or screen height)

I always want row 1 to dominant row 2. If H <= 100 then row 1 is only shown and row 2 is completely hidden. If H > 100, say, 110 then row 2's height is 10, if H = 300 then row 2's height is 300-100 = 200.

If H = 30, row 1's height is 30, row 2's height is 0.

the formulas would be

row1Height = min(100, max(0, H))
row2Height = max(0, H - row1Height)

e.g., if H = 200 then

row1Height = min(100, max(0, 200)) = 100
row2Height = max(0, H - row1Height) = 100

And they are split evenly,

but if H = 100, then

row1Height = min(100, max(0, H)) = 100
row2Height = max(0, H - row1Height) = 0

But what is happening is that when H <= 100, the height is split evenly, which I don't want.

I end up with

row1Height = 50
row2Height = 50

and row1height + row2Height = H.

That is the default algorithm, I suppose, equally distributing the height among the children but it is not what I want. I'm not sure how to get it to work.

I see what you are trying to do, no solution yet though.

Is there any way to modify the way the children are arranged in a box without creating an entirely new class?

Or, is there a away to create a derived class easily?

e.g.,

class NewBox : Box
{

Box OldBox;
override arranger....

this(Box box) { OldBox = box; }

// Dispatches everything to old box except arranger
Wrap!(Box, OldBox);

}

oldBox = new NewBox(box);

The idea is to just modify the behavior we want for the box and let everything else get dispatched back to the original.

while gtkd.Implement.ImplementClass would allow you to do just that, i
believe the function that determines the size isn't virtual.