Skip to content

Commit fed4c64

Browse files
committed
wip
1 parent 1bbdb70 commit fed4c64

File tree

3 files changed

+23
-92
lines changed

3 files changed

+23
-92
lines changed

GUI/EventsView.hs

+13-27
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ module GUI.EventsView (
1515
import GHC.RTS.Events
1616
import Debug.Trace
1717

18-
import Graphics.UI.Gtk
18+
import Graphics.UI.Gtk hiding (rectangle)
19+
import Graphics.Rendering.Cairo
1920
import qualified GUI.GtkExtras as GtkExt
2021

2122
import Control.Monad
@@ -303,44 +304,29 @@ drawEvents EventsView{drawArea, adj}
303304
columnGap = 20
304305
descrWidth = width - timeWidth - columnGap
305306

306-
traceM "draw each"
307307
sequence_
308308
[ do when (inside || selected) $
309-
GtkExt.stylePaintFlatBox
310-
style win
311-
state1 ShadowNone
312-
clipRect
313-
drawArea ""
314-
0 (round y) width (round lineHeight)
315-
traceM "stylePaint"
309+
renderWithDrawWindow win $ do
310+
-- TODO: figure out how I can grab the correct color from GTK's style
311+
setSourceRGBA 0.2 1 1 0.2
312+
rectangle 0 y (fromIntegral width) lineHeight
313+
fill
316314

317315
-- The event time
318316
layoutSetText layout (showEventTime event)
319-
traceM "set text"
320317
layoutSetAlignment layout AlignRight
321-
traceM "set align"
322318
layoutSetWidth layout (Just (fromIntegral timeWidth))
323-
traceM "set width"
324-
GtkExt.stylePaintLayout
325-
style win
326-
state2 True
327-
clipRect
328-
drawArea ""
329-
0 (round y)
330-
layout
331-
traceM "paint layout"
319+
renderWithDrawWindow win $ do
320+
moveTo 0 y
321+
showLayout layout
332322

333323
-- The event description text
334324
layoutSetText layout (showEventDescr event)
335325
layoutSetAlignment layout AlignLeft
336326
layoutSetWidth layout (Just (fromIntegral descrWidth))
337-
GtkExt.stylePaintLayout
338-
style win
339-
state2 True
340-
clipRect
341-
drawArea ""
342-
(timeWidth + columnGap) (round y)
343-
layout
327+
renderWithDrawWindow win $ do
328+
moveTo (fromIntegral $ timeWidth + columnGap) y
329+
showLayout layout
344330

345331
| n <- [begin..end]
346332
, let y = fromIntegral n * lineHeight - yOffset

GUI/GtkExtras.hs

-58
Original file line numberDiff line numberDiff line change
@@ -30,58 +30,6 @@ waitGUI = do
3030

3131
-------------------------------------------------------------------------------
3232

33-
stylePaintFlatBox :: WidgetClass widget
34-
=> Style
35-
-> DrawWindow
36-
-> StateType
37-
-> ShadowType
38-
-> Rectangle
39-
-> widget
40-
-> String
41-
-> Int -> Int -> Int -> Int
42-
-> IO ()
43-
stylePaintFlatBox style window stateType shadowType
44-
clipRect widget detail x y width height =
45-
with clipRect $ \rectPtr ->
46-
withCString detail $ \detailPtr ->
47-
(\(Style arg1) (DrawWindow arg2) arg3 arg4 arg5 (Widget arg6) arg7 arg8 arg9 arg10 arg11 -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg6 $ \argPtr6 -> gtk_paint_flat_box argPtr1 argPtr2 arg3 arg4 arg5 argPtr6 arg7 arg8 arg9 arg10 arg11)
48-
style
49-
window
50-
((fromIntegral.fromEnum) stateType)
51-
((fromIntegral.fromEnum) shadowType)
52-
(castPtr rectPtr)
53-
(toWidget widget)
54-
detailPtr
55-
(fromIntegral x) (fromIntegral y)
56-
(fromIntegral width) (fromIntegral height)
57-
58-
stylePaintLayout :: WidgetClass widget
59-
=> Style
60-
-> DrawWindow
61-
-> StateType
62-
-> Bool
63-
-> Rectangle
64-
-> widget
65-
-> String
66-
-> Int -> Int
67-
-> PangoLayout
68-
-> IO ()
69-
stylePaintLayout style window stateType useText
70-
clipRect widget detail x y (PangoLayout _ layout) =
71-
with clipRect $ \rectPtr ->
72-
withCString detail $ \detailPtr ->
73-
(\(Style arg1) (DrawWindow arg2) arg3 arg4 arg5 (Widget arg6) arg7 arg8 arg9 (PangoLayoutRaw arg10) -> withForeignPtr arg1 $ \argPtr1 ->withForeignPtr arg2 $ \argPtr2 ->withForeignPtr arg6 $ \argPtr6 ->withForeignPtr arg10 $ \argPtr10 -> gtk_paint_layout argPtr1 argPtr2 arg3 arg4 arg5 argPtr6 arg7 arg8 arg9 argPtr10)
74-
style
75-
window
76-
((fromIntegral.fromEnum) stateType)
77-
(fromBool useText)
78-
(castPtr rectPtr)
79-
(toWidget widget)
80-
detailPtr
81-
(fromIntegral x) (fromIntegral y)
82-
layout
83-
84-
8533
launchProgramForURI :: String -> IO Bool
8634
#if mingw32_HOST_OS || mingw32_TARGET_OS
8735
launchProgramForURI uri = do
@@ -115,12 +63,6 @@ launchProgramForURI uri =
11563

11664
-------------------------------------------------------------------------------
11765

118-
foreign import ccall safe "gtk_paint_flat_box"
119-
gtk_paint_flat_box :: Ptr Style -> Ptr DrawWindow -> CInt -> CInt -> Ptr () -> Ptr Widget -> Ptr CChar -> CInt -> CInt -> CInt -> CInt -> IO ()
120-
121-
foreign import ccall safe "gtk_paint_layout"
122-
gtk_paint_layout :: Ptr Style -> Ptr DrawWindow -> CInt -> CInt -> Ptr () -> Ptr Widget -> Ptr CChar -> CInt -> CInt -> Ptr PangoLayoutRaw -> IO ()
123-
12466
foreign import ccall safe "gtk_show_uri"
12567
gtk_show_uri :: Ptr Screen -> Ptr CChar -> CUInt -> Ptr (Ptr ()) -> IO CInt
12668

GUI/Histogram.hs

+10-7
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,16 @@ histogramViewNew builder = do
9191
Nothing -> return ()
9292
Just hecs
9393
| null (durHistogram hecs) -> do
94-
GtkExt.stylePaintLayout
95-
style win
96-
StateNormal True
97-
(Rectangle 0 0 w windowHeight)
98-
histogramDrawingArea ""
99-
4 20
100-
layout
94+
renderWithDrawWindow win $ do
95+
C.moveTo 4 20
96+
showLayout layout
97+
-- GtkExt.stylePaintLayout
98+
-- style win
99+
-- StateNormal True
100+
-- (Rectangle 0 0 w windowHeight)
101+
-- histogramDrawingArea ""
102+
-- 4 20
103+
-- layout
101104
return ()
102105
| otherwise -> do
103106
minterval <- readIORef mintervalIORef

0 commit comments

Comments
 (0)