Skip to content

Commit

Permalink
Merge pull request #10 from spdermn02/mp/dev
Browse files Browse the repository at this point in the history
Tiled icons, linear progress bar, new options for existing elements, & more
  • Loading branch information
spdermn02 authored Aug 7, 2023
2 parents 66fb3f8 + 1042d9e commit e8a00a6
Show file tree
Hide file tree
Showing 34 changed files with 1,742 additions and 7,383 deletions.
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

# Touch Portal Dynamic Icons - Change Log

## v1.0.0 - Initial Release
### Features:
- Actions for Simple Round Gauge and Simple Bar Graph

---
## v1.1.0-alpha1 - Layered Icons

### Features:
- Actions To allow for multiple layered icons
- Actions to manipulate origin/scale/transform/etc the layered icons
- Image Cache for faster image compilation
### Build Scripts:
- Conversion to js build script for multi arch compile at once
- entry.tp generator script

---
## v1.1.0
### New Features:
- Allow dynamically evaluate names for images files (https://github.com/spdermn02/TouchPortal-Dynamic-Icons/pull/6)
- An image layer's source file property can now be updated using the "Update a Value" action.
- Use 'file' type input fields for image source (for TP v3.1b8+) (https://github.com/spdermn02/TouchPortal-Dynamic-Icons/pull/7)
- Add plugin setting to control default base image directory (https://github.com/spdermn02/TouchPortal-Dynamic-Icons/pull/8)
### Fixes:
- Fix name of icon that is built with plugin (https://github.com/spdermn02/TouchPortal-Dynamic-Icons/pull/9)

---
## v1.2.0-alpha1 - Tiled Icons & More Options
### New Features:
- Allows generated icons to be "tiled" across multiple TP button spaces to create non-square images.
- Added a new Linear Progress Bar element with many stylng options. Designed to take advantage of new tiling feature.
- Rectangle shapes can now be drawn of any size using absolute (px) or relative (%) values. Size properties are dynamically evaluated (allowing embedded JS expressions).
- Several sizing properties (like stroke width or radius) can now be specified as absolute pixels as well as percentages.
- Radius sizes, stoke widths, shadow coordinates, and Effect Filter values are now dynamically evaluated by the plugin, allowing embedded JS expressions.
- Added plugin setting and per-image option to enable or disable GPU-based image rendering (on supported GPUs). Previously, GPU rendering was always enabled when available.
When disabled, or not available, rending is done using CPU resources (which may be faster or more efficient in some cases depending on other loads).

### Fixes:
- Shadows are no longer applied to both the fill and stroke of rectangles or text -- they're only drawn on the fill, or the stroke if the fill is transparent.
This prevents the shadow from overlaying the fill.
- Cached images are now automatically cleared when an icon instance is deleted.

### Changes:
- If a shadow is applied to a Styled Rectangle element, the drawn rectangle size is automatically adjusted so the shadow fits within the overall icon dimensions.

### Build Scripts:
- Changes for MacOS and Linux builds to include the required VIPS graphics library binary.
- Update/fix the TP startup command line in entry.tp for MacOS and Linux builds.
20 changes: 4 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Generate Dynamic Icons for Touch Portal based on Actions and 0-100% values.

- [TouchPortal-Dynamic-Icons](#touchportal-dynamic-icons)
- [Change Log](#change-log)
- [What Is This?](#what-is-this)
- [Change Log](#change-log)
- [Actions](#actions)
- [Simple Round Gauge](#simple-round-gauge)
- [Properties](#properties)
Expand All @@ -23,26 +23,14 @@ Generate Dynamic Icons for Touch Portal based on Actions and 0-100% values.
- [Bugs/Enhancements](#bugsenhancements)
- [Acknowledgements](#acknowledgements)

# Change Log
```
v1.0.0 - Initial Release
Features:
- Actions for Simple Round Gauge and Simple Bar Graph\
v1.1.0 - Layered Icons (Thanks to Max Paperno)
Features:
- Actions To allow for multiple layered icons
- Actions to manipulate origin/scale/transform/etc the layered icons
- Image Cache for faster image compilation
Build Scripts:
- Conversion to js build script for multi arch compile at once
- entry.tp generator script
```

# What Is This?

Do you find the need to render out a bar graph, or round gauge in Touch Portal, or some complex layered image like a flight altimeter, or flight level guage, thermometer, but it it needs to be dynamic. Look no further, this plugin can do that for you.
This will draw bar graphs, or round gauges, or more complex layered images with different transformations based on your configured actions, colors, etc. (see Actions section for info), see Sample section for what you can do with it.

# Change Log
See [CHANGELOG.md](https://github.com/spdermn02/TouchPortal-Dynamic-Icons/blob/main/CHANGELOG.md)

# Actions

Available Actions are
Expand Down
4 changes: 2 additions & 2 deletions base/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ then
sleep 1
fi

# this will output all Plugin log data to the TouchPortal/plugins/<prog> directory
# this will output all Plugin log data to the TouchPortal/plugins/<prog> directory
# in a file called <prog>log.txt instead of being captured inside the Touch Portal Logs
./$prog > ${prog}log.txt 2>&1 &
./$prog > ${prog}_log.txt 2>&1 &
66 changes: 39 additions & 27 deletions builders/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,70 @@ const fse = require("fs-extra")
const pkg = require("pkg");
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf8"))
const { exit } = require("process");
const { exec, execSync } = require("child_process");
const { execSync } = require("child_process");

// sharp/vips library path constants
const SHARP_ROOT = "./node_modules/sharp"
const SHARP_BUILD = SHARP_ROOT + "/build/Release"
const SHARP_VENDOR_V = "8.12.2"

const build = async(platform, options ) => {
if( fs.existsSync(`./base/${platform}`) ) {
fs.rmSync(`./base/${platform}`, { recursive : true})
}
fs.mkdirSync(`./base/${platform}`)
fs.copyFileSync("./base/plugin_icon.png", `./base/${platform}/${packageJson.name}.png`)

let nodeVersion = 'node16-win-x64'
let execName = `${packageJson.name}.exe`

if( platform != "Windows" ) {
execName = packageJson.name
fs.copyFileSync("./base/start.sh", `./base/${platform}/start.sh`)
}
else {
console.log("Making sure sharp is built for Windows")
execSync('npm rebuild --platform=win32 --arch=x64 sharp')
}
let osTarget = platform.toLowerCase()
let sharpPlatform = osTarget
let execName = packageJson.name
let libvipsSrcPath = SHARP_BUILD
let libvipsDestPath = `./base/${platform}/`

if( platform == "MacOS") {
nodeVersion = 'node16-macos-x64'
console.log("Making sure sharp is built for MacOs x64")
execSync('npm rebuild --platform=darwin --arch=x64 sharp')
if (platform == "Windows" ) {
osTarget = "win"
sharpPlatform = "win32"
execName += ".exe"
libvipsDestPath += `${SHARP_BUILD}/`
}
if( platform == "MacOS-Arm64") {
nodeVersion = '???'
else if (platform == "MacOS") {
sharpPlatform = 'darwin'
}
if( platform == "Linux") {
nodeVersion = 'node16-linux-x64'
console.log("Making sure sharp is built for Linux x64")
execSync('npm rebuild --platform=linux --arch=x64 sharp')
else if (platform == "MacOS-Arm64") {
console.error("Can't handle platform " + platform)
exit(1)
}

fse.copySync("./node_modules/sharp/build/Release", `./base/${platform}/node_modules/sharp/build/Release`)
if (platform != "Windows" ) {
libvipsSrcPath = `${SHARP_ROOT}/vendor/${SHARP_VENDOR_V}/${sharpPlatform}-x64/lib`
fs.copyFileSync("./base/start.sh", `./base/${platform}/start.sh`)
}

console.log(`Making sure sharp is built for ${platform} x64`)
execSync(`npm rebuild --platform=${sharpPlatform} --arch=x64 sharp`)
const libs = fs.readdirSync(libvipsSrcPath).filter(fn => fn.startsWith('lib'))
libs.forEach(fn => copyFileSync(`${libvipsSrcPath}/${fn}`, libvipsDestPath));
copyFileSync(`${SHARP_BUILD}/sharp-${sharpPlatform}-x64.node`, `./base/${platform}/${SHARP_BUILD}/`)

console.log("Generating entry.tp")
execSync(`node ./builders/gen_entry.js -v ${packageJson.version} -o ./base/${platform}`)

console.log("Running pkg")
await pkg.exec([
"--targets",
nodeVersion,
`${packageJson.config.nodeTarget}-${osTarget}-x64`,
"--output",
`base/${platform}/${execName}`,
".",
]);

console.log("Running Zip File Creation")
const zip = new AdmZip()
zip.addLocalFolder(
path.normalize(`./base/${platform}/`),
packageJson.name
);

let packageName = `./Installers/${packageJson.name}-${platform}-${packageJson.version}.tpp`
if( options?.type !== undefined ) {
packageName = `./Installers/${packageJson.name}-${platform}-${options.type}-${packageJson.version}.tpp`
Expand All @@ -81,11 +89,15 @@ const cleanInstallers = () => {
}
}

const copyFileSync = function(filePath, destDir) {
return fse.copySync(filePath, path.join(destDir, path.basename(filePath)))
}

const executeBuilds= async () => {
cleanInstallers()
await build("Windows")
await build("MacOS")
await build("Linux")
}

executeBuilds();
executeBuilds();
Loading

0 comments on commit e8a00a6

Please sign in to comment.