Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
davide13
Posts: 312
Registered: ‎03-13-2013
My Device: Z10

Divider

Hi,

it's possible to make a divider "more bold"?

Thanks :smileyhappy:

If this post is helpful, please click the "like" button! :smileyhappy:
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Divider

No, but of course you can do your own one using a 9-slice image on a containers background.

 


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
davide13
Posts: 312
Registered: ‎03-13-2013
My Device: Z10

Re: Divider

Mmm ok! Thanks!
If this post is helpful, please click the "like" button! :smileyhappy:
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Divider

Slightly more hacky and not elegant is to do this to make it more pronounced...

 

Container {
    id: thickDivider
    layout: DockLayout { }
    minHeight: 10.0
    Divider { horizontalAlignment: HorizontalAlignment.Center }
    Divider { horizontalAlignment: HorizontalAlignment.Center; translationY: 2.0 }
    Divider { horizontalAlignment: HorizontalAlignment.Center; translationY: 4.0 }
}

 Be elegant though use a 9-slice image. :smileyhappy:


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Developer
p8
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10

Re: Divider

[ Edited ]

Heres how to write your own Divider for greater control:

 

//-----------------------------------
#include <bb/cascades/Container>
//-----------------------------------------
namespace bb {
    namespace cascades
    {
        class Container;
        class Color;
        class ColorPaint;
    }
}
//-----------------------------------
using bb::cascades::Container;
using bb::cascades::Color;
using bb::cascades::ColorPaint;
//-----------------------------------------
class tRpSep: public Container { public: tRpSep(Container * Par=0); tRpSep(int h, ColorPaint C, Container * Par=0); void setHeight(int h); void setColor(ColorPaint C); void setHorFill(bool on); protected: void init(int h, ColorPaint C); static int defHeight(){ return 2;} static Color defColor(); };

 

#include "rp_sep.h"

#include <bb/cascades/Color>

using namespace bb::cascades;


//---------------------------------------------------------------------
//----------------------- tRpSep  -----------------------------
//---------------------------------------------------------------------
tRpSep::tRpSep(Container * Par)
	: Container(Par)
{
	init(defHeight(), defColor());
}
//---------------------------------------------------------------------
tRpSep::tRpSep(int h, ColorPaint Col, Container * Par)
	: Container(Par)
{
	init(h, Col);
}
//---------------------------------------------------------------------
void tRpSep::setHorFill(bool on)
{
	if(on)
		setHorizontalAlignment(HorizontalAlignment::Fill);
	else
		//setHorizontalAlignment(HorizontalAlignment::Left);
		resetHorizontalAlignment();
}
//---------------------------------------------------------------------
void tRpSep::init(int h, ColorPaint Col)
{
	setHorizontalAlignment(HorizontalAlignment::Fill);

	setHeight(h);
	setColor(Col);
}
//------------------------------------------------
Color tRpSep::defColor()
{
	return Color::DarkGray;
}
//---------------------------------------------------------------------
void tRpSep::setColor(ColorPaint Col)
{
	setBackground(Col);
}
//---------------------------------------------------------------------
void tRpSep::setHeight(int h)
{
	setMinHeight(h);
	setMaxHeight(h);
}

 

Developer
Developer
p8
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10

Re: Divider

[ Edited ]

set the height and color to any values you like:

 

//Container * Cont = someContainer()

 

// default, gray and 2 pixels high

new tRpSep(Cont);

 

// darker and higher separator

new tRpSep(5, Color::Black, Cont);

Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Divider

[ Edited ]

@p8 Woah! slight overkill isn't it, why create a class and new functions for those that already exist when all you are doing is effectively this...

 

Container {
        	minHeight: 6.0
        	background: Color.Black
        	horizontalAlignment: HorizontalAlignment.Fill
        	leftPadding: 6.0
        	rightPadding: 6.0            
}

[Edit] Put this in it's own QML file give it an id and a few property aliases and you have a custom control a lot more compact and memory friendly. But as I said 9-slice images will be nicer. :smileyhappy: and there are a lot of free images already available for use in apps out there on the web.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
BBSJdev
Posts: 6,116
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30

Re: Divider

If you've done this a lot for your app then your memory footprint must be horrendous. :smileyhappy:

 

Also for the beginners out there I would stay away from subclassing the components themselves as it can get you in to trouble if and when the internals of the class change.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Developer
p8
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10

Re: Divider

[ Edited ]

Thats like asking why write in c++.

Your "analog" is also a very good suggestion, however its a "quick and dirty" solution that has to be copy/pasted all over the project. An inelagant and more error prone method (if its needed often) compared to creating a reusable class with a clear interface.

 

Developer
Developer
p8
Posts: 132
Registered: ‎01-24-2013
My Device: blackberry z10

Re: Divider

[ Edited ]

P.S

I write mainly in c++ and I bet the memory footprint is a lot smaller than yours ;-)

If you think subclassing (or creating instance variables) in c++ uses more memory than using qml then you are quite mistaken