GoCarousel

package module
v0.0.0-...-d4038f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2014 License: Apache-2.0 Imports: 13 Imported by: 0

README

GoCarousel

A Go library that allows you to place in your Graphical Application a custom carousel. You can specify:

  • The images to rotate.
  • Whether to select the next image in rotation randomly. Current image is excluded from random selection.
  • The animation. The available animations are:
    • Rotate right to left
    • Rotate left to right
    • Rotate up to down
    • Rotate down to up
  • Interval between switching images.
  • Speed of transition.
  • Position of the carousel.
  • Width and height of the carousel.

Installation on Linux

$ sudo add-apt-repository ppa:ubuntu-sdk-team/ppa
$ sudo apt-get update
$ sudo apt-get install ubuntu-sdk qtbase5-private-dev qtdeclarative5-private-dev
$ go get github.com/martin-angelov1992/GoCarousel

For other operating systems if you manage to install qml you should be able to use the library.

Example

package main

import (
	"github.com/niemeyer/qml"
	"github.com/martin-angelov1992/GoCarousel"
)

func main() {
	qml.Init(nil)
	engine := qml.NewEngine()
	base, _ := engine.LoadFile("base.qml") // Where base.qml is an example qml file to add carousel to
	win := base.CreateWindow(nil)
	carousel := GoCarousel.NewCarousel(engine, win)
	carousel.SetImages([]string{"../test_images/ubuntu-gopher.png", "../test_images/firefox.png", "../test_images/fire.jpg"})
	carousel.SetWidth(200)
	carousel.SetHeight(GoCarousel.CALCULATE_DIMENSION) // Height will be calculated to keep aspect ratio
	win.Show()
	carousel.Run()
	win.Wait()
}

License

Apache license

Documentation

Index

Constants

View Source
const (
	DEFAULT_INTERVAL uint = 1000
	DEFAULT_SPEED         = 500
)

Default rotating speed and interval

View Source
const CALCULATE_DIMENSION uint = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type Carousel struct {
	// contains filtered or unexported fields
}

Main structure

func NewCarousel

func NewCarousel(engine *qml.Engine, win *qml.Window) *Carousel

Initializes and returns a new carousel by provided qml engine and window

func (*Carousel) AddImage

func (c *Carousel) AddImage(path string)

Add an image by a relative to the application path. You can add images while the carousel is running too.

func (*Carousel) Destroy

func (c *Carousel) Destroy()

Removes the carousel

func (*Carousel) GetAnimationFile

func (c *Carousel) GetAnimationFile() string

func (*Carousel) GetEngine

func (c *Carousel) GetEngine() *qml.Engine

func (*Carousel) GetHeight

func (c *Carousel) GetHeight() uint

func (*Carousel) GetInterval

func (c *Carousel) GetInterval() uint

func (*Carousel) GetPosX

func (c *Carousel) GetPosX() uint

func (*Carousel) GetPosY

func (c *Carousel) GetPosY() uint

func (*Carousel) GetSpeed

func (c *Carousel) GetSpeed() uint

func (*Carousel) GetWidth

func (c *Carousel) GetWidth() uint

func (*Carousel) GetWindow

func (c *Carousel) GetWindow() *qml.Window

func (*Carousel) IsResizingImages

func (c *Carousel) IsResizingImages() bool

func (*Carousel) Run

func (c *Carousel) Run()

Shows the carousel and starts rotating.

func (*Carousel) SetAnimationFile

func (c *Carousel) SetAnimationFile(file string)

Set animation qml file from the animations folder

func (*Carousel) SetHeight

func (c *Carousel) SetHeight(height uint)

Same as SetWidth but for height

func (*Carousel) SetImages

func (c *Carousel) SetImages(images []string)

Set a new list of images to rotate. Safe to use while carousel is running.

func (*Carousel) SetInterval

func (c *Carousel) SetInterval(interval uint)

func (*Carousel) SetPosX

func (c *Carousel) SetPosX(posX uint)

func (*Carousel) SetPosY

func (c *Carousel) SetPosY(posY uint)

func (*Carousel) SetResizeImages

func (c *Carousel) SetResizeImages(resize bool)

Whether carousel should resize the images or crop them

func (*Carousel) SetRotateRandomly

func (c *Carousel) SetRotateRandomly(rotateRandomly bool)

Whether the images should rotate randomly. Meaning, when image is shown the next images is chosen randomly from one of other images.

func (*Carousel) SetSpeed

func (c *Carousel) SetSpeed(speed uint)

func (*Carousel) SetWidth

func (c *Carousel) SetWidth(width uint)

Sets width of the carousel. You can put CALCULATE_DIMENSION as argument and it will calculate width based on provided height and first image to preserve aspect ratio.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL