Skip to content

Commit

Permalink
Move default skin
Browse files Browse the repository at this point in the history
  • Loading branch information
tobspr committed Feb 6, 2016
1 parent b66d524 commit acf5f53
Show file tree
Hide file tree
Showing 133 changed files with 168 additions and 22 deletions.
5 changes: 0 additions & 5 deletions Builtin/GenerateAtlas.bat

This file was deleted.

2 changes: 1 addition & 1 deletion Builtin/LUISkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LUIDefaultSkin(LUISkin):

""" The default skin which comes with LUI """

skin_location = os.path.dirname(os.path.abspath(__file__))
skin_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../Skins/Default/")

def __init__(self):
pass
Expand Down
56 changes: 56 additions & 0 deletions Demos/01_MinimalExample.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""
This file shows the smallest working LUI example, on which you can base your
LUI projects.
"""

# Add lui modules to the path. This will not be required when LUI is included
# in panda.
import sys
sys.path.insert(0, "../Builtin")

# Load some required LUI classes
from panda3d.lui import LUIRegion, LUIInputHandler

# Load a builtin LUI class. When lui is included in panda, this will be
# from direct.luiwidgets.LUIButton import LUIButton
from LUIButton import LUIButton
from LUISkin import LUIDefaultSkin

# Setup panda, nothing special here
from panda3d.core import load_prc_file_data
load_prc_file_data("", """
text-minfilter linear
text-magfilter linear
text-pixels-per-unit 32
sync-video #f
textures-power-2 none
show-frame-rate-meter #t
win-size 700 600
window-title LUI Minimal Example
""")

from direct.showbase.ShowBase import ShowBase

class Application(ShowBase):

def __init__(self):
ShowBase.__init__(self)

# Construct a new LUIRegion
region = LUIRegion.make("LUI", base.win)

# Construct a new InputHandler to catch and process events
handler = LUIInputHandler()
base.mouseWatcher.attach_new_node(handler)
region.set_input_handler(handler)

# Load the default LUI skin
skin = LUIDefaultSkin()
skin.load()

# LUI is initialized now, so we can start adding elements, for example:
button = LUIButton(parent=region.root, text="Hello world!", top=30, left=30)

Application().run()
25 changes: 10 additions & 15 deletions Demos/SimpleConsole.py → Demos/02_SimpleConsole.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
win-fixed-size #f
""")

# Imports
from panda3d.lui import LUIRegion, LUIObject, LUIInputHandler
from panda3d.lui import LUIVerticalLayout
from LUISkin import LUIDefaultSkin
Expand All @@ -29,14 +30,12 @@
from LUIFormattedLabel import LUIFormattedLabel
from LUIScrollableRegion import LUIScrollableRegion


from Skins.Metro.LUIMetroSkin import LUIMetroSkin


s = ShowBase()


if True:
# Load a LUI Skin
if False:
skin = LUIMetroSkin()
base.win.set_clear_color(Vec4(1))
else:
Expand All @@ -45,7 +44,7 @@

skin.load()


# Initialize LUI
region = LUIRegion.make("LUI", base.win)
handler = LUIInputHandler()
base.mouseWatcher.attach_new_node(handler)
Expand All @@ -56,15 +55,8 @@
font="header", pos=(25, 17))

# Container
container = LUIFrame(
parent = region.root,
pos=(0, 0),
width=700,
height=500,
style=LUIFrame.FS_sunken,
margin=30)

container.top = 50
container = LUIFrame(parent = region.root, width=700, height=500,
style=LUIFrame.FS_sunken, margin=30, top=50)

text_container = LUIScrollableRegion(parent=container, width=675, height=440,
padding=0)
Expand All @@ -73,6 +65,8 @@
layout = LUIVerticalLayout(parent=text_container.content_node)

def send_command(event):
""" Called when the user presses enter in the input field, submits the
command and prints something on the console """
label = LUIFormattedLabel()
color = (0.9, 0.9, 0.9, 1.0)
if event.message.startswith(u"/"):
Expand All @@ -88,7 +82,8 @@ def send_command(event):

text_container.scroll_to_bottom()

input_field = LUIInputField(parent=container, bottom=0, left=0, width=680)
# Create the input box
input_field = LUIInputField(parent=container, bottom=0, left=0, width="100%")
input_field.bind("enter", send_command)
input_field.request_focus()

Expand Down
1 change: 0 additions & 1 deletion Demos/Button.py → Demos/B_Button.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
f.add_constructor_parameter("text", "u'Button'")
f.add_constructor_parameter("template", "'ButtonDefault'")


# Functions
f.add_public_function("set_text", [("text", "string")])
f.add_public_function("get_text", [], "string")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions Demos/DemoFramework.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
"""
This file contains some setup code for all the widget examples
"""

import sys
sys.path.insert(0, "../")
sys.path.insert(0, "../Builtin")
Expand Down Expand Up @@ -37,6 +43,7 @@ class DemoFramework:
""" This is a small helper class to setup common stuff for the demos """

def __init__(self):
""" Constructs the demo framework """

if False:
self._skin = LUIMetroSkin()
Expand Down
7 changes: 7 additions & 0 deletions Demos/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


This directory contains various LUI demos. You should start with the demos
01 and 02.

After that, you can try out the demos starting with B_, showing builtin
LUI components.
5 changes: 5 additions & 0 deletions Skins/Default/GenerateAtlas.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@echo off

cd res
ppython ../../../Misc/LUIAtlasGen.py
pause
Empty file added Skins/Default/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
82 changes: 82 additions & 0 deletions Tests/Test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

import sys
sys.path.insert(0, "../Builtin")

from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject

from panda3d.core import *
load_prc_file_data("", """
text-minfilter linear
text-magfilter linear
text-pixels-per-unit 32
sync-video #f
textures-power-2 none
notify-level-lui info
show-frame-rate-meter #t
win-size 780 630
window-title LUI Demo
win-fixed-size #f
""")

from panda3d.lui import LUIRegion, LUIObject, LUIInputHandler, LUISprite, LUIVerticalLayout
from LUISkin import LUIDefaultSkin
from LUIFrame import LUIFrame
from LUIFormattedLabel import LUIFormattedLabel
from LUIInputField import LUIInputField
from LUIButton import LUIButton
from LUILabel import LUILabel
from LUICheckbox import LUICheckbox
from LUIRadiobox import LUIRadiobox
from LUIRadioboxGroup import LUIRadioboxGroup

s = ShowBase()
base.win.set_clear_color(Vec4(0.05, 0.05, 0.05, 1.0))

skin = LUIDefaultSkin()
skin.load()

region = LUIRegion.make("LUI", base.win)
handler = LUIInputHandler()
base.mouseWatcher.attach_new_node(handler)
region.set_input_handler(handler)

# bg = LUISprite(region.root, "blank", "skin")
# bg.pos = 200, 200
# bg.size = 200, 300

container = LUIFrame(
parent = region.root, pos = (200, 200), height=300,
style = LUIFrame.FS_sunken)


# label_tl = LUILabel(parent=container, text="Top Left", top_left=(0,0))
# label_tr = LUILabel(parent=container, text="Top Right", top_right=(0,0))
# label_bl = LUILabel(parent=container, text="Bottom Left", bottom_left=(0,0))
# label_br = LUILabel(parent=container, text="Bottom Right", bottom_right=(0,0))

# button = LUIButton(parent=container, top_left=(0, 0), text="Well this one .. is a long button! (A really long one!) ............ really long!")
# button.bind("click", lambda event: button.set_text("Hello!"))
container.size = 300, 300
# group = LUIRadioboxGroup()
# box = LUIRadiobox(parent=container, group=group, top=50)
# box2 = LUICheckbox(parent=container, top=100)

layout = LUIVerticalLayout(parent=container)
# layout.height = 280
# layout.width = 300

LUILabel(parent=layout.cell(), text="Hello")
LUILabel(parent=layout.cell(), text="World")
LUILabel(parent=layout.cell(100), text="100px row")
LUILabel(parent=layout.cell(), text="Next")
LUIButton(parent=layout.cell(), text="SomeButton")
LUILabel(parent=layout.cell('*'), text="Fill column")
LUILabel(parent=layout.cell(), text="Last column")

for i in range(5):
base.graphicsEngine.render_frame()

region.root.ls()

s.run()

0 comments on commit acf5f53

Please sign in to comment.