h-raylib-5.1.3.0: Raylib bindings for Haskell
Safe HaskellSafe-Inferred
LanguageHaskell2010

Raylib.Util.GUI

Description

Bindings to raygui

raygui is an immediate-mode GUI library built on top of raylib. The C version of raygui involves a lot of pointers because of the way it is designed. Unfortunately, this is problematic when binding it to Haskell, as Haskell's immutability makes it difficult to represent pointers properly. This means many functions will take the previous state of a control as an argument and return the updated state of that control.

Keep in mind that raygui is an immediate mode GUI, so it is designed mostly for debugging and development and not for actual game GUIs. To this end, it is not very customizable and the features are quite limited. For a real game, you should make your own retained mode GUI.

Synopsis

High level

Global gui state control functions

guiEnable :: IO () Source #

Enable gui controls (global state)

guiDisable :: IO () Source #

Disable gui controls (global state)

guiLock :: IO () Source #

Lock gui controls (global state)

guiUnlock :: IO () Source #

Unlock gui controls (global state)

guiIsLocked :: IO Bool Source #

Check if gui is locked (global state)

guiSetAlpha :: Float -> IO () Source #

Set gui controls alpha (global state), alpha goes from 0.0f to 1.0f

guiSetState :: GuiState -> IO () Source #

Set gui state (global state)

guiGetState :: IO GuiState Source #

Get gui state (global state)

Font set/get functions

guiSetFont :: Font -> IO () Source #

Set gui custom font (global state)

guiGetFont :: IO Font Source #

Get gui custom font (global state)

Style set/get functions

In the native C code, there is just one guiSetStyle function and one guiGetStyle function, which take a property type and an int as the property value. This int can represent a plain integer, a Color, or an enum, depending on the property type. This is very un-Haskelly behavior and not very user friendly (as it requires the use of colorToInt and such), so they have been split into 3 setters and getters, one for regular Ints, one for Colors, and one for Enums. There are also a bunch of specialized getters and setters for commonly used properties.

Set style

guiSetStyle :: Enum e => GuiControl -> e -> Int -> IO () Source #

Set style property as Int

guiSetStyleC :: Enum e => GuiControl -> e -> Color -> IO () Source #

Set style property as Color

guiSetStyleE :: (Enum e, Enum v) => GuiControl -> e -> v -> IO () Source #

Set style property as Enum

guiSetStyleBorderColorNormal :: GuiControl -> Color -> IO () Source #

Set BORDER_COLOR_NORMAL style property | Control border color in STATE_NORMAL

guiSetStyleBaseColorNormal :: GuiControl -> Color -> IO () Source #

Set BASE_COLOR_NORMAL style property | Control base color in STATE_NORMAL

guiSetStyleTextColorNormal :: GuiControl -> Color -> IO () Source #

Set TEXT_COLOR_NORMAL style property | Control text color in STATE_NORMAL

guiSetStyleBorderColorFocused :: GuiControl -> Color -> IO () Source #

Set BORDER_COLOR_FOCUSED style property | Control border color in STATE_FOCUSED

guiSetStyleBaseColorFocused :: GuiControl -> Color -> IO () Source #

Set BASE_COLOR_FOCUSED style property | Control base color in STATE_FOCUSED

guiSetStyleTextColorFocused :: GuiControl -> Color -> IO () Source #

Set TEXT_COLOR_FOCUSED style property | Control text color in STATE_FOCUSED

guiSetStyleBorderColorPressed :: GuiControl -> Color -> IO () Source #

Set BORDER_COLOR_PRESSED style property | Control border color in STATE_PRESSED

guiSetStyleBaseColorPressed :: GuiControl -> Color -> IO () Source #

Set BASE_COLOR_PRESSED style property | Control base color in STATE_PRESSED

guiSetStyleTextColorPressed :: GuiControl -> Color -> IO () Source #

Set TEXT_COLOR_PRESSED style property | Control text color in STATE_PRESSED

guiSetStyleBorderColorDisabled :: GuiControl -> Color -> IO () Source #

Set BORDER_COLOR_DISABLED style property | Control border color in STATE_DISABLED

guiSetStyleBaseColorDisabled :: GuiControl -> Color -> IO () Source #

Set BASE_COLOR_DISABLED style property | Control base color in STATE_DISABLED

guiSetStyleTextColorDisabled :: GuiControl -> Color -> IO () Source #

Set TEXT_COLOR_DISABLED style property | Control text color in STATE_DISABLED

guiSetStyleBorderWidth :: GuiControl -> Int -> IO () Source #

Set BORDER_WIDTH style property | Control border size, 0 for no border

guiSetStyleTextPadding :: GuiControl -> Int -> IO () Source #

Set TEXT_PADDING style property | Control text padding, not considering border

guiSetStyleTextAlignment :: GuiControl -> GuiTextAlignment -> IO () Source #

Set TEXT_ALIGNMENT style property | Control text horizontal alignment inside control text bound (after border and padding)

guiSetStyleTextSize :: Int -> IO () Source #

Set TEXT_SIZE default style property | Text size (glyphs max height)

guiSetStyleTextSpacing :: Int -> IO () Source #

Set TEXT_SPACING default style property | Text spacing between glyphs

guiSetStyleLineColor :: Color -> IO () Source #

Set LINE_COLOR default style property | Line control color

guiSetStyleBackgroundColor :: Color -> IO () Source #

Set BACKGROUND_COLOR default style property | Background color

guiSetStyleTextLineSpacing :: Int -> IO () Source #

Set TEXT_LINE_SPACING default style property | Text spacing between lines

guiSetStyleTextAlignmentVertical :: GuiTextAlignmentVertical -> IO () Source #

Set TEXT_ALIGNMENT_VERTICAL default style property | Text vertical alignment inside text bounds (after border and padding)

guiSetStyleTextWrapMode :: GuiTextWrapMode -> IO () Source #

Set TEXT_WRAP_MODE default style property | Text wrap-mode inside text bounds

Get style

guiGetStyle :: Enum e => GuiControl -> e -> IO Int Source #

Get style property as Int

guiGetStyleC :: Enum e => GuiControl -> e -> IO Color Source #

Set style property as Color

guiGetStyleE :: (Enum e, Enum v) => GuiControl -> e -> IO v Source #

Set style property as Enum

guiGetStyleBorderColorNormal :: GuiControl -> IO Color Source #

Get BORDER_COLOR_NORMAL style property | Control border color in STATE_NORMAL

guiGetStyleBaseColorNormal :: GuiControl -> IO Color Source #

Get BASE_COLOR_NORMAL style property | Control base color in STATE_NORMAL

guiGetStyleTextColorNormal :: GuiControl -> IO Color Source #

Get TEXT_COLOR_NORMAL style property | Control text color in STATE_NORMAL

guiGetStyleBorderColorFocused :: GuiControl -> IO Color Source #

Get BORDER_COLOR_FOCUSED style property | Control border color in STATE_FOCUSED

guiGetStyleBaseColorFocused :: GuiControl -> IO Color Source #

Get BASE_COLOR_FOCUSED style property | Control base color in STATE_FOCUSED

guiGetStyleTextColorFocused :: GuiControl -> IO Color Source #

Get TEXT_COLOR_FOCUSED style property | Control text color in STATE_FOCUSED

guiGetStyleBorderColorPressed :: GuiControl -> IO Color Source #

Get BORDER_COLOR_PRESSED style property | Control border color in STATE_PRESSED

guiGetStyleBaseColorPressed :: GuiControl -> IO Color Source #

Get BASE_COLOR_PRESSED style property | Control base color in STATE_PRESSED

guiGetStyleTextColorPressed :: GuiControl -> IO Color Source #

Get TEXT_COLOR_PRESSED style property | Control text color in STATE_PRESSED

guiGetStyleBorderColorDisabled :: GuiControl -> IO Color Source #

Get BORDER_COLOR_DISABLED style property | Control border color in STATE_DISABLED

guiGetStyleBaseColorDisabled :: GuiControl -> IO Color Source #

Get BASE_COLOR_DISABLED style property | Control base color in STATE_DISABLED

guiGetStyleTextColorDisabled :: GuiControl -> IO Color Source #

Get TEXT_COLOR_DISABLED style property | Control text color in STATE_DISABLED

guiGetStyleBorderWidth :: GuiControl -> IO Int Source #

Get BORDER_WIDTH style property | Control border size, 0 for no border

guiGetStyleTextPadding :: GuiControl -> IO Int Source #

Get TEXT_PADDING style property | Control text padding, not considering border

guiGetStyleTextAlignment :: GuiControl -> IO GuiTextAlignment Source #

Get TEXT_ALIGNMENT style property | Control text horizontal alignment inside control text bound (after border and padding)

guiGetStyleTextSize :: IO Int Source #

Get TEXT_SIZE default style property | Text size (glyphs max height)

guiGetStyleTextSpacing :: IO Int Source #

Get TEXT_SPACING default style property | Text spacing between glyphs

guiGetStyleLineColor :: IO Color Source #

Get LINE_COLOR default style property | Line control color

guiGetStyleBackgroundColor :: IO Color Source #

Get BACKGROUND_COLOR default style property | Background color

guiGetStyleTextLineSpacing :: IO Int Source #

Get TEXT_LINE_SPACING default style property | Text spacing between lines

guiGetStyleTextAlignmentVertical :: IO GuiTextAlignmentVertical Source #

Get TEXT_ALIGNMENT_VERTICAL default style property | Text vertical alignment inside text bounds (after border and padding)

guiGetStyleTextWrapMode :: IO GuiTextWrapMode Source #

Get TEXT_WRAP_MODE default style property | Text wrap-mode inside text bounds

Styles loading functions

guiLoadStyle :: String -> IO () Source #

Load style file over global style variable (.rgs)

guiLoadStyleDefault :: IO () Source #

Load style default over global style

Tooltips management functions

guiEnableTooltip :: IO () Source #

Enable gui tooltips (global state)

guiDisableTooltip :: IO () Source #

Disable gui tooltips (global state)

guiSetTooltip :: String -> IO () Source #

Set tooltip string

Icons functionality

guiIconText :: GuiIconName -> String -> IO String Source #

Get text with icon id prepended (if supported)

guiSetIconScale :: Int -> IO () Source #

Set default icon drawing size

guiGetIcons :: IO (Ptr CUInt) Source #

Get raygui icons raw pointer (8192 bytes)

guiLoadIcons Source #

Arguments

:: String 
-> Bool 
-> Int

The number of icons in the file

-> IO [String] 

Load raygui icons file (.rgi) into internal icons data

guiDrawIcon :: GuiIconName -> Int -> Int -> Int -> Color -> IO () Source #

Draw icon using pixel size at specified position

Controls

Container/separator controls, useful for controls organization

guiWindowBox Source #

Arguments

:: Rectangle 
-> Maybe String 
-> IO Bool

True if the close button is clicked

Window Box control, shows a window that can be closed

guiGroupBox :: Rectangle -> Maybe String -> IO () Source #

Group Box control with text name

guiLine :: Rectangle -> Maybe String -> IO () Source #

Line separator control, could contain text

guiPanel :: Rectangle -> Maybe String -> IO () Source #

Panel control, useful to group controls

guiTabBar Source #

Arguments

:: Rectangle 
-> [String] 
-> Maybe Int

The currently active tab's index, use Nothing if creating the tab bar for the first time

-> IO (Int, Maybe Int)

A tuple, the first element is the index of the active tab, the second element is the tab whose close button is pressed (if any)

Tab Bar control

guiScrollPanel Source #

Arguments

:: Rectangle 
-> Maybe String 
-> Rectangle 
-> Maybe Vector2

The panel's scroll vector, use Nothing if creating the panel for the first time

-> Maybe Rectangle

The panel's view rectangle, use Nothing if creating the panel for the first time

-> IO (Vector2, Rectangle)

The panel's updated scroll vector and view rectangle as a tuple

Scroll Panel control

Basic controls set

guiLabel :: Rectangle -> String -> IO () Source #

Label control

guiButton :: Rectangle -> Maybe String -> IO Bool Source #

Button control, returns true when clicked

guiLabelButton :: Rectangle -> Maybe String -> IO Bool Source #

Label button control, returns true when clicked

guiToggle :: Rectangle -> Maybe String -> Bool -> IO Bool Source #

Toggle Button control

guiToggleGroup Source #

Arguments

:: Rectangle 
-> String

The names of the toggles, separated with semicolons

-> Maybe Int

The currently active toggle's index, use Nothing if creating the toggle group for the first time

-> IO Int

The updated active toggle index

Toggle Group control

guiToggleSlider Source #

Arguments

:: Rectangle 
-> String

The names of the toggles, separated with semicolons

-> Maybe Int

The currently active toggle's index, use Nothing if creating the toggle slider for the first time

-> IO (Bool, Int)

A tuple, the first element is whether the slider was clicked, the second element is the updated toggle index

Toggle Slider control

guiCheckBox Source #

Arguments

:: Rectangle 
-> Maybe String 
-> Bool

The current checkbox state (checked/unchecked)

-> IO Bool

The updated checkbox state (checked/unchecked)

Check Box control

guiComboBox Source #

Arguments

:: Rectangle 
-> String

The names of the combobox options, separated with semicolons

-> Maybe Int

The currently active option's index, use Nothing if creating the combobox for the first time

-> IO Int

The updated active option index

Combo Box control

guiDropdownBox Source #

Arguments

:: Rectangle 
-> String

The names of the dropdown options, separated with semicolons

-> Maybe Int

The currently active option's index, use Nothing if creating the dropdown for the first time

-> Bool

True if the dropdown should be open (editable), false otherwise

-> IO (Bool, Int)

A tuple, the first element is whether the dropdown was clicked (i.e. the open/closed mode should be toggled), the second element is the updated toggle index

Dropdown Box control

guiSpinner Source #

Arguments

:: Rectangle 
-> Maybe String 
-> Int

The current value

-> Int 
-> Int 
-> Bool

True if the spinner should be editable, False otherwise

-> IO (Bool, Int)

A tuple, the first element is whether the spinner was toggled (i.e. the edit mode should be toggled), the second element is the updated value

Spinner control

guiValueBox Source #

Arguments

:: Rectangle 
-> Maybe String 
-> Int

The current value

-> Int 
-> Int 
-> Bool

True if the value box should be editable, False otherwise

-> IO (Bool, Int)

A tuple, the first element is whether the value box was toggled (i.e. the edit mode should be toggled), the second element is the updated value

Value Box control, updates input text with numbers

guiTextBox Source #

Arguments

:: Rectangle 
-> String 
-> Maybe Int

Text box buffer size; if Nothing, then it will automatically allocate a buffer large enough to fit the text

-> Bool

True if the text box should be editable, False otherwise

-> IO (Bool, String)

A tuple, the first element is whether the text box was toggled (i.e. the edit mode should be toggled), the second element is the updated text box value

Text Box control, updates input text

guiSlider Source #

Arguments

:: Rectangle 
-> Maybe String 
-> Maybe String 
-> Float

The current value

-> Float 
-> Float 
-> IO (Bool, Float)

A tuple, the first element is whether the slider was edited, the second element is the updated value

Slider control

guiSliderBar Source #

Arguments

:: Rectangle 
-> Maybe String 
-> Maybe String 
-> Float

The current value

-> Float 
-> Float 
-> IO (Bool, Float)

A tuple, the first element is whether the slider bar was edited, the second element is the updated value

Slider Bar control

guiProgressBar Source #

Arguments

:: Rectangle 
-> Maybe String 
-> Maybe String 
-> Float

The current value

-> Float 
-> Float 
-> IO Float

The updated value (clamped to min/max range)

Progress Bar control

guiStatusBar :: Rectangle -> String -> IO () Source #

Status Bar control, shows info text

guiDummyRec :: Rectangle -> String -> IO () Source #

Dummy control for placeholders

guiGrid Source #

Arguments

:: Rectangle 
-> Float 
-> Int 
-> IO (Maybe Vector2)

The cell the mouse is currently in

Grid control

Advanced controls set

guiListView Source #

Arguments

:: Rectangle 
-> String

The names of the list options, separated with semicolons

-> Int

Current scroll index

-> Maybe Int

Currently selected option index (active index)

-> IO (Int, Maybe Int)

A tuple, the first element is the updated scroll index, the second element is the updated active index

List View control

guiListViewEx Source #

Arguments

:: Rectangle 
-> [String]

The names of the list options

-> Int

Current scroll index

-> Maybe Int

Currently selected option index (active index)

-> Maybe Int

Currently focused option index

-> IO (Int, Maybe Int, Maybe Int)

A tuple, the first element is the updated scroll index, the second element is the updated active index, the third element is the updated focus index

List View with extended parameters

guiMessageBox Source #

Arguments

:: Rectangle 
-> Maybe String 
-> String 
-> String

Button labels separated by semicolons

-> IO (Maybe Int)

The index of the clicked button, if any (0 = close message box, 1,2,... = custom button)

Message Box control, displays a message

guiTextInputBox Source #

Arguments

:: Rectangle 
-> Maybe String 
-> String 
-> String

Button names, separated by semicolons

-> String

Current text box value

-> Maybe Int

Text box buffer size; if Nothing, then it will automatically allocate a buffer large enough to fit the text

-> Maybe Bool

Secret (password) mode; `Just True` if the value should be censored; `Just False` if it should not be censored but there should still be a button to hide it; Nothing if the value should not be censored at all

-> IO (Maybe Bool, String, Maybe Int)

A tuple, the first element is the updated secret mode, the second element is the updated text box value, the third element is the index of the clicked button, if any (0 = close input box, 1,2,... = custom button)

Text Input Box control, ask for text, supports secret

guiColorPicker Source #

Arguments

:: Rectangle 
-> Maybe Color

Currently selected color, use Nothing if creating the color picker for the first time

-> IO Color

Updated color

Color Picker control (multiple color controls)

guiColorPanel Source #

Arguments

:: Rectangle 
-> Maybe Color

Currently selected color, use Nothing if creating the color panel for the first time

-> IO Color

Updated color

Color Panel control

guiColorBarAlpha Source #

Arguments

:: Rectangle 
-> Float

Currently selected alpha

-> IO Float

Updated alpha

Color Bar Alpha control

guiColorBarHue Source #

Arguments

:: Rectangle 
-> Float

Currently selected hue

-> IO Float

Updated hue

Color Bar Hue control

guiColorPickerHSV Source #

Arguments

:: Rectangle 
-> Maybe Vector3

Currently selected color, use Nothing if creating the color picker for the first time

-> IO Vector3

Updated color

Color Picker control that avoids conversion to RGB on each call (multiple color controls)

guiColorPanelHSV Source #

Arguments

:: Rectangle 
-> Maybe Vector3

Currently selected color, use Nothing if creating the color panel for the first time

-> IO Vector3

Updated color

Color Panel control that updates Hue-Saturation-Value color value, used by guiColorPickerHSV

Native