Jump to content

[REL] Minimalistic Window System [Now with OOP]


AriosJentu

Recommended Posts

Hello all.

You know all about my custom windows (if you dont know, this is old thread).

But whats new?

- Added Fullscreen Button

- Window control buttons moved left (like mac or some linux systems)

- Can set size for title of window

- Added shadows (borders)

- You can resize window by 5 sides of window (left, left bottom, bottom, right bottom and right)

- You can use theme, where topbar and frame has one color (minimalistic)

- Added Error Window (function, what creating this window)

- Added relative for setStaticWindowTitleBarHeight

- Added events onClientStaticWindowOpen and onClientStaticWindowClose

Updated:

- Added new function getStaticWindowTitleBarHeight

- Added some new events for opening and closing

- Added OOP class - StaticWindow

Screen:

KZeZIgX.png?1

Download:

GitHub

Community

Functions:

gui-element, gui-element, gui-element, gui-element createStaticWindow(float PosX, float PosY, float Width, float Height, string Title, bool Relative, gui-element Parent) 

Function what create static window

OOP: StaticWindow.create

Returns: Frame, Title, Window (Frame Background), Window Panel (Window Background)

Returns OOP: Class [Table] (in table StaticWindow are StaticWindow.Frame, StaticWindow.Title, StaticWindow.Window and StaticWindow.Back)

openWindow(gui-element Frame, bool Animated) 

OOP: StaticWindow:open

Function, what opens window. If not Animated window opens without alpha changing.

closeWindow(gui-element Frame, bool Animated) 

OOP: StaticWindow:close

Function, what close window. If not Animated window hides after exec this function.

ocWindow(gui-element Frame, bool Animated) 

OOP: StaticWindow:oc

Function, what opens/close window

gui-element showError(string ErrorText, gui-element Parent) 

OOP: StaticWindow.error

Fuction, what create Error window.

Returns: Error Frame

setStaticWindowBorderSize(gui-element Frame, int Size) 

OOP: StaticWindow:setBorderSize

Function, what sets static window border size

setStaticWindowPosition(gui-element Frame, float PosX, float PosY, bool Relative) 

OOP: StaticWindow:setPosition

Function, what sets static window position

setStaticWindowSize(gui-element Frame, float Width, float Height, bool Relative, bool SkipMinMaxSizes) 

OOP: StaticWindow:setSize

Function, what sets static window size

setStaticWindowMinSize(gui-element Frame, float MinWidth, float MinHeight, bool Relative) 

OOP: StaticWindow:setMinSize

Function, what sets static window minimal size

setStaticWindowMaxSize(gui-element Frame, float MaxWidth, float MaxHeight, bool Relative) 

OOP: StaticWindow:setMaxSize

Function, what sets static window maximal size

setStaticWindowMovable(gui-element Frame, bool Movable) 

OOP: StaticWindow:setMovable

Function, what sets static window movable

setStaticWindowSizable(gui-element Frame, bool Sizable) 

OOP: StaticWindow:setSizable

Function, what sets static window sizable

setStaticWindowTitle(gui-element Frame, string TitleText) 

OOP: StaticWindow:setTitle

Function, what sets static window title text

setStaticWindowColorScheme(gui-element Frame, string RRGGBB-TitleColor, string RRGGBB-WindowColor, string RRGGBB-TitleTextColor) 

OOP: StaticWindow:setColorScheme

Function, what sets static window color sheme

setStaticWindowTitleBarHeight(gui-element Frame, int Height, bool Relative) 

OOP: StaticWindow:setTitleHeight

Function, what sets static window titlebar height

int getStaticWindowBorderSize(gui-element Frame) 

OOP: StaticWindow:getBorderSize

Function, what gets static window border size

Returns false or size {int}

float, float getStaticWindowPosition(gui-element Frame, bool Relative) 

OOP: StaticWindow:getPosition

Function, what gets static window position

Returns false or positions {PosX, PosY}

float, float getStaticWindowSize(gui-element Frame, bool Relative) 

OOP: StaticWindow:getSize

Function, what gets static window size

Returns false or size {Width, Height}

bool getStaticWindowMovable(gui-element Frame) 

OOP: StaticWindow:getMovable

Function, what gets static window movable

Returns movable or false

bool getStaticWindowSizable(gui-element Frame) 

OOP: StaticWindow:getSizable

Function, what gets static window sizable

Returns sizable or false

int getStaticWindowTitleBarHeight(gui-element Frame) 

OOP: StaticWindow:getTitleHeight

Function, what gets static window border size

Returns nil or height {integer}

Events:

onClientStaticWindowLeavingFullScreen

gui-element thisFrame 

Triggering when player leave from fullscreen mode of window (starts animation)

onClientStaticWindowLeavedFullScreen

gui-element thisFrame 

Triggering when player fully leave from fullscreen mode of window (finish animation)

 

onClientStaticWindowEnteringFullScreen

gui-element thisFrame 

Triggering when player enter in fullscreen mode of window (starts animation)

onClientStaticWindowEnteredFullScreen

gui-element thisFrame 

Triggering when player fully entered in fullscreen mode of window (finish animation)

 

onClientStaticWindowMove

gui-element thisFrame, float PosX, float PosY 

Triggering when window change position

 

onClientStaticWindowResize

gui-element thisFrame, float Width, float Height 

Triggering when window change size

onClientStaticWindowOpen

gui-element thisFrame 

Triggering when window opens

onClientStaticWindowClose

gui-element thisFrame 

Triggering when window closing

onClientStaticWindowFullOpened

gui-element thisFrame 

Triggering when window full opened (finish opening)

onClientStaticWindowFullClosed

gui-element thisFrame 

Triggering when window full closed (finish closing)

 

Example:

local wins = createStaticWindow(100, 100, 100, 100, "Test", false) 
setStaticWindowMaxSize(wins, 0.5, 0.9, true) 
  
bindKey("b", "up", function() ocWindow(wins) end) 
  
local wins2 = createStaticWindow(200, 100, 100, 100, "Test", false) 
setStaticWindowColorScheme(wins2, "444444", "444444", "FFFFFF") --Top, win, text 
  
bindKey("n", "up", function() ocWindow(wins2) end) 
  
local wins3 = createStaticWindow(300, 100, 100, 100, "Test", false) 
setStaticWindowColorScheme(wins3, "3498DB", "default", "FFFFFF") 
setStaticWindowTitleBarHeight(wins3, 40) 
  
local wins4 = createStaticWindow(400, 100, 100, 100, "Test", false) 
setStaticWindowColorScheme(wins4, "DB3498", "default", "FFFFFF") 
  
addEvent("onClientStaticWindowFullscreenEnter", true) 
addEvent("onClientStaticWindowFullscreenLeave", true) 
addEventHandler("onClientStaticWindowFullscreenEnter", root, function(window) 
    if window == wins3 then 
        setStaticWindowColorScheme(wins3, "invisible", "default", "3498DB") 
    end 
end) 
addEventHandler("onClientStaticWindowFullscreenLeave", root, function(window) 
    if window == wins3 then 
        setStaticWindowColorScheme(wins3, "3498DB", "default", "FFFFFF") 
    end 
end) 
  
bindKey("m", "up", function() ocWindow(wins3) end) 

OOP Example:

local SWin = StaticWindow.create(800, 300, 200, 200, "Test", false, nil) 
SWin:setBorderSize(2) 
SWin:setPosition(0.6, 0.1, true) 
SWin:setSize(300, 300, false) 
SWin:setMaxSize(700, 700, false) 
SWin:setColorScheme("DE6262", "DEDEDE", "FFFFFF") 
SWin:setMovable(false) 
--But you can use that 
setStaticWindowSizable(SWin.Frame, false) 
setStaticWindowTitleBarHeight(SWin.Title, 40) 
setStaticWindowMinSize(SWin.Back, 120, 120, false) 
SWin.Title:setColor(100, 100, 100) 
SWin.Title:setVerticalAlign("bottom") 

Designed by Mediym.

Thanks all

Edited by Guest
Link to comment
It's just a window, tahts hwat I meant, I dont think we can make a No-Lag gridlist and scrollbar, I tried making one, and it worked but it totally lags... I call it, Lagiana Grande

Quit the offtopic, will you?

And yes, it it's totally possible to make a gridlist without lag.

Link to comment
It's just a window, tahts hwat I meant, I dont think we can make a No-Lag gridlist and scrollbar, I tried making one, and it worked but it totally lags... I call it, Lagiana Grande

I answered a topic regarding scrollbars, and I provided a working example which does not lag - search for it and you'll find it.

OT:

It's a nice, simple yet sleek design. Personally, I prefer to have buttons on the right side, rather than the left. :)

Link to comment
It's just a window, tahts hwat I meant, I dont think we can make a No-Lag gridlist and scrollbar, I tried making one, and it worked but it totally lags... I call it, Lagiana Grande

Your code is wrong then.

Ontopic:

Nice design. Keep up with your projects

Link to comment
my codes are never wrong. Its the rendering part that is bugged. I dont think My code is wrong. because I tried 5-6 ways of making it Cadu.. so yeah..

On the contrary, your code is wrong. The rendering is not bugged, I made an example earlier on how to make a scrollbar - it did not lag. Since you don't seem to know how to search, here you go;

Okay here's a quick example I made, it was made using absolute values for 1920x1080 so if you use a smaller resolution you'll probably have to make it relative.

This is only to serve as an example, therefore, things are not working optimally, there's a lot of things to still do, but it will demonstrate how to do the basics of a scrollbar.

-- Variables 
local screenW, screenH = guiGetScreenSize(); 
local theSuperLongMessage = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. In ut diam bibendum, interdum odio et, hendrerit libero. Maecenas hendrerit sem ac orci mattis, vitae consectetur dui tincidunt. Cras fermentum nulla ac velit accumsan, dignissim finibus urna placerat. Morbi suscipit metus nisl, non pulvinar erat fermentum vitae. Fusce maximus risus non tortor molestie, et sagittis sem ullamcorper. Mauris ac ante facilisis, posuere neque sed, pretium ipsum. Quisque maximus porta mi. Praesent malesuada eleifend turpis sed faucibus. Etiam nec rutrum nisl, ac scelerisque magna. Donec finibus nulla mi, at gravida libero maximus et. Nulla auctor, erat vel fringilla efficitur, sem dolor condimentum erat, nec eleifend nisl orci et diam. Morbi pellentesque maximus tempus. Mauris pretium nec nisi id faucibus. Duis auctor odio vulputate maximus viverra. Nam consequat sapien a justo elementum, nec porttitor nulla bibendum.\n\nUt dictum scelerisque elementum. Donec sollicitudin dui id rhoncus consectetur. Etiam gravida libero ipsum, at varius velit pulvinar eleifend. Etiam at felis porta, varius est nec, fringilla lorem. Nullam eu sapien quis risus venenatis congue. Cras ac lacus sit amet odio faucibus pretium at non tortor. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque sit amet libero eu urna lobortis laoreet.\n\nVestibulum posuere faucibus gravida. Vivamus ligula urna, dictum a aliquam eu, pretium id felis. Sed non risus facilisis, ultrices elit eu, hendrerit sem. Sed varius tortor sed sapien dictum, sed aliquam ipsum viverra. Vivamus quis dictum eros. Curabitur et accumsan leo. Vivamus et lectus nunc. Sed euismod tincidunt consectetur. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla facilisi. Aenean euismod interdum ex at ullamcorper. Duis tincidunt gravida nisi eget egestas.\n\nNam id nunc nec ante venenatis vestibulum. Aliquam bibendum nulla tellus, a dapibus mi pharetra nec. Ut nec gravida dui, sit amet lacinia ex. Etiam sed maximus sapien, eget congue nisi. Maecenas non accumsan ipsum. Mauris condimentum interdum est et hendrerit. Phasellus convallis porta venenatis. Nullam viverra lacus justo, id tincidunt ipsum efficitur at.\n\nNulla eget consectetur lectus. In tincidunt pellentesque pellentesque. Aliquam posuere, purus id tristique congue, ligula ligula viverra ex, quis fermentum lorem ipsum in purus. Cras a odio interdum, porttitor diam vitae, vehicula leo. Nullam ante dolor, interdum in bibendum egestas, tempus sed ligula. Vivamus at odio convallis, porta ligula ut, tempor dui. Praesent eget facilisis risus. Nullam non ipsum eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer dictum dapibus lectus, vel pharetra libero luctus sed. Nam mollis ultrices varius. Praesent ornare, sapien id posuere placerat, urna odio facilisis sem, at malesuada risus lorem ac quam. Donec pharetra lectus eget egestas molestie. Suspendisse ipsum augue, ultricies at ultricies quis, tempor eget velit. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas."; 
local textSafeBox = dxCreateRenderTarget(570, 470, true); 
local isClientHoveringScroll = false; 
local isScrollBarClicked = false; 
local textOffset = 0; 
local scrollerPos = 662; 
  
-- Functions 
function isCursorWithin(posX, posY, theWidth, theHeight) 
    if(not isCursorShowing()) then 
        return false; 
    end 
    local cX, cY = getCursorPosition(); 
    local cX, cY = (cX*screenW), (cY*screenH); 
    if(cX >= posX and cX <= posX+theWidth) and (cY >= posY and cY <= posY+theHeight) then 
        return true; 
    else 
        return false; 
    end 
end 
  
function onStart_Handler() 
    showCursor(true); 
    if(textSafeBox) then 
        outputChatBox("Render Target was successfully created!", 0, 187, 0, true); 
        addEventHandler("onClientRender", root, draw_Stuff); 
    elseif(textSafeBox == false) then 
        outputChatBox("Render Target returned false!", 187, 0, 0, true); 
    end 
end 
addEventHandler("onClientResourceStart", resourceRoot, onStart_Handler); 
  
function draw_Stuff() 
    if(textSafeBox) then 
        dxSetRenderTarget(textSafeBox, false); 
        dxDrawText(theSuperLongMessage, (10-textOffset), 20, 570, 470, tocolor(255, 255, 255, 200), 1.0, "default-bold"); 
        dxSetRenderTarget(); 
        dxDrawRectangle(660, 290, 600, 500, tocolor(0, 30, 30, 200), false); 
        dxDrawRectangle(660, 747, 600, 43, tocolor(0, 30, 30, 200), false) 
        dxDrawLine(660, 746, 1260, 746, tocolor(255, 255, 255, 255), 1, false) 
        dxDrawLine(660, 290, 1260, 290); 
        dxDrawLine(660, 790, 1260, 790); 
        dxDrawLine(660, 290, 660, 790); 
        dxDrawLine(1260, 290, 1260, 790); 
        dxDrawImage(675, 305, 570, 470, textSafeBox); 
        dxDrawRectangle(scrollerPos, 748, 32, 41, tocolor(255, 255, 255, 255), false) 
    end 
    if(isCursorWithin(scrollerPos, 748, 32, 41)) then 
        isClientHoveringScroll = true; 
    else 
        isClientHoveringScroll = false; 
    end 
    if(isScrollBarClicked == true) then 
        if(isCursorWithin(660, 747, 600, 41)) then 
            local cX, cY = getCursorPosition(); 
            local cX, cY = (cX*screenW), (cY*screenH); 
            textOffset = (660-cX); 
            dxSetRenderTarget(textSafeBox, true); 
            dxDrawText(theSuperLongMessage, (10-textOffset), 20, 570, 470, tocolor(255, 255, 255, 200), 1.0, "default-bold"); 
            dxSetRenderTarget(); 
            scrollerPos = cX; 
        end 
    end 
end 
  
function detect_ScrollBarClick(theButton, theState) 
    if(theButton == "left" and theState == "down" and isClientHoveringScroll == true) then 
        isScrollBarClicked = true; 
    elseif(theButton == "left" and theState == "up" and isScrollBarClicked == true) then 
        isScrollBarClicked = false; 
    end 
end 
addEventHandler("onClientClick", root, detect_ScrollBarClick) 

Link to comment
This is not the best the topic for self-promotion

I don't mean to de-rail your topic, but my reply is not self-promotion - you might wanna look up the definition of that term before you throw it around.

I quoted myself because he's been bickering about it for a while, and it might be useful for others. How is trying to help self-promotion? :roll:

Link to comment
  • 2 weeks later...
  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...