環境設定の作法 / Manners of Preferences Window on macOS

2174bd20a68bf55c494a424ad3790f4a?s=47 1024jp
December 22, 2018

環境設定の作法 / Manners of Preferences Window on macOS

macOS native symposium (http://macos-native.github.io) #02 登壇資料

macOSアプリケーションにおけるお行儀の良い環境設定の作り方、またUserDefaultsの取り回しについてをライブコーディングを交えてお見せします。

2174bd20a68bf55c494a424ad3790f4a?s=128

1024jp

December 22, 2018
Tweet

Transcript

  1. 題: 発表者: 場所: 日付: ؀ڥઃఆͷ࡞๏ KQ NBD04OBUJWF4ZNQPTJVN 

  2. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ࣗݾ঺հ KQ ͸ NBD04 ΞϓϦέʔγϣϯઐ໳ͷϗϏʔ։ൃऀɻ 044 ϓϩδΣΫτӡӦ͔ΒϓϩάϥϛϯάɺΞΠίϯͷσ βΠϯ·ͰɺNBD04 ͷΞϓϦέʔγϣϯ։ൃʹؔΘΔ͜

    ͱͳΒશ෦΍ΔϚϯͰ͋Δɻ ͤΜʹ͡Ύ͏ΑΜ
 ͐͡ʔͽʔ 本業ではないよ
  3. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ࣗݾ঺հ CotEditor Gapplin BathyScaphe

    Qli application work plain-text editor SVG viewer 5ch browser movie player 2014年に
 正式引き継ぎ サポーtメンバー
 (主にデザイン・UI) 新作
  4. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢ ࠓ೔ͷओ໾

  5. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢ Toolbar Title Bar

    Preferences
 Pane Control Label Application Menu
  6. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢

  7. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢ͷྺ࢙ cite: Mac OS

    X 10.0 Cheetah, 512 Pixels, on 2018-12
 https://512pixels.net/projects/aqua-screenshot-library/mac-os-x-10-0-cheetah/ Mac OS X 10.0 | Mail.app
  8. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢ͷྺ࢙ cite: Playing around

    with Mac OS X Puma –YouTube, on 2018-12
 https://www.youtube.com/watch?v=2SBI27xUnug Mac OS X 10.1 | System Preferences © 2018 1024jp
  9. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT

  10. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT A preferences window

    is a modeless dialog that’s used to adjust an app’s preferences. Typically, a preferences window contains a toolbar that includes buttons for switching between groups of related settings, which are displayed in a view beneath the toolbar. These groupings are known as preference panes. cite: “Preferences Windows”, macOS Human Interface Guidelines, on 2018-12 ؀ڥઃఆ΢Πϯυ΢͸ΞϓϦέʔγϣϯͷ؀ڥΛௐ੔͢ΔϞʔυϨεͷμΠΞϩά Ͱ͋ΔɻҰൠతʹ؀ڥઃఆ΢Πϯυ΢͸ɺؔ܎͢ΔઃఆͷάϧʔϓΛ੾Γସ͑ΔϘ λϯΛ಺แͨ͠πʔϧόʔΛ͍࣋ͬͯΔɻ͜ΕΒάϧʔϓ͸؀ڥઃఆϖΠϯͱͯ͠ ஌ΒΕΔɻ Preferences Windows
  11. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT cite: “Preferences Windows”,

    macOS Human Interface Guidelines, on 2018-12 Preferences Windows – Apply preference changes immediately. – Disable the Minimize and Zoom buttons. – Make sure the toolbar is always visible and noncustomizable. – Indicate the active toolbar button. – Update the window's title to reflect the currently visible preference pane. – Restore the last viewed preference pane. ࠷ޙʹදࣔͨ͠ϖΠϯΛอ࣋͢Δɻ ݱࡏදࣔ͞Ε͍ͯΔϖΠϯΛ΢Πϯυ΢λΠτϧʹ͢Δɻ ΞΫςΟϒͳϖΠϯͷπʔϧόʔϘλϯΛબ୒͢Δɻ ͭͶʹπʔϧόʔΛදࣔ͠ɺ͔ͭฤूෆՄʹ͢Δɻ ࠷খԽϘλϯͱζʔϜϘλϯ͸ແޮʹ͢Δɻ ઃఆͷมߋ͸͙͢ʹ൓ө͢Δɻ
  12. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ? ؀ڥઃఆ΢Πϯυ΢ͷجຊͷৼΔ෣͍ ࠷ޙʹදࣔͨ͠ϖΠϯΛอ࣋͢Δɻ ݱࡏදࣔ͞Ε͍ͯΔϖΠϯΛ΢Πϯυ΢λΠτϧʹ͢Δɻ

    ΞΫςΟϒͳϖΠϯͷπʔϧόʔϘλϯΛબ୒͢Δɻ ͭͶʹπʔϧόʔΛදࣔ͠ɺ͔ͭฤूෆՄʹ͢Δɻ ࠷খԽϘλϯͱζʔϜϘλϯ͸ແޮʹ͢Δɻ ઃఆͷมߋ͸͙͢ʹ൓ө͢Δɻ ӈԼʹϔϧϓϘλϯΛ෇͚Δɻ ϖΠϯഎܠ͸σϑΥϧτ৭ɻ σεΫτοϓʹରͯ͠ηϯλϦϯάͯ͠දࣔ͢Δɻ EscΩʔͰ΢Πϯυ΢Λด͡Δɻ esc
  13. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ؀ڥઃఆ΢Πϯυ΢ͷϖΠϯ੾Γସ͑

  14. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ϖΠϯ੾Γସ͑ͷྲྀΕ General Advanced πʔϧόʔΞΠίϯΛΫϦοΫ

    ϖΠϯඇදࣔ ΢Πϯυ΢มܗ ϖΠϯදࣔ ΢Πϯυ΢λΠτϧมߋ ① ② ③ ΫϦοΫͨ͠ΞΠίϯΛબ୒ General Advanced
  15. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp – ͜Μͳʹڧ͍ఆܕ͕͋ΔͷʹɺͦͷৼΔ෣͍Λఏڙ͢Δ Cocoa API ͸ ɹ

    ɹɻ – ͱ͜ΖͰɿmacOS ։ൃऀ͸ Interface Builder ͕޷͖ɻ – ؀ڥઃఆ΢Πϯυ΢͸Ұ൪ Interface Builder ͕׆͖Δ✨ͱ͜Ζɻ ؀ڥઃఆ΢Πϯυ΢Λ࡞Δ Modern ✔ Storyboard ✔ NSTabViewController Legacy ✔ Xib ✔ NSWindowController →みんな独自に実装しているのだ(マジかよ... ੲ͔Β ͳ͍ ͩͬͯ Cocoa Binding ͸
 ɹɹɹɹɹ ɹɹ࠷ߴͩ΋ͷɻ
  16. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp $PDPB όΠϯσΟϯά ͩͬͯ Cocoa Binding ͸
 ɹɹɹɹɹ

    ɹɹ࠷ߴͩ΋ͷɻ – Key-Value Observation Λར༻ͨ͠ View ͱ Model-Controller ૚ͷಉظػೳɻ – macOS ʹ͔͠ͳ͍ɻ – Interface Builder ͔Βར༻Մೳ Moof! Input Field UserDefaults Text Field bind bind Moof! NSObjectベースである必要がある Mac OS X 10.3 Panther から存在 → 冗長なグルーコードが不要に。 .value [“message”] .value Model View View
  17. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp Let’s code! https://github.com/1024jp/Preferences-Demo

  18. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp 4UPSZCPBSE ࣮૷ͷ᠘ ⚠ NSTabViewItem.label ͕ϩʔΧϥΠζ͞Εͳ͍ɻ࠷ѱͩɻ ⚠

    tabView(tabView:willSelect:) ͰͷεΠον͸ macOS 10.12↓ Ͱࢮ͵ɻ – “endAppearanceTransition called too many times” ͩͦ͏Ͱ͢ɻ – macOS 10.13 Ҏ্͔͠૬खʹ͠ͳ͍ͳΒؾʹ͠ͳͯ͘Α͍ɻ – tabView(tabView:willSelect:)  Ͱ͸  tabViewItem.frame  Λर͏͚ͩʹͯ͠ tabView(tabView:didSelect:) ͰεΠον͠Α͏ɻ → viewDidLoad() あたりで手動でローカライズしよう。 → macOS 10.12を切ろう。
  19. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ·ͱΊ – ࠷ޙʹදࣔͨ͠ϖΠϯΛอ࣋͢Δɻ –

    ݱࡏදࣔ͞Ε͍ͯΔϖΠϯΛ΢Πϯυ΢λΠτϧʹ͢Δɻ – ΞΫςΟϒͳϖΠϯͷπʔϧόʔϘλϯΛબ୒͢Δɻ – ͭͶʹπʔϧόʔΛදࣔ͠ɺ͔ͭฤूෆՄʹ͢Δɻ – ࠷খԽϘλϯͱζʔϜϘλϯ͸ແޮʹ͢Δɻ – ઃఆͷมߋ͸͙͢ʹ൓ө͢Δɻ ʴ – ӈԼʹϔϧϓϘλϯΛ෇͚Δɻ – ϖΠϯഎܠ͸σϑΥϧτ৭ɻ – σεΫτοϓʹରͯ͠ηϯλϦϯάͯ͠දࣔ͢Δɻ – EscΩʔͰ΢Πϯυ΢Λด͡Δɻ by ౒ྗ໨ඪ by HIG  Cocoa Binding ͸࠷ߴɻ
  20. macOS native ؀ڥઃఆͷ࡞๏ © 2018 1024jp ͓ Θ Γ