82cb79feb3
Styling of these is not complete yet.
47 lines
1.2 KiB
Text
47 lines
1.2 KiB
Text
# Rule.nas : horizontal or vertical dividing line,
|
|
# optionally with a text label, eg to name a section
|
|
# Copyright (C) 2022 James Turner
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
gui.widgets.HorizontalRule = {
|
|
new: func(parent, style, cfg)
|
|
{
|
|
var m = gui.Widget.new(gui.widgets.HorizontalRule);
|
|
m._cfg = Config.new(cfg);
|
|
m._focus_policy = m.NoFocus;
|
|
m._setView( style.createWidget(parent, "rule", m._cfg) );
|
|
|
|
# should ask Style the rule height, not hard-code 1px
|
|
m.setLayoutMinimumSize([16, 1]);
|
|
m.setLayoutSizeHint([m._MAX_SIZE, 1]); # expand to fill
|
|
m.setLayoutMaximumSize([m._MAX_SIZE, 1]);
|
|
return m;
|
|
},
|
|
setText: func(text)
|
|
{
|
|
me._view.setText(me, text);
|
|
return me;
|
|
}
|
|
};
|
|
|
|
gui.widgets.VerticalRule = {
|
|
new: func(parent, style, cfg)
|
|
{
|
|
var m = gui.Widget.new(gui.widgets.VerticalRule);
|
|
m._cfg = Config.new(cfg);
|
|
m._focus_policy = m.NoFocus;
|
|
m._setView( style.createWidget(parent, "rule", m._cfg) );
|
|
|
|
# should ask Style the rule height, not hard-code 1px
|
|
m.setLayoutMinimumSize([1, 16]);
|
|
m.setLayoutSizeHint([1, m._MAX_SIZE]); # expand to fill
|
|
m.setLayoutMaximumSize([1, m._MAX_SIZE]);
|
|
return m;
|
|
},
|
|
setText: func(text)
|
|
{
|
|
me._view.setText(me, text);
|
|
return me;
|
|
}
|
|
};
|