Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On the platter tab, can you move some of the top icons 5 pixels to the right? #2436

Open
a4jp-com opened this issue Dec 20, 2014 · 11 comments
Open

Comments

@a4jp-com
Copy link

On the platter tab can you move some of the top icons 5 pixels to the right? This is just to make the program look nicer.

Slic3r 1.2.2-dev
Windows 7 64-bit

screen shot 12-20-14 at 11 12 am

screen shot 12-20-14 at 11 22 am

@a4jp-com a4jp-com changed the title On the platter tab can you move some of the top icons 5 pixels to the right? On the platter tab, can you move some of the top icons 5 pixels to the right? Dec 20, 2014
@alranel
Copy link
Member

alranel commented Dec 20, 2014

No, I can't. Sorry.

@alranel alranel closed this as completed Dec 20, 2014
@a4jp-com
Copy link
Author

I'll make some images/icons that are 5 pixels longer on one side then ^^
That will make everything look heaps better.

@alranel alranel reopened this Dec 20, 2014
@alranel
Copy link
Member

alranel commented Dec 20, 2014

Maybe SetBitmapMargins() can be used.

@a4jp-com
Copy link
Author

I fixed the files and everything looks heaps better. I also made 3 types of cogs as they are used in different areas.

The settings cog name on the 2D tab should be cog2.png

I can make them look nicer later on if you like as well.

screen shot 12-20-14 at 09 34 pm

http://a4jp.com/3d-files/bugs/icons.zip

Margins in the code later on would be good though.

@a4jp-com
Copy link
Author

I found you can also use text like a bitmap. You could just add spaces if there isn't another way:

http://members.inode.at/w.laun/cookbook/cookbook.html
Bitmap on a Button

The Task

Rather than labelling your buttons with text, you would like to use symbols represented by bitmaps.
Solution

bitmbutt

use strict;
use Tk;

my %Bitmap;
$Bitmap{bm_exit} = <<TheEnd;
..............
.11111111111..
.11111111111..
.11.......11..
.11..111..11..
.111.111.111..
.111.111.111..
.....111......
..111111111...
...1111111....
....11111.....
.....111......
......1.......
..............
TheEnd

$Bitmap{bm_print} = <<TheEnd;
..............
.11111111111..
.1.........1..
.1.........1..
.1.........1..
.1.........1..
.1.........1..
.1.........1..
.1......11.1..
.1.....11.11..
.11...1....1..
..11.1........
...11.........
..............
TheEnd

... more assignments to %Bitmap hash entries ...

sub setupScreen(){
my $winMain = MainWindow->new();
$winMain->title( 'Bitmaps on Buttons' );

PackBitmaps( $winMain, %Bitmap );

my $frmMenu = $winMain->Frame()->pack();
$frmMenu->Menubutton(
-text => 'Program',
-tearoff => 'no',
-menuitems => [
[ 'command', 'Print', -command => sub { },
-bitmap => 'bm_print',
-accelerator => 'Print' ],
[ 'command', 'Exit', -command => sub { exit(0) },
-bitmap => 'bm_exit',
-accelerator => 'Exit' ],
]
)->pack( -side => 'left' );

my $frmSel = $winMain->Frame();
$frmSel->pack(-side => 'top', -fill => 'both', -expand => 'yes');

my $but;
for my $bmkey ( qw{ bm_plus bm_minus bm_times bm_divide } ){
$but = $frmSel->Button( -bitmap => $bmkey, -text => $bmkey,
-command => sub { print "$bmkey\n"; } );
$but->pack( -side => 'right' );
}

}

sub PackBitmaps($$){
my( $mw, $bmref ) = @_;
for my $bmkey ( keys( %$bmref ) ){
my @lines = split( /\s*\n/, $bmref->{$bmkey} );
my $w = length( $lines[0] );
my $h = @lines;
$bmref->{$bmkey} = pack( "b$w"x$h, @lines );
$mw->DefineBitmap( $bmkey, $w, $h, $bmref->{$bmkey} );
}
}

setupScreen();
MainLoop();
Discussion

The key function of Perl/Tk in this example is DefineBitmap, creating a bitmap for later use:
$widget->DefineBitmap( name, columns, rows, vector )
The name will be used for referring to the bitmap which has the given number of pixel columns and rows. Its appearance is defined by the vector argument, a bitstring consisting of columns times rows bits. Since writing bitstrings is not a pleasant task we use a more convenient notation for our bitmaps, where characters '1' and '.' represent bit values 1 and 0, respectively. Looking at PackBitmaps now, we see how arranging these characters neatly in rows and columns permits us to use split to separate the string into lines, to determine the height and width and, finally, to pack the character strings into a bit string:
$bmref->{$bmkey} = pack( "b$w"x$h, @lines );
The pack template uses pack code b, with appropriate length and repetition, converting characters to bits, in the right ordering, depending on the least significant bit of the character's ord values. (That's why we can use '.' for zero bits - at least on systems with ASCII encoding.) Note that the bit vector must be allocated in some static location, for which we simply recycle the hash entry.
The subroutine setupScreen demonstrates how to use the defined bitmaps: option -bitmap in menu item definitions and in button widget constructors simply names the bitmap.

Don't overlook the labor-saving possibility of using reverse to obtain symmetric bitmaps. To flip the bitmap upside down, use this:

my @lines = reverse( split( /\s_\n/, $bmref->{$bmkey} ) );
To achieve mirroring along the vertical axis one could do:
my @lines = map { join( '', reverse( split( //, $_ ) ) ); }
split( /\s_\n/, $bmref->{$bmkey} );
Central symmetry (or rotation by 180 degrees) is, obtained by combining both transformations.

@a4jp-com
Copy link
Author

Or

httpatomoreillycomsourceoreillyimages76599

-padx => amount, -pady => amount

https://www.safaribooksonline.com/library/view/mastering-perltk/1565927168/ch04s13.html


How to Create a Bitmap

a The technique for using bitmaps introduced in the next example uses a simple text representation of the bitmap. While this may be put together with a text editor, on Unices there is a set of custom tools. The special purpose bitmap editor is called bitmap and creates the X Window System representation of a bitmap, typically stored on a file with the .xbm extension. Such files contain text (also fit for inclusion in a C program), e.g.
#define abmask_width 14
#define abmask_height 14

static unsigned char abmask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x1e, 0x1e, 0x3c, 0x0f,
0xf8, 0x07, 0xf0, 0x03, 0xe0, 0x01, 0xf0, 0x03,
0xf8, 0x07, 0x3c, 0x0f, 0x1e, 0x1e, 0x1e, 0x1e,
0x00, 0x00, 0x00, 0x00 };
To convert this to a simple ASCII text pattern, run the bmtoa converter while using the option -chars '.1', and you'll get this:
..............
..............
.1111....1111.
..1111..1111..
...11111111...
....111111....
.....1111.....
....111111....
...11111111...
..1111..1111..
.1111....1111.
.1111....1111.
..............
..............
(Omitting the -chars option would produce an output consisting of '-' and '#' characters, but these are not as convenient for processing in a Perl program, as we shall see in the example below.)
Since there is also the inverse conversion, atobm, you don't have to save all your bitmaps in xbm format. In case you'd need to make any changes, convert the text back to xbm format (again using the -chars '.1' option), edit with bmtoa, and so on.

@a4jp-com
Copy link
Author

Perl/Tk Pocket Reference
By Stephen Lidie

https://books.google.com/books?id=4RURWDZ2bj0C&pg=PA33&lpg=PA33&dq=perl+bitmap+padx+pady&source=bl&ots=eIUqn0OW8i&sig=q2mTmtKQsMBn9_bpRtqVryjT9Co&hl=en&sa=X&ei=uTeZVPyoCeG9mgXepID4DA&ved=0CFEQ6AEwCQ

★ padx and pady can be used with Lable, Message, Menubutton and Radiobutton.

For example:

use strict;
use Tk;

my @bitmaps = qw ( error gray25 gray50 hourglass info
questhead question warning );

my ($mw, $bm);

$mw = MainWindow->new();

foreach $bm (@bitmaps) {
$mw->Label(-bitmap => $bm)
->pack(-side => 'left',
-padx => '0.5c');
}

MainLoop;

@lordofhyphens lordofhyphens added this to the Pull Request or Bust milestone Jul 7, 2016
@lordofhyphens
Copy link
Member

@a4jp-com did anything actually noticably change?

@a4jp-com
Copy link
Author

a4jp-com commented Jul 8, 2016

I'll download and try ^^

@lordofhyphens
Copy link
Member

Much appreciated. :) The more things I can legitimately close the better.

"Nothing unreal exists." - Kiri-kin-tha's First Law of Metaphysics.

On Thu, Jul 7, 2016 at 10:45 PM, a4jp-com notifications@github.com wrote:

I'll download and try ^^


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#2436 (comment), or mute
the thread
https://github.com/notifications/unsubscribe/AAB8CrhvF11LSO_NUhVCk9RyoKAplYiJks5qTcfcgaJpZM4DKz1h
.

@a4jp-com
Copy link
Author

a4jp-com commented Jul 8, 2016

The interface looks a bit better than before but the padding is still wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants