Share
Embed
ツールバーアイコンとその実装 / Toolbar Icons on macOS
macOS native symposium (http://macos-native.github.io) #01 登壇資料
macOSアプリケーションのウインドウ上部に並ぶツールバーボタンは、macOSらしさを特徴付けています。ツールバーアイコンの歴史的変遷や用途によるデザインの違いを考察しながら、現在の最新システムにおけるネイティブらしいツールバーの実装方法をさぐります。
1024jp
August 29, 2018
Transcript
56 slides
-
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ࣗݾհ KQ NBD04 ΞϓϦέʔγϣϯઐͷϗϏʔ։ൃऀɻ 044 ϓϩδΣΫτӡӦ͔ΒϓϩάϥϛϯάɺΞΠίϯͷσ βΠϯ·ͰɺNBD04 ͷΞϓϦέʔγϣϯ։ൃʹؔΘΔ͜
ͱͳΒશ෦ΔϚϯͰ͋Δɻ ͤΜʹ͡Ύ͏ΑΜ ͐͡ʔͽʔ 本業ではないよ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ࣗݾհ CotEditor Gapplin BathyScaphe
ϑΫϩ Sparkle icon work application work plain-text editor SVG viewer 5ch browser twitter client updater 2014年に 正式引き継ぎ サポーtメンバー (主にデザイン・UI) アイコン提供だけしたやつ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ࠓͷτϐοΫ ѻ͏ – πʔϧόʔΞΠίϯͷ༷
– πʔϧόʔΞΠίϯͷྺ࢙ – AppleΞϓϦέʔγϣϯʹ͓͚ΔπʔϧόʔΞΠίϯͷ࣮ͷ͞Εํ – ݱࡏͷྑ͍πʔϧόʔΞΠίϯͷ͋Γํ ѻΘͳ͍ – πʔϧόʔͦͷͷͷڍಈ࣮ – ΞΠίϯܕʢϘλϯܕʣҎ֎ͷπʔϧόʔ߲ – ϝχϡʔɾϥϕϧͳͲπʔϧόʔ߲ʹؚ·ΕΔΞΠίϯ෦Ҏ֎ͷཁૉ – Mojaveʹؔ͢Δ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔ Toolbar Tab Bar
Status Bar Sidebar Title Bar -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT A toolbar resides
in the frame at the top of a window—below or integrated with the title bar—and provides convenient access to frequently used commands and features within an app window. cite: “Toolbars”, macOS Human Interface Guidelines, on 2018-08 Toolbar πʔϧόʔɺΠϯυ্෦ͷϑϨʔϜʢλΠτϧόʔͷԼ·ͨಉྻʣ ʹଘࡏ͠ɺΞϓϦέʔγϣϯΠϯυͷΑ͘͏ίϚϯυػೳͷศར ͳΞΫηεΛఏڙ͢Δɻ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT cite: “Toolbars”, macOS
Human Interface Guidelines, on 2018-08 Toolbar Items – Provide toolbar items for the things people do most often. Ϣʔβ͕ͬͱ͏ػೳΛπʔϧόʔ߲ͱͯ͠ఏڙ͢Δɻ – Include image buttons or system controls, but not both. ΠϝʔδϘλϯ͔γεςϜίϯτϩʔϧͲͪΒ͔ͷΈΛ͍ࠞࡏͤ͞ͳ͍ɻ – Use only toolbar-specific system control styles. πʔϧόʔ༻ͷγεςϜίϯτϩʔϧελΠϧͷΈΛ͏ɻ – Make every toolbar item available as a menu command. ͯ͢ͷπʔϧόʔ߲ϝχϡʔίϚϯυʹଘࡏ͠ͳ͍ͱ͚ͳ͍ɻ – Provide a short, descriptive label for every toolbar item. ͯ͢ͷπʔϧόʔ߲ʹ͘Θ͔Γ͍͢ϥϕϧΛ͚ͭΔɻ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp "QQ,JU Ͱͷ࣮ (private) NSToolbar NSWindow
NSTitlebarView NSToolbarItem NSToolbarItem NSToolbarItem _NSToolbarViewClipView NSToolbarItemViewer subview subview subview -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔͷྺ࢙ cite: “Today in
Apple history: NeXT customers get early taste of OS X”, Cult of Mac, 2017-09 https://www.cultofmac.com/503084/today-apple-history-next-customers-get-early-taste-os-x/ NeXTSTEP -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔͷྺ࢙ cite: Mac OS
X Public Beta, GUIdebook, on 2018-07 https://guidebookgallery.org/screenshots/macosxpb Mac OS X Public Beta -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔͷྺ࢙ cite: Mac OS
X 10.0.4, GUIdebook, on 2018-07 https://guidebookgallery.org/screenshots/macosx100 Mac OS X 10.0 Cheetah -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp /45PPMCBS*UFN ͷ࣮ NSToolbarItem – label
– image – view – tag – target – action – menuForm\ Representation – … – validate() -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp /45PPMCBS*UFN ͷ࣮ NSToolbarItem – label
– image – view – tag – target – action – menuForm\ Representation – … – validate() Image type Control type NSImage NSButton NSSearchField Search NSPopUpButton Menu NSSegmentedControl A B HIG 推奨 NSView Custom View な ん で も other NSView subclasses -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp /45PPMCBS*UFN ͷ࣮ NSToolbarItem – label
– image – view – tag – target – action – menuForm\ Representation – … – validate() Image type Control type NSImage NSButton NSSearchField Search NSPopUpButton Menu NSSegmentedControl A B HIG 推奨 NSView Custom View な ん で も other NSView subclasses ࠶ܝ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ͪΐͬͱલ .BWFSJDLT ͷπʔϧόʔ Pages
Finder Sketch ڥઃఆ (Safari) ϒϥβܕ app ڥઃఆ ΤσΟλܕ app -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ݱࡏ )JHI4JFSSB ͷπʔϧόʔ Pages
Finder Sketch ڥઃఆ (Safari) ϒϥβܕ app ڥઃఆ ΤσΟλܕ app -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔ߲ͷछྨͱ༻్ͷมભ ॳظ Mac OS
X தظ OS X ݱࡏ macOS ϒϥβܕɹ ΤσΟλܕ ڥઃఆ Button (Template) Button (Color) Image Button (Template) Image Image Image Image Image -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔ߲ Button (Template) Button
(Color) Image ڥઃఆ ϒϥβܕ ΞϓϦέʔγϣϯ ΤσΟλܕ ΞϓϦέʔγϣϯ ݱࡏͷ macOS (10.13) Ͱɿ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ΧϥʔϘλϯΞΠίϯͷखຊ Pages / Keynote
/ Numbers Apple 製でカラーなのはこの3つのみ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp Πϝʔδܕπʔϧόʔ߲ Button (Template) Button
(Color) Image ڥઃఆ ϒϥβܕ ΞϓϦέʔγϣϯ ΤσΟλܕ ΞϓϦέʔγϣϯ ݱࡏͷ macOS (10.13) Ͱɿ ࠶ܝ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp Πϝʔδܕπʔϧόʔ߲ – NSToolbarItem ͷجຊܕ –
.image ʹ NSImage Ληοτ͢Δ͚ͩͷ ୯७ͳ࣮ – macOS (Mac OS X) ͷ࠷ॳͷࠒɺ ΄΅ͯ͢ͷπʔϧόʔ߲͜ͷελΠϧ ͩͬͨ – ݱࡏ Apple ڥઃఆΠϯυ ʹͷΈ࠾༻ – 3rd party ͷΞϓϦέʔγϣϯͰɺ ࠓͰϝΠϯΠϯυʹ࠾༻͍ͯ͠Δ ͜ͱ͕͋Δ NSToolbarItem – label – image – view – tag – target – action – menuForm\ Representation – … – validate() NSImage 今後は環境設定にのみ採用すべき、かな? -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ڥઃఆπʔϧόʔ Apple ???
Finder Safari Keynote Mail Terminal Xcode GarageBand iTunes Advanced? センタリング(iTunes は特殊) -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ڥઃఆπʔϧόʔ ίϯλΫτγϟυܕ υϩοϓγϟυܕ ڥઃఆΞΠίϯͷڧ͍ఆܕελΠϧɿ
✔ ۩తͳϞνʔϑ ✔ ࣮ࣸతͳඳը ✔ ΠϯυʹӨΛམͱ͢ 両方アリだけど最近はドロップシャドウ型の方が優勢 →ウインドウ(物体)の上にアイコン(物体)が載ってる 厚みがある -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ڥઃఆπʔϧόʔ Tower Unclutter CotEditor
Sketch 3rd party ちょっとフラット すぎるかなぁ… Rが丸すぎる お手本的(自画自賛) -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ڥઃఆπʔϧόʔ Marked 2 OmniGraffle
mi Twitterrific 3rd party -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ڥઃఆπʔϧόʔ Fantastical Pixelmator Sketch
Transmit Twitterrific CotEditor NSPreferencesGeneral Keynote (だって公式のダサいんだもん…) Ұൠ (General pane) ༻ͷΞΠίϯಠࣗʹ࡞Γ͗͢ official app specific ??? – Apple ͕͍͜ͱ NSPreferencesGeneral ͷ Retina ൛Λ࡞Δͳ͔͔ͬͨΒɺ ࣌ Retina ରԠͷͨΊʹಠࣗʹ࡞Β͟ΔΛಘͳ͔ͬͨͱ͍͏ྺ࢙తܦҢʢগ͠ʣ͋Δ – ಉ͡ Apple ఏڙͰ NSAdvanced ΘΓͱΘΕΔʢ͔͍͍͔ͬ͜Βʣ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ڥઃఆπʔϧόʔc·ͱΊ ڥઃఆͷπʔϧόʔΞΠίϯɿ ✔ 32px
× 32px ͷ Image ελΠϧ ✔ ڧ͍ఆܕ͕͋Δ ✔ ཱମతɾ࣮ࣸతʹඳ͘ ✔ ʢඞཁʹԠͯ͡ʣΠϯυʹӨམͱ͢ ✔ γεςϜڥઃఆͷΞΠίϯͱಉ͡ελΠϧ ✔ σϑΥϧτͷ General pane ΞΠίϯΧοίΘΔ͍ 独自色は出すべきでない(と個人的には思う) ( ) -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp Ϙλϯܕπʔϧόʔ߲ Button (Template) Button
(Color) Image ڥઃఆ ϒϥβܕ ΞϓϦέʔγϣϯ ΤσΟλܕ ΞϓϦέʔγϣϯ ݱࡏͷ macOS (10.13) Ͱɿ ࠶ܝ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp Ϙλϯܕπʔϧόʔ߲ Template Color ϒϥβܕ
ΞϓϦέʔγϣϯ ΤσΟλܕ ΞϓϦέʔγϣϯ ্࣮ͷҧ͍ .image ͕ template ͔Ͳ͏͔ͷΈɻ → ػೳಉ͡ͳͷͰɺΠϯυͷੑ࣭ʹ߹Θͤͯબ΅͏ɻ → ͜ͷ2ͭࠞͥͯ OKɻ 環境設定以外のウインドウのツールバーアイコンなら ひとまずこれ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ςϯϓϨʔτܕͱΧϥʔܕͷ͍͚ Finder ϒϥβܕ Pages
ΤσΟλܕ App ͷ ৗ༻ੑ ૢ࡞ͷ ಛҟੑ App ͷ ৗ༻ੑ ૢ࡞ͷ ಛҟੑ पғͱͷ ௐੑ ݸʑͷ ࣝผੑ पғͱͷ ௐੑ ݸʑͷ ࣝผੑ ςϯϓϨʔτܕ Χϥʔܕ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp Ϙλϯܕπʔϧόʔ߲ cf. OS Xʹ͓͚ΔπʔϧόʔΞΠίϯͷ͍͚
-ϰΥϧϑϩογϡ http://wolfrosch.com/text/2013/04/26 -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp Ϙλϯܕπʔϧόʔ߲ͷ࣮ NSToolbarItem – label
– image – view – tag – target – action – menuForm\ Representation – … – validate() Image type item Button type item NSButton – title – image – tag – … + … NSImage NSImage NSToolbarItem – label – image – view – tag – target – action – menuForm\ Representation – … – validate() -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp Ϙλϯܕπʔϧόʔ߲ NSButton NSSegmentedControl ✔
ΫϦοΫͰ ϝχϡʔग़ݱ ✔ ΫϦοΫͰ ΞΫγϣϯ ✔ ӈଆΫϦοΫͰ ϝχϡʔग़ݱ ✔ ෳίϚϯυͷ άϧʔϓԽ – ΠϝʔδܕΑΓϘλϯܕͷํ͕ෳࡶͳૢ࡞͕ࣔͤΔɻ – ͍ΘΏΔϘλϯܕͳݟͨͰ͍Ζ͍Ζ͋Δɻ ཁ subclass NSMenu クリックして直ぐにメニューを出せない ΠϝʔδܕͰ Ͱ͖Δ Πϝʔδܕͩͱ Ͱ͖ͳ͍ A B -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔ߲ͷ WBMJEBUJPO πʔϧόʔ߲ͷvalidationɺtargetͱͳΔΦϒδΣΫτͷɿ – validateToolbarItem(_
item: NSToolbarItem) – validateUserInterfaceItem(_: NSValidatedUserInterfaceItem) ͲͪΒ͔Ͱߦ͏ɻ ūƃũƄ!? ⚠πʔϧόʔ߲͕ ϘλϯܕͩͱݺΕͳ͍ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp πʔϧόʔ߲ͷ WBMJEBUJPO NSButton – title
– image – tag – … + … NSImage NSToolbarItem – label – image – view – tag – target – action – menuForm\ Representation – … – validate() -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp - (void) validate {
BOOL enabled = YES; id target; /* No validation for custom views */ if (_view) return; target = [NSApp targetForAction: [self action] to: [self target] from: self]; if (target == nil || ![target respondsToSelector: [self action]]) { enabled = NO; } else if ([target respondsToSelector: @selector(validateToolbarItem:)]) { enabled = [target validateToolbarItem: self]; } else if ([target respondsToSelector: @selector(validateUserInterfaceItem:)]) { enabled = [target validateUserInterfaceItem: self]; } [self setEnabled: enabled]; } (OV4UFQ Ͱͷ /45PPMCBS*UFN ͷ࣮ .view がセットされてる時はここで抜ける べんり! ObjC -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ϘλϯλΠϓͷ߲Λ WBMJEBUF ͢Δ class ControlToolbarItem: NSToolbarItem
{ override func validate() { (self.view as! NSControl).isEnabled = { guard let action = self.action, let validator = NSApp.target(forAction: action, to: self.target, from: self) as AnyObject? else { return false } switch validator { case let validator as NSToolbarItemValidation: return validator.validateToolbarItem(self) case let validator as NSUserInterfaceValidations: return validator.validateUserInterfaceItem(self) default: return true } }() } } Swift -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ·ͱΊ Button (Template) Button
(Color) Image ڥઃఆ ϒϥβܕ ΞϓϦέʔγϣϯ ΤσΟλܕ ΞϓϦέʔγϣϯ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp )VNBO*OUFSGBDF(VJEFMJOFT cite: “Toolbars”, macOS
Human Interface Guidelines, on 2018-08 Toolbar Items – Provide toolbar items for the things people do most often. Ϣʔβ͕ͬͱ͏ػೳΛπʔϧόʔ߲ͱͯ͠ఏڙ͢Δɻ – Include image buttons or system controls, but not both. ΠϝʔδϘλϯ͔γεςϜίϯτϩʔϧͲͪΒ͔ͷΈΛ͍ࠞࡏͤ͞ͳ͍ɻ – Use only toolbar-specific system control styles. πʔϧόʔ༻ͷγεςϜίϯτϩʔϧελΠϧͷΈΛ͏ɻ – Make every toolbar item available as a menu command. ͯ͢ͷπʔϧόʔ߲ϝχϡʔίϚϯυʹଘࡏ͠ͳ͍ͱ͚ͳ͍ɻ – Provide a short, descriptive label for every toolbar item. ͯ͢ͷπʔϧόʔ߲ʹ͘Θ͔Γ͍͢ϥϕϧΛ͚ͭΔɻ ࠶ܝ -
macOS native πʔϧόʔΞΠίϯͱͦͷ࣮ © 2018 1024jp ࢀߟจݙ – Human Interface
Guidelines https://developer.apple.com/design/human-interface-guidelines/macos/ – Core GNUstep developers interview http://www.roard.com/docs/interview/ – Guidebook -Graphical User Interface Gallery https://guidebookgallery.org – OS Xʹ͓͚ΔπʔϧόʔΞΠίϯͷ͍͚ -ϰΥϧϑϩογϡ http://wolfrosch.com/text/2013/04/26