mirror of
https://gitee.com/energye/energy.git
synced 2024-11-30 18:57:39 +08:00
增加打包图形化配置 v1.0.0
This commit is contained in:
parent
694753acfc
commit
bbec7ae3af
225
cmd/internal/ide/ide-component-drag.go
Normal file
225
cmd/internal/ide/ide-component-drag.go
Normal file
@ -0,0 +1,225 @@
|
||||
package ide
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
"github.com/energye/golcl/lcl/types/colors"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x, y int32) {
|
||||
if m.isDown {
|
||||
if m.isBorder { //mouse down borderMargin > resize
|
||||
switch m.borderHT {
|
||||
case HTRIGHT:
|
||||
tmpWidth := m.ow + (x - m.dx)
|
||||
if tmpWidth <= minW {
|
||||
return
|
||||
}
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTLEFT:
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
if tmpWidth <= minW {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTTOP:
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpHeight := m.oh + (m.oy - tmpY)
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
case HTBOTTOM:
|
||||
tmpHeight := m.oh + (y - m.dy)
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(m.oh + (y - m.dy))
|
||||
case HTTOPRIGHT:
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpHeight := m.oh + (m.oy - tmpY)
|
||||
tmpWidth := m.ow + (x - m.dx)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTBOTTOMRIGHT:
|
||||
tmpWidth := m.ow + (x - m.dx)
|
||||
tmpHeight := m.oh + (y - m.dy)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
case HTTOPLEFT:
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpHeight := m.oh + (m.oy - tmpY)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
case HTBOTTOMLEFT:
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
tmpHeight := m.oh + (y - m.dy)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
}
|
||||
//rect := m.componentParentPanel.BoundsRect()
|
||||
//fx, fy, fw, fh = rect.Left, rect.Top, rect.Width(), rect.Height()
|
||||
//Ide.formsSyncSize(m.Id)
|
||||
m.refreshAnchorsPoint()
|
||||
return
|
||||
} else if m.isComponentArea && m.componentType != ctForm { // mouse down component area > move
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.isDClick = false
|
||||
//rect := m.componentParentPanel.BoundsRect()
|
||||
//fx, fy, fw, fh = rect.Left, rect.Top, rect.Width(), rect.Height()
|
||||
//Ide.formsSyncSize(m.Id)
|
||||
m.refreshAnchorsPoint()
|
||||
return
|
||||
}
|
||||
}
|
||||
//if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { // 右上
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeSW)
|
||||
// m.borderHT = HTTOPRIGHT
|
||||
//} else if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y <= m.oh && y >= m.oh-borderRange; m.isBorder { // 右下
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeSE)
|
||||
// m.borderHT = HTBOTTOMRIGHT
|
||||
//} else if m.isBorder = x <= borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { //左上
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeSE)
|
||||
// m.borderHT = HTTOPLEFT
|
||||
//} else if m.isBorder = x <= borderRange && y >= m.oh-borderRange; m.isBorder && m.componentType != ctForm { //左下
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeSW)
|
||||
// m.borderHT = HTBOTTOMLEFT
|
||||
//} else if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y > borderRange && y < m.oh-borderRange; m.isBorder { //右
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeW)
|
||||
// m.borderHT = HTRIGHT
|
||||
//} else if m.isBorder = x <= borderRange && y > borderRange && y < m.oh-borderRange; m.isBorder && m.componentType != ctForm { //左
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeW)
|
||||
// m.borderHT = HTLEFT
|
||||
//} else if m.isBorder = x > borderRange && x < m.ow-borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { //上
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeN)
|
||||
// m.borderHT = HTTOP
|
||||
//} else if m.isBorder = x > borderRange && x < m.ow-borderRange && y >= m.oh-borderRange; m.isBorder { //下
|
||||
// m.componentParentPanel.SetCursor(types.CrSizeN)
|
||||
// m.borderHT = HTBOTTOM
|
||||
//} else {
|
||||
// m.isBorder = false
|
||||
// m.componentParentPanel.SetCursor(types.CrDefault)
|
||||
//}
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *IDEComponent) mouseDown(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||
if button == types.MbLeft {
|
||||
if time.Now().UnixMilli()-m.clickTime.UnixMilli() < 500 {
|
||||
m.isDClick = true
|
||||
} else {
|
||||
m.isDClick = false
|
||||
}
|
||||
m.clickTime = time.Now()
|
||||
m.dx = x
|
||||
m.dy = y
|
||||
if m.componentType == ctForm {
|
||||
for _, form := range Ide.forms {
|
||||
if form.active != nil {
|
||||
form.active.clearBorderColor()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m.form.active.clearBorderColor()
|
||||
m.form.active = m
|
||||
if m.isUseBorder {
|
||||
m.form.active.setBorderColor(colors.ClBlack)
|
||||
} else {
|
||||
m.form.active.clearBorderColor()
|
||||
}
|
||||
}
|
||||
if !m.isBorder && m.componentType != ctForm {
|
||||
m.isComponentArea = true
|
||||
m.anchor.hide()
|
||||
m.componentParentPanel.SetCursor(types.CrSizeAll)
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
m.isDown = true
|
||||
}
|
||||
}
|
||||
|
||||
func (m *IDEComponent) mouseUp(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||
m.isDown = false
|
||||
m.isBorder = false
|
||||
if m.isComponentArea {
|
||||
m.anchor.show()
|
||||
m.isComponentArea = false
|
||||
if m.isDClick {
|
||||
fmt.Println("双击自定义组件", m.Id, m.name)
|
||||
return
|
||||
}
|
||||
m.componentParentPanel.SetCursor(types.CrDefault)
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
m.ox, m.oy, m.ow, m.oh = m.componentParentPanel.Left(), m.componentParentPanel.Top(), m.componentParentPanel.Width(), m.componentParentPanel.Height()
|
||||
}
|
@ -13,7 +13,7 @@ type IDEEdit struct {
|
||||
|
||||
func (m *IDEForm) CreateEdit() *IDEEdit {
|
||||
com := &IDEEdit{}
|
||||
com.IDEComponent = m.newIDEComponentContainer(true, 50, 50, 150, 24)
|
||||
com.IDEComponent = m.newIDEComponentContainer(false, 50, 50, 150, 24)
|
||||
com.Component = lcl.NewEdit(com.IDEComponent.componentParentPanel)
|
||||
com.Component.SetParent(com.IDEComponent.componentParentPanel)
|
||||
com.Component.SetAlign(types.AlClient)
|
||||
|
@ -16,7 +16,7 @@ func (m *IDEForm) CreateDialogOpen() *IDEOpenDialog {
|
||||
com.Component = lcl.NewOpenDialog(com.IDEComponent.componentParentPanel)
|
||||
com.component = com.Component
|
||||
m.addComponent(com.IDEComponent)
|
||||
com.componentType = ctLabel
|
||||
com.componentType = ctOpenDialog
|
||||
com.name = fmt.Sprintf("DialogOpen%d", com.Id)
|
||||
com.componentParentPanel.SetCaption(com.name)
|
||||
//com.createAnchor(m.componentParentPanel)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package ide
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/energye/energy/cef"
|
||||
"github.com/energye/golcl/lcl"
|
||||
"github.com/energye/golcl/lcl/types"
|
||||
@ -36,6 +35,29 @@ type anchor struct {
|
||||
topRight *lcl.TPanel
|
||||
bottomLeft *lcl.TPanel
|
||||
bottomRight *lcl.TPanel
|
||||
dx, dy int32
|
||||
}
|
||||
|
||||
func (m *anchor) hide() {
|
||||
m.top.Hide()
|
||||
m.bottom.Hide()
|
||||
m.left.Hide()
|
||||
m.right.Hide()
|
||||
m.topLeft.Hide()
|
||||
m.topRight.Hide()
|
||||
m.bottomLeft.Hide()
|
||||
m.bottomRight.Hide()
|
||||
}
|
||||
|
||||
func (m *anchor) show() {
|
||||
m.top.Show()
|
||||
m.bottom.Show()
|
||||
m.left.Show()
|
||||
m.right.Show()
|
||||
m.topLeft.Show()
|
||||
m.topRight.Show()
|
||||
m.bottomLeft.Show()
|
||||
m.bottomRight.Show()
|
||||
}
|
||||
|
||||
func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPanel {
|
||||
@ -59,18 +81,67 @@ func (m *IDEComponent) newAnchorPoint(owner lcl.IWinControl, ht int32) *lcl.TPan
|
||||
default:
|
||||
point.SetCursor(types.CrDefault)
|
||||
}
|
||||
m.mouseMove(sender, shift, x, y)
|
||||
//m.mouseMove(sender, shift, x, y)
|
||||
if m.isDown {
|
||||
var (
|
||||
x, y = x - m.anchor.dx, y - m.anchor.dy
|
||||
rect = m.componentParentPanel.BoundsRect()
|
||||
)
|
||||
switch ht {
|
||||
case HTRIGHT:
|
||||
tmpWidth := rect.Width() + x
|
||||
if tmpWidth <= minW {
|
||||
return
|
||||
}
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTLEFT:
|
||||
tmpX := rect.Left + x
|
||||
tmpWidth := rect.Width() + (rect.Left - tmpX)
|
||||
if tmpWidth <= minW {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTTOP:
|
||||
tmpY := rect.Top + y
|
||||
tmpHeight := rect.Height() + (rect.Top - tmpY)
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
case HTBOTTOM:
|
||||
tmpHeight := rect.Height() + y
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
default:
|
||||
return
|
||||
}
|
||||
m.refreshAnchorsPoint()
|
||||
}
|
||||
})
|
||||
point.SetOnMouseDown(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||
m.mouseDown(sender, button, shift, x, y)
|
||||
m.isDown = true
|
||||
m.anchor.dx, m.anchor.dy = x, y
|
||||
})
|
||||
point.SetOnMouseUp(func(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||
m.mouseUp(sender, button, shift, x, y)
|
||||
m.isDown = false
|
||||
})
|
||||
return point
|
||||
}
|
||||
|
||||
func (m *IDEComponent) createAnchor(owner lcl.IWinControl) {
|
||||
func (m *IDEComponent) createAnchor() {
|
||||
owner := m.componentParentPanel.Parent()
|
||||
acr := &anchor{}
|
||||
acr.top = m.newAnchorPoint(owner, HTTOP)
|
||||
acr.bottom = m.newAnchorPoint(owner, HTBOTTOM)
|
||||
@ -89,223 +160,14 @@ func (m *IDEComponent) refreshAnchorsPoint() {
|
||||
return
|
||||
}
|
||||
rect := m.componentParentPanel.BoundsRect()
|
||||
m.anchor.left.SetBounds(rect.Left-pointWC, rect.Top+rect.Height()/2-pointWC, pointW, pointW)
|
||||
m.anchor.top.SetBounds(rect.Left+rect.Width()/2-pointWC, rect.Top-pointWC, pointW, pointW)
|
||||
m.anchor.bottom.SetBounds(rect.Left+rect.Width()/2-pointWC, rect.Bottom-pointWC, pointW, pointW)
|
||||
m.anchor.left.SetBounds(rect.Left-pointWC, rect.Top+rect.Height()/2-pointWC, pointW, pointW)
|
||||
m.anchor.right.SetBounds(rect.Right-pointWC, rect.Top+rect.Height()/2-pointWC, pointW, pointW)
|
||||
}
|
||||
|
||||
func (m *IDEComponent) mouseMove(sender lcl.IObject, shift types.TShiftState, x, y int32) {
|
||||
if m.isDown {
|
||||
if m.isBorder { //mouse down borderMargin > resize
|
||||
switch m.borderHT {
|
||||
case HTRIGHT:
|
||||
tmpWidth := m.ow + (x - m.dx)
|
||||
if tmpWidth <= minW {
|
||||
return
|
||||
}
|
||||
if m.borderPanel != nil {
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
}
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTLEFT:
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
if tmpWidth <= minW {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTTOP:
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpHeight := m.oh + (m.oy - tmpY)
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
case HTBOTTOM:
|
||||
tmpHeight := m.oh + (y - m.dy)
|
||||
if tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(m.oh + (y - m.dy))
|
||||
case HTTOPRIGHT:
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpHeight := m.oh + (m.oy - tmpY)
|
||||
tmpWidth := m.ow + (x - m.dx)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
case HTBOTTOMRIGHT:
|
||||
tmpWidth := m.ow + (x - m.dx)
|
||||
tmpHeight := m.oh + (y - m.dy)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
case HTTOPLEFT:
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpHeight := m.oh + (m.oy - tmpY)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
case HTBOTTOMLEFT:
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
tmpWidth := m.ow + (m.ox - tmpX)
|
||||
tmpHeight := m.oh + (y - m.dy)
|
||||
if tmpWidth <= minW || tmpHeight <= minH {
|
||||
return
|
||||
}
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetWidth(tmpWidth + border)
|
||||
m.borderPanel.SetHeight(tmpHeight + border)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.componentParentPanel.SetWidth(tmpWidth)
|
||||
m.componentParentPanel.SetHeight(tmpHeight)
|
||||
}
|
||||
//rect := m.componentParentPanel.BoundsRect()
|
||||
//fx, fy, fw, fh = rect.Left, rect.Top, rect.Width(), rect.Height()
|
||||
//Ide.formsSyncSize(m.Id)
|
||||
//m.refreshAnchorsPoint()
|
||||
return
|
||||
} else if m.isComponentArea && m.componentType != ctForm { // mouse down component area > move
|
||||
tmpY := m.componentParentPanel.Top() + (y - m.dy)
|
||||
tmpX := m.componentParentPanel.Left() + (x - m.dx)
|
||||
m.borderPanel.SetLeft(tmpX - border/2)
|
||||
m.borderPanel.SetTop(tmpY - border/2)
|
||||
m.componentParentPanel.SetTop(tmpY)
|
||||
m.componentParentPanel.SetLeft(tmpX)
|
||||
m.isDClick = false
|
||||
//rect := m.componentParentPanel.BoundsRect()
|
||||
//fx, fy, fw, fh = rect.Left, rect.Top, rect.Width(), rect.Height()
|
||||
//Ide.formsSyncSize(m.Id)
|
||||
//m.refreshAnchorsPoint()
|
||||
return
|
||||
}
|
||||
}
|
||||
if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { // 右上
|
||||
m.componentParentPanel.SetCursor(types.CrSizeSW)
|
||||
m.borderHT = HTTOPRIGHT
|
||||
} else if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y <= m.oh && y >= m.oh-borderRange; m.isBorder { // 右下
|
||||
m.componentParentPanel.SetCursor(types.CrSizeSE)
|
||||
m.borderHT = HTBOTTOMRIGHT
|
||||
} else if m.isBorder = x <= borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { //左上
|
||||
m.componentParentPanel.SetCursor(types.CrSizeSE)
|
||||
m.borderHT = HTTOPLEFT
|
||||
} else if m.isBorder = x <= borderRange && y >= m.oh-borderRange; m.isBorder && m.componentType != ctForm { //左下
|
||||
m.componentParentPanel.SetCursor(types.CrSizeSW)
|
||||
m.borderHT = HTBOTTOMLEFT
|
||||
} else if m.isBorder = x <= m.ow && x >= m.ow-borderRange && y > borderRange && y < m.oh-borderRange; m.isBorder { //右
|
||||
m.componentParentPanel.SetCursor(types.CrSizeW)
|
||||
m.borderHT = HTRIGHT
|
||||
} else if m.isBorder = x <= borderRange && y > borderRange && y < m.oh-borderRange; m.isBorder && m.componentType != ctForm { //左
|
||||
m.componentParentPanel.SetCursor(types.CrSizeW)
|
||||
m.borderHT = HTLEFT
|
||||
} else if m.isBorder = x > borderRange && x < m.ow-borderRange && y <= borderRange; m.isBorder && m.componentType != ctForm { //上
|
||||
m.componentParentPanel.SetCursor(types.CrSizeN)
|
||||
m.borderHT = HTTOP
|
||||
} else if m.isBorder = x > borderRange && x < m.ow-borderRange && y >= m.oh-borderRange; m.isBorder { //下
|
||||
m.componentParentPanel.SetCursor(types.CrSizeN)
|
||||
m.borderHT = HTBOTTOM
|
||||
} else {
|
||||
m.isBorder = false
|
||||
m.componentParentPanel.SetCursor(types.CrDefault)
|
||||
}
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *IDEComponent) mouseDown(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||
if button == types.MbLeft {
|
||||
if time.Now().UnixMilli()-m.clickTime.UnixMilli() < 500 {
|
||||
m.isDClick = true
|
||||
} else {
|
||||
m.isDClick = false
|
||||
}
|
||||
m.clickTime = time.Now()
|
||||
m.dx = x
|
||||
m.dy = y
|
||||
if m.componentType == ctForm {
|
||||
for _, form := range Ide.forms {
|
||||
if form.active != nil {
|
||||
form.active.clearBorderColor()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m.form.active.clearBorderColor()
|
||||
m.form.active = m
|
||||
if m.isUseBorder {
|
||||
m.form.active.setBorderColor(colors.ClBlack)
|
||||
} else {
|
||||
m.form.active.clearBorderColor()
|
||||
}
|
||||
}
|
||||
if !m.isBorder && m.componentType != ctForm {
|
||||
m.isComponentArea = true
|
||||
m.componentParentPanel.SetCursor(types.CrSizeAll)
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
m.isDown = true
|
||||
}
|
||||
}
|
||||
|
||||
func (m *IDEComponent) mouseUp(sender lcl.IObject, button types.TMouseButton, shift types.TShiftState, x, y int32) {
|
||||
m.isDown = false
|
||||
if m.isComponentArea {
|
||||
if m.isDClick {
|
||||
fmt.Println("双击自定义组件", m.Id, m.name)
|
||||
return
|
||||
}
|
||||
m.isComponentArea = false
|
||||
m.componentParentPanel.SetCursor(types.CrDefault)
|
||||
if m.component != nil {
|
||||
switch m.component.(type) {
|
||||
case lcl.IControl:
|
||||
m.component.(lcl.IControl).SetCursor(m.componentParentPanel.Cursor())
|
||||
default:
|
||||
m.componentParentPanel.SetCursor(m.componentParentPanel.Cursor())
|
||||
}
|
||||
}
|
||||
}
|
||||
m.ox, m.oy, m.ow, m.oh = m.componentParentPanel.Left(), m.componentParentPanel.Top(), m.componentParentPanel.Width(), m.componentParentPanel.Height()
|
||||
m.anchor.topLeft.SetBounds(rect.Left-pointWC, rect.Top-pointWC, pointW, pointW)
|
||||
m.anchor.topRight.SetBounds(rect.Right-pointWC, rect.Top-pointWC, pointW, pointW)
|
||||
m.anchor.bottomLeft.SetBounds(rect.Left-pointWC, rect.Bottom-pointWC, pointW, pointW)
|
||||
m.anchor.bottomRight.SetBounds(rect.Right-pointWC, rect.Bottom-pointWC, pointW, pointW)
|
||||
}
|
||||
|
||||
func (m *IDEComponent) setBorderColor(color types.TColor) {
|
||||
@ -329,6 +191,7 @@ func (m *IDEComponent) clearBorderColor() {
|
||||
}
|
||||
|
||||
func (m *IDEComponent) createAfter() {
|
||||
m.createAnchor()
|
||||
m.componentParentPanel.SetCaption(m.name)
|
||||
m.component.SetName(m.name)
|
||||
pm := lcl.NewPopupMenu(m.component)
|
||||
|
@ -65,9 +65,9 @@ func (m *IDEForm) newIDEComponentContainer(useBorder bool, left, top, width, hei
|
||||
} else {
|
||||
ideComponent.componentParentPanel.SetBounds(left, top, width, height)
|
||||
}
|
||||
ideComponent.componentParentPanel.SetOnMouseMove(ideComponent.mouseMove)
|
||||
ideComponent.componentParentPanel.SetOnMouseDown(ideComponent.mouseDown)
|
||||
ideComponent.componentParentPanel.SetOnMouseUp(ideComponent.mouseUp)
|
||||
//ideComponent.componentParentPanel.SetOnMouseMove(ideComponent.mouseMove)
|
||||
//ideComponent.componentParentPanel.SetOnMouseDown(ideComponent.mouseDown)
|
||||
//ideComponent.componentParentPanel.SetOnMouseUp(ideComponent.mouseUp)
|
||||
ideComponent.ox, ideComponent.oy, ideComponent.ow, ideComponent.oh = ideComponent.componentParentPanel.Left(), ideComponent.componentParentPanel.Top(), ideComponent.componentParentPanel.Width(), ideComponent.componentParentPanel.Height()
|
||||
ideComponent.form = m
|
||||
ideComponent.isUseBorder = useBorder
|
||||
|
@ -38,6 +38,7 @@ const (
|
||||
ctImage
|
||||
ctButton
|
||||
ctLabel
|
||||
ctOpenDialog
|
||||
)
|
||||
|
||||
var (
|
||||
@ -200,8 +201,8 @@ func (m *IDE) initTopMainMenu() {
|
||||
action.SetHint("新建Form窗口|新建一个Form窗口")
|
||||
action.SetOnExecute(func(sender lcl.IObject) {
|
||||
form := m.CreateForm()
|
||||
form.CreateDialogOpen()
|
||||
form.CreateEdit()
|
||||
//form.CreateDialogOpen()
|
||||
//form.CreateEdit()
|
||||
form.CreateImage()
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user