package com.delormeloic.generator.view.slidesforms;

import com.delormeloic.generator.model.slides.Background;
import com.delormeloic.generator.view.helpers.GridPaneHelper;
import com.delormeloic.generator.view.helpers.TextHelper;

import javafx.scene.Node;
import javafx.scene.control.ColorPicker;
import javafx.scene.control.Label;

/**
 * This class represents a background form.
 *
 * @author DELORME Loïc
 * @since 1.0.0
 */
public class BackgroundForm implements IFormable
{
	/**
	 * The background.
	 */
	private final Background background;

	/**
	 * Create a background form.
	 * 
	 * @param background
	 *            The background.
	 */
	public BackgroundForm(Background background)
	{
		this.background = background;
	}

	/**
	 * @see com.delormeloic.generator.view.slidesforms.IFormable#toForm()
	 */
	@Override
	public Node toForm()
	{
		final ColorPicker backgroundColorPicker = new ColorPicker();

		backgroundColorPicker.valueProperty().bindBidirectional(this.background.getBackgroundColorProperty());

		final Node[] backgroundColorField = new Node[] { new Label(TextHelper.getText("backgroundFormBackgroundColorField")), backgroundColorPicker };

		return GridPaneHelper.buildGridPane(new Node[][] { backgroundColorField });
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString()
	{
		return "Background";
	}
}
@@ -150,24 +150,27 @@
 helpers.
-GridPane
+FormBuilder
 Helper;%0A
@@ -323,21 +323,26 @@
 control.
-Label
+TitledPane
 ;%0A%0A/**%0A 
@@ -914,17 +914,16 @@
 cker();%0A
-%0A
 %09%09backgr
@@ -1028,22 +1028,26 @@
 %09%09final 
-Node%5B%5D
+TitledPane
  backgro
@@ -1058,38 +1058,35 @@
 olor
-Field = new Node%5B%5D %7B new Label
+TitledPane = new TitledPane
 (Tex
@@ -1135,15 +1135,19 @@
 olor
-Field%22)
+TitledPane%22
 ), b
@@ -1170,30 +1170,116 @@
 cker
- %7D;%0A%0A%09%09return GridPane
+);%0A%09%09backgroundColorTitledPane.setCollapsible(false);%0A%0A%09%09final TitledPane backgroundTitledPane = FormBuilder
 Help
@@ -1290,52 +1290,241 @@
 uild
-Gri
+Title
 dPane(
-new Node%5B%5D%5B%5D %7B backgroundColorField
+TextHelper.getText(%22backgroundFormBackgroundTitledPane%22), new TitledPane%5B%5D %7B backgroundColorTitledPane %7D);%0A%0A%09%09return FormBuilderHelper.buildTitledPane(TextHelper.getText(%22dataForm%22), new TitledPane%5B%5D %7B backgroundTitledPane
  %7D);

improve visual layout by using titled pane instead of gridpane