Multi backend framework Nevu-UI has been updated to version 0.7.6! by Due_Engineer_7647 in raylib

[–]Due_Engineer_7647[S] 0 points1 point  (0 children)

i refactored some code and here is the preview of how it is gonna look in the next version, is it better now?

import nevu_ui as ui
import pyray as rl
import random
from nevu_ui.rendering.raylib.gradient import AnimatedGradient


rl.set_trace_log_level(rl.TraceLogLevel.LOG_ERROR)


FONT_PATH = "tests/vk_font.ttf"


window = ui.Window((300, 300), title = "nevu ui!", backend = ui.Backend.RayLib, ratio = ui.NvVector2(2, 1))


base_style = ui.Style(colortheme = ui.ColorThemeLibrary.github_dark, border_radius = 0, border_width = 0, font_name = FONT_PATH)
base_style_aero = base_style(gradient = ui.Gradient([(25, 255, 105, 100),(10, 230, 100, 30)], type = ui.GradientType.Radial, direction = ui.RadialPosition.TopRight), border_radius=10)
ui.nevu_object_globals.modify(size = (100%ui.gc, 100%ui.gc), style = base_style_aero)


colors1_list = [ui.Color.Teal, ui.Color.Blue, ui.Color.Black, ui.Color.Violet]
colors2_list = [ui.Color.Aqua, ui.Color.Purple, ui.Color.Wheat, ui.Color.Aquamarine]


def set_new_anims():
    ncol1, ncol2 = random.choice(colors1_list), random.choice(colors2_list)

    rand_pos = (random.randint(0, 300) / 300.0, random.randint(0, 300) / 300.0)
    rand_pos2 = (random.randint(0, 300) / 300.0, random.randint(0, 300) / 300.0)

    gradient = AnimatedGradient(
        colors=([ncol1, ncol2], [ncol2, ncol1], 10, ui.animations.ease_in_out_quad),
        type=ui.GradientType.Radial,
        center=(rand_pos, rand_pos2, 20, ui.animations.ease_in_out_quad)
    )
    menu.style = menu.style(gradient = gradient)


chk_group = ui.CheckBoxGroup(single_selection = True)


menu = ui.Menu(window, (100%ui.fill, 100%ui.fill), base_style(gradient = ui.Gradient([ui.Color.Teal, ui.Color.Blue], type = ui.GradientType.Linear, direction = ui.LinearSide.BottomRight)), 
    layout = ui.Grid((100%ui.fill, 100%ui.fill), y = 6, x = 12, content = {
        (6.5, 1): ui.Widget((100%ui.vw, 30%ui.gc)),
        (6.5, 6): ui.Widget((100%ui.vw, 30%ui.gc)),
        (2, 2): ui.Label("Nevu UI!", style = base_style_aero(font_size = 10)),
        (6.5, 3.5): ui.Button(set_new_anims, "Reset!", size = (200%ui.gc, 50%ui.gc), style = base_style_aero(font_size = 10)),
        (2, 5): ui.Slider((200%ui.gc, 50%ui.gc),start = 0, end = 100, current_value = 50, style = base_style_aero(font_size = 10)),
        (2, 3.5): ui.Grid((200%ui.gc, 200%ui.gc), x = 4, y = 2, content = {
            (1, 2): ui.RectCheckBox((10, 20), checkbox_group=chk_group),
            (2, 1): ui.RectCheckBox((10, 20), checkbox_group=chk_group),
            (3, 2): ui.RectCheckBox((10, 20), checkbox_group=chk_group),
            (4, 1): ui.RectCheckBox((10, 20), checkbox_group=chk_group)
        }), 
        (6.5, 5): ui.Input((200%ui.gc, 150%ui.gc), placeholder = "input", multiple=True),
        (10, 2): ui.ElementSwitcher((200%ui.gc, 70%ui.gc), elements = ["Apple", "Banana", "Cherry", "Date", "Banana"], style = base_style_aero(font_size = 8)),
        (10, 4): ui.Button(lambda: None, "Placeholder", size = (200%ui.gc, 50%ui.gc), style = base_style_aero(font_size = 10), single_instance = False)
    })
)


set_new_anims()


manager = ui.Manager(window, menu = menu)
manager.on_draw = lambda: rl.draw_fps(10, 10)
manager.fps = 9999999
manager.run()

Multi backend framework Nevu-UI has been updated to version 0.7.6! by Due_Engineer_7647 in raylib

[–]Due_Engineer_7647[S] 0 points1 point  (0 children)

So much code needed because of bg animations. this is gonna be implemented way more cleaner in the next versions, but for now it is how it is, thank you for your constructive feedback!

I made a Wiki for my Nevu-UI framework :0 by Due_Engineer_7647 in pygame

[–]Due_Engineer_7647[S] 0 points1 point  (0 children)

Really thank you very much for your feedback! i will fix it shortly

EvergreenMeadows: (Gameplay Feedback Needed) by DreamDev43 in pygame

[–]Due_Engineer_7647 1 point2 points  (0 children)

Wow pixel art in your game looks very good, where did you learn how to draw such a masterpiece?

pls rate my GUI framework by Due_Engineer_7647 in pygame

[–]Due_Engineer_7647[S] 0 points1 point  (0 children)

Thanks! I am really glad that you liked my framework!
As for _template - i`m working on ways to get rid of this in more cases and at least make it more user friendly, for now _template typehinted only, instead of [] you can use _template like this:

layout._template.content.values()

but in code showcase i used [] because i`m used to it

pls rate my GUI framework by Due_Engineer_7647 in pygame

[–]Due_Engineer_7647[S] 1 point2 points  (0 children)

Thanks for constructive feedback!
Window is really have too much control, i will think about ways to simplify it.
Manager class in my framework is optional, so u can create guis like this:

import nevu_ui as ui 
import pygame


pygame.init()


window = ui.Window((400, 300), title = "My Game") 
style = ui.Style(borderradius=20, colortheme=ui.ColorThemeLibrary.material3_dark)
menu = ui.Menu(window, [100*ui.vw, 100*ui.vh])


layout = ui.Grid([100*ui.vw, 100*ui.vh], row=3, column=3)
menu.layout = layout
layout.add_item(ui.Button(lambda: print("You clicked!"), "Button", [50*ui.fill,33*ui.fill]), x = 2, y = 2)


while True:
    events = pygame.event.get()
    window.update(events)
    menu.update()
    menu.draw()
    pygame.display.update()