diff options
Diffstat (limited to 'src/Chelleport')
| -rw-r--r-- | src/Chelleport/Control.hs | 12 | ||||
| -rw-r--r-- | src/Chelleport/Draw.hs | 5 | ||||
| -rw-r--r-- | src/Chelleport/KeySequence.hs | 3 | ||||
| -rw-r--r-- | src/Chelleport/Types.hs | 4 | ||||
| -rw-r--r-- | src/Chelleport/View.hs | 6 |
5 files changed, 21 insertions, 9 deletions
diff --git a/src/Chelleport/Control.hs b/src/Chelleport/Control.hs index 7b58fdf..0fd01cc 100644 --- a/src/Chelleport/Control.hs +++ b/src/Chelleport/Control.hs @@ -26,6 +26,16 @@ currentMousePosition _ctx = do isKeyPress :: SDL.KeyboardEventData -> Bool isKeyPress = (== SDL.Pressed) . SDL.keyboardEventKeyMotion +isKeyRelease :: SDL.KeyboardEventData -> Bool +isKeyRelease = (== SDL.Released) . SDL.keyboardEventKeyMotion + +eventToKeycode :: SDL.KeyboardEventData -> SDL.Keycode +eventToKeycode = SDL.keysymKeycode . SDL.keyboardEventKeysym + isKeyPressWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool isKeyPressWith keyboardEvent keyCode = - isKeyPress keyboardEvent && SDL.keysymKeycode (SDL.keyboardEventKeysym keyboardEvent) == keyCode + isKeyPress keyboardEvent && eventToKeycode keyboardEvent == keyCode + +isKeyReleaseWith :: SDL.KeyboardEventData -> SDL.Keycode -> Bool +isKeyReleaseWith keyboardEvent keyCode = + isKeyRelease keyboardEvent && eventToKeycode keyboardEvent == keyCode diff --git a/src/Chelleport/Draw.hs b/src/Chelleport/Draw.hs index 9ace9da..4ee5b31 100644 --- a/src/Chelleport/Draw.hs +++ b/src/Chelleport/Draw.hs @@ -23,7 +23,10 @@ colorHighlight :: SDL.V4 Word8 colorHighlight = colorAccent colorGridLines :: SDL.V4 Word8 -colorGridLines = SDL.V4 127 29 29 150 +colorGridLines = colorGray -- SDL.V4 127 29 29 150 + +colorFocusLines :: SDL.V4 Word8 +colorFocusLines = colorLightGray colorAxisLines :: SDL.V4 Word8 colorAxisLines = colorAccent diff --git a/src/Chelleport/KeySequence.hs b/src/Chelleport/KeySequence.hs index 9f7b5db..d92fe0e 100644 --- a/src/Chelleport/KeySequence.hs +++ b/src/Chelleport/KeySequence.hs @@ -53,9 +53,6 @@ generateGrid seed (rows, columns) hintKeys toKeyChar :: SDL.Keycode -> Maybe Char toKeyChar = (`Map.lookup` keycodeMapping) -eventToKeycode :: SDL.KeyboardEventData -> SDL.Keycode -eventToKeycode = SDL.keysymKeycode . SDL.keyboardEventKeysym - keycodeMapping :: Map.Map SDL.Keycode Char keycodeMapping = Map.fromList diff --git a/src/Chelleport/Types.hs b/src/Chelleport/Types.hs index 2238019..15d16f4 100644 --- a/src/Chelleport/Types.hs +++ b/src/Chelleport/Types.hs @@ -13,7 +13,8 @@ type KeyGrid = [[Cell]] data State = State { stateGrid :: KeyGrid, stateKeySequence :: KeySequence, - stateIsMatched :: Bool + stateIsMatched :: Bool, + stateIsShiftPressed :: Bool } data AppAction @@ -22,6 +23,7 @@ data AppAction | ResetKeys | TriggerLeftClick | IncrementMouseCursor (Int, Int) + | UpdateShiftState Bool data DrawContext = DrawContext { ctxWindow :: SDL.Window, diff --git a/src/Chelleport/View.hs b/src/Chelleport/View.hs index 2ac90a7..1ead214 100644 --- a/src/Chelleport/View.hs +++ b/src/Chelleport/View.hs @@ -6,12 +6,12 @@ import Chelleport.Utils (intToCInt, isEmpty, isNotEmpty) import Control.Monad (forM_, unless, void, when) import Data.IORef (modifyIORef', newIORef, readIORef) import Data.List (isPrefixOf) +import Data.Maybe (isJust) import qualified Data.Text as Text import qualified Data.Vector.Storable as Vector import Foreign.C (CInt) import SDL (($=)) import qualified SDL -import Data.Maybe (isJust) render :: State -> DrawContext -> IO () render state ctx = do @@ -66,12 +66,12 @@ renderGridLines state ctx@(DrawContext {ctxRenderer = renderer}) = do let rows = intToCInt $ length grid let columns = intToCInt $ length $ head grid forM_ [0 .. rows] $ \rowIndex -> do - SDL.rendererDrawColor renderer $= colorGray + SDL.rendererDrawColor renderer $= colorFocusLines drawHorizontalLine ctx (rowIndex * hcell + hcell `div` 2) SDL.rendererDrawColor renderer $= colorGridLines drawHorizontalLine ctx $ rowIndex * hcell forM_ [0 .. columns] $ \colIndex -> do - SDL.rendererDrawColor renderer $= colorGray + SDL.rendererDrawColor renderer $= colorFocusLines drawVerticalLine ctx (colIndex * wcell + wcell `div` 2) SDL.rendererDrawColor renderer $= colorGridLines drawVerticalLine ctx $ colIndex * wcell |
