SlideShare a Scribd company logo
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Scenegraphの操作とDialogの作り方
Yoshiki Takeoka (竹岡義樹)| Program Manager, Japan R&D, Adobe
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Japan R&Dの紹介
2
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
貂明朝テキスト
3
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Match Font for Japanese
4
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Adobe I/O - https://adobe.io/
5
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Scenegraphの基本
スターターキットを触ってみよう!
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
サンプルファイル
http://bit.ly/xdplugin-jp
7
01-01-scenegraph-sample
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Starter-project
 設定ファイル
 Plugin-ID
 Menu-UI
 Icon
 処理のコード
 アイコン
8
manifest.json
main.js
images/icon.png
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
manifest.json
9
Plugin Manager
Menu
アイコンは96px固定
name, descriptionは
日本語未対応
https://adobe.ioで取得
日本語使えます
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Plugin Manager と manifest.json の関係
10
description
name
icons
version
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Menu と manifest.json の uiEntryPoints
11
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
main.js を構成する3つの要素
12
manifest.jsonの設定値
require
selection, documentRoot
exports
functions
Scenenodeに正方形を追加
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Scenegraphとは
13
• Scenegraph: XDで描画されるオブジェクトの構成
• selection: 選択中のオブジェクト
• documentRoot : RootNode以下のファイル全体
selection.insertionParent.addChild(shape); //コピペと同じように要素を追加
sceneNode
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
API Modules – APIを利用するときはrequire!
 application require(’application’)
 XD, OSのバージョン、rendition の書き出し
 scenegraph require(’scenegraph’)
 documentNode(Artboard, Rectange, Ellipse, Line, Path … など )の参照、変更、追加、削除
 commands require(’commands’)
 selection に含まれるオブジェクトへの操作
 group, ungroup, createMaskGroup, bringToFront
 storage require(’uxp’)
 ローカルストレージへのアクセス
 clipboard require(’clipboard’)
 現在は clipboard.copyText() のみ可能 clipboard からアートボードへのコピペは不可
 Network require不要(global)
 websocket, XMLHttpRequest, Fetch
14
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
main.js をみなおしてみる
15
manifest.jsonの設定値
require
selection, documentRoot
Scenenodeに正方形を追加
exports
functions
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
動かしてみよう!
16
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Project Template の種類
17
Official Github (quick-start)
https://github.com/adobeXD/Plugin-samples
Adobe I/O
https://console.adobe.io/plugins
XD Awesome (Community)
https://github.com/AdobeXD/xd-awesome
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Dialogの基本
ユーザーの入力を取得する
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
サンプルファイル
http://bit.ly/xdplugin-jp
19
02-01-dialog-sample
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Dialog - XDで表示される UIのこと
20
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Dialogの利用例
21
確認・同意画面の提示 エラーメッセージの表示
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Dialogにおけるインタラクションの種類
 ESCキーの押下
 ※無効化できません
 Promise の値に “reasonCanceled” が設定される
 ENTERキーの押下
 form.onsubmit()が呼ばれる
 ボタンクリック
 OKとCancelの2つを用意
 各自eventlistenerの設定が必要
22
submit前に必ずチェック!
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Dialog を表示する
23
renderDialog() //Dialog Objectを作成
dialog = document.querySelector('#dialog');
dialog.showModal(); //Async,Promise
dialog.close(returnvalue);
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Dialogの描画 – DOMオブジェクトを追加する
24
<form method=“dialog”>
post, getは動作しない
<dialog>
input タグのボタンは不可
※下記のボタンは使えません
•<input type="button" />
•<input type="reset" />
•<input type="submit" />
uxp-variant
<footer>に<button>を配置
inline styleは書かない
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
eventlistenerの設定
 <dialog>
 DOMに追加すること!
 dialog.close()
 ユーザーの入力値を渡さない
 ユーザーのインタラクション
 Cancel Button - Click
 OK Button – Click
 ENTER – Keypress
 e.preventDefault() – bug?
 ESC – Keypress
 イベントリスナは設定不要
 Promiseの返り値が 'reasonCanceled’
25
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
dialog.close() – 入力値を受け取ったあとに閉じる
26
dialog.close()
ユーザーの入力値を含めない
Promiseを返す
ESC Keypress
dialog.close(‘reasonCanceled’
)が呼ばれる
Dialogを開いたあとのScenegraphの
操作は非同期で処理
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
動かしてみよう!
27
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
プラグイン開発にあたってのお願い
気をつけて頂きたいことなど
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
同期(Synchronized)と非同期(Asynchronized)
 同期(Synchronized) で実行するケース
 処理が高速(2秒程度)で終了するとき
 非同期(Asynchronized)で実行するケース
 storage, Network などの非同期関数を実行するとき
 処理に時間がかかるとき
 Dialogを表示したうえで「作業の進捗」を表示し、処理中の「キャンセル」ができるようにする
 Dialogを表示したり、(storage, Networkなどの)非同期関数を実行した後にScenegraphを操作
するとき
29
Plugin Error: Plugin `Plugin-id` is not permitted to make changes from the background. Return a Promise to
continue execution asynchronously.
https://adobexdplatform.com/plugin-docs/xdpegs/2-scenegraph.html#29-know-when-to-use-asynchronous-logic
同期処理に関するエラーメッセージの例
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Edit Context – 編集できるノードの制限
30
• 選択中のノード
• 選択中の直下のノード
Edit Context がRootNode
(何も選択していないとき)
Edit Context がRootNode以外のとき
• アートボード
• アートボード直下のノード
• PasteBoard中にあるノード
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
基本はES5ベース、 ES2015(ES6)は一部サポート
31
XDで動作するES2015の関数 説明
Template literals テンプレート文字列
Classes クラス構文
Block-scoped variables ( let , const ) ブロック内変数宣言
Object destructuring オブジェクトの分割代入
Default parameters デフォルトパラメーター
Spread and Rest ( … ) 配列の分割代入
Arrow functions アロー関数
Asynchronous functions ( async / await ) async/await による非同期処理
Promises Promise を用いた非同期処理
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
XDのプラグインは node.js でも ブラウザでもありません!
 node.js や ブラウザにある APIがそのまま動作する訳ではありません
 例えば・・・下記の関数は「現時点では」サポートされていません
 setTimeout
 clearTimeout
 cancelAnimationFrame
 requestAnimationFrame
 HTMLIFrameElement
 一部のcssプロパティ
32
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Node.js (npm) は動くが・・・注意が必要
 node_modules, package.json のパスはチェックしません。
 webpack, rollup などでバンドルが必須
 requireでは、localfileのみチェックします。
33
const someLib = require("somelib"); // no package.json lookup
xdpm と webpack(+babel) の組み合わせはオススメです
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
最後に・・・
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
GithubやForumの最新情報をチェックをお願いします
 GithubのアップデートやForumの議論が活発に行われています
 Adobeの社員も見てます!更新してます。
 公式リファレンスのミスがForumで発覚した事例も・・・orz、ごめんなさい
35
Forumのスレ – “ok”が渡される - 動く
https://forums.adobexdplatform.com/t/creating-modal-dialogs-is-so-hard/313/23
公式リファレンス- “ok”が渡されない - 動かない
https://adobexdplatform.com/plugin-docs/reference/ui/dialogs/dismissal.html
事例:Dialog の Keypress ENTER でdialog.close()の引数が渡せない
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
Appendix
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
node の properties の更新はインラインで行わない
38
Good
• node.fill の値に代入して更新して
いる
• (node.fill のsetter が呼び出されて
いる)
Bad
• node.color.r への直接の書き込み
はできない
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
現在、Adobe I/O Console でプラグインを登録できない
39
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
開発用, xdxファイル経由のインストールのみPlugin Managerの日本語が利用可能
40
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
プラグインができる編集
 ノード(オブジェクト)にそのものに対する操作・編集
 属性の更新
 ノード削除
 ノードの追加
 複数のノード、ノードの構造を伴う編集
 グループ化
 グループ化解除
 Z値(背面、前面)への移動
41
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
オブジェクト(ノード)の座標系
42
Local
coordinates
Parent
Coordinates
Global
Coordinates
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
ローカル座標系で左上が (0,0)とは限らない
43
Text path
0,0 から宣言されていない
© 2018 Adobe. All Rights Reserved. Adobe Confidential.
END

More Related Content

What's hot

GraphQL in Magento 2
GraphQL in Magento 2GraphQL in Magento 2
GraphQL in Magento 2
Sergii Ivashchenko
 
Micro frontend architecture_presentation_ssoni
Micro frontend architecture_presentation_ssoniMicro frontend architecture_presentation_ssoni
Micro frontend architecture_presentation_ssoni
Sandeep Soni
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
Eric Deng
 
도메인 주도 설계 (Domain Driven Design)
도메인 주도 설계 (Domain Driven Design)도메인 주도 설계 (Domain Driven Design)
도메인 주도 설계 (Domain Driven Design)
Ashal aka JOKER
 
产品设计与用户体验(据说是马化腾用来做培训的PPT)
产品设计与用户体验(据说是马化腾用来做培训的PPT)产品设计与用户体验(据说是马化腾用来做培训的PPT)
产品设计与用户体验(据说是马化腾用来做培训的PPT)Dahui Feng
 
Membuat storyboard
Membuat storyboardMembuat storyboard
Membuat storyboardSayugo
 
Next.js - ReactPlayIO.pptx
Next.js - ReactPlayIO.pptxNext.js - ReactPlayIO.pptx
Next.js - ReactPlayIO.pptx
DivyanshGupta922023
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
Ryan Cuprak
 
Everything you ever wanted to know about IIIF but were too afraid to ask
Everything you ever wanted to know about IIIF but were too afraid to askEverything you ever wanted to know about IIIF but were too afraid to ask
Everything you ever wanted to know about IIIF but were too afraid to ask
Cogapp
 
AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0
MoritzHalbritter
 
Micro Frontends Architecture
Micro Frontends ArchitectureMicro Frontends Architecture
Micro Frontends Architecture
Rag Dhiman
 
INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...
INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...
INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...
apidays
 
AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101
Adobe
 
Code Review - DevOn2013
Code Review - DevOn2013Code Review - DevOn2013
Code Review - DevOn2013
호정 이
 
Produksi film
Produksi filmProduksi film
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
Accunity Software
 
Session,Cookies and Authentication
Session,Cookies and AuthenticationSession,Cookies and Authentication
Session,Cookies and Authentication
Knoldus Inc.
 

What's hot (18)

GraphQL in Magento 2
GraphQL in Magento 2GraphQL in Magento 2
GraphQL in Magento 2
 
Micro frontend architecture_presentation_ssoni
Micro frontend architecture_presentation_ssoniMicro frontend architecture_presentation_ssoni
Micro frontend architecture_presentation_ssoni
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
Social networking
Social networkingSocial networking
Social networking
 
도메인 주도 설계 (Domain Driven Design)
도메인 주도 설계 (Domain Driven Design)도메인 주도 설계 (Domain Driven Design)
도메인 주도 설계 (Domain Driven Design)
 
产品设计与用户体验(据说是马化腾用来做培训的PPT)
产品设计与用户体验(据说是马化腾用来做培训的PPT)产品设计与用户体验(据说是马化腾用来做培训的PPT)
产品设计与用户体验(据说是马化腾用来做培训的PPT)
 
Membuat storyboard
Membuat storyboardMembuat storyboard
Membuat storyboard
 
Next.js - ReactPlayIO.pptx
Next.js - ReactPlayIO.pptxNext.js - ReactPlayIO.pptx
Next.js - ReactPlayIO.pptx
 
Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]Top 50 java ee 7 best practices [con5669]
Top 50 java ee 7 best practices [con5669]
 
Everything you ever wanted to know about IIIF but were too afraid to ask
Everything you ever wanted to know about IIIF but were too afraid to askEverything you ever wanted to know about IIIF but were too afraid to ask
Everything you ever wanted to know about IIIF but were too afraid to ask
 
AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0AOT and Native with Spring Boot 3.0
AOT and Native with Spring Boot 3.0
 
Micro Frontends Architecture
Micro Frontends ArchitectureMicro Frontends Architecture
Micro Frontends Architecture
 
INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...
INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...
INTERFACE by apidays_Recommendations for API Governance and an API Economy Ce...
 
AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101
 
Code Review - DevOn2013
Code Review - DevOn2013Code Review - DevOn2013
Code Review - DevOn2013
 
Produksi film
Produksi filmProduksi film
Produksi film
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
 
Session,Cookies and Authentication
Session,Cookies and AuthenticationSession,Cookies and Authentication
Session,Cookies and Authentication
 

Similar to Adobe XD Plugin「Scenegraph」の操作とDialogの作り方

30分でできる!Adobe XDプラグイン開発!
30分でできる!Adobe XDプラグイン開発!30分でできる!Adobe XDプラグイン開発!
30分でできる!Adobe XDプラグイン開発!
Yoshiki Takeoka
 
Flex開発を加速するFlash Builder 4新機能紹介
Flex開発を加速するFlash Builder 4新機能紹介Flex開発を加速するFlash Builder 4新機能紹介
Flex開発を加速するFlash Builder 4新機能紹介
Keisuke Todoroki
 
PhoneGapとハイブリッド開発
PhoneGapとハイブリッド開発PhoneGapとハイブリッド開発
PhoneGapとハイブリッド開発
Andy Hall
 
Adobe & HTML5
Adobe & HTML5Adobe & HTML5
Adobe & HTML5
Andy Hall
 
PHPにおけるRIA事情と開発
PHPにおけるRIA事情と開発PHPにおけるRIA事情と開発
PHPにおけるRIA事情と開発
konekto
 
スマホキャンプサマー2012:ANEとアプリ内課金に挑戦
スマホキャンプサマー2012:ANEとアプリ内課金に挑戦スマホキャンプサマー2012:ANEとアプリ内課金に挑戦
スマホキャンプサマー2012:ANEとアプリ内課金に挑戦
Tetsuya Shiraishi
 
Sneak Previews (ADC MEETUP ROUND 01)
Sneak Previews (ADC MEETUP ROUND 01)Sneak Previews (ADC MEETUP ROUND 01)
Sneak Previews (ADC MEETUP ROUND 01)
Teiichi Ota
 
Flashテクノロジーの今後とあなたの人生とのかかわりについて
Flashテクノロジーの今後とあなたの人生とのかかわりについてFlashテクノロジーの今後とあなたの人生とのかかわりについて
Flashテクノロジーの今後とあなたの人生とのかかわりについて
Teiichi Ota
 
120829atechhills3flashfinal 120829215733-phpapp01
120829atechhills3flashfinal 120829215733-phpapp01120829atechhills3flashfinal 120829215733-phpapp01
120829atechhills3flashfinal 120829215733-phpapp01
Chris Brownlee
 
無償でここまで使えるアドビのWeb制作ツール for デブサミ2013
無償でここまで使えるアドビのWeb制作ツール for デブサミ2013無償でここまで使えるアドビのWeb制作ツール for デブサミ2013
無償でここまで使えるアドビのWeb制作ツール for デブサミ2013
Keisuke Todoroki
 
モバイルコンテンツ制作を効 率化するツールを使いこなせ
モバイルコンテンツ制作を効 率化するツールを使いこなせモバイルコンテンツ制作を効 率化するツールを使いこなせ
モバイルコンテンツ制作を効 率化するツールを使いこなせ
Keisuke Todoroki
 
20150622 Adobe Analytics
20150622 Adobe Analytics20150622 Adobe Analytics
20150622 Adobe Analytics
Keisuke Anzai
 
Deploy TypeScript with CodePipeline in Fargate
Deploy TypeScript with CodePipeline in FargateDeploy TypeScript with CodePipeline in Fargate
Deploy TypeScript with CodePipeline in Fargate
bitbank, Inc. Tokyo, Japan
 
アイデアを形にする ③3時間でアプリ公開!ゼロからのプログラミング講座
アイデアを形にする  ③3時間でアプリ公開!ゼロからのプログラミング講座アイデアを形にする  ③3時間でアプリ公開!ゼロからのプログラミング講座
アイデアを形にする ③3時間でアプリ公開!ゼロからのプログラミング講座
DIVE INTO CODE Corp.
 
つ部 Android Studio 勉強会 12/7
つ部 Android Studio 勉強会 12/7つ部 Android Studio 勉強会 12/7
つ部 Android Studio 勉強会 12/7
Hikaru Wada
 
OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』
OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』
OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』
Shinichiro Yoshida
 
Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2
Amazon Web Services Japan
 
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
Fumiya Sakai
 

Similar to Adobe XD Plugin「Scenegraph」の操作とDialogの作り方 (20)

30分でできる!Adobe XDプラグイン開発!
30分でできる!Adobe XDプラグイン開発!30分でできる!Adobe XDプラグイン開発!
30分でできる!Adobe XDプラグイン開発!
 
Flex開発を加速するFlash Builder 4新機能紹介
Flex開発を加速するFlash Builder 4新機能紹介Flex開発を加速するFlash Builder 4新機能紹介
Flex開発を加速するFlash Builder 4新機能紹介
 
PhoneGapとハイブリッド開発
PhoneGapとハイブリッド開発PhoneGapとハイブリッド開発
PhoneGapとハイブリッド開発
 
Adobe & HTML5
Adobe & HTML5Adobe & HTML5
Adobe & HTML5
 
PHPにおけるRIA事情と開発
PHPにおけるRIA事情と開発PHPにおけるRIA事情と開発
PHPにおけるRIA事情と開発
 
スマホキャンプサマー2012:ANEとアプリ内課金に挑戦
スマホキャンプサマー2012:ANEとアプリ内課金に挑戦スマホキャンプサマー2012:ANEとアプリ内課金に挑戦
スマホキャンプサマー2012:ANEとアプリ内課金に挑戦
 
Sneak Previews (ADC MEETUP ROUND 01)
Sneak Previews (ADC MEETUP ROUND 01)Sneak Previews (ADC MEETUP ROUND 01)
Sneak Previews (ADC MEETUP ROUND 01)
 
Flashテクノロジーの今後とあなたの人生とのかかわりについて
Flashテクノロジーの今後とあなたの人生とのかかわりについてFlashテクノロジーの今後とあなたの人生とのかかわりについて
Flashテクノロジーの今後とあなたの人生とのかかわりについて
 
120829atechhills3flashfinal 120829215733-phpapp01
120829atechhills3flashfinal 120829215733-phpapp01120829atechhills3flashfinal 120829215733-phpapp01
120829atechhills3flashfinal 120829215733-phpapp01
 
無償でここまで使えるアドビのWeb制作ツール for デブサミ2013
無償でここまで使えるアドビのWeb制作ツール for デブサミ2013無償でここまで使えるアドビのWeb制作ツール for デブサミ2013
無償でここまで使えるアドビのWeb制作ツール for デブサミ2013
 
モバイルコンテンツ制作を効 率化するツールを使いこなせ
モバイルコンテンツ制作を効 率化するツールを使いこなせモバイルコンテンツ制作を効 率化するツールを使いこなせ
モバイルコンテンツ制作を効 率化するツールを使いこなせ
 
ZendStudioのご紹介
ZendStudioのご紹介ZendStudioのご紹介
ZendStudioのご紹介
 
20150622 Adobe Analytics
20150622 Adobe Analytics20150622 Adobe Analytics
20150622 Adobe Analytics
 
Deploy TypeScript with CodePipeline in Fargate
Deploy TypeScript with CodePipeline in FargateDeploy TypeScript with CodePipeline in Fargate
Deploy TypeScript with CodePipeline in Fargate
 
アイデアを形にする ③3時間でアプリ公開!ゼロからのプログラミング講座
アイデアを形にする  ③3時間でアプリ公開!ゼロからのプログラミング講座アイデアを形にする  ③3時間でアプリ公開!ゼロからのプログラミング講座
アイデアを形にする ③3時間でアプリ公開!ゼロからのプログラミング講座
 
つ部 Android Studio 勉強会 12/7
つ部 Android Studio 勉強会 12/7つ部 Android Studio 勉強会 12/7
つ部 Android Studio 勉強会 12/7
 
OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』
OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』
OSC2011 Tokyo/Spring 『Red5とFlexで「簡易電子会議室システム」を作ってみよう!』
 
Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2Gaming cicd-pipeline gaming-technight-2
Gaming cicd-pipeline gaming-technight-2
 
AndroidでDIxAOP
AndroidでDIxAOPAndroidでDIxAOP
AndroidでDIxAOP
 
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
RxDataSourceをNSDiffableDataSourceへ置き換える際のTips集紹介
 

Adobe XD Plugin「Scenegraph」の操作とDialogの作り方

  • 1. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Scenegraphの操作とDialogの作り方 Yoshiki Takeoka (竹岡義樹)| Program Manager, Japan R&D, Adobe
  • 2. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Japan R&Dの紹介 2
  • 3. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 貂明朝テキスト 3
  • 4. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Match Font for Japanese 4
  • 5. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Adobe I/O - https://adobe.io/ 5
  • 6. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Scenegraphの基本 スターターキットを触ってみよう!
  • 7. © 2018 Adobe. All Rights Reserved. Adobe Confidential. サンプルファイル http://bit.ly/xdplugin-jp 7 01-01-scenegraph-sample
  • 8. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Starter-project  設定ファイル  Plugin-ID  Menu-UI  Icon  処理のコード  アイコン 8 manifest.json main.js images/icon.png
  • 9. © 2018 Adobe. All Rights Reserved. Adobe Confidential. manifest.json 9 Plugin Manager Menu アイコンは96px固定 name, descriptionは 日本語未対応 https://adobe.ioで取得 日本語使えます
  • 10. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Plugin Manager と manifest.json の関係 10 description name icons version
  • 11. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Menu と manifest.json の uiEntryPoints 11
  • 12. © 2018 Adobe. All Rights Reserved. Adobe Confidential. main.js を構成する3つの要素 12 manifest.jsonの設定値 require selection, documentRoot exports functions Scenenodeに正方形を追加
  • 13. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Scenegraphとは 13 • Scenegraph: XDで描画されるオブジェクトの構成 • selection: 選択中のオブジェクト • documentRoot : RootNode以下のファイル全体 selection.insertionParent.addChild(shape); //コピペと同じように要素を追加 sceneNode
  • 14. © 2018 Adobe. All Rights Reserved. Adobe Confidential. API Modules – APIを利用するときはrequire!  application require(’application’)  XD, OSのバージョン、rendition の書き出し  scenegraph require(’scenegraph’)  documentNode(Artboard, Rectange, Ellipse, Line, Path … など )の参照、変更、追加、削除  commands require(’commands’)  selection に含まれるオブジェクトへの操作  group, ungroup, createMaskGroup, bringToFront  storage require(’uxp’)  ローカルストレージへのアクセス  clipboard require(’clipboard’)  現在は clipboard.copyText() のみ可能 clipboard からアートボードへのコピペは不可  Network require不要(global)  websocket, XMLHttpRequest, Fetch 14
  • 15. © 2018 Adobe. All Rights Reserved. Adobe Confidential. main.js をみなおしてみる 15 manifest.jsonの設定値 require selection, documentRoot Scenenodeに正方形を追加 exports functions
  • 16. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 動かしてみよう! 16
  • 17. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Project Template の種類 17 Official Github (quick-start) https://github.com/adobeXD/Plugin-samples Adobe I/O https://console.adobe.io/plugins XD Awesome (Community) https://github.com/AdobeXD/xd-awesome
  • 18. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Dialogの基本 ユーザーの入力を取得する
  • 19. © 2018 Adobe. All Rights Reserved. Adobe Confidential. サンプルファイル http://bit.ly/xdplugin-jp 19 02-01-dialog-sample
  • 20. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Dialog - XDで表示される UIのこと 20
  • 21. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Dialogの利用例 21 確認・同意画面の提示 エラーメッセージの表示
  • 22. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Dialogにおけるインタラクションの種類  ESCキーの押下  ※無効化できません  Promise の値に “reasonCanceled” が設定される  ENTERキーの押下  form.onsubmit()が呼ばれる  ボタンクリック  OKとCancelの2つを用意  各自eventlistenerの設定が必要 22 submit前に必ずチェック!
  • 23. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Dialog を表示する 23 renderDialog() //Dialog Objectを作成 dialog = document.querySelector('#dialog'); dialog.showModal(); //Async,Promise dialog.close(returnvalue);
  • 24. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Dialogの描画 – DOMオブジェクトを追加する 24 <form method=“dialog”> post, getは動作しない <dialog> input タグのボタンは不可 ※下記のボタンは使えません •<input type="button" /> •<input type="reset" /> •<input type="submit" /> uxp-variant <footer>に<button>を配置 inline styleは書かない
  • 25. © 2018 Adobe. All Rights Reserved. Adobe Confidential. eventlistenerの設定  <dialog>  DOMに追加すること!  dialog.close()  ユーザーの入力値を渡さない  ユーザーのインタラクション  Cancel Button - Click  OK Button – Click  ENTER – Keypress  e.preventDefault() – bug?  ESC – Keypress  イベントリスナは設定不要  Promiseの返り値が 'reasonCanceled’ 25
  • 26. © 2018 Adobe. All Rights Reserved. Adobe Confidential. dialog.close() – 入力値を受け取ったあとに閉じる 26 dialog.close() ユーザーの入力値を含めない Promiseを返す ESC Keypress dialog.close(‘reasonCanceled’ )が呼ばれる Dialogを開いたあとのScenegraphの 操作は非同期で処理
  • 27. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 動かしてみよう! 27
  • 28. © 2018 Adobe. All Rights Reserved. Adobe Confidential. プラグイン開発にあたってのお願い 気をつけて頂きたいことなど
  • 29. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 同期(Synchronized)と非同期(Asynchronized)  同期(Synchronized) で実行するケース  処理が高速(2秒程度)で終了するとき  非同期(Asynchronized)で実行するケース  storage, Network などの非同期関数を実行するとき  処理に時間がかかるとき  Dialogを表示したうえで「作業の進捗」を表示し、処理中の「キャンセル」ができるようにする  Dialogを表示したり、(storage, Networkなどの)非同期関数を実行した後にScenegraphを操作 するとき 29 Plugin Error: Plugin `Plugin-id` is not permitted to make changes from the background. Return a Promise to continue execution asynchronously. https://adobexdplatform.com/plugin-docs/xdpegs/2-scenegraph.html#29-know-when-to-use-asynchronous-logic 同期処理に関するエラーメッセージの例
  • 30. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Edit Context – 編集できるノードの制限 30 • 選択中のノード • 選択中の直下のノード Edit Context がRootNode (何も選択していないとき) Edit Context がRootNode以外のとき • アートボード • アートボード直下のノード • PasteBoard中にあるノード
  • 31. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 基本はES5ベース、 ES2015(ES6)は一部サポート 31 XDで動作するES2015の関数 説明 Template literals テンプレート文字列 Classes クラス構文 Block-scoped variables ( let , const ) ブロック内変数宣言 Object destructuring オブジェクトの分割代入 Default parameters デフォルトパラメーター Spread and Rest ( … ) 配列の分割代入 Arrow functions アロー関数 Asynchronous functions ( async / await ) async/await による非同期処理 Promises Promise を用いた非同期処理
  • 32. © 2018 Adobe. All Rights Reserved. Adobe Confidential. XDのプラグインは node.js でも ブラウザでもありません!  node.js や ブラウザにある APIがそのまま動作する訳ではありません  例えば・・・下記の関数は「現時点では」サポートされていません  setTimeout  clearTimeout  cancelAnimationFrame  requestAnimationFrame  HTMLIFrameElement  一部のcssプロパティ 32
  • 33. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Node.js (npm) は動くが・・・注意が必要  node_modules, package.json のパスはチェックしません。  webpack, rollup などでバンドルが必須  requireでは、localfileのみチェックします。 33 const someLib = require("somelib"); // no package.json lookup xdpm と webpack(+babel) の組み合わせはオススメです
  • 34. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 最後に・・・
  • 35. © 2018 Adobe. All Rights Reserved. Adobe Confidential. GithubやForumの最新情報をチェックをお願いします  GithubのアップデートやForumの議論が活発に行われています  Adobeの社員も見てます!更新してます。  公式リファレンスのミスがForumで発覚した事例も・・・orz、ごめんなさい 35 Forumのスレ – “ok”が渡される - 動く https://forums.adobexdplatform.com/t/creating-modal-dialogs-is-so-hard/313/23 公式リファレンス- “ok”が渡されない - 動かない https://adobexdplatform.com/plugin-docs/reference/ui/dialogs/dismissal.html 事例:Dialog の Keypress ENTER でdialog.close()の引数が渡せない
  • 36.
  • 37. © 2018 Adobe. All Rights Reserved. Adobe Confidential. Appendix
  • 38. © 2018 Adobe. All Rights Reserved. Adobe Confidential. node の properties の更新はインラインで行わない 38 Good • node.fill の値に代入して更新して いる • (node.fill のsetter が呼び出されて いる) Bad • node.color.r への直接の書き込み はできない
  • 39. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 現在、Adobe I/O Console でプラグインを登録できない 39
  • 40. © 2018 Adobe. All Rights Reserved. Adobe Confidential. 開発用, xdxファイル経由のインストールのみPlugin Managerの日本語が利用可能 40
  • 41. © 2018 Adobe. All Rights Reserved. Adobe Confidential. プラグインができる編集  ノード(オブジェクト)にそのものに対する操作・編集  属性の更新  ノード削除  ノードの追加  複数のノード、ノードの構造を伴う編集  グループ化  グループ化解除  Z値(背面、前面)への移動 41
  • 42. © 2018 Adobe. All Rights Reserved. Adobe Confidential. オブジェクト(ノード)の座標系 42 Local coordinates Parent Coordinates Global Coordinates
  • 43. © 2018 Adobe. All Rights Reserved. Adobe Confidential. ローカル座標系で左上が (0,0)とは限らない 43 Text path 0,0 から宣言されていない
  • 44. © 2018 Adobe. All Rights Reserved. Adobe Confidential. END