Esempio n. 1
0
func run() error {
	qml.Init(nil)
	engine := qml.NewEngine()
	engine.AddImageProvider("pwd", func(id string, width, height int) image.Image {
		f, err := os.Open(id)
		if err != nil {
			panic(err)
		}
		defer f.Close()
		image, err := png.Decode(f)
		if err != nil {
			panic(err)
		}
		return image
	})

	component, err := engine.LoadFile("imgprovider.qml")
	if err != nil {
		return err
	}

	win := component.CreateWindow(nil)
	win.Show()
	win.Wait()

	return nil
}
Esempio n. 2
0
func run(filename string) error {
	qml.Init(nil)
	engine := qml.NewEngine()

	model, err := Read("model/gopher.obj")
	if err != nil {
		return err
	}

	qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
		Init: func(g *Gopher, obj qml.Object) {
			g.Object = obj
			g.model = model
		},
	}})

	component, err := engine.LoadFile(filename)
	if err != nil {
		return err
	}

	win := component.CreateWindow(nil)
	win.Set("x", 560)
	win.Set("y", 320)
	win.Show()
	win.Wait()
	return nil
}
Esempio n. 3
0
func run() error {
	qml.Init(nil)
	engine := qml.NewEngine()

	component, err := engine.LoadFile("samegame.qml")
	if err != nil {
		return err
	}

	game := Game{
		MaxColumn: MAX_COL,
		MaxRow:    MAX_ROW,
		MaxIndex:  MAX_COL * MAX_ROW,
	}

	context := engine.Context()
	context.SetVar("game", &game)

	win := component.CreateWindow(nil)

	blockComponent, err := engine.LoadFile("Block.qml")
	if err != nil {
		return err
	}

	block := &Block{Component: blockComponent}
	game.Block = block

	game.Score = win.Root().ObjectByName("score")

	win.Show()
	win.Wait()

	return nil
}
Esempio n. 4
0
func run() error {
	qml.Init(nil)
	engine := qml.NewEngine()
	component, err := engine.LoadFile(os.Args[1])
	if err != nil {
		return err
	}
	window := component.CreateWindow(nil)
	window.Show()
	window.Wait()
	return nil
}
Esempio n. 5
0
File: main.go Progetto: ntcong/qml
func main() {
	qml.Init(nil)
	engine := qml.NewEngine()
	engine.On("quit", func() { os.Exit(0) })
	component, err := engine.LoadFile("basiclayout.qml")
	if err != nil {
		fmt.Println(err)
		return
	}

	window := component.CreateWindow(nil)
	window.Show()
	window.Wait()
}
Esempio n. 6
0
func run() error {
	qml.Init(nil)
	engine := qml.NewEngine()
	component, err := engine.LoadString("webview.qml", webview)
	if err != nil {
		return err
	}
	ctrl := &Control{
		done: make(chan error),
		win:  component.CreateWindow(nil),
	}
	engine.Context().SetVar("ctrl", ctrl)
	root := ctrl.win.Root()
	root.On("loadingChanged", ctrl.Snapshot)
	root.Set("url", os.Args[1])
	ctrl.win.Show()
	return <-ctrl.done
}
Esempio n. 7
0
func run() error {
	qml.Init(nil)

	qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
		Init: func(r *GoRect, obj qml.Object) { r.Object = obj },
	}})

	engine := qml.NewEngine()
	component, err := engine.LoadFile("painting.qml")
	if err != nil {
		return err
	}

	win := component.CreateWindow(nil)
	win.Show()
	win.Wait()

	return nil
}
Esempio n. 8
0
func run() error {
	qml.Init(nil)

	qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
		Name: "GoRect",
		New:  func() interface{} { return &GoRect{} },
	}})

	engine := qml.NewEngine()
	component, err := engine.LoadFile("painting.qml")
	if err != nil {
		return err
	}

	win := component.CreateWindow(nil)
	win.Show()
	win.Wait()

	return nil
}
Esempio n. 9
0
func run() error {
	qml.Init(nil)
	engine := qml.NewEngine()
	colors := &Colors{}
	engine.Context().SetVar("colors", colors)
	component, err := engine.LoadFile("delegate.qml")
	if err != nil {
		return err
	}
	window := component.CreateWindow(nil)
	window.Show()
	go func() {
		n := func() uint8 { return uint8(rand.Intn(256)) }
		for i := 0; i < 100; i++ {
			colors.Add(color.RGBA{n(), n(), n(), 0xff})
			time.Sleep(1 * time.Second)
		}
	}()
	window.Wait()
	return nil
}
Esempio n. 10
0
File: main.go Progetto: hahaya/qml
func main() {
	qml.Init(nil)
	engine := qml.NewEngine()
	component, err := engine.LoadFile("particle.qml")
	if err != nil {
		panic(err)
	}

	ctrl := Control{Message: "Hello from Go!"}

	context := engine.Context()
	context.SetVar("ctrl", &ctrl)

	window := component.CreateWindow(nil)

	ctrl.Root = window.Root()

	rand.Seed(time.Now().Unix())

	window.Show()
	window.Wait()
}
Esempio n. 11
0
func run() error {
	qml.Init(nil)

	qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
		Init: func(v *GoType, obj qml.Object) {},
	}, {
		Init: func(v *GoSingleton, obj qml.Object) { v.Event = "birthday" },

		Singleton: true,
	}})

	engine := qml.NewEngine()
	component, err := engine.LoadFile("customtype.qml")
	if err != nil {
		return err
	}

	value := component.Create(nil)
	fmt.Println("Text is:", value.Interface().(*GoType).Text)

	return nil
}
Esempio n. 12
0
func run() error {
	qml.Init(nil)

	qml.RegisterTypes("GoExtensions", 1, 0, []qml.TypeSpec{{
		Name: "GoType",
		New:  func() interface{} { return &GoType{} },
	}, {
		Name:      "GoSingleton",
		New:       func() interface{} { return &GoSingleton{Event: "birthday"} },
		Singleton: true,
	}})

	engine := qml.NewEngine()
	component, err := engine.LoadFile("customtype.qml")
	if err != nil {
		return err
	}

	value := component.Create(nil)
	fmt.Println("Text is:", value.Interface().(*GoType).Text)

	return nil
}
Esempio n. 13
0
func main() {
	qml.Init(nil)
	engine := qml.NewEngine()
	engine.On("quit", func() {
		fmt.Println("quit")
		os.Exit(0)
	})

	component, err := engine.LoadFile("basiclayout.qml")
	if err != nil {
		fmt.Println(err)
		return
	}

	ctrl := Control{Polje1: "Hello from Go!", Polje2: "tekst2"}
	context := engine.Context()
	context.SetVar("ctrl", &ctrl)

	window := component.CreateWindow(nil)
	ctrl.Root = window.Root()

	window.Show()
	window.Wait()
}
Esempio n. 14
0
func run() error {
	qml.Init(nil)

	engine := qml.NewEngine()

	base, err := engine.LoadFile("base.qml")
	if err != nil {
		return err
	}
	rect, err := engine.LoadFile("rect.qml")
	if err != nil {
		return err
	}

	win := base.CreateWindow(nil)
	obj := rect.Create(nil)

	obj.Set("parent", win.Root())

	win.Show()
	win.Wait()

	return nil
}
Esempio n. 15
0
func (t *tbfe) loop() {
	qml.Init(nil)
	engine := qml.NewEngine()

	engine.Context().SetVar("lines", t)
	engine.Context().SetVar("frontend", t)
	engine.Context().SetVar("editor", backend.GetEditor())

	backend.OnNew.Add(func(v *backend.View) {
		fv := &frontendView{bv: v}
		v.Buffer().AddCallback(fv.bufferChanged)
		v.Settings().AddOnChange("blah", func(name string) {
			if name == "lime.syntax.updated" {
				// force redraw, as the syntax regions might have changed...
				for i := range fv.FormattedLine {
					fv.formatLine(i)
				}
			}
		})

		t.views[v] = fv
		t.Len = len(t.views)
		qml.Changed(t, &t.Len)
	})

	ed := backend.GetEditor()
	ed.SetFrontend(t)
	ed.LogInput(false)
	ed.LogCommands(false)
	c := ed.Console()

	t.Console = &frontendView{bv: c}
	c.Buffer().AddCallback(t.Console.bufferChanged)

	if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
		log4go.Error(err)
	} else {
		scheme = sc
	}

	defer func() {
		fmt.Println(util.Prof)
	}()

	w := ed.NewWindow()
	v := w.OpenFile("main.go", 0)
	v.Settings().Set("trace", true)
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")
	c.Buffer().AddCallback(t.scroll)

	sel := v.Sel()
	sel.Clear()
	sel.Add(Region{0, 0})

	{
		w, h := 800, 600
		t.lock.Lock()
		t.layout[v] = layout{0, 0, w, h - console_height - 1, Region{}, 0}
		t.layout[c] = layout{0, h - console_height + 1, w, console_height - 5, Region{}, 0}
		t.lock.Unlock()
		t.Show(v, Region{1, 1})
	}
	t.Show(v, Region{100, 100})
	t.Show(v, Region{1, 1})
	//	t.Len, _ = v.Buffer().RowCol(v.Buffer().Size())

	ed.Init()
	sublime.Init()

	component, err := engine.LoadFile("main.qml")
	if err != nil {
		log4go.Exit(err)
	}
	window := component.CreateWindow(nil)
	window.Show()

	log4go.Debug("Done")
	window.Wait()
}
Esempio n. 16
0
func (s *S) SetUpSuite(c *C) {
	qml.Init(nil)
}
Esempio n. 17
0
File: main.go Progetto: nicecai/lime
func (t *tbfe) loop() {
	qml.Init(nil)
	engine := qml.NewEngine()

	engine.Context().SetVar("lines", t)
	engine.Context().SetVar("frontend", t)
	engine.Context().SetVar("editor", backend.GetEditor())

	backend.OnNew.Add(func(v *backend.View) {
		v.Settings().AddOnChange("lime.frontend.html.render", func(name string) { t.dirty = true })
	})
	backend.OnModified.Add(func(v *backend.View) {
		t.dirty = true
	})
	backend.OnSelectionModified.Add(func(v *backend.View) {
		t.dirty = true
	})

	ed := backend.GetEditor()
	ed.SetFrontend(t)
	ed.LogInput(false)
	ed.LogCommands(false)
	c := ed.Console()
	if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
		log4go.Error(err)
	} else {
		scheme = sc
	}

	defer func() {
		fmt.Println(util.Prof)
	}()

	w := ed.NewWindow()
	v := w.OpenFile("main.go", 0)
	v.Settings().Set("trace", true)
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")
	c.Buffer().AddCallback(t.scroll)

	sel := v.Sel()
	sel.Clear()
	sel.Add(Region{0, 0})

	{
		w, h := 800, 600
		t.lock.Lock()
		t.layout[v] = layout{0, 0, w, h - console_height - 1, Region{}, 0}
		t.layout[c] = layout{0, h - console_height + 1, w, console_height - 5, Region{}, 0}
		t.lock.Unlock()
		t.Show(v, Region{1, 1})
	}
	t.Show(v, Region{100, 100})
	t.Show(v, Region{1, 1})
	t.Len, _ = v.Buffer().RowCol(v.Buffer().Size())

	ed.Init()
	sublime.Init()

	component, err := engine.LoadFile("main.qml")
	if err != nil {
		log4go.Exit(err)
	}
	window := component.CreateWindow(nil)
	window.Show()
	qml.Changed(t, &t.Len)

	log4go.Debug("Done")
	window.Wait()
}
Esempio n. 18
0
File: main.go Progetto: jlneder/lime
func (t *tbfe) loop() {
	qml.Init(nil)
	engine := qml.NewEngine()

	engine.Context().SetVar("lines", t)
	engine.Context().SetVar("frontend", t)
	engine.Context().SetVar("editor", backend.GetEditor())

	backend.OnNew.Add(func(v *backend.View) {
		fv := &frontendView{bv: v}
		v.Buffer().AddCallback(fv.bufferChanged)
		v.Settings().AddOnChange("blah", func(name string) {
			if name == "lime.syntax.updated" {
				// force redraw, as the syntax regions might have changed...
				for i := range fv.FormattedLine {
					fv.formatLine(i)
				}
			}
		})

		w2 := t.windows[v.Window()]
		w2.views = append(w2.views, fv)
		w2.Len = len(w2.views)
		t.qmlChanged(w2, &w2.Len)
	})

	ed := backend.GetEditor()
	ed.SetFrontend(t)
	ed.LogInput(false)
	ed.LogCommands(false)
	c := ed.Console()
	t.Console = &frontendView{bv: c}
	c.Buffer().AddCallback(t.Console.bufferChanged)
	c.Buffer().AddCallback(t.scroll)

	component, err := engine.LoadFile("main.qml")
	if err != nil {
		log4go.Exit(err)
	}

	wg := sync.WaitGroup{}
	backend.OnNewWindow.Add(func(w *backend.Window) {
		wg.Add(1)
		fw := &frontendWindow{bw: w, window: component.CreateWindow(nil)}
		t.windows[w] = fw
		fw.window.Show()
		fw.window.Set("myWindow", fw)

		go func() {
			fw.window.Wait()
			wg.Done()
		}()
	})

	// TODO: should be done backend side
	if sc, err := textmate.LoadTheme("../../3rdparty/bundles/TextMate-Themes/GlitterBomb.tmTheme"); err != nil {
		log4go.Error(err)
	} else {
		scheme = sc
	}

	defer func() {
		fmt.Println(util.Prof)
	}()

	w := ed.NewWindow()
	v := w.OpenFile("main.go", 0)
	// TODO: should be done backend side
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")
	v = w.OpenFile("../../backend/editor.go", 0)
	// TODO: should be done backend side
	v.Settings().Set("syntax", "../../3rdparty/bundles/go.tmbundle/Syntaxes/Go.tmLanguage")

	ed.Init()
	sublime.Init()
	wg.Wait()
}
Esempio n. 19
0
func main() {
	Init()

	qml.Init(nil)

	runtime.GOMAXPROCS(runtime.NumCPU())

	ethchain.InitFees()
	ethutil.ReadConfig(DataDir)
	ethutil.Config.Seed = UseSeed

	// Instantiated a eth stack
	ethereum, err := eth.New(eth.CapDefault, UseUPnP)
	if err != nil {
		log.Println("eth start err:", err)
		return
	}
	ethereum.Port = OutboundPort

	if GenAddr {
		fmt.Println("This action overwrites your old private key. Are you sure? (y/n)")

		var r string
		fmt.Scanln(&r)
		for ; ; fmt.Scanln(&r) {
			if r == "n" || r == "y" {
				break
			} else {
				fmt.Printf("Yes or no?", r)
			}
		}

		if r == "y" {
			utils.CreateKeyPair(true)
		}
		os.Exit(0)
	} else {
		if len(ImportKey) > 0 {
			fmt.Println("This action overwrites your old private key. Are you sure? (y/n)")
			var r string
			fmt.Scanln(&r)
			for ; ; fmt.Scanln(&r) {
				if r == "n" || r == "y" {
					break
				} else {
					fmt.Printf("Yes or no?", r)
				}
			}

			if r == "y" {
				utils.ImportPrivateKey(ImportKey)
				os.Exit(0)
			}
		} else {
			utils.CreateKeyPair(false)
		}
	}

	if ExportKey {
		key := ethutil.Config.Db.GetKeys()[0]
		fmt.Printf("%x\n", key.PrivateKey)
		os.Exit(0)
	}

	if ShowGenesis {
		fmt.Println(ethereum.BlockChain().Genesis())
		os.Exit(0)
	}

	log.Printf("Starting Ethereum GUI v%s\n", ethutil.Config.Ver)

	// Set the max peers
	ethereum.MaxPeers = MaxPeer

	gui := ethui.New(ethereum)
	gui.Start(AssetPath)
}