forked from mbk-lab/rui_orig
2
0
Fork 0

Removed Init function from View interface

This commit is contained in:
Alexei Anoshenko 2022-09-01 11:04:50 +03:00
parent 69fcfa0839
commit dcf8240235
28 changed files with 82 additions and 88 deletions

View File

@ -14,7 +14,7 @@ type absoluteLayoutData struct {
// NewAbsoluteLayout create new AbsoluteLayout object and return it
func NewAbsoluteLayout(session Session, params Params) AbsoluteLayout {
view := new(absoluteLayoutData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -24,8 +24,8 @@ func newAbsoluteLayout(session Session) View {
}
// Init initialize fields of ViewsContainer by default values
func (layout *absoluteLayoutData) Init(session Session) {
layout.viewsContainerData.Init(session)
func (layout *absoluteLayoutData) init(session Session) {
layout.viewsContainerData.init(session)
layout.tag = "AbsoluteLayout"
layout.systemClass = "ruiAbsoluteLayout"
}

View File

@ -11,7 +11,7 @@ type audioPlayerData struct {
// NewAudioPlayer create new MediaPlayer object and return it
func NewAudioPlayer(session Session, params Params) AudioPlayer {
view := new(audioPlayerData)
view.Init(session)
view.init(session)
view.tag = "AudioPlayer"
setInitParams(view, params)
return view
@ -21,8 +21,8 @@ func newAudioPlayer(session Session) View {
return NewAudioPlayer(session, nil)
}
func (player *audioPlayerData) Init(session Session) {
player.mediaPlayerData.Init(session)
func (player *audioPlayerData) init(session Session) {
player.mediaPlayerData.init(session)
player.tag = "AudioPlayer"
}

View File

@ -21,7 +21,7 @@ type canvasViewData struct {
// NewCanvasView creates the new custom draw view
func NewCanvasView(session Session, params Params) CanvasView {
view := new(canvasViewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -31,8 +31,8 @@ func newCanvasView(session Session) View {
}
// Init initialize fields of ViewsContainer by default values
func (canvasView *canvasViewData) Init(session Session) {
canvasView.viewData.Init(session)
func (canvasView *canvasViewData) init(session Session) {
canvasView.viewData.init(session)
canvasView.tag = "CanvasView"
}

View File

@ -23,7 +23,7 @@ type checkboxData struct {
// NewCheckbox create new Checkbox object and return it
func NewCheckbox(session Session, params Params) Checkbox {
view := new(checkboxData)
view.Init(session)
view.init(session)
setInitParams(view, Params{
ClickEvent: checkboxClickListener,
KeyDownEvent: checkboxKeyListener,
@ -36,8 +36,8 @@ func newCheckbox(session Session) View {
return NewCheckbox(session, nil)
}
func (button *checkboxData) Init(session Session) {
button.viewsContainerData.Init(session)
func (button *checkboxData) init(session Session) {
button.viewsContainerData.init(session)
button.tag = "Checkbox"
button.systemClass = "ruiGridLayout ruiCheckbox"
button.checkedListeners = []func(Checkbox, bool){}

View File

@ -23,7 +23,7 @@ type colorPickerData struct {
// NewColorPicker create new ColorPicker object and return it
func NewColorPicker(session Session, params Params) ColorPicker {
view := new(colorPickerData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -32,8 +32,8 @@ func newColorPicker(session Session) View {
return NewColorPicker(session, nil)
}
func (picker *colorPickerData) Init(session Session) {
picker.viewData.Init(session)
func (picker *colorPickerData) init(session Session) {
picker.viewData.init(session)
picker.tag = "ColorPicker"
picker.colorChangedListeners = []func(ColorPicker, Color){}
picker.properties[Padding] = Px(0)

View File

@ -47,7 +47,7 @@ type columnLayoutData struct {
// NewColumnLayout create new ColumnLayout object and return it
func NewColumnLayout(session Session, params Params) ColumnLayout {
view := new(columnLayoutData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -57,8 +57,8 @@ func newColumnLayout(session Session) View {
}
// Init initialize fields of ColumnLayout by default values
func (ColumnLayout *columnLayoutData) Init(session Session) {
ColumnLayout.viewsContainerData.Init(session)
func (ColumnLayout *columnLayoutData) init(session Session) {
ColumnLayout.viewsContainerData.init(session)
ColumnLayout.tag = "ColumnLayout"
//ColumnLayout.systemClass = "ruiColumnLayout"
}

View File

@ -87,10 +87,6 @@ func (customView *CustomViewData) Clear() {
customView.superView.Clear()
}
// Init initializes fields of View by default values
func (customView *CustomViewData) Init(session Session) {
}
func (customView *CustomViewData) cssViewStyle(buffer cssBuilder, session Session) {
customView.superView.cssViewStyle(buffer, session)
}

View File

@ -29,7 +29,7 @@ type datePickerData struct {
// NewDatePicker create new DatePicker object and return it
func NewDatePicker(session Session, params Params) DatePicker {
view := new(datePickerData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -38,8 +38,8 @@ func newDatePicker(session Session) View {
return NewDatePicker(session, nil)
}
func (picker *datePickerData) Init(session Session) {
picker.viewData.Init(session)
func (picker *datePickerData) init(session Session) {
picker.viewData.init(session)
picker.tag = "DatePicker"
picker.dateChangedListeners = []func(DatePicker, time.Time){}
}

View File

@ -24,7 +24,7 @@ type detailsViewData struct {
// NewDetailsView create new DetailsView object and return it
func NewDetailsView(session Session, params Params) DetailsView {
view := new(detailsViewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -34,8 +34,8 @@ func newDetailsView(session Session) View {
}
// Init initialize fields of DetailsView by default values
func (detailsView *detailsViewData) Init(session Session) {
detailsView.viewsContainerData.Init(session)
func (detailsView *detailsViewData) init(session Session) {
detailsView.viewsContainerData.init(session)
detailsView.tag = "DetailsView"
//detailsView.systemClass = "ruiDetailsView"
}

View File

@ -27,7 +27,7 @@ type dropDownListData struct {
// NewDropDownList create new DropDownList object and return it
func NewDropDownList(session Session, params Params) DropDownList {
view := new(dropDownListData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -36,8 +36,8 @@ func newDropDownList(session Session) View {
return NewDropDownList(session, nil)
}
func (list *dropDownListData) Init(session Session) {
list.viewData.Init(session)
func (list *dropDownListData) init(session Session) {
list.viewData.init(session)
list.tag = "DropDownList"
list.items = []string{}
list.disabledItems = []any{}

View File

@ -48,7 +48,7 @@ type editViewData struct {
// NewEditView create new EditView object and return it
func NewEditView(session Session, params Params) EditView {
view := new(editViewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -57,8 +57,8 @@ func newEditView(session Session) View {
return NewEditView(session, nil)
}
func (edit *editViewData) Init(session Session) {
edit.viewData.Init(session)
func (edit *editViewData) init(session Session) {
edit.viewData.init(session)
edit.textChangeListeners = []func(EditView, string){}
edit.tag = "EditView"
}

View File

@ -72,7 +72,7 @@ func (file *FileInfo) initBy(node DataValue) {
// NewFilePicker create new FilePicker object and return it
func NewFilePicker(session Session, params Params) FilePicker {
view := new(filePickerData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -81,8 +81,8 @@ func newFilePicker(session Session) View {
return NewFilePicker(session, nil)
}
func (picker *filePickerData) Init(session Session) {
picker.viewData.Init(session)
func (picker *filePickerData) init(session Session) {
picker.viewData.init(session)
picker.tag = "FilePicker"
picker.files = []FileInfo{}
picker.loader = map[int]func(FileInfo, []byte){}

View File

@ -17,7 +17,7 @@ type gridLayoutData struct {
// NewGridLayout create new GridLayout object and return it
func NewGridLayout(session Session, params Params) GridLayout {
view := new(gridLayoutData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -27,8 +27,8 @@ func newGridLayout(session Session) View {
}
// Init initialize fields of GridLayout by default values
func (gridLayout *gridLayoutData) Init(session Session) {
gridLayout.viewsContainerData.Init(session)
func (gridLayout *gridLayoutData) init(session Session) {
gridLayout.viewsContainerData.init(session)
gridLayout.tag = "GridLayout"
gridLayout.systemClass = "ruiGridLayout"
}

View File

@ -54,7 +54,7 @@ type imageViewData struct {
// NewImageView create new ImageView object and return it
func NewImageView(session Session, params Params) ImageView {
view := new(imageViewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -64,8 +64,8 @@ func newImageView(session Session) View {
}
// Init initialize fields of imageView by default values
func (imageView *imageViewData) Init(session Session) {
imageView.viewData.Init(session)
func (imageView *imageViewData) init(session Session) {
imageView.viewData.init(session)
imageView.tag = "ImageView"
//imageView.systemClass = "ruiImageView"

View File

@ -33,7 +33,7 @@ type listLayoutData struct {
// NewListLayout create new ListLayout object and return it
func NewListLayout(session Session, params Params) ListLayout {
view := new(listLayoutData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -43,8 +43,8 @@ func newListLayout(session Session) View {
}
// Init initialize fields of ViewsAlignContainer by default values
func (listLayout *listLayoutData) Init(session Session) {
listLayout.viewsContainerData.Init(session)
func (listLayout *listLayoutData) init(session Session) {
listLayout.viewsContainerData.init(session)
listLayout.tag = "ListLayout"
listLayout.systemClass = "ruiListLayout"
}

View File

@ -69,7 +69,7 @@ type listViewData struct {
// NewListView creates the new list view
func NewListView(session Session, params Params) ListView {
view := new(listViewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -79,8 +79,8 @@ func newListView(session Session) View {
}
// Init initialize fields of ViewsContainer by default values
func (listView *listViewData) Init(session Session) {
listView.viewData.Init(session)
func (listView *listViewData) init(session Session) {
listView.viewData.init(session)
listView.tag = "ListView"
listView.systemClass = "ruiListView"
listView.items = []View{}

View File

@ -163,8 +163,8 @@ type MediaSource struct {
MimeType string
}
func (player *mediaPlayerData) Init(session Session) {
player.viewData.Init(session)
func (player *mediaPlayerData) init(session Session) {
player.viewData.init(session)
player.tag = "MediaPlayer"
}

View File

@ -36,7 +36,7 @@ type numberPickerData struct {
// NewNumberPicker create new NumberPicker object and return it
func NewNumberPicker(session Session, params Params) NumberPicker {
view := new(numberPickerData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -45,8 +45,8 @@ func newNumberPicker(session Session) View {
return NewNumberPicker(session, nil)
}
func (picker *numberPickerData) Init(session Session) {
picker.viewData.Init(session)
func (picker *numberPickerData) init(session Session) {
picker.viewData.init(session)
picker.tag = "NumberPicker"
picker.numberChangedListeners = []func(NumberPicker, float64){}
}

View File

@ -22,7 +22,7 @@ type progressBarData struct {
// NewProgressBar create new ProgressBar object and return it
func NewProgressBar(session Session, params Params) ProgressBar {
view := new(progressBarData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -31,8 +31,8 @@ func newProgressBar(session Session) View {
return NewProgressBar(session, nil)
}
func (progress *progressBarData) Init(session Session) {
progress.viewData.Init(session)
func (progress *progressBarData) init(session Session) {
progress.viewData.init(session)
progress.tag = "ProgressBar"
}

View File

@ -45,7 +45,7 @@ type resizableData struct {
// NewResizable create new Resizable object and return it
func NewResizable(session Session, params Params) Resizable {
view := new(resizableData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -54,8 +54,8 @@ func newResizable(session Session) View {
return NewResizable(session, nil)
}
func (resizable *resizableData) Init(session Session) {
resizable.viewData.Init(session)
func (resizable *resizableData) init(session Session) {
resizable.viewData.init(session)
resizable.tag = "Resizable"
resizable.systemClass = "ruiGridLayout"
resizable.content = []View{}

View File

@ -41,7 +41,7 @@ type stackLayoutData struct {
// NewStackLayout create new StackLayout object and return it
func NewStackLayout(session Session, params Params) StackLayout {
view := new(stackLayoutData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -51,8 +51,8 @@ func newStackLayout(session Session) View {
}
// Init initialize fields of ViewsContainer by default values
func (layout *stackLayoutData) Init(session Session) {
layout.viewsContainerData.Init(session)
func (layout *stackLayoutData) init(session Session) {
layout.viewsContainerData.init(session)
layout.tag = "StackLayout"
layout.systemClass = "ruiStackLayout"
layout.properties[TransitionEndEvent] = []func(View, string){layout.pushFinished, layout.popFinished}

View File

@ -245,7 +245,7 @@ type tableCellView struct {
// NewTableView create new TableView object and return it
func NewTableView(session Session, params Params) TableView {
view := new(tableViewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -255,8 +255,8 @@ func newTableView(session Session) View {
}
// Init initialize fields of TableView by default values
func (table *tableViewData) Init(session Session) {
table.viewData.Init(session)
func (table *tableViewData) init(session Session) {
table.viewData.init(session)
table.tag = "TableView"
table.cellViews = []View{}
table.cellFrame = []Frame{}
@ -828,7 +828,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
defer freeStringBuilder(cssBuilder.buffer)
var view tableCellView
view.Init(session)
view.init(session)
ignorCells := []struct{ row, column int }{}
selectionMode := GetTableSelectionMode(table)

View File

@ -81,7 +81,7 @@ type tabsLayoutData struct {
// NewTabsLayout create new TabsLayout object and return it
func NewTabsLayout(session Session, params Params) TabsLayout {
view := new(tabsLayoutData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -91,8 +91,8 @@ func newTabsLayout(session Session) View {
}
// Init initialize fields of ViewsContainer by default values
func (tabsLayout *tabsLayoutData) Init(session Session) {
tabsLayout.viewsContainerData.Init(session)
func (tabsLayout *tabsLayoutData) init(session Session) {
tabsLayout.viewsContainerData.init(session)
tabsLayout.tag = "TabsLayout"
tabsLayout.systemClass = "ruiTabsLayout"
tabsLayout.tabListener = []func(TabsLayout, int, int){}

View File

@ -17,7 +17,7 @@ type textViewData struct {
// NewTextView create new TextView object and return it
func NewTextView(session Session, params Params) TextView {
view := new(textViewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -27,8 +27,8 @@ func newTextView(session Session) View {
}
// Init initialize fields of TextView by default values
func (textView *textViewData) Init(session Session) {
textView.viewData.Init(session)
func (textView *textViewData) init(session Session) {
textView.viewData.init(session)
textView.tag = "TextView"
}

View File

@ -29,7 +29,7 @@ type timePickerData struct {
// NewTimePicker create new TimePicker object and return it
func NewTimePicker(session Session, params Params) TimePicker {
view := new(timePickerData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
@ -38,8 +38,8 @@ func newTimePicker(session Session) View {
return NewTimePicker(session, nil)
}
func (picker *timePickerData) Init(session Session) {
picker.viewData.Init(session)
func (picker *timePickerData) init(session Session) {
picker.viewData.init(session)
picker.tag = "TimePicker"
picker.timeChangedListeners = []func(TimePicker, time.Time){}
}

View File

@ -29,7 +29,7 @@ type videoPlayerData struct {
// NewVideoPlayer create new MediaPlayer object and return it
func NewVideoPlayer(session Session, params Params) VideoPlayer {
view := new(videoPlayerData)
view.Init(session)
view.init(session)
view.tag = "VideoPlayer"
setInitParams(view, params)
return view
@ -39,8 +39,8 @@ func newVideoPlayer(session Session) View {
return NewVideoPlayer(session, nil)
}
func (player *videoPlayerData) Init(session Session) {
player.mediaPlayerData.Init(session)
func (player *videoPlayerData) init(session Session) {
player.mediaPlayerData.init(session)
player.tag = "VideoPlayer"
}

12
view.go
View File

@ -33,14 +33,10 @@ type View interface {
ViewStyle
fmt.Stringer
// Init initializes fields of View by default values
Init(session Session)
// Session returns the current Session interface
Session() Session
// Parent returns the parent view
Parent() View
parentHTMLID() string
setParentID(parentID string)
// Tag returns the tag of View interface
Tag() string
// ID returns the id of the view
@ -65,6 +61,8 @@ type View interface {
htmlTag() string
closeHTMLTag() bool
htmlID() string
parentHTMLID() string
setParentID(parentID string)
htmlSubviews(self View, buffer *strings.Builder)
htmlProperties(self View, buffer *strings.Builder)
htmlDisabledProperties(self View, buffer *strings.Builder)
@ -100,7 +98,7 @@ type viewData struct {
func newView(session Session) View {
view := new(viewData)
view.Init(session)
view.init(session)
return view
}
@ -122,12 +120,12 @@ func setInitParams(view View, params Params) {
// NewView create new View object and return it
func NewView(session Session, params Params) View {
view := new(viewData)
view.Init(session)
view.init(session)
setInitParams(view, params)
return view
}
func (view *viewData) Init(session Session) {
func (view *viewData) init(session Session) {
view.viewStyle.init()
view.tag = "View"
view.session = session

View File

@ -25,8 +25,8 @@ type viewsContainerData struct {
}
// Init initialize fields of ViewsContainer by default values
func (container *viewsContainerData) Init(session Session) {
container.viewData.Init(session)
func (container *viewsContainerData) init(session Session) {
container.viewData.init(session)
container.tag = "ViewsContainer"
container.views = []View{}
}