More fixes on layer preview. Layer buttons now activate on click instead of release.
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1937 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
cd5b3346b0
commit
2e5b97eb41
169
src/engine.c
169
src/engine.c
@ -579,6 +579,71 @@ void Status_print_palette_color(byte color)
|
|||||||
Print_in_menu(str,0);
|
Print_in_menu(str,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Layer_preview_on(int * preview_is_visible)
|
||||||
|
{
|
||||||
|
int x,y;
|
||||||
|
short layer;
|
||||||
|
short layercount = Main_backups->Pages->Nb_layers;
|
||||||
|
static int previewW=0, previewH=0;
|
||||||
|
|
||||||
|
if (! *preview_is_visible)
|
||||||
|
{
|
||||||
|
previewW = Min(Main_image_width/Menu_factor_X,Layer_button_width);
|
||||||
|
previewH = previewW * Main_image_height / Main_image_width * Menu_factor_X / Menu_factor_Y;
|
||||||
|
if (previewH > Screen_height/4)
|
||||||
|
{
|
||||||
|
previewH = Screen_height/4;
|
||||||
|
previewW = Main_image_width*previewH/Main_image_height*Menu_factor_Y/Menu_factor_X;
|
||||||
|
}
|
||||||
|
|
||||||
|
Open_popup((Buttons_Pool[BUTTON_LAYER_SELECT].X_offset + 2)*Menu_factor_X,
|
||||||
|
Menu_Y - previewH * Menu_factor_Y, Buttons_Pool[BUTTON_LAYER_SELECT].Width, previewH);
|
||||||
|
*preview_is_visible = 1;
|
||||||
|
|
||||||
|
// Make the system think the menu is visible (Open_popup hides it)
|
||||||
|
// so Button_under_mouse still works
|
||||||
|
Menu_is_visible=Menu_is_visible_before_window;
|
||||||
|
Menu_Y=Menu_Y_before_window;
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOT an else of the previous if - variable may have changed
|
||||||
|
if (*preview_is_visible)
|
||||||
|
{
|
||||||
|
//layer = Layer_under_mouse();
|
||||||
|
for(layer = 0; layer < layercount; ++layer)
|
||||||
|
{
|
||||||
|
int offset;
|
||||||
|
// Stop if the window is too small to show the
|
||||||
|
// layer button (ex: 320x200 can only display 12 layers)
|
||||||
|
if (layer*Layer_button_width+previewW > Window_width)
|
||||||
|
break;
|
||||||
|
|
||||||
|
offset=(Layer_button_width-previewW)/2;
|
||||||
|
for (y = 0; y < previewH*Pixel_height*Menu_factor_Y; y++)
|
||||||
|
for (x = 0; x < previewW*Pixel_width*Menu_factor_X; x++)
|
||||||
|
{
|
||||||
|
int imgx = x * Main_image_width / previewW/Pixel_width/Menu_factor_X;
|
||||||
|
int imgy = y * Main_image_height / previewH/Pixel_height/Menu_factor_Y;
|
||||||
|
// Use Pixel_simple() in order to get highest resolution
|
||||||
|
Pixel_simple(x+((layer*Layer_button_width+offset)*Menu_factor_X+Window_pos_X)*Pixel_width, y+Window_pos_Y*Pixel_height, *(Main_backups->Pages->Image[layer].Pixels
|
||||||
|
+ imgx + imgy * Main_image_width));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Update_window_area(0,0,Window_width, Window_height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Layer_preview_off(int * preview_is_visible)
|
||||||
|
{
|
||||||
|
if (*preview_is_visible)
|
||||||
|
{
|
||||||
|
int x = Mouse_K;
|
||||||
|
Close_popup();
|
||||||
|
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
||||||
|
*preview_is_visible = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///Main handler for everything. This is the main loop of the program
|
///Main handler for everything. This is the main loop of the program
|
||||||
void Main_handler(void)
|
void Main_handler(void)
|
||||||
{
|
{
|
||||||
@ -592,9 +657,8 @@ void Main_handler(void)
|
|||||||
byte action;
|
byte action;
|
||||||
dword key_pressed;
|
dword key_pressed;
|
||||||
|
|
||||||
static int preview_is_visible;
|
int preview_is_visible=0;
|
||||||
static int previewW, previewH;
|
// This is used for the layer preview
|
||||||
// This is used for the layer preview
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -691,13 +755,8 @@ void Main_handler(void)
|
|||||||
{
|
{
|
||||||
if (Is_shortcut(Key,key_index))
|
if (Is_shortcut(Key,key_index))
|
||||||
{
|
{
|
||||||
if (preview_is_visible)
|
Layer_preview_off(&preview_is_visible);
|
||||||
{
|
|
||||||
int x = Mouse_K;
|
|
||||||
Close_popup();
|
|
||||||
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
|
||||||
preview_is_visible = 0;
|
|
||||||
}
|
|
||||||
// Special keys (functions not hooked to a UI button)
|
// Special keys (functions not hooked to a UI button)
|
||||||
switch(key_index)
|
switch(key_index)
|
||||||
{
|
{
|
||||||
@ -1316,26 +1375,14 @@ void Main_handler(void)
|
|||||||
{
|
{
|
||||||
if (Is_shortcut(key_pressed,0x100+button_index))
|
if (Is_shortcut(key_pressed,0x100+button_index))
|
||||||
{
|
{
|
||||||
if (preview_is_visible)
|
Layer_preview_off(&preview_is_visible);
|
||||||
{
|
|
||||||
int x = Mouse_K;
|
|
||||||
Close_popup();
|
|
||||||
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
|
||||||
preview_is_visible = 0;
|
|
||||||
}
|
|
||||||
Select_button(button_index,LEFT_SIDE);
|
Select_button(button_index,LEFT_SIDE);
|
||||||
prev_button_number=-1;
|
prev_button_number=-1;
|
||||||
action++;
|
action++;
|
||||||
}
|
}
|
||||||
else if (Is_shortcut(key_pressed,0x200+button_index))
|
else if (Is_shortcut(key_pressed,0x200+button_index))
|
||||||
{
|
{
|
||||||
if (preview_is_visible)
|
Layer_preview_off(&preview_is_visible);
|
||||||
{
|
|
||||||
int x = Mouse_K;
|
|
||||||
Close_popup();
|
|
||||||
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
|
||||||
preview_is_visible = 0;
|
|
||||||
}
|
|
||||||
Select_button(button_index,RIGHT_SIDE);
|
Select_button(button_index,RIGHT_SIDE);
|
||||||
prev_button_number=-1;
|
prev_button_number=-1;
|
||||||
action++;
|
action++;
|
||||||
@ -1398,12 +1445,7 @@ void Main_handler(void)
|
|||||||
|
|
||||||
// If we get here, we mayjust have left the layerbar (towards the
|
// If we get here, we mayjust have left the layerbar (towards the
|
||||||
// main menu or statusbar). If so, close the popup.
|
// main menu or statusbar). If so, close the popup.
|
||||||
if (preview_is_visible) {
|
Layer_preview_off(&preview_is_visible);
|
||||||
int x = Mouse_K;
|
|
||||||
Close_popup();
|
|
||||||
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
|
||||||
preview_is_visible = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1423,60 +1465,11 @@ void Main_handler(void)
|
|||||||
|
|
||||||
if (button_index == BUTTON_LAYER_SELECT)
|
if (button_index == BUTTON_LAYER_SELECT)
|
||||||
{
|
{
|
||||||
int x,y;
|
Layer_preview_on(&preview_is_visible);
|
||||||
short layer;
|
}
|
||||||
short layercount = Main_backups->Pages->Nb_layers;
|
else
|
||||||
|
{
|
||||||
if (!preview_is_visible)
|
Layer_preview_off(&preview_is_visible);
|
||||||
{
|
|
||||||
previewW = Min(Main_image_width/Menu_factor_X,Layer_button_width);
|
|
||||||
previewH = previewW * Main_image_height / Main_image_width * Menu_factor_X / Menu_factor_Y;
|
|
||||||
if (previewH > Screen_height/4)
|
|
||||||
{
|
|
||||||
previewH = Screen_height/4;
|
|
||||||
previewW = Main_image_width*previewH/Main_image_height*Menu_factor_Y/Menu_factor_X;
|
|
||||||
}
|
|
||||||
|
|
||||||
Open_popup((Buttons_Pool[BUTTON_LAYER_SELECT].X_offset + 2)*Menu_factor_X,
|
|
||||||
Menu_Y - previewH * Menu_factor_Y, Buttons_Pool[BUTTON_LAYER_SELECT].Width, previewH);
|
|
||||||
preview_is_visible = 1;
|
|
||||||
|
|
||||||
// Make the system think the menu is visible (Open_popup hides it)
|
|
||||||
// so Button_under_mouse still works
|
|
||||||
Menu_is_visible=Menu_is_visible_before_window;
|
|
||||||
Menu_Y=Menu_Y_before_window;
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOT an else of the previous if - variable may have changed
|
|
||||||
if (preview_is_visible)
|
|
||||||
{
|
|
||||||
//layer = Layer_under_mouse();
|
|
||||||
for(layer = 0; layer < layercount; ++layer)
|
|
||||||
{
|
|
||||||
int offset;
|
|
||||||
// Stop if the window is too small to show the
|
|
||||||
// layer button (ex: 320x200 can only display 12 layers)
|
|
||||||
if (layer*Layer_button_width+previewW > Window_width)
|
|
||||||
break;
|
|
||||||
|
|
||||||
offset=(Layer_button_width-previewW)/2;
|
|
||||||
for (y = 0; y < previewH*Pixel_height*Menu_factor_Y; y++)
|
|
||||||
for (x = 0; x < previewW*Pixel_width*Menu_factor_X; x++)
|
|
||||||
{
|
|
||||||
int imgx = x * Main_image_width / previewW/Pixel_width/Menu_factor_X;
|
|
||||||
int imgy = y * Main_image_height / previewH/Pixel_height/Menu_factor_Y;
|
|
||||||
// Use Pixel_simple() in order to get highest resolution
|
|
||||||
Pixel_simple(x+((layer*Layer_button_width+offset)*Menu_factor_X+Window_pos_X)*Pixel_width, y+Window_pos_Y*Pixel_height, *(Main_backups->Pages->Image[layer].Pixels
|
|
||||||
+ imgx + imgy * Main_image_width));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Update_window_area(0,0,Window_width, Window_height);
|
|
||||||
}
|
|
||||||
} else if (preview_is_visible) {
|
|
||||||
int x = Mouse_K;
|
|
||||||
Close_popup();
|
|
||||||
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
|
||||||
preview_is_visible = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Print_in_menu(Buttons_Pool[button_index].Tooltip,0);
|
Print_in_menu(Buttons_Pool[button_index].Tooltip,0);
|
||||||
@ -1509,12 +1502,7 @@ void Main_handler(void)
|
|||||||
|
|
||||||
// If we get here, we mayjust have left the layerbar (towards the
|
// If we get here, we mayjust have left the layerbar (towards the
|
||||||
// main menu or statusbar). If so, close the popup.
|
// main menu or statusbar). If so, close the popup.
|
||||||
if (preview_is_visible) {
|
Layer_preview_off(&preview_is_visible);
|
||||||
int x = Mouse_K;
|
|
||||||
Close_popup();
|
|
||||||
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
|
||||||
preview_is_visible = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1551,6 +1539,7 @@ void Main_handler(void)
|
|||||||
if(Cursor_in_menu_previous)
|
if(Cursor_in_menu_previous)
|
||||||
{
|
{
|
||||||
Hide_cursor();
|
Hide_cursor();
|
||||||
|
Layer_preview_off(&preview_is_visible);
|
||||||
|
|
||||||
/*if (Gfx->Hover_effect && prev_button_number > -1 && !Buttons_Pool[prev_button_number].Pressed)
|
/*if (Gfx->Hover_effect && prev_button_number > -1 && !Buttons_Pool[prev_button_number].Pressed)
|
||||||
Draw_menu_button(prev_button_number, BUTTON_RELEASED);
|
Draw_menu_button(prev_button_number, BUTTON_RELEASED);
|
||||||
|
|||||||
@ -1274,7 +1274,7 @@ void Init_buttons(void)
|
|||||||
13,9, // Will be updated according to actual number of layers
|
13,9, // Will be updated according to actual number of layers
|
||||||
BUTTON_SHAPE_NO_FRAME,
|
BUTTON_SHAPE_NO_FRAME,
|
||||||
Button_Layer_select, Button_Layer_toggle,
|
Button_Layer_select, Button_Layer_toggle,
|
||||||
0,0,
|
1,1,
|
||||||
Do_nothing,
|
Do_nothing,
|
||||||
FAMILY_INSTANT);
|
FAMILY_INSTANT);
|
||||||
|
|
||||||
|
|||||||
@ -178,6 +178,7 @@ void Button_Layer_select(void)
|
|||||||
{
|
{
|
||||||
short layer = Layer_under_mouse();
|
short layer = Layer_under_mouse();
|
||||||
Layer_activate(layer, LEFT_SIDE);
|
Layer_activate(layer, LEFT_SIDE);
|
||||||
|
Mouse_K=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button_Layer_toggle(void)
|
void Button_Layer_toggle(void)
|
||||||
@ -194,6 +195,7 @@ void Button_Layer_toggle(void)
|
|||||||
layer=Main_backups->Pages->Nb_layers-1;
|
layer=Main_backups->Pages->Nb_layers-1;
|
||||||
|
|
||||||
Layer_activate(layer, RIGHT_SIDE);
|
Layer_activate(layer, RIGHT_SIDE);
|
||||||
|
Mouse_K=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Draw_transparent_color(byte color)
|
static void Draw_transparent_color(byte color)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user