1 Star 0 Fork 0

yangzheng/walk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
separator.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
Simon Rozman 提交于 2019-09-26 17:03 . DPI: Merge SizePixels to Size
// Copyright 2017 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build windows
package walk
import (
"github.com/lxn/win"
)
type Separator struct {
WidgetBase
vertical bool
}
func NewHSeparator(parent Container) (*Separator, error) {
return newSeparator(parent, false)
}
func NewVSeparator(parent Container) (*Separator, error) {
return newSeparator(parent, true)
}
func newSeparator(parent Container, vertical bool) (*Separator, error) {
s := &Separator{vertical: vertical}
if err := InitWidget(
s,
parent,
"STATIC",
win.WS_VISIBLE|win.SS_ETCHEDHORZ,
0); err != nil {
return nil, err
}
return s, nil
}
func (s *Separator) CreateLayoutItem(ctx *LayoutContext) LayoutItem {
var layoutFlags LayoutFlags
if s.vertical {
layoutFlags = GrowableHorz | GreedyHorz
} else {
layoutFlags = GrowableVert | GreedyVert
}
return &separatorLayoutItem{
layoutFlags: layoutFlags,
}
}
type separatorLayoutItem struct {
LayoutItemBase
layoutFlags LayoutFlags
}
func (li *separatorLayoutItem) LayoutFlags() LayoutFlags {
return li.layoutFlags
}
func (li *separatorLayoutItem) IdealSize() Size {
return li.MinSize()
}
func (li *separatorLayoutItem) MinSize() Size {
return SizeFrom96DPI(Size{2, 2}, li.ctx.dpi)
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/xtyzheng/walk.git
git@gitee.com:xtyzheng/walk.git
xtyzheng
walk
walk
master

搜索帮助