# Path: glbackground.py
# class GLBackground(GLOrtho):
#     margin = 8
#     bg_color = (0.0, 0.0, 0.0, 0.6)
# 
#     #bg_color = (30/255.0,0,255/255.0, 100/255.0)
#     def gl_draw(self):
#         #if hasattr(self, 'highlight_bg_color') and self in self.get_root().find_widget(mouse.get_pos()).all_parents():
#         #    color = self.highlight_bg_color
#         #else:
#         color = tuple(self.bg_color) + (1.0,)
# 
#         glEnable(GL_BLEND)
#         glColor(color[0], color[1], color[2], color[3])
#         glVertexPointer(2, GL_FLOAT, 0, array([-1, -1, -1, 1, 1, 1, 1, -1], dtype='float32'))
#         glDrawArrays(GL_QUADS, 0, 4)
#         glDisable(GL_BLEND)


from numpy.core.umath import absolute
from pygame import key
from albow import Label
from pymclevel.box import Vector
from glbackground import GLBackground
import config
        self.shrink_wrap()

        # tooltipBacking = Panel()
        # tooltipBacking.bg_color = (0, 0, 0, 0.6)
        keys = [config.config.get("Keys", k).upper() for k in ("Forward", "Back", "Left", "Right", "Up", "Down")]

        nudgeLabel.tooltipText = "Click and hold.  While holding, use the movement keys ({0}{1}{2}{3}{4}{5}) to nudge. Hold SHIFT to nudge faster.".format(*keys)
        # tooltipBacking.shrink_wrap()

    def mouse_down(self, event):
        self.focus()

    def mouse_up(self, event):
        self.get_root().mcedit.editor.focus_switch = None  # xxxx restore focus to editor better

    def key_down(self, evt):
        keyname = key.name(evt.key)
        if keyname == config.config.get("Keys", "Up"):
            self.nudge(Vector(0, 1, 0))
        if keyname == config.config.get("Keys", "Down"):
            self.nudge(Vector(0, -1, 0))

        Z = self.get_root().mcedit.editor.mainViewport.cameraVector  # xxx mouthful
        absZ = map(abs, Z)
        if absZ[0] < absZ[2]:
            forward = (0, 0, (-1 if Z[2] < 0 else 1))
        else:
            forward = ((-1 if Z[0] < 0 else 1), 0, 0)

        back = map(int.__neg__, forward)

# Path: glbackground.py
# class GLBackground(GLOrtho):
#     margin = 8
#     bg_color = (0.0, 0.0, 0.0, 0.6)
# 
#     #bg_color = (30/255.0,0,255/255.0, 100/255.0)
#     def gl_draw(self):
#         #if hasattr(self, 'highlight_bg_color') and self in self.get_root().find_widget(mouse.get_pos()).all_parents():
#         #    color = self.highlight_bg_color
#         #else:
#         color = tuple(self.bg_color) + (1.0,)
# 
#         glEnable(GL_BLEND)
#         glColor(color[0], color[1], color[2], color[3])
#         glVertexPointer(2, GL_FLOAT, 0, array([-1, -1, -1, 1, 1, 1, 1, -1], dtype='float32'))
#         glDrawArrays(GL_QUADS, 0, 4)
#         glDisable(GL_BLEND)


# Path: editortools/nudgebutton.py
from numpy.core.umath import absolute
from pygame import key
from albow import Label
from pymclevel.box import Vector
from glbackground import GLBackground
import config

        self.shrink_wrap()

        # tooltipBacking = Panel()
        # tooltipBacking.bg_color = (0, 0, 0, 0.6)
        keys = [config.config.get("Keys", k).upper() for k in ("Forward", "Back", "Left", "Right", "Up", "Down")]

        nudgeLabel.tooltipText = "Click and hold.  While holding, use the movement keys ({0}{1}{2}{3}{4}{5}) to nudge. Hold SHIFT to nudge faster.".format(*keys)
        # tooltipBacking.shrink_wrap()

    def mouse_down(self, event):
        self.focus()

    def mouse_up(self, event):
        self.get_root().mcedit.editor.focus_switch = None  # xxxx restore focus to editor better

    def key_down(self, evt):
        keyname = key.name(evt.key)
        if keyname == config.config.get("Keys", "Up"):
            self.nudge(Vector(0, 1, 0))
        if keyname == config.config.get("Keys", "Down"):
            self.nudge(Vector(0, -1, 0))

        Z = self.get_root().mcedit.editor.mainViewport.cameraVector  # xxx mouthful
        absZ = map(abs, Z)
        if absZ[0] < absZ[2]:
            forward = (0, 0, (-1 if Z[2] < 0 else 1))
        else:
            forward = ((-1 if Z[0] < 0 else 1), 0, 0)

        back = map(int.__neg__, forward)

        left = forward[2], forward[1], -forward[0]