diff --git a/init.c b/init.c index 39e48b34..d7754c8e 100644 --- a/init.c +++ b/init.c @@ -1312,7 +1312,7 @@ void Init_buttons(void) Init_button(BUTTON_LAYER_SELECT, 142,0, 13,9, // Will be updated according to actual number of layers - BUTTON_SHAPE_RECTANGLE, + BUTTON_SHAPE_NO_FRAME, Button_Layer_select, Button_Layer_select, Do_nothing, FAMILY_INSTANT); diff --git a/windows.c b/windows.c index dd6d83e3..0e22d039 100644 --- a/windows.c +++ b/windows.c @@ -420,6 +420,85 @@ int Pick_color_in_palette() return color; } +/// Display / update the layer menubar +void Display_layerbar(void) +{ + word current_menu; + word y_off=0; + word x_off=0; + word button_width = LAYER_SPRITE_WIDTH; + word button_number = Main_backups->Pages->Nb_layers; + word horiz_space; + word current_button; + word repeats=1; + + // Find top + for (current_menu = MENUBAR_COUNT - 1; current_menu > MENUBAR_LAYERS; current_menu --) + { + if(Menu_bars[current_menu].Visible) + { + y_off += Menu_bars[current_menu].Height; + } + } + // Available space in pixels + horiz_space = Screen_width / Menu_factor_X - Menu_bars[MENUBAR_LAYERS].Skin_width; + + // Don't display all buttons if not enough room + if (horiz_space/button_width < button_number) + button_number = horiz_space/button_width; + + // Enlarge the buttons themselves if there's enough room + while (button_number*(button_width+2) < horiz_space && repeats < 20) + { + repeats+=1; + button_width+=2; + } + + x_off=Menu_bars[MENUBAR_LAYERS].Skin_width; + for (current_button=0; current_button0; i--) + { + Pixel_in_menu(x_pos + x_off, y_pos + y_off, Gfx->Layer_sprite[sprite_index][current_button][y_pos][source_x]); + x_pos++; + } + } + // Next line + x_pos=0; + } + // Next button + x_off+=button_width; + } + // Update the active area of the layers pseudo-button + Buttons_Pool[BUTTON_LAYER_SELECT].Width = button_number * button_width; +} + + /// Display the whole menu void Display_menu(void) { @@ -447,6 +526,8 @@ void Display_menu(void) for (x_pos=Menu_bars[current_menu].Skin_width;x_pos