-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42742dd
commit e4de320
Showing
46 changed files
with
1,182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0"?> | ||
|
||
<project name="DisplayModeIcons" default="dist" basedir="."> | ||
|
||
<!-- set global properties for this build --> | ||
<property name="aoilocation" value=".." /> | ||
<property name="src" value="./src" /> | ||
<property name="build" value="./build" /> | ||
<property name="docs" value="./docs" /> | ||
<property name="dist" value="${aoilocation}/Plugins" /> | ||
<property name="aoijar" value="${aoilocation}/ArtOfIllusion.jar" /> | ||
|
||
<target name="init"> | ||
<!-- Create the time stamp --> | ||
<tstamp/> | ||
<!-- Create the build directory structure used by compile --> | ||
<mkdir dir="${build}" /> | ||
<!-- Create the docs directory structure used by documentation --> | ||
<mkdir dir="${docs}" /> | ||
</target> | ||
|
||
<target name="compile" depends="init"> | ||
<!-- Compile the java code from ${src} into ${build} --> | ||
<javac source="1.6" target="1.6" srcdir="${src}" destdir="${build}" classpath="${aoijar}:${mtjjar}" debug="on" extdirs="" includeantruntime="false"/> | ||
</target> | ||
|
||
<target name="dist" depends="compile"> | ||
<!-- Copy all necessary files into ${build}, then create the jar file --> | ||
<copy file="${src}/extensions.xml" todir="${build}" /> | ||
<copy todir="${build}"> | ||
<fileset dir="${src}" includes="**/*.properties" /> | ||
</copy> | ||
<copy todir="${build}/displaymodeicons"> | ||
<fileset dir="${src}/artofillusion/displaymodeicons/Icons" /> | ||
</copy> | ||
<jar jarfile="${dist}/DisplayModeIcons.jar" basedir="${build}" /> | ||
</target> | ||
|
||
<target name="docs" depends="init"> | ||
<javadoc packagenames="artofillusion.*" | ||
sourcepath="${src}" | ||
classpath="${aoijar}" | ||
defaultexcludes="yes" | ||
destdir="${docs}" | ||
author="true" | ||
version="true" | ||
use="true" | ||
windowtitle="Display Mode Icons Documentation" | ||
public="true"> | ||
<doctitle><![CDATA[<h1>Display Mode Icons</h1>]]></doctitle> | ||
<bottom><![CDATA[<i>Copyright © 2007 by Francois Guillet. Copyright © 2015-2023 by Petri Ihalainen.</i>]]></bottom> | ||
</javadoc> | ||
</target> | ||
|
||
<target name="clean"> | ||
<!-- Delete the ${build} and ${docs} directory trees --> | ||
<delete dir="${build}" /> | ||
<delete dir="${docs}" /> | ||
</target> | ||
</project> | ||
|
96 changes: 96 additions & 0 deletions
96
src/artofillusion/displaymodeicons/AlignToAxesControl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright (C) 2019 - 2023 Petri Ihalainen | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 2 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
*/ | ||
|
||
package artofillusion.displaymodeicons; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Insets; | ||
|
||
import buoy.event.*; | ||
import buoy.widget.*; | ||
import artofillusion.ViewerCanvas; | ||
import artofillusion.math.*; | ||
import artofillusion.ui.*; | ||
import artofillusion.view.*; | ||
|
||
public class AlignToAxesControl implements ViewerControl | ||
{ | ||
public Widget createWidget(ViewerCanvas view) | ||
{ | ||
return new AlignToAxesControlWidget(view); | ||
} | ||
|
||
public String getName() | ||
{ | ||
return ("Align with axes button"); | ||
} | ||
|
||
public class AlignToAxesControlWidget extends RowContainer | ||
{ | ||
private ViewerCanvas view; | ||
private Vec3 up, fw; | ||
private short upZeros, fwZeros; | ||
private BLabel buttonLabel = new BLabel(ThemeManager.getIcon("displaymodeicons:align")); | ||
public AlignToAxesControlWidget(ViewerCanvas view) | ||
{ | ||
super(); | ||
this.view = view; | ||
buttonLabel.addEventLink(MouseReleasedEvent.class, this, "buttonPressed"); | ||
buttonLabel.addEventLink(ToolTipEvent.class, this, "showToolTip"); | ||
view.addEventLink(ViewChangedEvent.class, this, "viewChanged"); | ||
setDefaultLayout(new LayoutInfo(LayoutInfo.CENTER, LayoutInfo.NONE, new Insets(0, 0, 0, 0), new Dimension(0,0))); | ||
add(buttonLabel); | ||
viewChanged(); | ||
} | ||
|
||
private void viewChanged() | ||
{ | ||
if (viewIsAligned()) | ||
buttonLabel.setIcon(ThemeManager.getIcon("displaymodeicons:is_aligned")); | ||
else | ||
buttonLabel.setIcon(ThemeManager.getIcon("displaymodeicons:not_aligned")); | ||
} | ||
|
||
private void buttonPressed() | ||
{ | ||
// At start up ViewAnimation is still null. Therefore getting it here every time. | ||
|
||
ViewAnimation a = view.getViewAnimation(); | ||
if (a == null || a.animatingMove() || a.changingPerspective()) | ||
return; | ||
buttonLabel.setIcon(ThemeManager.getIcon("displaymodeicons:align_disabled")); | ||
view.alignWithClosestAxis(); | ||
} | ||
|
||
private boolean viewIsAligned() | ||
{ | ||
up = view.getCamera().getCameraCoordinates().getUpDirection(); | ||
fw = view.getCamera().getCameraCoordinates().getZDirection(); | ||
upZeros = 0; | ||
if (up.x == 0) upZeros++; | ||
if (up.y == 0) upZeros++; | ||
if (up.z == 0) upZeros++; | ||
fwZeros = 0; | ||
if (fw.x == 0) fwZeros++; | ||
if (fw.y == 0) fwZeros++; | ||
if (fw.z == 0) fwZeros++; | ||
|
||
if (upZeros > 1 && fwZeros > 1) | ||
return true; | ||
return false; | ||
} | ||
|
||
private void showToolTip(ToolTipEvent e) | ||
{ | ||
new BToolTip(Translate.text("displaymodeicons:alignment")).processEvent(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (C) 2007 François Guillet | ||
* Changes copyright (C) 2023 Petri Ihalainen | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 2 of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
*/ | ||
|
||
package artofillusion.displaymodeicons; | ||
|
||
import java.awt.Dimension; | ||
import java.awt.Insets; | ||
|
||
import buoy.event.ValueChangedEvent; | ||
import buoy.event.ToolTipEvent; | ||
import buoy.widget.BToolTip; | ||
import buoy.widget.LayoutInfo; | ||
import buoy.widget.RowContainer; | ||
import buoy.widget.Widget; | ||
import artofillusion.ViewerCanvas; | ||
import artofillusion.ui.ThemeManager; | ||
import artofillusion.ui.ToolButtonWidget; | ||
import artofillusion.ui.Translate; | ||
import artofillusion.view.ViewChangedEvent; | ||
import artofillusion.view.ViewerControl; | ||
|
||
public class AxesViewerControl implements ViewerControl | ||
{ | ||
public Widget createWidget(ViewerCanvas canvas) | ||
{ | ||
return new AxesViewerControlWidget(canvas); | ||
} | ||
|
||
public String getName() | ||
{ | ||
return ("Axes Toggle Button"); | ||
} | ||
|
||
public class AxesViewerControlWidget extends RowContainer | ||
{ | ||
private ViewerCanvas canvas; | ||
private ToolButtonWidget button; | ||
|
||
public AxesViewerControlWidget(ViewerCanvas canvas) | ||
{ | ||
super(); | ||
this.canvas = canvas; | ||
canvas.addEventLink(ViewChangedEvent.class, this, "viewCanged"); | ||
button = new ToolButtonWidget(ThemeManager.getToolButton(this, "displaymodeicons:axis")); | ||
button.addEventLink(ValueChangedEvent.class, this, "buttonPressed"); | ||
button.addEventLink(ToolTipEvent.class, this, "showToolTip"); | ||
setDefaultLayout(new LayoutInfo(LayoutInfo.CENTER, LayoutInfo.NONE, new Insets(0, 0, 0, 0), new Dimension(0,0))); | ||
add(button); | ||
viewCanged(); | ||
} | ||
|
||
private void viewCanged() | ||
{ | ||
button.setSelected(canvas.getShowAxes()); | ||
} | ||
|
||
private void buttonPressed() | ||
{ | ||
canvas.setShowAxes(button.isSelected()); | ||
canvas.repaint(); | ||
} | ||
|
||
private void showToolTip(ToolTipEvent e) | ||
{ | ||
if (canvas.getShowAxes()) | ||
new BToolTip(Translate.text("displaymodeicons:hideAxes")).processEvent(e); | ||
else | ||
new BToolTip(Translate.text("displaymodeicons:showAxes")).processEvent(e); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.