Skip to content

Commit

Permalink
Hide the DesktopElement while dragging it (sometimes it still reappea…
Browse files Browse the repository at this point in the history
…rs!).
  • Loading branch information
informatimago committed Aug 4, 2019
1 parent 8689a46 commit 8fbc65b
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 31 deletions.
Expand Up @@ -34,13 +34,31 @@
<rect key="frame" x="0.0" y="0.0" width="1366" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="twP-ZY-ZlX" customClass="DesktopView" customModule="SchmidtSynthesizerLibrarian" customModuleProvider="target">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uYF-vl-hXe" customClass="DesktopScrollView" customModule="SchmidtSynthesizerLibrarian" customModuleProvider="target">
<rect key="frame" x="0.0" y="20" width="1366" height="954"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="twP-ZY-ZlX" customClass="DesktopView" customModule="SchmidtSynthesizerLibrarian" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="1366" height="954"/>
<color key="backgroundColor" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
</subviews>
<constraints>
<constraint firstItem="twP-ZY-ZlX" firstAttribute="centerY" secondItem="uYF-vl-hXe" secondAttribute="centerY" id="2DC-Nw-kKo"/>
<constraint firstItem="twP-ZY-ZlX" firstAttribute="top" secondItem="uYF-vl-hXe" secondAttribute="top" id="Ide-sm-mxa"/>
<constraint firstItem="twP-ZY-ZlX" firstAttribute="leading" secondItem="uYF-vl-hXe" secondAttribute="leading" id="ek2-HR-MoH"/>
<constraint firstAttribute="trailing" secondItem="twP-ZY-ZlX" secondAttribute="trailing" id="lZV-Ob-PPw"/>
<constraint firstAttribute="bottom" secondItem="twP-ZY-ZlX" secondAttribute="bottom" id="o7f-KD-3vY"/>
<constraint firstItem="twP-ZY-ZlX" firstAttribute="centerX" secondItem="uYF-vl-hXe" secondAttribute="centerX" id="yHj-01-QOt"/>
</constraints>
</scrollView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="uYF-vl-hXe" secondAttribute="trailing" id="AHc-Hm-uzI"/>
<constraint firstItem="uYF-vl-hXe" firstAttribute="bottom" secondItem="bBJ-wA-yMW" secondAttribute="bottom" id="YVZ-0O-k0g"/>
<constraint firstItem="uYF-vl-hXe" firstAttribute="leading" secondItem="6EQ-4f-ysK" secondAttribute="leading" id="iig-Os-fS0"/>
<constraint firstItem="uYF-vl-hXe" firstAttribute="top" secondItem="bBJ-wA-yMW" secondAttribute="top" id="x4l-jr-aLh"/>
</constraints>
<viewLayoutGuide key="safeArea" id="bBJ-wA-yMW"/>
</view>
<tabBarItem key="tabBarItem" title="Desktop" id="BE4-09-FXw" userLabel="Desktop"/>
Expand Down
Expand Up @@ -12,10 +12,9 @@ class Bank: NamedObject {

var data:NSData?
var programs:[Program]=[]

required init(name:String){
super.init(name:name)
}


}
Expand Up @@ -12,7 +12,7 @@ class BankSet: NamedObject {

var data:NSData?
var banks:[Bank]=[]

required init(name:String){
super.init(name:name)
}
Expand Down
Expand Up @@ -9,10 +9,13 @@
import UIKit

class Category: NSObject {

var name:String
var color:Int

init(color:Int,name:String){
self.name=name
self.color=color
}

}
Expand Up @@ -9,10 +9,11 @@
import UIKit

class NamedObject: NSObject {

var name="Unnamed"

required init(name:String){
super.init()
self.name=name
}
}
Expand Up @@ -12,7 +12,7 @@ class Program: NamedObject {

var data:NSData?
var category:Category?

required init(name:String){
super.init(name:name)
}
Expand Down
Expand Up @@ -9,7 +9,7 @@
import UIKit

class Synthesizer: NamedObject {

required init(name:String){
super.init(name:name)
}
Expand Down
Expand Up @@ -8,7 +8,6 @@

import UIKit


func typeLetter(_ instance:NamedObject) -> String {
if(instance is Directory<Program>) {return "DP"}
if(instance is Directory<Bank>) {return "DB"}
Expand Down
Expand Up @@ -11,7 +11,7 @@ import UIKit
class BankSetWindow: DesktopWindow {

var set:BankSet?

init(frame:CGRect,name:String,set:BankSet){
super.init(frame:frame,name:name)
self.set=set
Expand Down
Expand Up @@ -11,11 +11,11 @@ import UIKit
class BankWindow: DesktopWindow {

var bank:Bank?

init(frame:CGRect,name:String,bank:Bank){
super.init(frame:frame,name:name)
self.bank=bank

// Add subviews for programs
var irect=CGRect(x:10,y:30,width:frame.size.width-20,height:20)
var i=1
Expand All @@ -25,7 +25,7 @@ class BankWindow: DesktopWindow {
i+=1
}
}

required init?(coder:NSCoder){
super.init(coder:coder)
}
Expand Down
Expand Up @@ -19,7 +19,7 @@ func pointAdd(_ a:CGPoint,_ b:CGPoint) -> CGPoint{
class DesktopElement: UIView,DropTarget
// ,UIDragInteractionDelegate,NSItemProviderWriting
{

var name="Untitled"

init(frame:CGRect,name:String){
Expand Down
Expand Up @@ -9,9 +9,9 @@
import UIKit

class DesktopIcon: DesktopElement {

var icon:UIImage?

init(frame:CGRect,name:String,icon:UIImage){
self.icon=icon
super.init(frame:frame,name:name)
Expand All @@ -20,7 +20,7 @@ class DesktopIcon: DesktopElement {
required init?(coder:NSCoder){
super.init(coder:coder)
}

override func draw(_ rect: CGRect) {
icon?.draw(at:frame.origin)
name.draw(in:frame)
Expand Down
Expand Up @@ -46,14 +46,14 @@ class DesktopInstance: DesktopElement {
icon:(UIImage(contentsOfFile:"schmidt_detail_01")!)));
}


/*
completeDrop startDrop
file -> directory move (option)copy
 file -> desktop alias
file -> desktop alias
directory -> desktop alias
program file -> bank file insert program (select program slot in bank file)
Expand All @@ -73,7 +73,7 @@ class DesktopInstance: DesktopElement {
item -> trash remove from desktop
category -> program set program category
program -> category set program category
program -> category set program category
*/

Expand Down
Expand Up @@ -76,11 +76,13 @@ class DesktopView: UIView,DropTarget {
isDropDestination=false
element.frame=CGRect(origin:pointAdd(element.frame.origin,pointMinus(to,from)),
size:element.frame.size)
element.isHidden=false
setNeedsDisplay() }

func cancelDrop(element:DesktopElement,from:CGPoint){
print("cancelDrop element:\(element) from:\(from)")
isDropDestination=false
element.isHidden=false
setNeedsDisplay() }

// Drag-and-Drop:
Expand All @@ -99,6 +101,7 @@ class DesktopView: UIView,DropTarget {
originalFrame=element.superview!.convert(element.frame,to:self)
currentElement=element
currentImageView=element.imageView()
element.isHidden=true
addSubview(currentImageView!)
setNeedsDisplay() }

Expand Down Expand Up @@ -138,7 +141,7 @@ class DesktopView: UIView,DropTarget {

func updateTarget(touchLocation:CGPoint,with event:UIEvent?,update:(DropTarget,CGPoint)->Void){
var newTarget=hitTest(touchLocation,with:event) as? DropTarget
if newTarget == nil {
if (newTarget == nil) || (currentElement == newTarget as? DesktopElement) {
newTarget=self }
let new=newTarget as! UIView
if currentTarget != nil {
Expand Down
Expand Up @@ -9,9 +9,9 @@
import UIKit

class DesktopWindow: DesktopElement {

var contents:UIView?

override init(frame:CGRect,name:String){
super.init(frame:frame,name:name)
}
Expand All @@ -24,13 +24,13 @@ class DesktopWindow: DesktopElement {
drawWindowFrame()
super.draw(rect) // draw contents
}

func drawWindowFrame(){
let color:UIColor=UIColor.black
let path:UIBezierPath=UIBezierPath(rect:bounds)
color.set()
path.stroke()
name.draw(in:bounds)
}

}
6 changes: 3 additions & 3 deletions sources/librarian/loader.lisp
@@ -1,7 +1,7 @@
(cd #P"~/works/synth/schmidt/sources/")
(cd #P"~/works/synth/schmidt/sources/librarian/")

(push #P"~/works/synth/CoreMIDI/" asdf:*central-registry*)
(push #P"~/works/synth/schmidt/sources/" asdf:*central-registry*)
(push #P"~/works/synth/CoreMIDI/" asdf:*central-registry*)
(push #P"~/works/synth/schmidt/sources/librarian/" asdf:*central-registry*)

(ql:quickload :com.informatimago.synthesizer.schmidt.librarian)
(in-package :com.informatimago.synthesizer.schmidt)
Expand Down

0 comments on commit 8fbc65b

Please sign in to comment.