Ejemplo n.º 1
0
  public CPLayersPalette(CPCommonController controller) {
    super(controller);

    title = "Layers";

    // Widgets creation

    Image icons = controller.loadImage("smallicons.png");

    addButton = new CPIconButton(icons, 16, 16, 0, 1);
    addButton.addController(this);
    addButton.setCPActionCommand(CPCommandId.AddLayer);

    removeButton = new CPIconButton(icons, 16, 16, 1, 1);
    removeButton.addController(this);
    removeButton.setCPActionCommand(CPCommandId.RemoveLayer);

    alphaSlider = new CPAlphaSlider();

    blendCombo = new JComboBox<String>(modeNames);
    blendCombo.addActionListener(this);

    lw = new CPLayerWidget();
    renameField = new CPRenameField();
    lw.add(renameField);
    scrollPane = new JScrollPane(lw);

    cbSampleAllLayers = new JCheckBox("Sample All Layers");
    cbSampleAllLayers.setSelected(controller.artwork.isSampleAllLayers());
    cbSampleAllLayers.addItemListener(this);

    cbLockAlpha = new JCheckBox("Lock Alpha");
    cbLockAlpha.setSelected(controller.artwork.isLockAlpha());
    cbLockAlpha.addItemListener(this);

    // Layout

    // Add/Remove Layer
    Box hb = Box.createHorizontalBox();
    hb.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    hb.add(addButton);
    hb.add(Box.createRigidArea(new Dimension(5, 0)));
    hb.add(removeButton);
    hb.add(Box.createHorizontalGlue());

    // blend mode
    blendCombo.setPreferredSize(new Dimension(100, 16));

    Box hb2 = Box.createHorizontalBox();
    hb2.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    hb2.add(blendCombo);
    hb2.add(Box.createHorizontalGlue());

    // layer opacity
    alphaSlider.setPreferredSize(new Dimension(100, 16));
    alphaSlider.setMaximumSize(new Dimension(100, 16));

    Box hb3 = Box.createHorizontalBox();
    hb3.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    hb3.add(alphaSlider);
    hb3.add(Box.createRigidArea(new Dimension(0, 16)));
    hb3.add(Box.createHorizontalGlue());

    Box hb4 = Box.createHorizontalBox();
    hb4.add(cbSampleAllLayers);
    hb4.add(Box.createHorizontalGlue());

    Box hb5 = Box.createHorizontalBox();
    hb5.add(cbLockAlpha);
    hb5.add(Box.createHorizontalGlue());

    Box vb = Box.createVerticalBox();
    vb.add(hb2);
    vb.add(hb3);
    vb.add(hb4);
    vb.add(hb5);

    setLayout(new BorderLayout());
    add(scrollPane, BorderLayout.CENTER);
    add(vb, BorderLayout.PAGE_START);
    add(hb, BorderLayout.PAGE_END);

    // Set initial values
    CPArtwork artwork = controller.getArtwork();
    alphaSlider.setValue(artwork.getActiveLayer().getAlpha());

    // add listeners

    addListener();
    // validate();
    // pack();
  }
Ejemplo n.º 2
0
 public void setEnabledForTransform(boolean enabled) {
   layerMovingAndChangingCurrentEnabled = enabled;
   addButton.setEnabled(enabled);
   removeButton.setEnabled(enabled);
 }