gioui.org@v0.6.1-0.20240506124620-7a9ce51988ce/io/system/decoration.go (about) 1 package system 2 3 import ( 4 "strings" 5 6 "gioui.org/internal/ops" 7 "gioui.org/op" 8 ) 9 10 // ActionAreaOp makes the current clip area available for 11 // system gestures. 12 // 13 // Note: only ActionMove is supported. 14 type ActionInputOp Action 15 16 // Action is a set of window decoration actions. 17 type Action uint 18 19 const ( 20 // ActionMinimize minimizes a window. 21 ActionMinimize Action = 1 << iota 22 // ActionMaximize maximizes a window. 23 ActionMaximize 24 // ActionUnmaximize restores a maximized window. 25 ActionUnmaximize 26 // ActionFullscreen makes a window fullscreen. 27 ActionFullscreen 28 // ActionRaise requests that the platform bring this window to the top of all open windows. 29 // Some platforms do not allow this except under certain circumstances, such as when 30 // a window from the same application already has focus. If the platform does not 31 // support it, this method will do nothing. 32 ActionRaise 33 // ActionCenter centers the window on the screen. 34 // It is ignored in Fullscreen mode and on Wayland. 35 ActionCenter 36 // ActionClose closes a window. 37 // Only applicable on macOS, Windows, X11 and Wayland. 38 ActionClose 39 // ActionMove moves a window directed by the user. 40 ActionMove 41 ) 42 43 func (op ActionInputOp) Add(o *op.Ops) { 44 data := ops.Write(&o.Internal, ops.TypeActionInputLen) 45 data[0] = byte(ops.TypeActionInput) 46 data[1] = byte(op) 47 } 48 49 func (a Action) String() string { 50 var buf strings.Builder 51 for b := Action(1); a != 0; b <<= 1 { 52 if a&b != 0 { 53 if buf.Len() > 0 { 54 buf.WriteByte('|') 55 } 56 buf.WriteString(b.string()) 57 a &^= b 58 } 59 } 60 return buf.String() 61 } 62 63 func (a Action) string() string { 64 switch a { 65 case ActionMinimize: 66 return "ActionMinimize" 67 case ActionMaximize: 68 return "ActionMaximize" 69 case ActionUnmaximize: 70 return "ActionUnmaximize" 71 case ActionClose: 72 return "ActionClose" 73 case ActionMove: 74 return "ActionMove" 75 } 76 return "" 77 }