Skip to content

Commit

Permalink
Slicer: show grid subdivisions, update to v0.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Mignari committed Jul 30, 2018
1 parent d537e6a commit 6a7ef2e
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/ObjectBuilder-app.xml
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<application xmlns="http://ns.adobe.com/air/application/25.0">
<application xmlns="http://ns.adobe.com/air/application/29.0">

<id>com.mignari.ObjectBuilder</id>
<filename>ObjectBuilder</filename>
<name>Object Builder</name>
<versionNumber>0.4.5</versionNumber>
<versionLabel>0.4.5</versionLabel>
<versionNumber>0.4.6</versionNumber>
<versionLabel>0.4.6</versionLabel>
<copyright>
<![CDATA[Copyright (c) 2014-2018 <a href="https://github.com/Mignari/ObjectBuilder/graphs/contributors">Contributors</a>]]>
</copyright>
Expand Down
32 changes: 31 additions & 1 deletion src/otlib/components/SurfaceCells.as
Expand Up @@ -23,6 +23,8 @@
package otlib.components
{
import flash.display.BlendMode;
import flash.display.CapsStyle;
import flash.display.LineScaleMode;

import mx.core.UIComponent;

Expand All @@ -37,6 +39,7 @@ package otlib.components
private var _rows:uint;
private var _cellWidth:uint;
private var _cellHeight:uint;
private var _subdivisions:Boolean;

//--------------------------------------
// Getters / Setters
Expand Down Expand Up @@ -82,6 +85,15 @@ package otlib.components
}
}

public function get subdivisions():Boolean { return _subdivisions; }
public function set subdivisions(value:Boolean):void
{
if (_subdivisions != value) {
_subdivisions = value;
invalidateDisplayList();
}
}

//--------------------------------------------------------------------------
// METHODS
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -110,12 +122,30 @@ package otlib.components
{
super.updateDisplayList(unscaledWidth, unscaledHeight);

var halfWidth:Number = _cellWidth / 2;
var halfHeight:Number = _cellHeight / 2;
var x:Number;
var y:Number;

graphics.clear();
for (var c:uint = 0; c < _columns; c++) {
for (var r:uint = 0; r < _rows; r++) {
x = c * _cellWidth;
y = r * _cellHeight;

graphics.lineStyle(0.1, 0);
graphics.beginFill(0, 0);
graphics.drawRect(c * _cellWidth, r * _cellHeight, _cellWidth, _cellHeight);
graphics.drawRect(x, y, _cellWidth, _cellHeight);

if (_subdivisions) {
graphics.endFill();
graphics.lineStyle(0.1, 0, 0.3);
graphics.moveTo(x + halfWidth, y);
graphics.lineTo(x + halfWidth, y + _cellHeight);
graphics.moveTo(x, y + halfHeight);
graphics.lineTo(x + _cellWidth, y + halfHeight);
graphics.endFill();
}
}
}
graphics.endFill();
Expand Down
14 changes: 14 additions & 0 deletions src/slicer/Slicer.mxml
Expand Up @@ -175,6 +175,7 @@ THE SOFTWARE.
_surfaceCells.cellHeight = size;
_surfaceCells.columns = columnsStepper.value;
_surfaceCells.rows = rowsStepper.value;
_surfaceCells.subdivisions = subdivisionsCheckBox.selected;
var sw:uint = (size * _surfaceCells.columns);
var sh:uint = (size * _surfaceCells.rows);
Expand Down Expand Up @@ -339,11 +340,14 @@ THE SOFTWARE.
this.maximize();
else
WindowUtil.centralizeWindowOnScreen(this);
subdivisionsCheckBox.selected = _settings.subdivisions;
}
private function saveSettings():void
{
_settings.maximized = (nativeWindow.displayState == NativeWindowDisplayState.MAXIMIZED);
_settings.subdivisions = subdivisionsCheckBox.selected;
_settingsManager.saveSettings(_settings);
}
Expand Down Expand Up @@ -521,6 +525,11 @@ THE SOFTWARE.
_surfaceCells.y = Math.round(_surfaceCells.y);
}
protected function subdivisionsCheckBoxChangeHandler(event:Event):void
{
_surfaceCells.subdivisions = subdivisionsCheckBox.selected;
}
protected function offsetStepperChangeHandler(event:Event):void
{
_surfaceCells.x = offsetXStepper.value;
Expand Down Expand Up @@ -721,6 +730,11 @@ THE SOFTWARE.
paddingBottom="10"/>
</nail:layout>

<s:CheckBox id="subdivisionsCheckBox" label="Subdivisions"
change="subdivisionsCheckBoxChangeHandler(event)"/>

<s:Spacer height="10" />

<s:TileGroup width="100%"
requestedColumnCount="2"
verticalAlign="middle">
Expand Down
1 change: 1 addition & 0 deletions src/slicer/settings/SlicerSettings.as
Expand Up @@ -37,6 +37,7 @@ package slicer.settings

public var maximized:Boolean;
public var lastDirectory:String;
public var subdivisions:Boolean;

//--------------------------------------------------------------------------
// CONSTRUCTOR
Expand Down

0 comments on commit 6a7ef2e

Please sign in to comment.