Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Commit

Permalink
Start on model
Browse files Browse the repository at this point in the history
  • Loading branch information
owickstrom committed Apr 15, 2018
0 parents commit f1ea660
Show file tree
Hide file tree
Showing 10 changed files with 1,678 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
/dist
/dist-newstyle
/.stack-work
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,4 @@
# FastCut Changelog

* **0.1.0***
- Initial version of FastCut!
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Setup.hs
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
31 changes: 31 additions & 0 deletions fastcut.cabal
@@ -0,0 +1,31 @@
name: fastcut
version: 0.1.0
synopsis: High-productivity video and audio editing
-- description:
license: MPL-2.0
license-file: LICENSE
author: Oskar Wickström
maintainer: oskar.wickstrom@gmail.com
copyright: Oskar Wickström
category: Multimedia
build-type: Simple
cabal-version: >=1.10

extra-source-files: CHANGELOG.md
data-dir: src/data
data-files: gui.glade

executable fastcut
main-is: Main.hs
other-modules: Paths_fastcut
, FastCut.Scene
-- other-extensions:
build-depends: base >=4.10 && <4.12
, gi-gobject
, gi-gtk
, haskell-gi
, haskell-gi-base
, text
, time
hs-source-dirs: src
default-language: Haskell2010
58 changes: 58 additions & 0 deletions src/FastCut/Scene.hs
@@ -0,0 +1,58 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE StandaloneDeriving #-}
module FastCut.Scene where

import Data.Text (Text)
import qualified Data.Text as Text
import Data.Time.Clock (NominalDiffTime)

type Duration = NominalDiffTime

data ClipMetadata = ClipMetadata
{ name :: Text
, path :: FilePath
, duration :: Duration
} deriving (Eq, Show)

data ClipType = Video | Audio

data Clip (a :: ClipType) where
VideoClip :: ClipMetadata -> Clip Video
AudioClip :: ClipMetadata -> Clip Audio
VideoGap :: Duration -> Clip Video
AudioGap :: Duration -> Clip Audio

deriving instance Eq (Clip a)
deriving instance Show (Clip a)

data Sequence
= Sequenced [Sequence]
| Composed [Clip Video] [Clip Audio]
deriving (Eq, Show)

single :: Clip a -> Sequence
single c = case c of
VideoClip{} -> Composed [c] []
VideoGap{} -> Composed [c] []
AudioClip{} -> Composed [] [c]
AudioGap{} -> Composed [] [c]

instance Semigroup Sequence where
Sequenced a <> Sequenced b = Sequenced (a <> b)
Sequenced a <> b = Sequenced (a <> [b])
a <> Sequenced b = Sequenced (a : b)
a <> b = Sequenced [a, b]

instance Monoid Sequence where
mempty = Sequenced []

data Scene = Scene { name :: Text, sequence :: Sequence }
deriving (Eq, Show)

testClip = VideoClip (ClipMetadata "hello" "/tmp/hello.mp4" 5)
46 changes: 46 additions & 0 deletions src/Main.hs
@@ -0,0 +1,46 @@
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}

import Data.GI.Base
import Data.GI.Base.Properties
import Data.Maybe
import Data.Text
import GI.GObject
import qualified GI.Gtk as Gtk
import GI.Gtk.Objects.Window (windowResize)

import Paths_fastcut

main :: IO ()
main = do
Gtk.init Nothing

gladeFile <- getDataFileName "gui.glade"
builder <- Gtk.builderNewFromFile (pack gladeFile)

window <- builderGetObject Gtk.Window builder "window"
fileChooserButton <- builderGetObject Gtk.Button builder "file-chooser-button"

on window #destroy Gtk.mainQuit

windowResize window 640 480


on fileChooserButton #clicked $ set
fileChooserButton
[#sensitive := False, #label := "Thanks for clicking me"]

#showAll window

Gtk.main

builderGetObject
:: (GI.GObject.GObject b, Gtk.IsBuilder a)
=> (Data.GI.Base.ManagedPtr b -> b)
-> a
-> Prelude.String
-> IO b
builderGetObject objectTypeClass builder objectId =
fromJust
<$> Gtk.builderGetObject builder (pack objectId)
>>= Gtk.unsafeCastTo objectTypeClass

0 comments on commit f1ea660

Please sign in to comment.