From dcf824023587c2a088254a37f5bc42bb383d89a3 Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko Date: Thu, 1 Sep 2022 11:04:50 +0300 Subject: [PATCH] Removed Init function from View interface --- absoluteLayout.go | 6 +++--- audioPlayer.go | 6 +++--- canvasView.go | 6 +++--- checkbox.go | 6 +++--- colorPicker.go | 6 +++--- columnLayout.go | 6 +++--- customView.go | 4 ---- datePicker.go | 6 +++--- detailsView.go | 6 +++--- dropDownList.go | 6 +++--- editView.go | 6 +++--- filePicker.go | 6 +++--- gridLayout.go | 6 +++--- imageView.go | 6 +++--- listLayout.go | 6 +++--- listView.go | 6 +++--- mediaPlayer.go | 4 ++-- numberPicker.go | 6 +++--- progressBar.go | 6 +++--- resizable.go | 6 +++--- stackLayout.go | 6 +++--- tableView.go | 8 ++++---- tabsLayout.go | 6 +++--- textView.go | 6 +++--- timePicker.go | 6 +++--- videoPlayer.go | 6 +++--- view.go | 12 +++++------- viewsContainer.go | 4 ++-- 28 files changed, 82 insertions(+), 88 deletions(-) diff --git a/absoluteLayout.go b/absoluteLayout.go index 704e28c..d55cdac 100644 --- a/absoluteLayout.go +++ b/absoluteLayout.go @@ -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" } diff --git a/audioPlayer.go b/audioPlayer.go index ab27a64..a7cecc3 100644 --- a/audioPlayer.go +++ b/audioPlayer.go @@ -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" } diff --git a/canvasView.go b/canvasView.go index 10a18bb..a0b1286 100644 --- a/canvasView.go +++ b/canvasView.go @@ -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" } diff --git a/checkbox.go b/checkbox.go index 4248686..b366066 100644 --- a/checkbox.go +++ b/checkbox.go @@ -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){} diff --git a/colorPicker.go b/colorPicker.go index 0d95803..ed0f055 100644 --- a/colorPicker.go +++ b/colorPicker.go @@ -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) diff --git a/columnLayout.go b/columnLayout.go index c9032e7..ec10221 100644 --- a/columnLayout.go +++ b/columnLayout.go @@ -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" } diff --git a/customView.go b/customView.go index 54e732f..e88df6c 100644 --- a/customView.go +++ b/customView.go @@ -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) } diff --git a/datePicker.go b/datePicker.go index da45faa..2709b71 100644 --- a/datePicker.go +++ b/datePicker.go @@ -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){} } diff --git a/detailsView.go b/detailsView.go index 5eedbec..8cf9307 100644 --- a/detailsView.go +++ b/detailsView.go @@ -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" } diff --git a/dropDownList.go b/dropDownList.go index 0f740c8..9658976 100644 --- a/dropDownList.go +++ b/dropDownList.go @@ -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{} diff --git a/editView.go b/editView.go index 0ffe59e..f60f3b4 100644 --- a/editView.go +++ b/editView.go @@ -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" } diff --git a/filePicker.go b/filePicker.go index 66f8fea..63203eb 100644 --- a/filePicker.go +++ b/filePicker.go @@ -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){} diff --git a/gridLayout.go b/gridLayout.go index da9a6e3..0db165f 100644 --- a/gridLayout.go +++ b/gridLayout.go @@ -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" } diff --git a/imageView.go b/imageView.go index 1302d61..4ed1ae4 100644 --- a/imageView.go +++ b/imageView.go @@ -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" diff --git a/listLayout.go b/listLayout.go index 872d762..dc608de 100644 --- a/listLayout.go +++ b/listLayout.go @@ -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" } diff --git a/listView.go b/listView.go index 30c0a49..d7ef071 100644 --- a/listView.go +++ b/listView.go @@ -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{} diff --git a/mediaPlayer.go b/mediaPlayer.go index 22a5d54..9ea43b9 100644 --- a/mediaPlayer.go +++ b/mediaPlayer.go @@ -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" } diff --git a/numberPicker.go b/numberPicker.go index e405115..49bc038 100644 --- a/numberPicker.go +++ b/numberPicker.go @@ -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){} } diff --git a/progressBar.go b/progressBar.go index 78767de..f93a372 100644 --- a/progressBar.go +++ b/progressBar.go @@ -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" } diff --git a/resizable.go b/resizable.go index 4131ef8..f6da563 100644 --- a/resizable.go +++ b/resizable.go @@ -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{} diff --git a/stackLayout.go b/stackLayout.go index b8491b5..5f09800 100644 --- a/stackLayout.go +++ b/stackLayout.go @@ -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} diff --git a/tableView.go b/tableView.go index eead271..bd979ff 100644 --- a/tableView.go +++ b/tableView.go @@ -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) diff --git a/tabsLayout.go b/tabsLayout.go index 94c3d0e..ca069a2 100644 --- a/tabsLayout.go +++ b/tabsLayout.go @@ -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){} diff --git a/textView.go b/textView.go index e38a9f9..dac9f9c 100644 --- a/textView.go +++ b/textView.go @@ -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" } diff --git a/timePicker.go b/timePicker.go index f9cd8aa..9a603ba 100644 --- a/timePicker.go +++ b/timePicker.go @@ -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){} } diff --git a/videoPlayer.go b/videoPlayer.go index b9db00e..94592e0 100644 --- a/videoPlayer.go +++ b/videoPlayer.go @@ -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" } diff --git a/view.go b/view.go index 39c9848..9df58ab 100644 --- a/view.go +++ b/view.go @@ -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 diff --git a/viewsContainer.go b/viewsContainer.go index 549d9bd..86bf757 100644 --- a/viewsContainer.go +++ b/viewsContainer.go @@ -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{} }