1 // Written in the D programming language. 2 /++ 3 + Authors: KanzakiKino 4 + Copyright: KanzakiKino 2018 5 + License: LGPL-3.0 6 ++/ 7 module w4d.widget.popup.dialog.base; 8 import w4d.parser.colorset, 9 w4d.style.rect, 10 w4d.style.scalar, 11 w4d.widget.popup.base, 12 w4d.widget.base, 13 w4d.exception; 14 import gl3n.linalg; 15 16 /// A base widget of popup dialog. 17 class PopupDialogWidget : PopupWidget 18 { 19 /// 20 override void handlePopup ( bool opened, WindowContext w ) 21 { 22 if ( opened ) { 23 requestLayout(); 24 } 25 super.handlePopup( opened, w ); 26 } 27 28 /// 29 this () 30 { 31 super(); 32 33 parseColorSetsFromFile!"colorset/dialog.yaml"( style ); 34 style.box.borderWidth = Rect(1.pixel); 35 style.box.paddings = Rect(2.mm); 36 } 37 38 /// 39 override void move ( vec2, vec2 ) 40 { 41 throw new W4dException( "Cannot move the dialog." ); 42 } 43 44 /// 45 override vec2 layout ( vec2 pos, vec2 parentSize ) 46 { 47 const size = .Widget.layout( pos, parentSize ); 48 auto late = (parentSize-size)/2 + pos; 49 late -= style.translate; 50 51 shift( late - style.translate ); 52 53 return vec2(0,0); 54 } 55 }