Is there a way to set the bg color for an InsetPane? I couldn't find it.
The bg color should be used as the color of the insets (similar to BorderPane, which I am using now with a zero pixel border to achieve the desired effect).
andyWed 24 Nov 2010
BorderPane is the right widget there - I do that all over the place in my code.
HenriWed 24 Nov 2010
OK, but do we then still need InsetPane anymore?
Talking about BorderPane, would it not be simpler to add border, insets and bg properties directly to EdgePane, GridPane, Tree, etc. (or perhaps even Widget), and remove BorderPane entirely? It is designed as a decorator, but at the cost of (many) extra layers in the component tree. I need borders and/or insets so often that decoration becomes a chore.
So you would get:
EdgePane
{
border = Border("#ddf")
insets = Insets(2)
bg = Color.white
top = ...
center = ...
}
I've considered that as well - its nice to have since it takes insets in the ctor - but does overlap BorderPane - not sure I have a strong opinion there.
Talking about BorderPane, would it not be simpler to add border, insets and bg properties directly to EdgePane, GridPane, Tree, etc.
I think we have the right model today. Each Widget is designed to do a specific task really well. It keeps implementations really simple, and composition simple as well IMO. Also, BorderPane is just one way to decorate a Widget, so we wouldn't want to dictate that at such a low level.
HenriWed 24 Nov 2010
Thanks for considering Andy, no problem. I think I'll create some simple BorderPane forwarding subclasses like BorderedEdgePane, BorderedGridPane and BorderedTree to get the effect I was looking for. See how that works out.
HenriFri 26 Nov 2010
BorderPane.content is not virtual, so this doesn't work very well either.
andyFri 26 Nov 2010
Thats just a field (see ContentPane.content). Typically you would do all your custom work in prefSize and onLayout. What exactly are you trying to do?
HenriFri 26 Nov 2010
For convenience I am trying to build a reusable component that is an EdgePane wrapped in a BorderPane. The EdgePane has a title label in a header (at EdgePane.top). And I would like to use content in the component's API to map to the EdgePane's center. It's just a little façade.
So I would have something like this (simplified):
class MyStandardPanel : BorderPane
{
private EdgePane innerEdgePane := EdgePane
{
top = Label()
bottom = Label()
}
...
Widget? content
{
get { innerEdgePane.center }
set { innerEdgePane.center = it }
}
Str title
{
get { innerEdgePane.top->text }
set { innerEdgePane.top->text = it }
}
new make()
{
border = ...
insets = ...
bg = ...
content = innerEdgePane
}
...
}
This way I don't have to implement prefSize or onLayout. But since BorderPane.content isn't virtual, I need to use a different field name (such as center). It's no big deal, though.
I would expect decorator classes like BorderPane to be a bit more open for extension, but maybe the fact that it has to work with a native peer, which I suppose requires some careful coordination between the two, puts limitations on the extendibility of the class.
Henri Wed 24 Nov 2010
Is there a way to set the
bg
color for anInsetPane
? I couldn't find it.The
bg
color should be used as the color of the insets (similar toBorderPane
, which I am using now with a zero pixel border to achieve the desired effect).andy Wed 24 Nov 2010
BorderPane
is the right widget there - I do that all over the place in my code.Henri Wed 24 Nov 2010
OK, but do we then still need
InsetPane
anymore?Talking about
BorderPane
, would it not be simpler to addborder
,insets
andbg
properties directly toEdgePane
,GridPane
,Tree
, etc. (or perhaps evenWidget
), and removeBorderPane
entirely? It is designed as a decorator, but at the cost of (many) extra layers in the component tree. I need borders and/or insets so often that decoration becomes a chore.So you would get:
Instead of:
andy Wed 24 Nov 2010
I've considered that as well - its nice to have since it takes insets in the ctor - but does overlap BorderPane - not sure I have a strong opinion there.
I think we have the right model today. Each Widget is designed to do a specific task really well. It keeps implementations really simple, and composition simple as well IMO. Also, BorderPane is just one way to decorate a Widget, so we wouldn't want to dictate that at such a low level.
Henri Wed 24 Nov 2010
Thanks for considering Andy, no problem. I think I'll create some simple
BorderPane
forwarding subclasses likeBorderedEdgePane
,BorderedGridPane
andBorderedTree
to get the effect I was looking for. See how that works out.Henri Fri 26 Nov 2010
BorderPane.content
is not virtual, so this doesn't work very well either.andy Fri 26 Nov 2010
Thats just a field (see
ContentPane.content
). Typically you would do all your custom work inprefSize
andonLayout
. What exactly are you trying to do?Henri Fri 26 Nov 2010
For convenience I am trying to build a reusable component that is an
EdgePane
wrapped in aBorderPane
. TheEdgePane
has a title label in a header (at EdgePane.top). And I would like to usecontent
in the component's API to map to theEdgePane
'scenter
. It's just a little façade.So I would have something like this (simplified):
This way I don't have to implement
prefSize
oronLayout
. But sinceBorderPane.content
isn't virtual, I need to use a different field name (such ascenter
). It's no big deal, though.I would expect decorator classes like
BorderPane
to be a bit more open for extension, but maybe the fact that it has to work with a native peer, which I suppose requires some careful coordination between the two, puts limitations on the extendibility of the class.