Code Monkey home page Code Monkey logo

imgui-lua-notifications's Introduction

Preview

API

Constructor

notifications = Notifications.new(ImGuiInstance [, iconsTable, languageCode])
Argument Description Example
iconsTable table that contains icons characters { Success = utf8.char(0xe86c), Warning = utf8.char(0xf083), Error = utf8.char(0xe888), Info = utf8.char(0xe88e) }
Icons font: "MaterialIconsRound-Regular" from Google
languageCode Used to display default title
Edit "Notifications.TRANSLATION" variable in "Notification.lua"
"en-EN", "fr-FR" etc.

Push new notification

notifications:add([windowType, title, content, waitTime, positionFlags])
Argument Description Values
windowType (string) Type of the notification window. Different types have different title color (default: Notifications.NONE) Notifications.NONE , Notifications.SUCCESS , Notifications.WARNING , Notifications.ERROR , Notifications.INFO
title (string) window title (if empty of nil, uses default name depending on windowType) any
content (string) shown message (default: "") any
waitTime (number) window display time in seconds (default: 4) any > 0
positionFlags (number) can be mixed with logical OR operator (default: bottom right) Notifications.TOP, Notifications.LEFT, Notifications.BOTTOM, Notifications.RIGHT
notifications:addCloseable([windowType, title, content, waitTime, position])

Same as above, but the window is displayed until the user closes it.
Does not work properly when only title is displayed (WIP)

Change language

notifications:setLanguage(languageCode)

Example

require "Notification"

ui = ImGui.new()
stage:addChild(ui)
notifications = Notifications.new(ui)


function onEnterFrame(e)
	ui:newFrame(e.deltaTime)
	
	if (ui:button("Add")) then 
		notifications:add(
				Notifications.WARNING, -- message type
				"", -- Default title
				"You've lost your connection", 
				2, -- wait 2 seconds
				Notifications.BOTTOM | Notifications.LEFT -- show in bottom left corner
			)
	end
	notifications:draw()
	
	ui:render()
	ui:endFrame()
end
stage:addEventListener("enterFrame", onEnterFrame)

imgui-lua-notifications's People

Contributors

multipain avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.