Fix layer preview :
* Avoids running its own event loop and intercepting keyboard shortcuts * Show all the layers (lined up with the buttons) * Do not draw outside of screen when picture has strange dimensions. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1924 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
b435ff2582
commit
dcffab6c79
53
src/engine.c
53
src/engine.c
@ -592,6 +592,9 @@ void Main_handler(void)
|
|||||||
byte action;
|
byte action;
|
||||||
dword key_pressed;
|
dword key_pressed;
|
||||||
|
|
||||||
|
static int preview_is_visible;
|
||||||
|
// This is used for the layer preview
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// Resize requested
|
// Resize requested
|
||||||
@ -1371,6 +1374,15 @@ void Main_handler(void)
|
|||||||
Block(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,Menu_factor_Y<<3,MC_Light);
|
Block(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,Menu_factor_Y<<3,MC_Light);
|
||||||
Update_rect(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,Menu_factor_Y<<3);
|
Update_rect(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,Menu_factor_Y<<3);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
|
|
||||||
|
// If we get here, we mayjust have left the layerbar (towards the
|
||||||
|
// main menu or statusbar). If so, close the popup.
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1392,46 +1404,48 @@ void Main_handler(void)
|
|||||||
{
|
{
|
||||||
int x,y;
|
int x,y;
|
||||||
int previewW, previewH;
|
int previewW, previewH;
|
||||||
short layer, prev_layer;
|
short layer;
|
||||||
|
short layercount = Main_backups->Pages->Nb_layers;
|
||||||
|
|
||||||
|
if (!preview_is_visible)
|
||||||
|
{
|
||||||
previewW = Buttons_Pool[BUTTON_LAYER_SELECT].Width / Main_backups->Pages->Nb_layers;
|
previewW = Buttons_Pool[BUTTON_LAYER_SELECT].Width / Main_backups->Pages->Nb_layers;
|
||||||
previewH = previewW * Main_image_height / Main_image_width;
|
previewH = previewW * Main_image_height / Main_image_width;
|
||||||
// TODO this will give stupid out of screen results for very narrow images...
|
if (previewH > Menu_Y) previewH = Menu_Y;
|
||||||
|
|
||||||
Open_popup((Buttons_Pool[BUTTON_LAYER_SELECT].X_offset + 2)*Menu_factor_X,
|
Open_popup((Buttons_Pool[BUTTON_LAYER_SELECT].X_offset + 2)*Menu_factor_X,
|
||||||
Menu_Y - previewH, previewW, previewH);
|
Menu_Y - previewH * Menu_factor_Y, previewW * layercount, previewH);
|
||||||
|
preview_is_visible = 1;
|
||||||
prev_layer = -1;
|
|
||||||
|
|
||||||
// Make the system think the menu is visible (Open_popup hides it)
|
// Make the system think the menu is visible (Open_popup hides it)
|
||||||
// so Button_under_mouse still works
|
// so Button_under_mouse still works
|
||||||
Menu_is_visible=Menu_is_visible_before_window;
|
Menu_is_visible=Menu_is_visible_before_window;
|
||||||
Menu_Y=Menu_Y_before_window;
|
Menu_Y=Menu_Y_before_window;
|
||||||
while(Button_under_mouse() == BUTTON_LAYER_SELECT && Mouse_K == 0)
|
}
|
||||||
|
|
||||||
|
// NOT an else of the previous if - variable may have changed
|
||||||
|
if (preview_is_visible)
|
||||||
{
|
{
|
||||||
layer = Layer_under_mouse();
|
layer = Layer_under_mouse();
|
||||||
if (layer != prev_layer)
|
for(layer = 0; layer < layercount; ++layer)
|
||||||
{
|
{
|
||||||
for (x = 0; x < Window_width; x++)
|
for (x = 0; x < Window_width; x++)
|
||||||
for (y = 0; y < Window_height; y++)
|
for (y = 0; y < Window_height; y++)
|
||||||
{
|
{
|
||||||
int imgx = x * Main_image_width / Window_width;
|
int imgx = x * Main_image_width / Window_width;
|
||||||
int imgy = y * Main_image_height / Window_height;
|
int imgy = y * Main_image_height / Window_height;
|
||||||
Pixel_in_window(x, y, *(Main_backups->Pages->Image[layer].Pixels
|
Pixel_in_window(x + previewW*layer, y, *(Main_backups->Pages->Image[layer].Pixels
|
||||||
+ imgx + imgy * Main_image_width));
|
+ imgx + imgy * Main_image_width));
|
||||||
}
|
}
|
||||||
|
|
||||||
Update_window_area(0,0,Window_width, Window_height);
|
Update_window_area(0,0,Window_width, Window_height);
|
||||||
prev_layer = layer;
|
|
||||||
}
|
}
|
||||||
Get_input(20);
|
}
|
||||||
};
|
} else if (preview_is_visible) {
|
||||||
|
int x = Mouse_K;
|
||||||
x = Mouse_K;
|
|
||||||
|
|
||||||
Close_popup();
|
Close_popup();
|
||||||
|
|
||||||
Mouse_K = x; // Close_popup waits for end of click and resets Mouse_K...
|
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);
|
||||||
@ -1460,6 +1474,15 @@ void Main_handler(void)
|
|||||||
Update_rect(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,8*Menu_factor_Y);
|
Update_rect(18*Menu_factor_X,Menu_status_Y,192*Menu_factor_X,8*Menu_factor_Y);
|
||||||
Display_cursor();
|
Display_cursor();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we get here, we mayjust have left the layerbar (towards the
|
||||||
|
// main menu or statusbar). If so, close the popup.
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user