Gabriel95 / scalafx

Automatically exported from code.google.com/p/scalafx
Other
0 stars 0 forks source link

TextField does not expose JFX `alignment` property #22

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The `alignment` property in SFX TextField is a pseudo-property, it cannot be 
used to align text within the text field.

JavaFX TextField has `alignment` property but it is not exposed, can be only 
accessed directly referencing the delegate. So to, for instance, center a text 
you end up with something like this:

new TextField {
  text = "Correctly aligned text"
  prefColumnCount = 30
  delegate.setAlignment(Pos.CENTER)
}

SFX text field need to have property, say, `innerAlignment` that exposes JFX  
`alignment` property.

Even better the "pseudo-properties" like `alignment` should be renamed to 
something else, say `externalAlignment` that does not conflict with JFX names, 
and JFX TextField `alignment` should be exposed as SFX TextField `alignment`.

Original issue reported on code.google.com by jpsacha on 9 Jan 2013 at 10:04

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by Alain.Fa...@gmail.com on 16 Jan 2013 at 1:12

GoogleCodeExporter commented 8 years ago
The follow JavaFX Classes presents a "alignment" property: Labeled, TextField, 
FlowPane, GridPane, HBox, StackPane, TilePane and VBox. We could create a 
AlignDelegate trait in delegate package. 

package scalafx.delegate

import DimensionDelegate._
import javafx.beans.{ property => jfxbp }
import javafx.{geometry => jfxg }
import scalafx.Includes._
import scalafx.geometry._

object AlignDelegate {

  /**
   * Types that contains `height` and `width` properties.
   */
  type Aligned = {

    def alignmentProperty(): jfxg.Pos
  }
}

trait AlignDelegate[J <: Object with Aligned]
  extends SFXDelegate[J] {

  def align = delegate.alignmentProperty
  def align_=(p: Pos) {
    align() = p
  }

} 

I agree with Jarek that to give a new name to `alignment` Node's 
pseudo-properties would be the best to do. However, before this, I think that 
it is necessary ask in dev or users list if someone is using this 
pseudo-property to avoid conflicts.

Thanks,

Rafael Afonso

Original comment by rafael.a...@gmail.com on 19 Jan 2013 at 12:49

GoogleCodeExporter commented 8 years ago
Now I saw that ScalaFX layouts (FlowPane, GridPane, HBox, StackPane, TilePane 
and VBox) have a innerAlignment getter/setters that calls their respective 
alignment property. This name was adopted excatly to avoid conflicts with 
alignment Nodes's proerty (e.g. see 
http://code.google.com/p/scalafx/source/browse/scalafx-core/src/main/scala/scala
fx/scene/layout/HBox.scala#88). I think that the best to do, as it was written 
above, is rename aligment's Node to other name (such as externalAlignment) and 
rename innerAlignment to alignment (may be using AlignDelegte trait). Again, it 
will necessary verify impact of this modification over code already written.

Original comment by rafael.a...@gmail.com on 19 Jan 2013 at 6:31

GoogleCodeExporter commented 8 years ago
In my clone (http://code.google.com/r/rafaelafonso-scalafx/), I created a 
branch 'alignment' 
(http://code.google.com/r/rafaelafonso-scalafx/source/browse/?name=alignment) 
where I created a AlignmentDelegate 
(http://code.google.com/r/rafaelafonso-scalafx/source/browse/scalafx-core/src/ma
in/scala/scalafx/delegate/AlignmentDelegate.scala?spec=svn3fdbec2801ed7d79a18f15
9efcb98dbfe8370fbb&name=alignment&r=3fdbec2801ed7d79a18f159efcb98dbfe8370fbb) 
and changed classes mentioned above. 
In Layout classes there was there was a getter and setter for "innerAlignment" 
that basically wraps alignmentProperty from their original classes (see 
http://code.google.com/r/rafaelafonso-scalafx/source/detail?r=3fdbec2801ed7d79a1
8f159efcb98dbfe8370fbb&name=alignment as example). I isolated these methods and 
moved them to AlignmentDelegate . 
My question is if we'll "alignment" pseudo-property in Node with this name or 
change for a more apropriated name to avoid confusion and rename 
"innerAlignment" from AlignmentDelegate to "alignment".

Original comment by rafael.a...@gmail.com on 22 Jan 2013 at 12:35

GoogleCodeExporter commented 8 years ago
In my 'alignment' 
(http://code.google.com/r/rafaelafonso-scalafx/source/browse/?name=alignment), 
Node's alignment pseudo-property was renamed to alignmentInParent 
(http://code.google.com/r/rafaelafonso-scalafx/source/detail?r=3ffc0095acbfdacb6
ab7f2295dd3ea8f6cacdd5d&name=alignment). Later, AlignmentDelegate's alignment 
property renamed to alignment 
(http://code.google.com/r/rafaelafonso-scalafx/source/detail?name=alignment&r=e3
433f5738db2229b426d7cedc130a9efd384da6) according with solicitations 
(https://groups.google.com/forum/?fromgroups=#!topic/scalafx-dev/JzL0SuzCoRU). 
Later, 'alignment' branch will be merged with default branch.

Original comment by rafael.a...@gmail.com on 26 Jan 2013 at 12:49

GoogleCodeExporter commented 8 years ago
Changes merged with default branch in main repository. See 
http://code.google.com/p/scalafx/source/detail?r=33dcc6dc7eae662792efcc312af5f3a
5082ed6c9

Original comment by rafael.a...@gmail.com on 2 Feb 2013 at 11:38