How To Move A Panel

This article will demonstrate how to move a panel on screen using SwinGame’s User Interface.

Level

Intermediate

Details

In most programs you will want to move the component around the screen using the mouse. To do this it is required SwinGame’s User Interface functionality.

The function that enables the component to be able to move around the screen using a mouse is called PanelSetDraggable. This procedure allows the dragging of component around the screen using a mouse.

To allow more customization you can also set the background color of the component to a different color by calling the GuiSetBackGroundColor procedure.

Call UpdateInterface in the game loop to check for draggable, region clicked and updated the interface to the latest change.

To demonstrate the use of SwinGAme’s User Interface a video will be display on the right and below is the code of the program.

Source Code Widget

  • program HowToMoveAPanel;
    uses SwinGame,sgTypes,sgUserInterface;
    
    procedure Main();
    var
        p : Panel;
    begin
        OpenGraphicsWindow('How To Move A Panel' ,800 ,600 );
        LoadDefaultColors();
        p := LoadPanel('panelwithlabel.txt' );
        ShowPanel(p );
        repeat
            ProcessEvents();
            ClearScreen(ColorWhite );
            DrawInterface();
            PanelSetDraggable(p ,true );
            GUISetBackgroundColor(ColorGreen );
            UpdateInterface();
            RefreshScreen();
        
        until WindowCloseRequested();
        ReleaseAllResources();
    end;
    begin
        Main();
    end.
    Download Now"
  • #include 
    #include "SwinGame.h"
    int main() 
    {
        panel  p;
        open_graphics_window("How To Move A Panel" ,800 ,600 );
        load_default_colors();
        p = load_panel("panelwithlabel.txt" ) ;
        show_panel(p );
        do 
        {
            process_events();
            clear_screen(color_white );
            draw_interface();
            panel_set_draggable(p ,true );
            guiset_background_color(color_green );
            update_interface();
            refresh_screen();
        }
        while ( ! (window_close_requested() ) );
        release_all_resources();
        return 0;
    }
    
    Download Now"
  • Source Code Coming Soon

  • Source Code Coming Soon

  • Source Code Coming Soon

If there is a useful hint you will find it in a box like this

Possibilities

Suggested projects will appear here.