魔法のメモ

CG N GAME BLOG

Python_18.RED_サンプル

# -*- coding: utf-8 -*-
import engine.cmds as cmds
import engine.wpf as wpf
class GridTest:
    def makeGridSplitterColumn(self, parent,  column, row, rowSpan = 1):
        gridSplitterColumn = wpf.createElement('GridSplitter', parent)
        gridSplitterColumn.HorizontalAlignment = 'Stretch'
        gridSplitterColumn.VerticalAlignment = 'Stretch'
        gridSplitterColumn.Width = 4
        gridSplitterColumn.Grid_Column = column
        gridSplitterColumn.Grid_Row = row
        gridSplitterColumn.Grid_RowSpan = rowSpan
        
    def makeGridSplitterRow(self, parent,  column, row, columnSpan = 1):
        gridSplitterRow = wpf.createElement('GridSplitter', parent)
        gridSplitterRow.HorizontalAlignment = 'Stretch'
        gridSplitterRow.VerticalAlignment = 'Stretch'
        gridSplitterRow.Height = 4
        gridSplitterRow.Grid_Column = column
        gridSplitterRow.Grid_Row = row
        gridSplitterRow.Grid_ColumnSpan = columnSpan
        
    def separateGrid(self, isColumn, x, y, parent):
        grid = wpf.createElement('Grid', parent)
        if isColumn == True:
            for width in [x, 'auto', y]:
                r = wpf.createElement('ColumnDefinition', grid)
                r.Width = width
        else:
            for height in [x, 'auto', y]:
                r = wpf.createElement('RowDefinition', grid)
                r.Height = height
        return grid
        
    def makeWindow(self):
        self.win = wpf.createElement('Window')
        self.win.Width = 1000
        self.win.Height = 700
        self.win.Title = 'GridSample'
        self.win.Background = 'Gray'
        
    def makeMenu(self, parent, gridColumn, gridRow):
        grid = self.separateGrid(False, '1*', '8*', parent)
        grid.Grid_Column = gridColumn
        grid.Grid_Row = gridRow
        self.makeGridSplitterRow(grid, 0, 1)
        
        panel = wpf.createElement('StackPanel', grid)
        panel.Grid_Row = 0
        
        menu = wpf.createElement('Menu', panel)
        m_menuItem1 = wpf.createElement('MenuItem', menu)
        m_menuItem1.Header = 'File'
        m_menuItem2 = wpf.createElement('MenuItem', menu)
        m_menuItem2.Header = 'Edit'
        
        return grid
        
    def makeInspector(self, parent, gridColumn, gridRow):
        grid = self.separateGrid(True, '3*', '1*', parent)
        grid.Grid_Column = gridColumn
        grid.Grid_Row = gridRow
        self.makeGridSplitterColumn(grid, 1, 0)
        
        panel = wpf.createElement('StackPanel', grid)
        panel.Grid_Column = 2
        textBlock = wpf.createElement('TextBlock', panel)
        textBlock.Text = 'Inspector'
        textBlock.Foreground = 'White'
        
        return grid
        
    def makeAssetBrowser(self, parent, gridColumn, gridRow):
        grid = self.separateGrid(False, '2*', '1*', parent)
        grid.Grid_Column = gridColumn
        grid.Grid_Row = gridRow
        self.makeGridSplitterRow(grid, 0, 1)
        
        panel = wpf.createElement('StackPanel', grid)
        panel.Grid_Row = 2
        textBlock = wpf.createElement('TextBlock', panel)
        textBlock.Text = 'AssetBrowser'
        textBlock.Foreground = 'White'
        
        return grid
        
    def makeHierarcy(self, parent, gridColumn, gridRow):
        grid = self.separateGrid(True, '1*', '2*', parent)
        grid.Grid_Column = gridColumn
        grid.Grid_Row = gridRow
        self.makeGridSplitterColumn(grid, 1, 0)
        
        panel = wpf.createElement('StackPanel', grid)
        panel.Grid_Column = 0
        textBlock = wpf.createElement('TextBlock', panel)
        textBlock.Text = 'Hierarchies'
        textBlock.Foreground = 'White'
        
        return grid
        
    def makeRuntime(self, parent, gridColumn, gridRow):
        grid = self.separateGrid(False, '1*', '4*', parent)
        grid.Grid_Column = gridColumn
        grid.Grid_Row = gridRow
        self.makeGridSplitterRow(grid, 0, 1)
        
        panel = wpf.createElement('StackPanel', grid)
        panel.Background = 'Black'
        panel.Grid_Row = 2
        
        return grid
        
    def makeMacroShelf(self, parent):
        tabControl = wpf.createElement('TabControl', parent)
        tabControlGrid_Row = 0
        tabItem1 = wpf.createElement('TabItem', tabControl)
        tabItem1.Header = 'Asset'
        tabItem2 = wpf.createElement('TabItem', tabControl)
        tabItem2.Header = 'Collision'
        buttonStack = wpf.createElement('StackPanel', tabItem1)
        buttonStack.Orientation = 'Horizontal'
        buttonStack.VerticalAlignment = 'Top'
        for var in range(0, 10):
            button = wpf.createElement('Button', buttonStack)
            button.Width = 40
            button.Height = 40
        
    def makeGrid(self):
        menuGrid = self.makeMenu(self.win, 0, 0)
        inspectorGrid = self.makeInspector(menuGrid, 0, 2)
        assetBrowserGrid = self.makeAssetBrowser(inspectorGrid, 0, 2)
        hierarcyGrid = self.makeHierarcy(assetBrowserGrid, 0,0)
        runtimeGrid = self.makeRuntime(hierarcyGrid, 2,0)
        self.makeMacroShelf(runtimeGrid)
        
    def __init__(self):
        self.makeWindow()
        self.makeGrid()
        
        self.win.Show()
GridTest()