コード例 #1
0
ファイル: Button.java プロジェクト: Hakot/Java-Graph
 public static void draw(Display disp) {
   double mouseposx = disp.getMouseX();
   double mouseposy = disp.getMouseY();
   for (Button b : buttonRegistry) {
     if (b.isVisible()) {
       if (mouseposx > b.x
           && mouseposx < b.x + b.width
           && mouseposy > b.y
           && mouseposy < b.y + b.height) {
         if (b.isActive()) b.br.onHover(mouseposx, mouseposy);
         b.hovered = true;
         disp.color(b.hr, b.hg, b.hb);
       } else {
         b.hovered = false;
         disp.color(b.r, b.g, b.b);
       }
       disp.fillQuadi(
           b.x, b.y, b.x + b.width, b.y, b.x + b.width, b.y + b.height, b.x, b.x + b.height);
     }
   }
 }
コード例 #2
0
ファイル: Button.java プロジェクト: Hakot/Java-Graph
 public static void poll(Display disp) {
   if (!disp.isMouseButtonDown(0)) {
     used = false;
     return;
   }
   double mouseposx = disp.getMouseX();
   double mouseposy = disp.getMouseY();
   for (Button b : buttonRegistry) {
     if (b.isActive()) {
       if (mouseposx > b.x
           && mouseposx < b.x + b.width
           && mouseposy > b.y
           && mouseposy < b.y + b.height) {
         b.br.onPress(mouseposx, mouseposy, used == false);
         b.pressed = true;
       } else {
         b.pressed = false;
       }
     }
   }
   used = true;
 }