anchor.diff:    // Update Objects Palette scroll position
     if not (ObjIndex in [61, 255])
       and not InRange(ObjIndex,
  -                    ObjectsPalette_Scroll.Position*fObjPaletteTableSize.X,
  -                    ObjectsPalette_Scroll.Position*fObjPaletteTableSize.X + fObjPaletteTableSize.X*fObjPaletteTableSize.Y - 1) then
  -    ObjectsPalette_Scroll.Position := ((ObjIndex - 1) div fObjPaletteTableSize.X);
  +                    Scroll_ObjectsPalette.Position*fObjPaletteTableSize.X,
  +                    Scroll_ObjectsPalette.Position*fObjPaletteTableSize.X + fObjPaletteTableSize.X*fObjPaletteTableSize.Y - 1) then
  +    Scroll_ObjectsPalette.Position := ((ObjIndex - 1) div fObjPaletteTableSize.X);
   end;
   
   
  
positive.code:   PopUp_ObjectsPalette.Left := 25;
    PopUp_ObjectsPalette.Top := 25;
  
      ObjectsPalette_Bevel := TKMBevel.Create(PopUp_ObjectsPalette, -1000,  -1000, 4000, 4000);
      ObjectsPalette_Bevel.BackAlpha := 0.7;
      ObjectsPalette_Bevel.EdgeAlpha := 0.9;
  
      ObjectsPalette_Image := TKMImage.Create(PopUp_ObjectsPalette, 0, 0, PopUp_ObjectsPalette.Width, PopUp_ObjectsPalette.Height, 3, rxGuiMain);
      ObjectsPalette_Image.ImageStretch;
  
      ObjectsPalette_Scroll := TKMScrollBar.Create(PopUp_ObjectsPalette, PopUp_ObjectsPalette.Width - 20, 25, 20, PopUp_ObjectsPalette.Height - 75, sa_Vertical, bsGame);
      ObjectsPalette_Scroll.MinValue := 0;
      ObjectsPalette_Scroll.Position := 0;
      ObjectsPalette_Scroll.OnChange := ObjectsPalette_Refresh;
  
      ObjectsPalette_Image.OnMouseWheel := ObjectsPalette_Scroll.MouseWheel;
      ObjectsPalette_Image.OnClickShift := ObjPalette_ClickShift;
      ObjectsPalette_Bevel.OnMouseWheel := ObjectsPalette_Scroll.MouseWheel;
      ObjectsPalette_Bevel.OnClickShift := ObjPalette_ClickShift;
  
      SetLength(ObjPaletteTable, fCountCompact);
      for I := 0 to fCountCompact - 1 do
      begin
        ObjPaletteTable[I] := TKMButtonFlat.Create(PopUp_ObjectsPalette, 0, 0, 64, 84, 1, rxTrees); // Left and Top will update later
        ObjPaletteTable[I].Tag := I; //Store ID
        ObjPaletteTable[I].Enable;
        ObjPaletteTable[I].Hide;
        ObjPaletteTable[I].OnMouseWheel := ObjectsPalette_Scroll.MouseWheel;
        ObjPaletteTable[I].OnClickShift := ObjPalette_ClickShift;
      end;
  
      ObjectsPalette_Label := TKMLabel.Create(PopUp_ObjectsPalette, PopUp_ObjectsPalette.Center.X, 0, 'Objects palette', fnt_Outline, taCenter); //Todo translate
  
      ClosePalette_Button  := TKMButton.Create(PopUp_ObjectsPalette, PopUp_ObjectsPalette.Center.X - 100, PopUp_ObjectsPalette.Bottom - 50,
                                               200, 30, 'Close palette', bsGame); //Todo translate
      ClosePalette_Button.Anchors := [anLeft,anBottom];
      ClosePalette_Button.OnClick := ObjectsPaletteClose_Click;
  
      ObjPalette_UpdateControlsPosition;
  end;
  
negative.code: 
    RowsCnt := (PopUp_ObjectsPalette.Height - 80) div 85;
    ColsCnt := Min(OBJECTS_PALETTE_MAX_COLS_CNT, (PopUp_ObjectsPalette.Width) div 65); // Calc cols count without Scroll first
    Scroll_ObjectsPalette.Visible := RowsCnt*ColsCnt < fCountCompact;
    ColsCnt := Min(OBJECTS_PALETTE_MAX_COLS_CNT, (PopUp_ObjectsPalette.Width - 25*Byte(Scroll_ObjectsPalette.Visible)) div 65); // Recalc ColsCount considering possible scroll width
  
    fObjPaletteTableSize := KMPoint(ColsCnt, RowsCnt);
  
    Image_ObjectsPalette.Width := GetObjPaletteTableWidth + 100;
    Image_ObjectsPalette.Height := GetObjPaletteTableHeight + 150;
    Image_ObjectsPalette.Left := (PopUp_ObjectsPalette.Width - Image_ObjectsPalette.Width) div 2;
    Image_ObjectsPalette.Top := ((PopUp_ObjectsPalette.Height - Image_ObjectsPalette.Height) div 2);
  
    Label_ObjectsPalette.Left := PopUp_ObjectsPalette.Center.X;
    Label_ObjectsPalette.Top := Image_ObjectsPalette.Top + 25;
  
    Button_ClosePalette.Left := PopUp_ObjectsPalette.Center.X - 100;
    Button_ClosePalette.Top := Image_ObjectsPalette.Bottom - 70;
  
    Scroll_ObjectsPalette.Left := Image_ObjectsPalette.Right - 50;
    Scroll_ObjectsPalette.Top := Image_ObjectsPalette.Top + 50;
    Scroll_ObjectsPalette.Height := Image_ObjectsPalette.Height - 150;
  
    Scroll_ObjectsPalette.MaxValue := ((fCountCompact - 1) div ColsCnt) + 1 - RowsCnt;
  
    ObjectsPalette_Refresh(nil);
  end;
  