string $KNF_reNaming_n = "RE_NAMING";
//윈도우 이름을 정하고 변수 선언
if(`window -exists $KNF_reNaming_n`)
//RE_NAMING 이란 윈도우가 있으면 창을 닫는다
deleteUI $KNF_reNaming_n;
window -t "Re Naming MEL" $KNF_reNaming_n;
//윈도우 타이틀
string $form = `formLayout`;
//레이아웃 변수 선언
string $KNF_reN_textField
= `textFieldGrp -label "Input String : " -text "" reNaming_UI`;
//텍스트 필드
string $KNF_reN_radioButtonGrpA = `radioButtonGrp -numberOfRadioButtons 4
-cc KNF_ccOptionMenu
-labelArray4 "Re Name" "Replace" "Add prefix" "Add postfix" -sl 1 KNF_reN_radioButtonGrp1`;
//라디오버튼 그룹
string $KNF_reN_buttonA = `button -h 30 -w 250 -label "EXCUTE" -c KNF_reN_Excute`;
//버튼
string $KNF_reN_buttonB = `button -h 30 -w 250 -label "CANCLE" -command ("deleteUI -window " + $KNF_reNaming_n)`;
//버튼
string $KNF_reN_checkBoxA = `checkBox -label "AutoGroup(Just Rename in BF)" -align "left" -enable 0 -v 0 KNF_reN_checkboxAUI`;
//체크박스
string $KNF_reN_checkBoxB = `checkBox -label "Fix Padding Number" -align "left" -cc KNF_reN_ccCheckboxB -v 1 KNF_reN_checkboxBUI`;
//체크박스
string $KNF_reN_intSliderA = `intSliderGrp -field true -minValue 3 -maxValue 8 -value 3 -enable 1 KNF_reN_intSliderAUI`;
//슬라이드 바
optionMenu -label "Name Type :" -cc KNF_ccOptionMenu KNF_whichNameType;
//옵션메뉴
menuItem -label "Done";
menuItem -label "geo";
menuItem -label "shp";
menuItem -label "lgt";
menuItem -label "anm";
menuItem -label "bon";
menuItem -label "cam";
menuItem -label "grp";
menuItem -label "con";
menuItem -label "msc";
string $fgtextA = `text -label "By Kyounan
5:36pm, 17/06/10"
-align "left"
-font "smallPlainLabelFont"`;
//텍스트
string $fgtextB = `text -label "V 0.3.0"
-align "right"
-font "smallPlainLabelFont"`;
//텍스트
string $fgseparatorA = `separator`;
//분할라인
//여기서 부터가 윈도우에 배치
formLayout -edit
-attachForm
$KNF_reN_textField
"top"
10
-attachForm
$KNF_reN_textField
"left"
1
-attachForm
KNF_whichNameType
"top"
10
-attachControl
KNF_whichNameType
"left"
10
$KNF_reN_textField
-attachControl
$KNF_reN_radioButtonGrpA
"top"
10
$KNF_reN_textField
-attachForm
$KNF_reN_radioButtonGrpA
"left"
70
-attachControl
$KNF_reN_buttonA
"top"
10
$KNF_reN_radioButtonGrpA
-attachForm
$KNF_reN_buttonA
"left"
20
-attachControl
$KNF_reN_buttonB
"top"
10
$KNF_reN_buttonA
-attachForm
$KNF_reN_buttonB
"left"
20
-attachControl
$KNF_reN_checkBoxA
"top"
10
$KNF_reN_radioButtonGrpA
-attachControl
$KNF_reN_checkBoxA
"left"
20
$KNF_reN_buttonA
-attachControl
$KNF_reN_checkBoxB
"top"
5
$KNF_reN_checkBoxA
-attachControl
$KNF_reN_checkBoxB
"left"
20
$KNF_reN_buttonA
-attachControl
$KNF_reN_intSliderA
"top"
5
$KNF_reN_checkBoxB
-attachForm
$KNF_reN_intSliderA
"right"
20
-attachForm
$fgtextA
"bottom"
2
-attachForm
$fgtextA
"left"
5
-attachForm
$fgtextB
"bottom"
2
-attachForm
$fgtextB
"right"
5
-attachForm
$fgseparatorA
"bottom"
20
-attachForm
$fgseparatorA
"left"
5
-attachForm
$fgseparatorA
"right"
5
$form;
//여기까지가 윈도우 배치
showWindow $KNF_reNaming_n;
//윈도우 표시
window -e -wh 550 180 $KNF_reNaming_n;
//윈도우 창 크기 설정
위의 코드를 실행 하면 다음과 같은 윈도우가 생성이 됩니다.
제가 mel 을 이용하여 UI 를 만들때 가장 쉽다고 생각 되는 부분이 formLayout 을
이용하여 작성 하는 것인데요..
윈도우 배치 부분만을 설명을 드리면
제일 마지막 줄에서 윈도우 크기를 지정을 하고 그 안에 적절하게 배치 될 수 있게
-attachControl, -attachForm 플래그를 사용하여 작성하는 방법입니다.
길어 보이지만 상당히 간단 합니다.
-attachForm 은 윈도우에 붙인다는 뜻으로
-attachForm
$KNF_reN_textField
"top"
10 의 경우
$KNF_reN_textField 에 해당하는 아이템을 윈도우의 top을 기준으로 10픽셀을 띄우고
배치 한다는 뜻입니다.
-attachControl 은 윈도우가 아닌 해당 아이템을 다른 아이템을 기준으로 붙인다는뜻으로
-attachControl
$KNF_reN_radioButtonGrpA
"top"
10
$KNF_reN_textField
$KNF_reN_radioButtonGrpA 에 해당하는 아이템을 $KNF_reN_textField 에 해당하는 아이템
을 기준으로 10픽셀을 띄우고 배치 하라는 의미 입니다.
즉, $KNF_reN_textField 에 해당하는 아이템 밑에 10픽셀의 공간을 두고 배치하게 됩니다.
위 코드를 실행 해보고 formlayout 부분을 확인 하면 쉽게 알 수 있을것입니다.